Bläddra i källkod

fit: 数据中心app管理接口9个

gaoyagang 1 år sedan
förälder
incheckning
608b0a1d32
45 ändrade filer med 3955 tillägg och 901 borttagningar
  1. 49 11
      app/cmd/dtgateway/desc/dtgateway.api
  2. 58 0
      app/cmd/dtgateway/desc/dtgateway/appinfo.api
  3. 16 0
      app/cmd/dtgateway/desc/dtgateway/common.api
  4. 3 14
      app/cmd/dtgateway/desc/dtgateway/dtgateway.api
  5. 1 1
      app/cmd/dtgateway/etc/dtgateway.test.yaml
  6. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/createAppInfoHandler.go
  7. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/disableAppInfoHandler.go
  8. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/enableAppInfoHandler.go
  9. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/expireAppSecretHandler.go
  10. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/findAppListHandler.go
  11. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/getAppInfoHandler.go
  12. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/removeAppInfoHandler.go
  13. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/resetAppProjectHandler.go
  14. 28 0
      app/cmd/dtgateway/internal/handler/dtgateway/resetAppSecretHandler.go
  15. 45 0
      app/cmd/dtgateway/internal/handler/routes.go
  16. 42 0
      app/cmd/dtgateway/internal/logic/dtgateway/createAppInfoLogic.go
  17. 40 0
      app/cmd/dtgateway/internal/logic/dtgateway/disableAppInfoLogic.go
  18. 40 0
      app/cmd/dtgateway/internal/logic/dtgateway/enableAppInfoLogic.go
  19. 41 0
      app/cmd/dtgateway/internal/logic/dtgateway/expireAppSecretLogic.go
  20. 42 0
      app/cmd/dtgateway/internal/logic/dtgateway/findAppListLogic.go
  21. 40 0
      app/cmd/dtgateway/internal/logic/dtgateway/getAppInfoLogic.go
  22. 40 0
      app/cmd/dtgateway/internal/logic/dtgateway/removeAppInfoLogic.go
  23. 41 0
      app/cmd/dtgateway/internal/logic/dtgateway/resetAppProjectLogic.go
  24. 40 0
      app/cmd/dtgateway/internal/logic/dtgateway/resetAppSecretLogic.go
  25. 3 2
      app/cmd/dtgateway/internal/middleware/datasignMiddleware.go
  26. 51 0
      app/cmd/dtgateway/internal/types/types.go
  27. 1 1
      app/cmd/organization/etc/organization.test.yaml
  28. 59 0
      app/cmd/organization/internal/logic/createAppInfoLogic.go
  29. 41 0
      app/cmd/organization/internal/logic/disableAppInfoLogic.go
  30. 41 0
      app/cmd/organization/internal/logic/enableAppInfoLogic.go
  31. 41 0
      app/cmd/organization/internal/logic/expireAppSecretLogic.go
  32. 53 0
      app/cmd/organization/internal/logic/findAppListLogic.go
  33. 40 0
      app/cmd/organization/internal/logic/getAppInfoLogic.go
  34. 35 0
      app/cmd/organization/internal/logic/removeAppInfoLogic.go
  35. 39 0
      app/cmd/organization/internal/logic/resetAppProjectLogic.go
  36. 41 0
      app/cmd/organization/internal/logic/resetAppSecretLogic.go
  37. 45 0
      app/cmd/organization/internal/server/organizationServer.go
  38. 2 0
      app/cmd/organization/internal/svc/vars.go
  39. 105 0
      app/cmd/organization/organization.proto
  40. 74 0
      app/cmd/organization/organization/organization.go
  41. 2053 807
      app/cmd/organization/pb/organization.pb.go
  42. 352 44
      app/cmd/organization/pb/organization_grpc.pb.go
  43. 43 12
      app/model/GtDataStore.sql
  44. 36 9
      app/model/dcAppInfoModel_gen.go
  45. 10 0
      app/model/vars.go

+ 49 - 11
app/cmd/dtgateway/desc/dtgateway.api

