Browse Source

feat:xiugai

wangchuanjin 9 tháng trước cách đây
mục cha
commit
a32a67deac

+ 28 - 0
api/internal/handler/deletecachehandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func deleteCacheHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.DeleteCacheInfoReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewDeleteCacheLogic(r.Context(), svcCtx)
+		resp, err := l.DeleteCache(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 5 - 0
api/internal/handler/routes.go

@@ -92,6 +92,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/networkManage/init/updateInitInfo",
 				Handler: updateInitInfoHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/networkManage/deleteCache",
+				Handler: deleteCacheHandler(serverCtx),
+			},
 		},
 	)
 }

+ 30 - 0
api/internal/logic/deletecachelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/service"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/types"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DeleteCacheLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewDeleteCacheLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteCacheLogic {
+	return &DeleteCacheLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *DeleteCacheLogic) DeleteCache(req *types.DeleteCacheInfoReq) (resp *types.Reply, err error) {
+	service.Network.DeleteCache(req.PositionId)
+	resp = &types.Reply{Data: map[string]interface{}{"status": 1}}
+	return
+}

+ 1 - 1
api/internal/service/network.go

@@ -330,7 +330,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 	reply = &types.Reply{}
 	key := fmt.Sprintf(NetworkManageAllProjectKey, in.PositionId)
 	rbt, rerr := redis.GetNewBytes("newother", key)
-	if rerr == nil && rbt != nil {
+	if false && rerr == nil && rbt != nil {
 		json.Unmarshal(*rbt, &reply)
 		return
 	}

+ 7 - 2
api/internal/service/network_test.go

@@ -109,8 +109,8 @@ func TestNetWorkList(t *testing.T) {
 func TestAllProject(t *testing.T) {
 	InitConf()
 	res := Network.AllProject(&types.AllprojectReq{
-		EntAccountId: 64,
-		PositionId:   935,
+		EntAccountId: 900824,
+		PositionId:   1205621877,
 		//PositionId: 1205591997, //刘苗
 		//PositionId: 1205592003,//刘亚丽
 		//Id:   "009c313ef8e740e59d57432aea777102",
@@ -170,3 +170,8 @@ func TestInitNetwork(t *testing.T) {
 	}
 	inw.Init()
 }
+
+func TestDeleteCache(t *testing.T) {
+	InitConf()
+	Network.DeleteCache(935)
+}

+ 4 - 0
api/internal/types/types.go

@@ -194,3 +194,7 @@ type PrCollectListReq struct {
 	PageSize   int    `json:"pageSize"`
 	PageNum    int    `json:"pageNum"`
 }
+
+type DeleteCacheInfoReq struct {
+	PositionId int64 `header:"positionId,optional"`
+}

+ 7 - 0
api/networkmanage.api

@@ -178,6 +178,9 @@ type (
 		PageSize   int    `json:"pageSize"`
 		PageNum    int    `json:"pageNum"`
 	}
+	DeleteCacheInfoReq {
+		PositionId int64 `header:"positionId,optional"`
+	}
 )
 
 service networkManage {
@@ -244,4 +247,8 @@ service networkManage {
 	@doc "初始化设置"
 	@handler updateInitInfo
 	post /networkManage/init/updateInitInfo (UpdateInitInfoReq) returns (Reply)
+	
+	@doc "删除缓存"
+	@handler deleteCache
+	post /networkManage/deleteCache (DeleteCacheInfoReq) returns (Reply)
 }