@@ -1,7 +1,9 @@
 syntax = "v1"
 
 import (
+	"dtgateway/common.api"
 	"dtgateway/dtgateway.api"
+	"dtgateway/appinfo.api"
 )
 
 @server(
@@ -13,48 +15,84 @@ service dtgateway {
 	@doc "查询working uf信息"
 	@handler WorkingUf
 	get /working-uf/info (DcWorkingReq) returns (CommonResponse)
-	
+
 	@doc "查询working uf信息"
 	@handler WorkingUfByCycle
 	get /working-uf/cycle (WorkingUfByCycleReq) returns (CommonResponse)
-	
+
 	@doc "查询working ro信息"
 	@handler WorkingRo
 	get /working-ro/info (DcWorkingReq) returns (CommonResponse)
-	
+
 	@doc "查询working chest信息"
 	@handler WorkingChest
 	get /working-chest/info (DcWorkingReq) returns (CommonResponse)
-	
+
 	@doc "查询working pump信息"
 	@handler WorkingPump
 	get /working-pump/info (DcWorkingReq) returns (CommonResponse)
-	
+
 	@doc "查询working valve信息"
 	@handler WorkingValve
 	get /working-valve/info (DcWorkingReq) returns (CommonResponse)
-	
+
 	@doc "秒级单点数据批量入库"
 	@handler ItemHistoryDataMultiAdd
 	post /item-history/multi-add (MultiAddItemHistoryDataReq) returns (CommonResponse)
-	
+
 	@doc "点位历史数据查询"
 	@handler ItemHistoryDataList
 	get /item-history/list (ItemHistoryDataListReq) returns (CommonResponse)
-	
+
 	@doc "按时间点位历史数据查询"
 	@handler ItemHistoryDataInfo
 	get /item-history/info (ItemHistoryDataByTimeReq) returns (CommonResponse)
-	
+
 	@doc "按时间点位历史数据最大值最小值查询"
 	@handler ItemHistoryDataMaxMin
 	get /item-history/max-min (ItemHistoryDataMaxMinByTimeReq) returns (CommonResponse)
-	
+
 	@doc "点位查询时间内第一个和最后一个值"
 	@handler ItemHistoryDataFirstLast
 	get /item-history/first-last (ItemHistoryDataByTimeReq) returns (CommonResponse)
-	
+
 	@doc "最新变化值点位数据"
 	@handler ChangeTypeItemData
 	get /item-change/info (ItemHistoryDataByTimeReq) returns (CommonResponse)
+
+	@doc "appSecret -> 查询列表"
+	@handler FindAppList
+	get /app/list (FindAppListReq) returns (CommonResponse)
+
+	@doc "appSecret -> 单个APP信息"
+	@handler GetAppInfo
+	get /app/info (GetAppInfoReq) returns (CommonResponse)
+
+	@doc "appSecret -> 创建一个新的记录"
+	@handler CreateAppInfo
+	post /app/create (CreateAppInfoReq) returns (CommonResponse)
+
+	@doc "appSecret -> 删除记录"
+	@handler RemoveAppInfo
+	post /app/remove (RemoveAppInfoReq) returns (CommonResponse)
+
+	@doc "appSecret -> 禁用"
+	@handler DisableAppInfo
+	post /app/disable (DisableAppInfoReq) returns (CommonResponse)
+
+	@doc "appSecret -> 启用"
+	@handler EnableAppInfo
+	post /app/enable (EnableAppInfoReq) returns (CommonResponse)
+
+	@doc "appSecret -> 重置secret"
+	@handler ResetAppSecret
+	post /app/secret/reset (ResetAppSecretReq) returns (CommonResponse)
+
+	@doc "appSecret -> 有效期设置"
+	@handler ExpireAppSecret
+	post /app/secret/expire (ExpireAppSecretReq) returns (CommonResponse)
+
+	@doc "appSecret -> 设置可管理的项目列表"
+	@handler ResetAppProject
+	post /app/project/reset (ResetAppProjectReq) returns (CommonResponse)
 }

+ 58 - 0
app/cmd/dtgateway/desc/dtgateway/appinfo.api

@@ -0,0 +1,58 @@
+syntax = "v1"
+
+import (
+    "common.api"
+)
+
+type (
+    FindAppListReq {
+        CommonParams
+        Page int64 `form:"page"`
+        PageSize int64 `form:"page_size"`
+        Order string `form:"order"`
+    }
+
+    GetAppInfoReq {
+        CommonParams
+        AppName string `form:"app_name"`
+    }
+
+    CreateAppInfoReq {
+        CommonParams
+        AppName string `json:"app_name"`
+        ProjectIds []int64 `json:"project_ids"`
+        Expire int64 `json:"expire"` // 有效期, 单位为秒
+    }
+
+    RemoveAppInfoReq {
+        CommonParams
+        AppName string `json:"app_name"`
+    }
+
+    DisableAppInfoReq {
+        CommonParams
+        AppName string `json:"app_name"`
+    }
+
+    EnableAppInfoReq {
+        CommonParams
+        AppName string `json:"app_name"`
+    }
+
+    ResetAppSecretReq {
+        CommonParams
+        AppName string `json:"app_name"`
+    }
+
+    ExpireAppSecretReq {
+        CommonParams
+        AppName string `json:"app_name"`
+        Expire int64 `json:"expire"` // 延长的有效期, 单位为秒
+    }
+
+    ResetAppProjectReq {
+        CommonParams
+        AppName string `json:"app_name"`
+        ProjectIds []int64 `json:"project_ids"`
+    }
+)

+ 16 - 0
app/cmd/dtgateway/desc/dtgateway/common.api

@@ -0,0 +1,16 @@
+syntax = "v1"
+
+type CommonParams {
+    Ts int64 `form:"ts"`
+    ProjectId int64 `form:"project_id"`
+    Sign string `form:"sign"`
+    SignFlag uint8 `form:"sign_flag,optional"`
+    AppName string `header:"APP-NAME"`
+    Order string `form:"order,optional,default=asc"`
+}
+
+type CommonResponse {
+    Code uint32 `json:"code"`
+    Msg string `json:"msg"`
+    Data interface{} `json:"data,omitempty"`
+}

+ 3 - 14
app/cmd/dtgateway/desc/dtgateway/dtgateway.api

@@ -1,19 +1,8 @@
 syntax = "v1"
 
-type CommonParams {
-    Ts int64 `form:"ts"`
-    ProjectId int64 `form:"project_id"`
-    Sign string `form:"sign"`
-    SignFlag uint8 `form:"sign_flag,optional"`
-    AppName string `header:"APP-NAME"`
-    Order string `form:"order,optional,default=asc"`
-}
-
-type CommonResponse {
-    Code uint32 `json:"code"`
-    Msg string `json:"msg"`
-    Data interface{} `json:"data,omitempty"`
-}
+import (
+    "common.api"
+)
 
 type (
     DcWorkingReq {

+ 1 - 1
app/cmd/dtgateway/etc/dtgateway.test.yaml

@@ -15,7 +15,7 @@ JwtAuth:
 Log:
   ServiceName: dtgateway-api
   Mode: console
-  Level: error
+  Level: info
 
 DtDataStoreDB:
   #  DataSource: ws_data:c712f89fc4f8edaf30e41b828f4e3d26@tcp(192.168.60.201:4000)/ws_data?charset=utf8mb4&parseTime=True&loc=&loc=Asia%2FShanghai

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/createAppInfoHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func CreateAppInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CreateAppInfoReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewCreateAppInfoLogic(r.Context(), svcCtx)
+		resp, err := l.CreateAppInfo(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/disableAppInfoHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func DisableAppInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.DisableAppInfoReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewDisableAppInfoLogic(r.Context(), svcCtx)
+		resp, err := l.DisableAppInfo(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/enableAppInfoHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func EnableAppInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.EnableAppInfoReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewEnableAppInfoLogic(r.Context(), svcCtx)
+		resp, err := l.EnableAppInfo(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/expireAppSecretHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func ExpireAppSecretHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ExpireAppSecretReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewExpireAppSecretLogic(r.Context(), svcCtx)
+		resp, err := l.ExpireAppSecret(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/findAppListHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func FindAppListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.FindAppListReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewFindAppListLogic(r.Context(), svcCtx)
+		resp, err := l.FindAppList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/getAppInfoHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func GetAppInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.GetAppInfoReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewGetAppInfoLogic(r.Context(), svcCtx)
+		resp, err := l.GetAppInfo(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/removeAppInfoHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func RemoveAppInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.RemoveAppInfoReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewRemoveAppInfoLogic(r.Context(), svcCtx)
+		resp, err := l.RemoveAppInfo(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/resetAppProjectHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func ResetAppProjectHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ResetAppProjectReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewResetAppProjectLogic(r.Context(), svcCtx)
+		resp, err := l.ResetAppProject(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
app/cmd/dtgateway/internal/handler/dtgateway/resetAppSecretHandler.go

@@ -0,0 +1,28 @@
+package dtgateway
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/dtgateway/internal/logic/dtgateway"
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func ResetAppSecretHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ResetAppSecretReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := dtgateway.NewResetAppSecretLogic(r.Context(), svcCtx)
+		resp, err := l.ResetAppSecret(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 45 - 0
app/cmd/dtgateway/internal/handler/routes.go

@@ -75,6 +75,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 					Path:    "/item-change/info",
 					Handler: dtgateway.ChangeTypeItemDataHandler(serverCtx),
 				},
+				{
+					Method:  http.MethodGet,
+					Path:    "/app/list",
+					Handler: dtgateway.FindAppListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodGet,
+					Path:    "/app/info",
+					Handler: dtgateway.GetAppInfoHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/app/create",
+					Handler: dtgateway.CreateAppInfoHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/app/remove",
+					Handler: dtgateway.RemoveAppInfoHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/app/disable",
+					Handler: dtgateway.DisableAppInfoHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/app/enable",
+					Handler: dtgateway.EnableAppInfoHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/app/secret/reset",
+					Handler: dtgateway.ResetAppSecretHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/app/secret/expire",
+					Handler: dtgateway.ExpireAppSecretHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/app/project/reset",
+					Handler: dtgateway.ResetAppProjectHandler(serverCtx),
+				},
 			}...,
 		),
 		rest.WithPrefix("/api/dtgateway/v1"),

+ 42 - 0
app/cmd/dtgateway/internal/logic/dtgateway/createAppInfoLogic.go

@@ -0,0 +1,42 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CreateAppInfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewCreateAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAppInfoLogic {
+	return &CreateAppInfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *CreateAppInfoLogic) CreateAppInfo(req *types.CreateAppInfoReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.CreateAppInfo(l.ctx, &pb.CreateAppInfoReq{
+		AppName:    req.AppName,
+		ProjectIds: req.ProjectIds,
+		Expire:     req.Expire,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 40 - 0
app/cmd/dtgateway/internal/logic/dtgateway/disableAppInfoLogic.go

@@ -0,0 +1,40 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DisableAppInfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewDisableAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DisableAppInfoLogic {
+	return &DisableAppInfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *DisableAppInfoLogic) DisableAppInfo(req *types.DisableAppInfoReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.DisableAppInfo(l.ctx, &pb.DisableAppInfoReq{
+		AppName: req.AppName,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 40 - 0
app/cmd/dtgateway/internal/logic/dtgateway/enableAppInfoLogic.go

@@ -0,0 +1,40 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type EnableAppInfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewEnableAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EnableAppInfoLogic {
+	return &EnableAppInfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *EnableAppInfoLogic) EnableAppInfo(req *types.EnableAppInfoReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.EnableAppInfo(l.ctx, &pb.EnableAppInfoReq{
+		AppName: req.AppName,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 41 - 0
app/cmd/dtgateway/internal/logic/dtgateway/expireAppSecretLogic.go

@@ -0,0 +1,41 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ExpireAppSecretLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewExpireAppSecretLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExpireAppSecretLogic {
+	return &ExpireAppSecretLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ExpireAppSecretLogic) ExpireAppSecret(req *types.ExpireAppSecretReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.ExpireAppSecret(l.ctx, &pb.ExpireAppSecretReq{
+		AppName: req.AppName,
+		Expire:  req.Expire,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 42 - 0
app/cmd/dtgateway/internal/logic/dtgateway/findAppListLogic.go

@@ -0,0 +1,42 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type FindAppListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewFindAppListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindAppListLogic {
+	return &FindAppListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *FindAppListLogic) FindAppList(req *types.FindAppListReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.FindAppList(l.ctx, &pb.FindAppListReq{
+		Page:     req.Page,
+		PageSize: req.PageSize,
+		Order:    req.Order,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 40 - 0
app/cmd/dtgateway/internal/logic/dtgateway/getAppInfoLogic.go

@@ -0,0 +1,40 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetAppInfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAppInfoLogic {
+	return &GetAppInfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GetAppInfoLogic) GetAppInfo(req *types.GetAppInfoReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.GetAppInfo(l.ctx, &pb.GetAppInfoReq{
+		AppName: req.AppName,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 40 - 0
app/cmd/dtgateway/internal/logic/dtgateway/removeAppInfoLogic.go

@@ -0,0 +1,40 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type RemoveAppInfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewRemoveAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveAppInfoLogic {
+	return &RemoveAppInfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *RemoveAppInfoLogic) RemoveAppInfo(req *types.RemoveAppInfoReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.RemoveAppInfo(l.ctx, &pb.RemoveAppInfoReq{
+		AppName: req.AppName,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 41 - 0
app/cmd/dtgateway/internal/logic/dtgateway/resetAppProjectLogic.go

@@ -0,0 +1,41 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ResetAppProjectLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewResetAppProjectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResetAppProjectLogic {
+	return &ResetAppProjectLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ResetAppProjectLogic) ResetAppProject(req *types.ResetAppProjectReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.ResetAppProject(l.ctx, &pb.ResetAppProjectReq{
+		AppName:    req.AppName,
+		ProjectIds: req.ProjectIds,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 40 - 0
app/cmd/dtgateway/internal/logic/dtgateway/resetAppSecretLogic.go

@@ -0,0 +1,40 @@
+package dtgateway
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+
+	"GtDataStore/app/cmd/dtgateway/internal/svc"
+	"GtDataStore/app/cmd/dtgateway/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ResetAppSecretLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewResetAppSecretLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResetAppSecretLogic {
+	return &ResetAppSecretLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ResetAppSecretLogic) ResetAppSecret(req *types.ResetAppSecretReq) (resp *types.CommonResponse, err error) {
+	rpcData, err := l.svcCtx.OrganizationRpc.ResetAppSecret(l.ctx, &pb.ResetAppSecretReq{
+		AppName: req.AppName,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: rpcData,
+	}, nil
+}

+ 3 - 2
app/cmd/dtgateway/internal/middleware/datasignMiddleware.go

@@ -207,7 +207,7 @@ func (m *DataSignMiddleware) parseQuery(r *http.Request) (query string, err erro
 
 func (m *DataSignMiddleware) getAppSecret(appName string) (string, error) {
 	if secret, ok := appSecrets[appName]; ok {
-		if secret.Expire.After(time.Now()) == false {
+		if secret.Expire.After(time.Now()) {
 			return secret.Secret, nil
 		}
 	}
@@ -221,7 +221,8 @@ func (m *DataSignMiddleware) getAppSecret(appName string) (string, error) {
 			Status: appInfo.Status,
 			Expire: time.Now().Add(APP_SECRET_CACHE_EXPIRE * time.Second),
 		}
-		if appInfo.Status == 0 {
+		// 状态正常 并且 secret未过期
+		if appInfo.Status == 0 && appInfo.ExpireAt.After(time.Now()) {
 			return appInfo.Secret, nil
 		}
 	}

+ 51 - 0
app/cmd/dtgateway/internal/types/types.go

@@ -73,3 +73,54 @@ type WorkingUfByCycleReq struct {
 	FilterTimeEnd   float64 `form:"filter_time_end"`
 	Limit           int64   `form:"limit"`
 }
+
+type FindAppListReq struct {
+	CommonParams
+	Page     int64  `form:"page"`
+	PageSize int64  `form:"page_size"`
+	Order    string `form:"order"`
+}
+
+type GetAppInfoReq struct {
+	CommonParams
+	AppName string `form:"app_name"`
+}
+
+type CreateAppInfoReq struct {
+	CommonParams
+	AppName    string  `json:"app_name"`
+	ProjectIds []int64 `json:"project_ids"`
+	Expire     int64   `json:"expire"` // 有效期, 单位为秒
+}
+
+type RemoveAppInfoReq struct {
+	CommonParams
+	AppName string `json:"app_name"`
+}
+
+type DisableAppInfoReq struct {
+	CommonParams
+	AppName string `json:"app_name"`
+}
+
+type EnableAppInfoReq struct {
+	CommonParams
+	AppName string `json:"app_name"`
+}
+
+type ResetAppSecretReq struct {
+	CommonParams
+	AppName string `json:"app_name"`
+}
+
+type ExpireAppSecretReq struct {
+	CommonParams
+	AppName string `json:"app_name"`
+	Expire  int64  `json:"expire"` // 延长的有效期, 单位为秒
+}
+
+type ResetAppProjectReq struct {
+	CommonParams
+	AppName    string  `json:"app_name"`
+	ProjectIds []int64 `json:"project_ids"`
+}

+ 1 - 1
app/cmd/organization/etc/organization.test.yaml

@@ -7,7 +7,7 @@ Mode: test
 Log:
   ServiceName: organization-rpc
   Mode: console
-  Level: error
+  Level: info
 
 #双胞胎服务
 GtServerIp: 47.96.12.136:8788

+ 59 - 0
app/cmd/organization/internal/logic/createAppInfoLogic.go

@@ -0,0 +1,59 @@
+package logic
+
+import (
+	"GtDataStore/app/model"
+	"GtDataStore/common/crypto/md5"
+	"context"
+	"fmt"
+	"time"
+
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CreateAppInfoLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewCreateAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAppInfoLogic {
+	return &CreateAppInfoLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *CreateAppInfoLogic) CreateAppInfo(in *pb.CreateAppInfoReq) (*pb.CreateAppInfoResp, error) {
+	now := time.Now()
+	expire := now.Add(time.Duration(in.Expire) * time.Second)
+
+	appInfo := &model.DcAppInfo{
+		AppName:    in.AppName,
+		ProjectIds: in.ProjectIds,
+		Secret:     md5.Md5([]byte(fmt.Sprintf("%s_%d:%d", in.AppName, 0, expire.UnixMilli()))),
+		Status:     0,
+		ExpireAt:   expire,
+		MTime:      now,
+	}
+
+	r, err := l.svcCtx.AppInfo.Insert(l.ctx, appInfo)
+	if err != nil {
+		return nil, err
+	}
+
+	lid, _ := r.LastInsertId()
+
+	return &pb.CreateAppInfoResp{AppInfo: &pb.AppInfo{
+		Id:         lid,
+		AppName:    appInfo.AppName,
+		ProjectIds: appInfo.ProjectIds,
+		Secret:     appInfo.Secret,
+		Status:     appInfo.Status,
+		ExpireAt:   appInfo.ExpireAt.Format("2006-01-02 15:04:05"),
+		CTime:      appInfo.MTime.Format("2006-01-02 15:04:05"),
+	}}, nil
+}

+ 41 - 0
app/cmd/organization/internal/logic/disableAppInfoLogic.go

@@ -0,0 +1,41 @@
+package logic
+
+import (
+	"context"
+
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DisableAppInfoLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDisableAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DisableAppInfoLogic {
+	return &DisableAppInfoLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *DisableAppInfoLogic) DisableAppInfo(in *pb.DisableAppInfoReq) (*pb.DisableAppInfoResp, error) {
+	appInfo, err := l.svcCtx.AppInfo.FindOneByAppName(l.ctx, in.AppName)
+	if err != nil {
+		return nil, err
+	}
+
+	if appInfo.Status != 1 {
+		appInfo.Status = 1
+		err = l.svcCtx.AppInfo.Update(l.ctx, appInfo)
+		if err != nil {
+			return nil, err
+		}
+	}
+
+	return &pb.DisableAppInfoResp{Ok: true}, nil
+}

+ 41 - 0
app/cmd/organization/internal/logic/enableAppInfoLogic.go

@@ -0,0 +1,41 @@
+package logic
+
+import (
+	"context"
+
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type EnableAppInfoLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewEnableAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EnableAppInfoLogic {
+	return &EnableAppInfoLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *EnableAppInfoLogic) EnableAppInfo(in *pb.EnableAppInfoReq) (*pb.EnableAppInfoResp, error) {
+	appInfo, err := l.svcCtx.AppInfo.FindOneByAppName(l.ctx, in.AppName)
+	if err != nil {
+		return nil, err
+	}
+
+	if appInfo.Status != 0 {
+		appInfo.Status = 0
+		err = l.svcCtx.AppInfo.Update(l.ctx, appInfo)
+		if err != nil {
+			return nil, err
+		}
+	}
+
+	return &pb.EnableAppInfoResp{Ok: true}, nil
+}

+ 41 - 0
app/cmd/organization/internal/logic/expireAppSecretLogic.go

@@ -0,0 +1,41 @@
+package logic
+
+import (
+	"context"
+	"time"
+
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ExpireAppSecretLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewExpireAppSecretLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExpireAppSecretLogic {
+	return &ExpireAppSecretLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *ExpireAppSecretLogic) ExpireAppSecret(in *pb.ExpireAppSecretReq) (*pb.ExpireAppSecretResp, error) {
+	appInfo, err := l.svcCtx.AppInfo.FindOneByAppName(l.ctx, in.AppName)
+	if err != nil {
+		return nil, err
+	}
+
+	appInfo.ExpireAt = appInfo.ExpireAt.Add(time.Duration(in.Expire) * time.Second)
+
+	err = l.svcCtx.AppInfo.Update(l.ctx, appInfo)
+	if err != nil {
+		return nil, err
+	}
+
+	return &pb.ExpireAppSecretResp{ExpireAt: appInfo.ExpireAt.Format("2006-01-02 15:04:05")}, nil
+}

+ 53 - 0
app/cmd/organization/internal/logic/findAppListLogic.go

@@ -0,0 +1,53 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type FindAppListLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewFindAppListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindAppListLogic {
+	return &FindAppListLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *FindAppListLogic) FindAppList(in *pb.FindAppListReq) (*pb.FindAppListResp, error) {
+	if in.Page <= 1 {
+		in.Page = 1
+	}
+	offset, limit := (in.Page-1)*in.PageSize, in.PageSize
+	appInfos, total, err := l.svcCtx.AppInfo.Find(l.ctx, offset, limit, "`id` DESC")
+	if err != nil {
+		return nil, err
+	}
+
+	res := make([]*pb.AppInfo, len(appInfos))
+	for i, info := range appInfos {
+		res[i] = &pb.AppInfo{
+			Id:         info.Id,
+			AppName:    info.AppName,
+			ProjectIds: info.ProjectIds,
+			Secret:     info.Secret,
+			Status:     info.Status,
+			ExpireAt:   info.ExpireAt.Format("2006-01-02 15:04:05"),
+			CTime:      info.MTime.Format("2006-01-02 15:04:05"),
+		}
+	}
+
+	return &pb.FindAppListResp{List: res, Pagination: &pb.Pagination{
+		Current:  uint32(in.Page),
+		PageSize: uint32(in.PageSize),
+		Total:    uint32(total),
+	}}, nil
+}

+ 40 - 0
app/cmd/organization/internal/logic/getAppInfoLogic.go

@@ -0,0 +1,40 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetAppInfoLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAppInfoLogic {
+	return &GetAppInfoLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetAppInfoLogic) GetAppInfo(in *pb.GetAppInfoReq) (*pb.GetAppInfoResp, error) {
+	appInfo, err := l.svcCtx.AppInfo.FindOneByAppName(l.ctx, in.AppName)
+	if err != nil {
+		return nil, err
+	}
+
+	return &pb.GetAppInfoResp{AppInfo: &pb.AppInfo{
+		Id:         appInfo.Id,
+		AppName:    appInfo.AppName,
+		ProjectIds: appInfo.ProjectIds,
+		Secret:     appInfo.Secret,
+		Status:     appInfo.Status,
+		ExpireAt:   appInfo.ExpireAt.Format("2006-01-02 15:04:05"),
+		CTime:      appInfo.MTime.Format("2006-01-02 15:04:05"),
+	}}, nil
+}

+ 35 - 0
app/cmd/organization/internal/logic/removeAppInfoLogic.go

@@ -0,0 +1,35 @@
+package logic
+
+import (
+	"context"
+
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type RemoveAppInfoLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewRemoveAppInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveAppInfoLogic {
+	return &RemoveAppInfoLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *RemoveAppInfoLogic) RemoveAppInfo(in *pb.RemoveAppInfoReq) (*pb.RemoveAppInfoResp, error) {
+	appInfo, err := l.svcCtx.AppInfo.FindOneByAppName(l.ctx, in.AppName)
+	if err != nil {
+		return nil, err
+	}
+
+	err = l.svcCtx.AppInfo.Delete(l.ctx, appInfo.Id)
+
+	return &pb.RemoveAppInfoResp{Ok: err == nil}, nil
+}

+ 39 - 0
app/cmd/organization/internal/logic/resetAppProjectLogic.go

@@ -0,0 +1,39 @@
+package logic
+
+import (
+	"context"
+
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ResetAppProjectLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewResetAppProjectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResetAppProjectLogic {
+	return &ResetAppProjectLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *ResetAppProjectLogic) ResetAppProject(in *pb.ResetAppProjectReq) (*pb.ResetAppProjectResp, error) {
+	appInfo, err := l.svcCtx.AppInfo.FindOneByAppName(l.ctx, in.AppName)
+	if err != nil {
+		return nil, err
+	}
+
+	appInfo.ProjectIds = in.ProjectIds
+	err = l.svcCtx.AppInfo.Update(l.ctx, appInfo)
+	if err != nil {
+		return nil, err
+	}
+
+	return &pb.ResetAppProjectResp{RemoveProjectIds: nil}, nil
+}

+ 41 - 0
app/cmd/organization/internal/logic/resetAppSecretLogic.go

@@ -0,0 +1,41 @@
+package logic
+
+import (
+	"GtDataStore/common/crypto/md5"
+	"context"
+	"fmt"
+
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ResetAppSecretLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewResetAppSecretLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResetAppSecretLogic {
+	return &ResetAppSecretLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *ResetAppSecretLogic) ResetAppSecret(in *pb.ResetAppSecretReq) (*pb.ResetAppSecretResp, error) {
+	appInfo, err := l.svcCtx.AppInfo.FindOneByAppName(l.ctx, in.AppName)
+	if err != nil {
+		return nil, err
+	}
+
+	appInfo.Secret = md5.Md5([]byte(fmt.Sprintf("%s_%d:%d", in.AppName, appInfo.Status, appInfo.ExpireAt.UnixMilli())))
+	err = l.svcCtx.AppInfo.Update(l.ctx, appInfo)
+	if err != nil {
+		return nil, err
+	}
+
+	return &pb.ResetAppSecretResp{Secret: appInfo.Secret}, nil
+}

+ 45 - 0
app/cmd/organization/internal/server/organizationServer.go

@@ -86,3 +86,48 @@ func (s *OrganizationServer) ItemHistoryDataForChart(ctx context.Context, in *pb
 	l := logic.NewItemHistoryDataForChartLogic(ctx, s.svcCtx)
 	return l.ItemHistoryDataForChart(in)
 }
+
+func (s *OrganizationServer) FindAppList(ctx context.Context, in *pb.FindAppListReq) (*pb.FindAppListResp, error) {
+	l := logic.NewFindAppListLogic(ctx, s.svcCtx)
+	return l.FindAppList(in)
+}
+
+func (s *OrganizationServer) GetAppInfo(ctx context.Context, in *pb.GetAppInfoReq) (*pb.GetAppInfoResp, error) {
+	l := logic.NewGetAppInfoLogic(ctx, s.svcCtx)
+	return l.GetAppInfo(in)
+}
+
+func (s *OrganizationServer) CreateAppInfo(ctx context.Context, in *pb.CreateAppInfoReq) (*pb.CreateAppInfoResp, error) {
+	l := logic.NewCreateAppInfoLogic(ctx, s.svcCtx)
+	return l.CreateAppInfo(in)
+}
+
+func (s *OrganizationServer) RemoveAppInfo(ctx context.Context, in *pb.RemoveAppInfoReq) (*pb.RemoveAppInfoResp, error) {
+	l := logic.NewRemoveAppInfoLogic(ctx, s.svcCtx)
+	return l.RemoveAppInfo(in)
+}
+
+func (s *OrganizationServer) DisableAppInfo(ctx context.Context, in *pb.DisableAppInfoReq) (*pb.DisableAppInfoResp, error) {
+	l := logic.NewDisableAppInfoLogic(ctx, s.svcCtx)
+	return l.DisableAppInfo(in)
+}
+
+func (s *OrganizationServer) EnableAppInfo(ctx context.Context, in *pb.EnableAppInfoReq) (*pb.EnableAppInfoResp, error) {
+	l := logic.NewEnableAppInfoLogic(ctx, s.svcCtx)
+	return l.EnableAppInfo(in)
+}
+
+func (s *OrganizationServer) ResetAppSecret(ctx context.Context, in *pb.ResetAppSecretReq) (*pb.ResetAppSecretResp, error) {
+	l := logic.NewResetAppSecretLogic(ctx, s.svcCtx)
+	return l.ResetAppSecret(in)
+}
+
+func (s *OrganizationServer) ExpireAppSecret(ctx context.Context, in *pb.ExpireAppSecretReq) (*pb.ExpireAppSecretResp, error) {
+	l := logic.NewExpireAppSecretLogic(ctx, s.svcCtx)
+	return l.ExpireAppSecret(in)
+}
+
+func (s *OrganizationServer) ResetAppProject(ctx context.Context, in *pb.ResetAppProjectReq) (*pb.ResetAppProjectResp, error) {
+	l := logic.NewResetAppProjectLogic(ctx, s.svcCtx)
+	return l.ResetAppProject(in)
+}

+ 2 - 0
app/cmd/organization/internal/svc/vars.go

@@ -8,6 +8,7 @@ import (
 type modelList struct {
 	DeviceBind      model.DcDeviceBindModel
 	ProjectConfig   model.DcProjectConfigModel
+	AppInfo         model.DcAppInfoModel
 	WorkingUf       model.DcWorkingUfModel
 	WorkingMf       model.DcWorkingMfModel
 	WorkingNf       model.DcWorkingNfModel
@@ -21,6 +22,7 @@ type modelList struct {
 func initModel(svc *ServiceContext) {
 	mysql := sqlx.NewMysql(svc.Config.DtDataStoreDB.DataSource)
 	svc.DeviceBind = model.NewDcDeviceBindModel(mysql)
+	svc.AppInfo = model.NewDcAppInfoModel(mysql)
 	svc.ProjectConfig = model.NewDcProjectConfigModel(mysql)
 	svc.WorkingUf = model.NewDcWorkingUfModel(mysql)
 	svc.WorkingMf = model.NewDcWorkingMfModel(mysql)

+ 105 - 0
app/cmd/organization/organization.proto

@@ -3,6 +3,22 @@ syntax = "proto3";
 package pb;
 option go_package = "./pb";
 
+message Pagination {
+  uint32 current = 1;
+  uint32 pageSize = 2;
+  uint32 total = 3;
+}
+
+message AppInfo {
+  int64 id = 1;
+  string app_name = 2;
+  repeated int64 project_ids = 3;
+  string secret = 4;
+  int64 status = 5;
+  string expire_at = 6;
+  string c_time = 7;
+}
+
 message DcWorkingReq{
   int64   project_id = 1;
   string  device_code = 2;
@@ -584,6 +600,85 @@ message GetWorkingChestByCodeResp{
   repeated WorkingChest list = 1;
 }
 
+message FindAppListReq {
+  int64 page = 1;
+  int64 page_size = 2;
+  string order = 3; // 排序字段及方向 例: id desc
+}
+
+message FindAppListResp {
+  repeated AppInfo list = 1;
+  Pagination pagination = 2;
+}
+
+message GetAppInfoReq {
+  string app_name = 1;
+}
+
+message GetAppInfoResp {
+  AppInfo app_info = 1;
+}
+
+message CreateAppInfoReq {
+  string app_name = 1;
+  repeated int64 project_ids = 2;
+  int64 expire = 3;
+}
+
+message CreateAppInfoResp {
+  AppInfo app_info = 1;
+}
+
+message RemoveAppInfoReq {
+  string app_name = 1;
+}
+
+message RemoveAppInfoResp {
+  bool ok = 1;
+}
+
+message DisableAppInfoReq {
+  string app_name = 1;
+}
+
+message DisableAppInfoResp {
+  bool ok = 1;
+}
+
+message EnableAppInfoReq {
+  string app_name = 1;
+}
+
+message EnableAppInfoResp {
+  bool ok = 1;
+}
+
+message ResetAppSecretReq {
+  string app_name = 1;
+}
+
+message ResetAppSecretResp {
+  string secret = 1;
+}
+
+message ExpireAppSecretReq {
+  string app_name = 1;
+  int64 expire = 3;
+}
+
+message ExpireAppSecretResp {
+  string expire_at = 3;
+}
+
+message ResetAppProjectReq {
+  string app_name = 1;
+  repeated int64 project_ids = 2;
+}
+
+message ResetAppProjectResp {
+  repeated int64 remove_project_ids = 1;
+}
+
 service Organization {
   rpc GetWorkingUfByCode(DcWorkingReq) returns(GetWorkingUfByCodeResp);
   rpc FindWorkingUfByCycle(FindWorkingUfByCycleReq) returns(FindWorkingUfByCycleResp);
@@ -598,4 +693,14 @@ service Organization {
   rpc ItemHistoryDataFirstLastByTime(ItemHistoryDataByTimeReq) returns(ItemHistoryDataFirstLastResp);
   rpc ChangeTypeItemHistoryData(ItemHistoryDataByTimeReq) returns(ChangeTypeItemHistoryDataResp);
   rpc ItemHistoryDataForChart(ItemHistoryDataForChartReq) returns(ItemHistoryDataForChartResp);
+
+  rpc FindAppList (FindAppListReq) returns (FindAppListResp);
+  rpc GetAppInfo (GetAppInfoReq) returns (GetAppInfoResp);
+  rpc CreateAppInfo (CreateAppInfoReq) returns (CreateAppInfoResp);
+  rpc RemoveAppInfo (RemoveAppInfoReq) returns (RemoveAppInfoResp);
+  rpc DisableAppInfo (DisableAppInfoReq) returns (DisableAppInfoResp);
+  rpc EnableAppInfo (EnableAppInfoReq) returns (EnableAppInfoResp);
+  rpc ResetAppSecret (ResetAppSecretReq) returns (ResetAppSecretResp);
+  rpc ExpireAppSecret (ExpireAppSecretReq) returns (ExpireAppSecretResp);
+  rpc ResetAppProject (ResetAppProjectReq) returns (ResetAppProjectResp);
 }

+ 74 - 0
app/cmd/organization/organization/organization.go

@@ -13,10 +13,23 @@ import (
 )
 
 type (
+	AppInfo                       = pb.AppInfo
 	ChangeTypeItemHistoryDataResp = pb.ChangeTypeItemHistoryDataResp
+	CreateAppInfoReq              = pb.CreateAppInfoReq
+	CreateAppInfoResp             = pb.CreateAppInfoResp
 	DcWorkingReq                  = pb.DcWorkingReq
+	DisableAppInfoReq             = pb.DisableAppInfoReq
+	DisableAppInfoResp            = pb.DisableAppInfoResp
+	EnableAppInfoReq              = pb.EnableAppInfoReq
+	EnableAppInfoResp             = pb.EnableAppInfoResp
+	ExpireAppSecretReq            = pb.ExpireAppSecretReq
+	ExpireAppSecretResp           = pb.ExpireAppSecretResp
+	FindAppListReq                = pb.FindAppListReq
+	FindAppListResp               = pb.FindAppListResp
 	FindWorkingUfByCycleReq       = pb.FindWorkingUfByCycleReq
 	FindWorkingUfByCycleResp      = pb.FindWorkingUfByCycleResp
+	GetAppInfoReq                 = pb.GetAppInfoReq
+	GetAppInfoResp                = pb.GetAppInfoResp
 	GetWorkingChestByCodeResp     = pb.GetWorkingChestByCodeResp
 	GetWorkingMfByCodeResp        = pb.GetWorkingMfByCodeResp
 	GetWorkingNfByCodeResp        = pb.GetWorkingNfByCodeResp
@@ -36,6 +49,13 @@ type (
 	ItemHistoryDataMaxMinResp     = pb.ItemHistoryDataMaxMinResp
 	MultiAddItemHistoryDataReq    = pb.MultiAddItemHistoryDataReq
 	MultiAddItemHistoryDataResp   = pb.MultiAddItemHistoryDataResp
+	Pagination                    = pb.Pagination
+	RemoveAppInfoReq              = pb.RemoveAppInfoReq
+	RemoveAppInfoResp             = pb.RemoveAppInfoResp
+	ResetAppProjectReq            = pb.ResetAppProjectReq
+	ResetAppProjectResp           = pb.ResetAppProjectResp
+	ResetAppSecretReq             = pb.ResetAppSecretReq
+	ResetAppSecretResp            = pb.ResetAppSecretResp
 	WorkingChest                  = pb.WorkingChest
 	WorkingMf                     = pb.WorkingMf
 	WorkingNf                     = pb.WorkingNf
@@ -58,6 +78,15 @@ type (
 		ItemHistoryDataFirstLastByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ItemHistoryDataFirstLastResp, error)
 		ChangeTypeItemHistoryData(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ChangeTypeItemHistoryDataResp, error)
 		ItemHistoryDataForChart(ctx context.Context, in *ItemHistoryDataForChartReq, opts ...grpc.CallOption) (*ItemHistoryDataForChartResp, error)
+		FindAppList(ctx context.Context, in *FindAppListReq, opts ...grpc.CallOption) (*FindAppListResp, error)
+		GetAppInfo(ctx context.Context, in *GetAppInfoReq, opts ...grpc.CallOption) (*GetAppInfoResp, error)
+		CreateAppInfo(ctx context.Context, in *CreateAppInfoReq, opts ...grpc.CallOption) (*CreateAppInfoResp, error)
+		RemoveAppInfo(ctx context.Context, in *RemoveAppInfoReq, opts ...grpc.CallOption) (*RemoveAppInfoResp, error)
+		DisableAppInfo(ctx context.Context, in *DisableAppInfoReq, opts ...grpc.CallOption) (*DisableAppInfoResp, error)
+		EnableAppInfo(ctx context.Context, in *EnableAppInfoReq, opts ...grpc.CallOption) (*EnableAppInfoResp, error)
+		ResetAppSecret(ctx context.Context, in *ResetAppSecretReq, opts ...grpc.CallOption) (*ResetAppSecretResp, error)
+		ExpireAppSecret(ctx context.Context, in *ExpireAppSecretReq, opts ...grpc.CallOption) (*ExpireAppSecretResp, error)
+		ResetAppProject(ctx context.Context, in *ResetAppProjectReq, opts ...grpc.CallOption) (*ResetAppProjectResp, error)
 	}
 
 	defaultOrganization struct {
@@ -135,3 +164,48 @@ func (m *defaultOrganization) ItemHistoryDataForChart(ctx context.Context, in *I
 	client := pb.NewOrganizationClient(m.cli.Conn())
 	return client.ItemHistoryDataForChart(ctx, in, opts...)
 }
+
+func (m *defaultOrganization) FindAppList(ctx context.Context, in *FindAppListReq, opts ...grpc.CallOption) (*FindAppListResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.FindAppList(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) GetAppInfo(ctx context.Context, in *GetAppInfoReq, opts ...grpc.CallOption) (*GetAppInfoResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.GetAppInfo(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) CreateAppInfo(ctx context.Context, in *CreateAppInfoReq, opts ...grpc.CallOption) (*CreateAppInfoResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.CreateAppInfo(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) RemoveAppInfo(ctx context.Context, in *RemoveAppInfoReq, opts ...grpc.CallOption) (*RemoveAppInfoResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.RemoveAppInfo(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) DisableAppInfo(ctx context.Context, in *DisableAppInfoReq, opts ...grpc.CallOption) (*DisableAppInfoResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.DisableAppInfo(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) EnableAppInfo(ctx context.Context, in *EnableAppInfoReq, opts ...grpc.CallOption) (*EnableAppInfoResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.EnableAppInfo(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) ResetAppSecret(ctx context.Context, in *ResetAppSecretReq, opts ...grpc.CallOption) (*ResetAppSecretResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.ResetAppSecret(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) ExpireAppSecret(ctx context.Context, in *ExpireAppSecretReq, opts ...grpc.CallOption) (*ExpireAppSecretResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.ExpireAppSecret(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) ResetAppProject(ctx context.Context, in *ResetAppProjectReq, opts ...grpc.CallOption) (*ResetAppProjectResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.ResetAppProject(ctx, in, opts...)
+}

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2053 - 807
app/cmd/organization/pb/organization.pb.go


+ 352 - 44
app/cmd/organization/pb/organization_grpc.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
 // versions:
-// - protoc-gen-go-grpc v1.3.0
-// - protoc             v3.21.12
+// - protoc-gen-go-grpc v1.2.0
+// - protoc             v4.23.4
 // source: organization.proto
 
 package pb
@@ -18,22 +18,6 @@ import (
 // Requires gRPC-Go v1.32.0 or later.
 const _ = grpc.SupportPackageIsVersion7
 
-const (
-	Organization_GetWorkingUfByCode_FullMethodName             = "/pb.Organization/GetWorkingUfByCode"
-	Organization_FindWorkingUfByCycle_FullMethodName           = "/pb.Organization/FindWorkingUfByCycle"
-	Organization_GetWorkingRoByCode_FullMethodName             = "/pb.Organization/GetWorkingRoByCode"
-	Organization_GetWorkingChestByCode_FullMethodName          = "/pb.Organization/GetWorkingChestByCode"
-	Organization_GetWorkingPumpByCode_FullMethodName           = "/pb.Organization/GetWorkingPumpByCode"
-	Organization_GetWorkingValveByCode_FullMethodName          = "/pb.Organization/GetWorkingValveByCode"
-	Organization_MultiAddItemHistoryData_FullMethodName        = "/pb.Organization/MultiAddItemHistoryData"
-	Organization_ItemHistoryDataList_FullMethodName            = "/pb.Organization/ItemHistoryDataList"
-	Organization_ItemHistoryDataByTime_FullMethodName          = "/pb.Organization/ItemHistoryDataByTime"
-	Organization_ItemHistoryDataMaxMinByTime_FullMethodName    = "/pb.Organization/ItemHistoryDataMaxMinByTime"
-	Organization_ItemHistoryDataFirstLastByTime_FullMethodName = "/pb.Organization/ItemHistoryDataFirstLastByTime"
-	Organization_ChangeTypeItemHistoryData_FullMethodName      = "/pb.Organization/ChangeTypeItemHistoryData"
-	Organization_ItemHistoryDataForChart_FullMethodName        = "/pb.Organization/ItemHistoryDataForChart"
-)
-
 // OrganizationClient is the client API for Organization service.
 //
 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
@@ -51,6 +35,15 @@ type OrganizationClient interface {
 	ItemHistoryDataFirstLastByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ItemHistoryDataFirstLastResp, error)
 	ChangeTypeItemHistoryData(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ChangeTypeItemHistoryDataResp, error)
 	ItemHistoryDataForChart(ctx context.Context, in *ItemHistoryDataForChartReq, opts ...grpc.CallOption) (*ItemHistoryDataForChartResp, error)
+	FindAppList(ctx context.Context, in *FindAppListReq, opts ...grpc.CallOption) (*FindAppListResp, error)
+	GetAppInfo(ctx context.Context, in *GetAppInfoReq, opts ...grpc.CallOption) (*GetAppInfoResp, error)
+	CreateAppInfo(ctx context.Context, in *CreateAppInfoReq, opts ...grpc.CallOption) (*CreateAppInfoResp, error)
+	RemoveAppInfo(ctx context.Context, in *RemoveAppInfoReq, opts ...grpc.CallOption) (*RemoveAppInfoResp, error)
+	DisableAppInfo(ctx context.Context, in *DisableAppInfoReq, opts ...grpc.CallOption) (*DisableAppInfoResp, error)
+	EnableAppInfo(ctx context.Context, in *EnableAppInfoReq, opts ...grpc.CallOption) (*EnableAppInfoResp, error)
+	ResetAppSecret(ctx context.Context, in *ResetAppSecretReq, opts ...grpc.CallOption) (*ResetAppSecretResp, error)
+	ExpireAppSecret(ctx context.Context, in *ExpireAppSecretReq, opts ...grpc.CallOption) (*ExpireAppSecretResp, error)
+	ResetAppProject(ctx context.Context, in *ResetAppProjectReq, opts ...grpc.CallOption) (*ResetAppProjectResp, error)
 }
 
 type organizationClient struct {
@@ -63,7 +56,7 @@ func NewOrganizationClient(cc grpc.ClientConnInterface) OrganizationClient {
 
 func (c *organizationClient) GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingUfByCodeResp, error) {
 	out := new(GetWorkingUfByCodeResp)
-	err := c.cc.Invoke(ctx, Organization_GetWorkingUfByCode_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingUfByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -72,7 +65,7 @@ func (c *organizationClient) GetWorkingUfByCode(ctx context.Context, in *DcWorki
 
 func (c *organizationClient) FindWorkingUfByCycle(ctx context.Context, in *FindWorkingUfByCycleReq, opts ...grpc.CallOption) (*FindWorkingUfByCycleResp, error) {
 	out := new(FindWorkingUfByCycleResp)
-	err := c.cc.Invoke(ctx, Organization_FindWorkingUfByCycle_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/FindWorkingUfByCycle", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -81,7 +74,7 @@ func (c *organizationClient) FindWorkingUfByCycle(ctx context.Context, in *FindW
 
 func (c *organizationClient) GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingRoByCodeResp, error) {
 	out := new(GetWorkingRoByCodeResp)
-	err := c.cc.Invoke(ctx, Organization_GetWorkingRoByCode_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingRoByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -90,7 +83,7 @@ func (c *organizationClient) GetWorkingRoByCode(ctx context.Context, in *DcWorki
 
 func (c *organizationClient) GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingChestByCodeResp, error) {
 	out := new(GetWorkingChestByCodeResp)
-	err := c.cc.Invoke(ctx, Organization_GetWorkingChestByCode_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingChestByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -99,7 +92,7 @@ func (c *organizationClient) GetWorkingChestByCode(ctx context.Context, in *DcWo
 
 func (c *organizationClient) GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingPumpByCodeResp, error) {
 	out := new(GetWorkingPumpByCodeResp)
-	err := c.cc.Invoke(ctx, Organization_GetWorkingPumpByCode_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingPumpByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -108,7 +101,7 @@ func (c *organizationClient) GetWorkingPumpByCode(ctx context.Context, in *DcWor
 
 func (c *organizationClient) GetWorkingValveByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingValveByCodeResp, error) {
 	out := new(GetWorkingValveByCodeResp)
-	err := c.cc.Invoke(ctx, Organization_GetWorkingValveByCode_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingValveByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -117,7 +110,7 @@ func (c *organizationClient) GetWorkingValveByCode(ctx context.Context, in *DcWo
 
 func (c *organizationClient) MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error) {
 	out := new(MultiAddItemHistoryDataResp)
-	err := c.cc.Invoke(ctx, Organization_MultiAddItemHistoryData_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/MultiAddItemHistoryData", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -126,7 +119,7 @@ func (c *organizationClient) MultiAddItemHistoryData(ctx context.Context, in *Mu
 
 func (c *organizationClient) ItemHistoryDataList(ctx context.Context, in *ItemHistoryDataListReq, opts ...grpc.CallOption) (*ItemHistoryDataListResp, error) {
 	out := new(ItemHistoryDataListResp)
-	err := c.cc.Invoke(ctx, Organization_ItemHistoryDataList_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ItemHistoryDataList", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -135,7 +128,7 @@ func (c *organizationClient) ItemHistoryDataList(ctx context.Context, in *ItemHi
 
 func (c *organizationClient) ItemHistoryDataByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ItemHistoryDataListResp, error) {
 	out := new(ItemHistoryDataListResp)
-	err := c.cc.Invoke(ctx, Organization_ItemHistoryDataByTime_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ItemHistoryDataByTime", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -144,7 +137,7 @@ func (c *organizationClient) ItemHistoryDataByTime(ctx context.Context, in *Item
 
 func (c *organizationClient) ItemHistoryDataMaxMinByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ItemHistoryDataMaxMinResp, error) {
 	out := new(ItemHistoryDataMaxMinResp)
-	err := c.cc.Invoke(ctx, Organization_ItemHistoryDataMaxMinByTime_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ItemHistoryDataMaxMinByTime", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -153,7 +146,7 @@ func (c *organizationClient) ItemHistoryDataMaxMinByTime(ctx context.Context, in
 
 func (c *organizationClient) ItemHistoryDataFirstLastByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ItemHistoryDataFirstLastResp, error) {
 	out := new(ItemHistoryDataFirstLastResp)
-	err := c.cc.Invoke(ctx, Organization_ItemHistoryDataFirstLastByTime_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ItemHistoryDataFirstLastByTime", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -162,7 +155,7 @@ func (c *organizationClient) ItemHistoryDataFirstLastByTime(ctx context.Context,
 
 func (c *organizationClient) ChangeTypeItemHistoryData(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ChangeTypeItemHistoryDataResp, error) {
 	out := new(ChangeTypeItemHistoryDataResp)
-	err := c.cc.Invoke(ctx, Organization_ChangeTypeItemHistoryData_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ChangeTypeItemHistoryData", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -171,7 +164,88 @@ func (c *organizationClient) ChangeTypeItemHistoryData(ctx context.Context, in *
 
 func (c *organizationClient) ItemHistoryDataForChart(ctx context.Context, in *ItemHistoryDataForChartReq, opts ...grpc.CallOption) (*ItemHistoryDataForChartResp, error) {
 	out := new(ItemHistoryDataForChartResp)
-	err := c.cc.Invoke(ctx, Organization_ItemHistoryDataForChart_FullMethodName, in, out, opts...)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ItemHistoryDataForChart", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) FindAppList(ctx context.Context, in *FindAppListReq, opts ...grpc.CallOption) (*FindAppListResp, error) {
+	out := new(FindAppListResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/FindAppList", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) GetAppInfo(ctx context.Context, in *GetAppInfoReq, opts ...grpc.CallOption) (*GetAppInfoResp, error) {
+	out := new(GetAppInfoResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/GetAppInfo", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) CreateAppInfo(ctx context.Context, in *CreateAppInfoReq, opts ...grpc.CallOption) (*CreateAppInfoResp, error) {
+	out := new(CreateAppInfoResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/CreateAppInfo", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) RemoveAppInfo(ctx context.Context, in *RemoveAppInfoReq, opts ...grpc.CallOption) (*RemoveAppInfoResp, error) {
+	out := new(RemoveAppInfoResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/RemoveAppInfo", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) DisableAppInfo(ctx context.Context, in *DisableAppInfoReq, opts ...grpc.CallOption) (*DisableAppInfoResp, error) {
+	out := new(DisableAppInfoResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/DisableAppInfo", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) EnableAppInfo(ctx context.Context, in *EnableAppInfoReq, opts ...grpc.CallOption) (*EnableAppInfoResp, error) {
+	out := new(EnableAppInfoResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/EnableAppInfo", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) ResetAppSecret(ctx context.Context, in *ResetAppSecretReq, opts ...grpc.CallOption) (*ResetAppSecretResp, error) {
+	out := new(ResetAppSecretResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ResetAppSecret", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) ExpireAppSecret(ctx context.Context, in *ExpireAppSecretReq, opts ...grpc.CallOption) (*ExpireAppSecretResp, error) {
+	out := new(ExpireAppSecretResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ExpireAppSecret", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) ResetAppProject(ctx context.Context, in *ResetAppProjectReq, opts ...grpc.CallOption) (*ResetAppProjectResp, error) {
+	out := new(ResetAppProjectResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/ResetAppProject", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -195,6 +269,15 @@ type OrganizationServer interface {
 	ItemHistoryDataFirstLastByTime(context.Context, *ItemHistoryDataByTimeReq) (*ItemHistoryDataFirstLastResp, error)
 	ChangeTypeItemHistoryData(context.Context, *ItemHistoryDataByTimeReq) (*ChangeTypeItemHistoryDataResp, error)
 	ItemHistoryDataForChart(context.Context, *ItemHistoryDataForChartReq) (*ItemHistoryDataForChartResp, error)
+	FindAppList(context.Context, *FindAppListReq) (*FindAppListResp, error)
+	GetAppInfo(context.Context, *GetAppInfoReq) (*GetAppInfoResp, error)
+	CreateAppInfo(context.Context, *CreateAppInfoReq) (*CreateAppInfoResp, error)
+	RemoveAppInfo(context.Context, *RemoveAppInfoReq) (*RemoveAppInfoResp, error)
+	DisableAppInfo(context.Context, *DisableAppInfoReq) (*DisableAppInfoResp, error)
+	EnableAppInfo(context.Context, *EnableAppInfoReq) (*EnableAppInfoResp, error)
+	ResetAppSecret(context.Context, *ResetAppSecretReq) (*ResetAppSecretResp, error)
+	ExpireAppSecret(context.Context, *ExpireAppSecretReq) (*ExpireAppSecretResp, error)
+	ResetAppProject(context.Context, *ResetAppProjectReq) (*ResetAppProjectResp, error)
 	mustEmbedUnimplementedOrganizationServer()
 }
 
@@ -241,6 +324,33 @@ func (UnimplementedOrganizationServer) ChangeTypeItemHistoryData(context.Context
 func (UnimplementedOrganizationServer) ItemHistoryDataForChart(context.Context, *ItemHistoryDataForChartReq) (*ItemHistoryDataForChartResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ItemHistoryDataForChart not implemented")
 }
+func (UnimplementedOrganizationServer) FindAppList(context.Context, *FindAppListReq) (*FindAppListResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method FindAppList not implemented")
+}
+func (UnimplementedOrganizationServer) GetAppInfo(context.Context, *GetAppInfoReq) (*GetAppInfoResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetAppInfo not implemented")
+}
+func (UnimplementedOrganizationServer) CreateAppInfo(context.Context, *CreateAppInfoReq) (*CreateAppInfoResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method CreateAppInfo not implemented")
+}
+func (UnimplementedOrganizationServer) RemoveAppInfo(context.Context, *RemoveAppInfoReq) (*RemoveAppInfoResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method RemoveAppInfo not implemented")
+}
+func (UnimplementedOrganizationServer) DisableAppInfo(context.Context, *DisableAppInfoReq) (*DisableAppInfoResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method DisableAppInfo not implemented")
+}
+func (UnimplementedOrganizationServer) EnableAppInfo(context.Context, *EnableAppInfoReq) (*EnableAppInfoResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method EnableAppInfo not implemented")
+}
+func (UnimplementedOrganizationServer) ResetAppSecret(context.Context, *ResetAppSecretReq) (*ResetAppSecretResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ResetAppSecret not implemented")
+}
+func (UnimplementedOrganizationServer) ExpireAppSecret(context.Context, *ExpireAppSecretReq) (*ExpireAppSecretResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ExpireAppSecret not implemented")
+}
+func (UnimplementedOrganizationServer) ResetAppProject(context.Context, *ResetAppProjectReq) (*ResetAppProjectResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ResetAppProject not implemented")
+}
 func (UnimplementedOrganizationServer) mustEmbedUnimplementedOrganizationServer() {}
 
 // UnsafeOrganizationServer may be embedded to opt out of forward compatibility for this service.
@@ -264,7 +374,7 @@ func _Organization_GetWorkingUfByCode_Handler(srv interface{}, ctx context.Conte
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_GetWorkingUfByCode_FullMethodName,
+		FullMethod: "/pb.Organization/GetWorkingUfByCode",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).GetWorkingUfByCode(ctx, req.(*DcWorkingReq))
@@ -282,7 +392,7 @@ func _Organization_FindWorkingUfByCycle_Handler(srv interface{}, ctx context.Con
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_FindWorkingUfByCycle_FullMethodName,
+		FullMethod: "/pb.Organization/FindWorkingUfByCycle",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).FindWorkingUfByCycle(ctx, req.(*FindWorkingUfByCycleReq))
@@ -300,7 +410,7 @@ func _Organization_GetWorkingRoByCode_Handler(srv interface{}, ctx context.Conte
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_GetWorkingRoByCode_FullMethodName,
+		FullMethod: "/pb.Organization/GetWorkingRoByCode",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).GetWorkingRoByCode(ctx, req.(*DcWorkingReq))
@@ -318,7 +428,7 @@ func _Organization_GetWorkingChestByCode_Handler(srv interface{}, ctx context.Co
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_GetWorkingChestByCode_FullMethodName,
+		FullMethod: "/pb.Organization/GetWorkingChestByCode",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).GetWorkingChestByCode(ctx, req.(*DcWorkingReq))
@@ -336,7 +446,7 @@ func _Organization_GetWorkingPumpByCode_Handler(srv interface{}, ctx context.Con
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_GetWorkingPumpByCode_FullMethodName,
+		FullMethod: "/pb.Organization/GetWorkingPumpByCode",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).GetWorkingPumpByCode(ctx, req.(*DcWorkingReq))
@@ -354,7 +464,7 @@ func _Organization_GetWorkingValveByCode_Handler(srv interface{}, ctx context.Co
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_GetWorkingValveByCode_FullMethodName,
+		FullMethod: "/pb.Organization/GetWorkingValveByCode",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).GetWorkingValveByCode(ctx, req.(*DcWorkingReq))
@@ -372,7 +482,7 @@ func _Organization_MultiAddItemHistoryData_Handler(srv interface{}, ctx context.
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_MultiAddItemHistoryData_FullMethodName,
+		FullMethod: "/pb.Organization/MultiAddItemHistoryData",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).MultiAddItemHistoryData(ctx, req.(*MultiAddItemHistoryDataReq))
@@ -390,7 +500,7 @@ func _Organization_ItemHistoryDataList_Handler(srv interface{}, ctx context.Cont
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_ItemHistoryDataList_FullMethodName,
+		FullMethod: "/pb.Organization/ItemHistoryDataList",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).ItemHistoryDataList(ctx, req.(*ItemHistoryDataListReq))
@@ -408,7 +518,7 @@ func _Organization_ItemHistoryDataByTime_Handler(srv interface{}, ctx context.Co
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_ItemHistoryDataByTime_FullMethodName,
+		FullMethod: "/pb.Organization/ItemHistoryDataByTime",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).ItemHistoryDataByTime(ctx, req.(*ItemHistoryDataByTimeReq))
@@ -426,7 +536,7 @@ func _Organization_ItemHistoryDataMaxMinByTime_Handler(srv interface{}, ctx cont
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_ItemHistoryDataMaxMinByTime_FullMethodName,
+		FullMethod: "/pb.Organization/ItemHistoryDataMaxMinByTime",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).ItemHistoryDataMaxMinByTime(ctx, req.(*ItemHistoryDataByTimeReq))
@@ -444,7 +554,7 @@ func _Organization_ItemHistoryDataFirstLastByTime_Handler(srv interface{}, ctx c
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_ItemHistoryDataFirstLastByTime_FullMethodName,
+		FullMethod: "/pb.Organization/ItemHistoryDataFirstLastByTime",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).ItemHistoryDataFirstLastByTime(ctx, req.(*ItemHistoryDataByTimeReq))
@@ -462,7 +572,7 @@ func _Organization_ChangeTypeItemHistoryData_Handler(srv interface{}, ctx contex
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_ChangeTypeItemHistoryData_FullMethodName,
+		FullMethod: "/pb.Organization/ChangeTypeItemHistoryData",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).ChangeTypeItemHistoryData(ctx, req.(*ItemHistoryDataByTimeReq))
@@ -480,7 +590,7 @@ func _Organization_ItemHistoryDataForChart_Handler(srv interface{}, ctx context.
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: Organization_ItemHistoryDataForChart_FullMethodName,
+		FullMethod: "/pb.Organization/ItemHistoryDataForChart",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(OrganizationServer).ItemHistoryDataForChart(ctx, req.(*ItemHistoryDataForChartReq))
@@ -488,6 +598,168 @@ func _Organization_ItemHistoryDataForChart_Handler(srv interface{}, ctx context.
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Organization_FindAppList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(FindAppListReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).FindAppList(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/FindAppList",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).FindAppList(ctx, req.(*FindAppListReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_GetAppInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GetAppInfoReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).GetAppInfo(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/GetAppInfo",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).GetAppInfo(ctx, req.(*GetAppInfoReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_CreateAppInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(CreateAppInfoReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).CreateAppInfo(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/CreateAppInfo",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).CreateAppInfo(ctx, req.(*CreateAppInfoReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_RemoveAppInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(RemoveAppInfoReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).RemoveAppInfo(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/RemoveAppInfo",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).RemoveAppInfo(ctx, req.(*RemoveAppInfoReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_DisableAppInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(DisableAppInfoReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).DisableAppInfo(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/DisableAppInfo",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).DisableAppInfo(ctx, req.(*DisableAppInfoReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_EnableAppInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(EnableAppInfoReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).EnableAppInfo(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/EnableAppInfo",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).EnableAppInfo(ctx, req.(*EnableAppInfoReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_ResetAppSecret_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ResetAppSecretReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).ResetAppSecret(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/ResetAppSecret",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).ResetAppSecret(ctx, req.(*ResetAppSecretReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_ExpireAppSecret_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ExpireAppSecretReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).ExpireAppSecret(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/ExpireAppSecret",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).ExpireAppSecret(ctx, req.(*ExpireAppSecretReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_ResetAppProject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ResetAppProjectReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).ResetAppProject(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/pb.Organization/ResetAppProject",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).ResetAppProject(ctx, req.(*ResetAppProjectReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // Organization_ServiceDesc is the grpc.ServiceDesc for Organization service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -547,6 +819,42 @@ var Organization_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "ItemHistoryDataForChart",
 			Handler:    _Organization_ItemHistoryDataForChart_Handler,
 		},
+		{
+			MethodName: "FindAppList",
+			Handler:    _Organization_FindAppList_Handler,
+		},
+		{
+			MethodName: "GetAppInfo",
+			Handler:    _Organization_GetAppInfo_Handler,
+		},
+		{
+			MethodName: "CreateAppInfo",
+			Handler:    _Organization_CreateAppInfo_Handler,
+		},
+		{
+			MethodName: "RemoveAppInfo",
+			Handler:    _Organization_RemoveAppInfo_Handler,
+		},
+		{
+			MethodName: "DisableAppInfo",
+			Handler:    _Organization_DisableAppInfo_Handler,
+		},
+		{
+			MethodName: "EnableAppInfo",
+			Handler:    _Organization_EnableAppInfo_Handler,
+		},
+		{
+			MethodName: "ResetAppSecret",
+			Handler:    _Organization_ResetAppSecret_Handler,
+		},
+		{
+			MethodName: "ExpireAppSecret",
+			Handler:    _Organization_ExpireAppSecret_Handler,
+		},
+		{
+			MethodName: "ResetAppProject",
+			Handler:    _Organization_ResetAppProject_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "organization.proto",

+ 43 - 12
app/model/GtDataStore.sql

@@ -33,12 +33,14 @@ CREATE TABLE `dc_app_info` (
                                `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
                                `app_name` varchar(30) NOT NULL DEFAULT '' COMMENT '应用名称',
                                `project_id` int(11) NOT NULL DEFAULT '0' COMMENT '限定服务的project_id',
+                               `project_ids` varchar(2048) NOT NULL DEFAULT '[]' COMMENT '可以操作的项目id列表',
                                `secret` varchar(32) NOT NULL DEFAULT '' COMMENT '数据签名的secret',
                                `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态 0: 正常 1: 禁用',
+                               `expire_at` timestamp NOT NULL COMMENT '失效时间',
                                `m_time` timestamp NOT NULL COMMENT '更新时间',
                                PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
                                UNIQUE KEY `app_name` (`app_name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=30001;
 
 -- Create syntax for TABLE 'dc_clean_bind'
 CREATE TABLE `dc_clean_bind` (
@@ -128,7 +130,7 @@ CREATE TABLE `dc_event_list` (
                                  `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
                                  KEY `project_id` (`project_id`,`name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=30001 /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=60001 /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
 
 -- Create syntax for TABLE 'dc_event_rule'
 CREATE TABLE `dc_event_rule` (
@@ -155,7 +157,7 @@ CREATE TABLE `dc_item_config` (
                                   `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                   PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
                                   KEY `idx_project_item` (`project_id`,`item_name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=90001 COMMENT='点位量程';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=120001 COMMENT='点位量程';
 
 -- Create syntax for TABLE 'dc_item_data'
 CREATE TABLE `dc_item_data` (
@@ -170,6 +172,30 @@ CREATE TABLE `dc_item_data` (
                                 KEY `tag` (`tag`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=44424777 /*T![ttl] TTL=`htime` + INTERVAL 60 DAY */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
 
+-- Create syntax for TABLE 'dc_item_history_data_111'
+CREATE TABLE `dc_item_history_data_111` (
+                                            `item_name` varchar(100) NOT NULL DEFAULT '' COMMENT '点位名',
+                                            `val` decimal(12,6) NOT NULL DEFAULT '0' COMMENT '值',
+                                            `h_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '采集数据时间',
+                                            PRIMARY KEY (`item_name`,`h_time`) /*T![clustered_index] CLUSTERED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='单点位秒级历史数据' /*T![ttl] TTL=`h_time` + INTERVAL 12 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+
+-- Create syntax for TABLE 'dc_item_history_data_117'
+CREATE TABLE `dc_item_history_data_117` (
+                                            `item_name` varchar(100) NOT NULL DEFAULT '' COMMENT '点位名',
+                                            `val` decimal(12,6) NOT NULL DEFAULT '0' COMMENT '值',
+                                            `h_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '采集数据时间',
+                                            PRIMARY KEY (`item_name`,`h_time`) /*T![clustered_index] CLUSTERED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='单点位秒级历史数据' /*T![ttl] TTL=`h_time` + INTERVAL 12 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+
+-- Create syntax for TABLE 'dc_item_history_data_1181'
+CREATE TABLE `dc_item_history_data_1181` (
+                                             `item_name` varchar(100) NOT NULL DEFAULT '' COMMENT '点位名',
+                                             `val` decimal(12,6) NOT NULL DEFAULT '0' COMMENT '值',
+                                             `h_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '采集数据时间',
+                                             PRIMARY KEY (`item_name`,`h_time`) /*T![clustered_index] CLUSTERED */
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='单点位秒级历史数据' /*T![ttl] TTL=`h_time` + INTERVAL 12 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+
 -- Create syntax for TABLE 'dc_item_history_data_46'
 CREATE TABLE `dc_item_history_data_46` (
                                            `item_name` varchar(100) NOT NULL DEFAULT '' COMMENT '点位名',
@@ -230,7 +256,7 @@ CREATE TABLE `dc_working_chest` (
                                     `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                     PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
                                     KEY `project_id` (`project_id`,`device_code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=42750001 COMMENT='药箱液位' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=43140001 COMMENT='药箱液位' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
 
 -- Create syntax for TABLE 'dc_working_mf'
 CREATE TABLE `dc_working_mf` (
@@ -263,9 +289,10 @@ CREATE TABLE `dc_working_mf` (
                                  `product_wq_p` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '产水水质:磷',
                                  `step` int(11) DEFAULT NULL COMMENT '设备当前步序值',
                                  `filter_time` decimal(8,2) DEFAULT NULL,
+                                 `filter_cycle` int(11) DEFAULT NULL COMMENT '当前过滤周期',
                                  `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
-                                 KEY `project_id` (`project_id`,`device_code`)
+                                 KEY `project_id` (`project_id`,`device_code`,`filter_cycle`,`step`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='微滤' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
 
 -- Create syntax for TABLE 'dc_working_nf'
@@ -318,9 +345,10 @@ CREATE TABLE `dc_working_nf` (
                                  `product_wq_p` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '产水水质:磷',
                                  `step` int(11) DEFAULT NULL COMMENT '设备当前步序值',
                                  `filter_time` decimal(8,2) DEFAULT NULL,
+                                 `filter_cycle` int(11) DEFAULT NULL COMMENT '当前过滤周期',
                                  `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
-                                 KEY `project_id` (`project_id`,`device_code`)
+                                 KEY `project_id` (`project_id`,`device_code`,`filter_cycle`,`step`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='纳滤' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
 
 -- Create syntax for TABLE 'dc_working_pump'
@@ -340,7 +368,7 @@ CREATE TABLE `dc_working_pump` (
                                    `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                    PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
                                    KEY `project_id` (`project_id`,`device_code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=79500001 COMMENT='水泵' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=80280001 COMMENT='水泵' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
 
 -- Create syntax for TABLE 'dc_working_ro'
 CREATE TABLE `dc_working_ro` (
@@ -392,10 +420,11 @@ CREATE TABLE `dc_working_ro` (
                                  `product_wq_p` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '产水水质:磷',
                                  `step` int(11) DEFAULT NULL COMMENT '设备当前步序值',
                                  `filter_time` decimal(8,2) DEFAULT NULL,
+                                 `filter_cycle` int(11) DEFAULT NULL COMMENT '当前过滤周期',
                                  `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
-                                 KEY `project_id` (`project_id`,`device_code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=11880001 COMMENT='反渗透' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+                                 KEY `project_id_2` (`project_id`,`device_code`,`filter_cycle`,`step`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=12000001 COMMENT='反渗透' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
 
 -- Create syntax for TABLE 'dc_working_uf'
 CREATE TABLE `dc_working_uf` (
@@ -411,6 +440,7 @@ CREATE TABLE `dc_working_uf` (
                                  `product_pressure` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '产水压力',
                                  `tmp` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '跨膜压差',
                                  `flux` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '膜通量',
+                                 `permeability` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '渗透率',
                                  `feed_wq_turbidity` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '进水浊度',
                                  `feed_wq_ph` tinyint(4) NOT NULL DEFAULT '0' COMMENT '进水 PH 值',
                                  `product_wq_ph` tinyint(4) NOT NULL DEFAULT '0' COMMENT '产水 PH 值',
@@ -426,12 +456,13 @@ CREATE TABLE `dc_working_uf` (
                                  `product_wq_cod` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '产水水质:COD',
                                  `feed_wq_p` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '进水水质:磷',
                                  `product_wq_p` decimal(8,4) NOT NULL DEFAULT '0' COMMENT '产水水质:磷',
+                                 `filter_cycle` int(11) DEFAULT NULL COMMENT '当前过滤周期',
                                  `step` int(11) DEFAULT NULL COMMENT '设备当前步序值',
                                  `filter_time` decimal(8,2) DEFAULT NULL,
                                  `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
-                                 KEY `project_id` (`project_id`,`device_code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=11970001 COMMENT='超滤' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+                                 KEY `project_id_2` (`project_id`,`device_code`,`filter_cycle`,`step`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=12090001 COMMENT='超滤' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
 
 -- Create syntax for TABLE 'dc_working_valve'
 CREATE TABLE `dc_working_valve` (
@@ -446,4 +477,4 @@ CREATE TABLE `dc_working_valve` (
                                     `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                     PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
                                     KEY `project_id` (`project_id`,`device_code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=27630001 COMMENT='阀门' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=27870001 COMMENT='阀门' /*T![ttl] TTL=`c_time` + INTERVAL 3 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;

+ 36 - 9
app/model/dcAppInfoModel_gen.go

@@ -5,6 +5,7 @@ package model
 import (
 	"context"
 	"database/sql"
+	"errors"
 	"fmt"
 	"strings"
 	"time"
@@ -25,6 +26,7 @@ var (
 type (
 	dcAppInfoModel interface {
 		Insert(ctx context.Context, data *DcAppInfo) (sql.Result, error)
+		Find(ctx context.Context, offset, limit int64, order string) ([]DcAppInfo, int64, error)
 		FindOne(ctx context.Context, id int64) (*DcAppInfo, error)
 		FindOneByAppName(ctx context.Context, appName string) (*DcAppInfo, error)
 		Update(ctx context.Context, data *DcAppInfo) error
@@ -36,13 +38,17 @@ type (
 		table string
 	}
 
+	ManageProjectIds []int64
+
 	DcAppInfo struct {
-		Id        int64     `db:"id"`
-		AppName   string    `db:"app_name"`   // 应用名称
-		ProjectId int64     `db:"project_id"` // 限定服务的project_id
-		Secret    string    `db:"secret"`     // 数据签名的secret
-		Status    int64     `db:"status"`     // 状态 0: 正常 1: 禁用
-		MTime     time.Time `db:"m_time"`     // 更新时间
+		Id         int64            `db:"id"`
+		AppName    string           `db:"app_name"`    // 应用名称
+		ProjectId  int64            `db:"project_id"`  // 限定服务的project_id
+		ProjectIds ManageProjectIds `db:"project_ids"` // 可以操作的项目id列表
+		Secret     string           `db:"secret"`      // 数据签名的secret
+		Status     int64            `db:"status"`      // 状态 0: 正常 1: 禁用
+		ExpireAt   time.Time        `db:"expire_at"`   // 失效时间
+		MTime      time.Time        `db:"m_time"`      // 更新时间
 	}
 )
 
@@ -60,6 +66,27 @@ func (m *defaultDcAppInfoModel) withSession(session sqlx.Session) *defaultDcAppI
 	}
 }
 
+func (m *defaultDcAppInfoModel) Find(ctx context.Context, offset, limit int64, order string) ([]DcAppInfo, int64, error) {
+	var total int64
+	cq := fmt.Sprintf("select count(*) as total from %s", m.table)
+	err := m.conn.QueryRowCtx(ctx, &total, cq)
+	if err != nil || total == 0 {
+		return nil, total, errors.New("not found appinfo")
+	}
+
+	query := fmt.Sprintf("select %s from %s order by %s limit %d,%d", dcAppInfoRows, m.table, order, offset, limit)
+	var resp []DcAppInfo
+	err = m.conn.QueryRowsCtx(ctx, &resp, query)
+	switch err {
+	case nil:
+		return resp, total, nil
+	case sqlc.ErrNotFound:
+		return nil, total, ErrNotFound
+	default:
+		return nil, total, err
+	}
+}
+
 func (m *defaultDcAppInfoModel) Delete(ctx context.Context, id int64) error {
 	query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
 	_, err := m.conn.ExecCtx(ctx, query, id)
@@ -95,14 +122,14 @@ func (m *defaultDcAppInfoModel) FindOneByAppName(ctx context.Context, appName st
 }
 
 func (m *defaultDcAppInfoModel) Insert(ctx context.Context, data *DcAppInfo) (sql.Result, error) {
-	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?)", m.table, dcAppInfoRowsExpectAutoSet)
-	ret, err := m.conn.ExecCtx(ctx, query, data.AppName, data.ProjectId, data.Secret, data.Status, data.MTime)
+	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, dcAppInfoRowsExpectAutoSet)
+	ret, err := m.conn.ExecCtx(ctx, query, data.AppName, data.ProjectId, data.ProjectIds, data.Secret, data.Status, data.ExpireAt, data.MTime)
 	return ret, err
 }
 
 func (m *defaultDcAppInfoModel) Update(ctx context.Context, newData *DcAppInfo) error {
 	query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, dcAppInfoRowsWithPlaceHolder)
-	_, err := m.conn.ExecCtx(ctx, query, newData.AppName, newData.ProjectId, newData.Secret, newData.Status, newData.MTime, newData.Id)
+	_, err := m.conn.ExecCtx(ctx, query, newData.AppName, newData.ProjectId, newData.ProjectIds, newData.Secret, newData.Status, newData.ExpireAt, newData.MTime, newData.Id)
 	return err
 }
 

+ 10 - 0
app/model/vars.go

@@ -11,6 +11,16 @@ var ErrNotFound = sqlx.ErrNotFound
 
 type Technologys []string
 
+func (d ManageProjectIds) Value() (driver.Value, error) {
+	return json.Marshal(d)
+}
+
+// Scan 实现方法
+func (d *ManageProjectIds) Scan(input interface{}) error {
+	_ = json.Unmarshal(input.([]byte), &d)
+	return nil
+}
+
 func (d Technologys) Value() (driver.Value, error) {
 	return json.Marshal(d)
 }

Vissa filer visades inte eftersom för många filer har ändrats