diff --git a/app/file/api/etc/file-api.yaml b/app/file/api/etc/file-api.yaml index 1e831d4..e6dde15 100644 --- a/app/file/api/etc/file-api.yaml +++ b/app/file/api/etc/file-api.yaml @@ -4,6 +4,8 @@ Log: Encoding: plain Host: 0.0.0.0 Port: 9002 +Timeout: 300000 +MaxBytes: 1048576000 Auth: AccessSecret: 9149f2eb-d517-4a50-a03a-231dbcf0d872 diff --git a/app/file/api/file.api b/app/file/api/file.api index 7c2b6c1..2edc803 100644 --- a/app/file/api/file.api +++ b/app/file/api/file.api @@ -28,10 +28,67 @@ type ( PageSize int `json:"pageSize,optional"` Name string `json:"name,optional"` } + FileListResp { + List []FileInfo `json:"list"` + Total int64 `json:"total"` + } // 文件ID请求 FileIdReq { Id string `path:"id"` } + // ---------- 存储配置 ---------- + StorageConfigInfo { + Id string `json:"id"` + Type string `json:"type"` + Name string `json:"name"` + Endpoint string `json:"endpoint"` + AccessKeyId string `json:"accessKeyId"` + AccessKeySecret string `json:"accessKeySecret"` + BucketName string `json:"bucketName"` + BucketUrl string `json:"bucketUrl"` + Region string `json:"region"` + IsDefault int `json:"isDefault"` + Status int `json:"status"` + Remark string `json:"remark"` + } + CreateStorageConfigReq { + Type string `json:"type"` + Name string `json:"name"` + Endpoint string `json:"endpoint"` + AccessKeyId string `json:"accessKeyId"` + AccessKeySecret string `json:"accessKeySecret"` + BucketName string `json:"bucketName"` + BucketUrl string `json:"bucketUrl"` + Region string `json:"region,optional"` + Status int `json:"status,optional"` + Remark string `json:"remark,optional"` + } + UpdateStorageConfigReq { + Id string `json:"id"` + Type string `json:"type"` + Name string `json:"name"` + Endpoint string `json:"endpoint"` + AccessKeyId string `json:"accessKeyId"` + AccessKeySecret string `json:"accessKeySecret"` + BucketName string `json:"bucketName"` + BucketUrl string `json:"bucketUrl"` + Region string `json:"region,optional"` + Status int `json:"status,optional"` + Remark string `json:"remark,optional"` + } + SetDefaultStorageConfigReq { + Id string `json:"id"` + } + StorageConfigListReq { + Current int `json:"current,optional"` + PageSize int `json:"pageSize,optional"` + Type string `json:"type,optional"` + Name string `json:"name,optional"` + } + StorageConfigListResp { + List []StorageConfigInfo `json:"list"` + Total int64 `json:"total"` + } ) // ========== 需要鉴权的接口 ========== @@ -51,10 +108,35 @@ service file-api { @doc "文件列表" @handler GetFileList - post /list (FileListReq) + post /list (FileListReq) returns (FileListResp) @doc "获取文件信息" @handler GetFileById get /:id (FileIdReq) returns (FileInfo) + + @doc "下载文件" + @handler DownloadFile + get /download/:id (FileIdReq) + + // ---------- 存储配置管理 ---------- + @doc "创建存储配置" + @handler CreateStorageConfig + post /config/create (CreateStorageConfigReq) + + @doc "更新存储配置" + @handler UpdateStorageConfig + post /config/update (UpdateStorageConfigReq) + + @doc "删除存储配置" + @handler DeleteStorageConfig + post /config/delete (IdsReq) + + @doc "设置默认存储配置" + @handler SetDefaultStorageConfig + post /config/setDefault (SetDefaultStorageConfigReq) + + @doc "获取存储配置列表" + @handler GetStorageConfigList + post /config/list (StorageConfigListReq) returns (StorageConfigListResp) } diff --git a/app/file/api/internal/handler/file/createStorageConfigHandler.go b/app/file/api/internal/handler/file/createStorageConfigHandler.go new file mode 100644 index 0000000..efe5816 --- /dev/null +++ b/app/file/api/internal/handler/file/createStorageConfigHandler.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "sundynix-micro-go/app/file/api/internal/logic/file" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/common/response" +) + +// 创建存储配置 +func CreateStorageConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateStorageConfigReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + + l := file.NewCreateStorageConfigLogic(r.Context(), svcCtx) + err := l.CreateStorageConfig(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.OkWithData(w, nil) + } + } +} diff --git a/app/file/api/internal/handler/file/deleteStorageConfigHandler.go b/app/file/api/internal/handler/file/deleteStorageConfigHandler.go new file mode 100644 index 0000000..d596523 --- /dev/null +++ b/app/file/api/internal/handler/file/deleteStorageConfigHandler.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "sundynix-micro-go/app/file/api/internal/logic/file" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/common/response" +) + +// 删除存储配置 +func DeleteStorageConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.IdsReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + + l := file.NewDeleteStorageConfigLogic(r.Context(), svcCtx) + err := l.DeleteStorageConfig(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.OkWithData(w, nil) + } + } +} diff --git a/app/file/api/internal/handler/file/downloadFileHandler.go b/app/file/api/internal/handler/file/downloadFileHandler.go new file mode 100644 index 0000000..6dcba79 --- /dev/null +++ b/app/file/api/internal/handler/file/downloadFileHandler.go @@ -0,0 +1,30 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "sundynix-micro-go/app/file/api/internal/logic/file" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" +) + +// 下载文件 +func DownloadFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.FileIdReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := file.NewDownloadFileLogic(r.Context(), svcCtx) + err := l.DownloadFile(w, &req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } + } +} diff --git a/app/file/api/internal/handler/file/getFileListHandler.go b/app/file/api/internal/handler/file/getFileListHandler.go index 237b182..df02136 100644 --- a/app/file/api/internal/handler/file/getFileListHandler.go +++ b/app/file/api/internal/handler/file/getFileListHandler.go @@ -23,11 +23,11 @@ func GetFileListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { } l := file.NewGetFileListLogic(r.Context(), svcCtx) - err := l.GetFileList(&req) + resp, err := l.GetFileList(&req) if err != nil { response.Fail(w, err.Error()) } else { - response.Ok(w) + response.OkWithData(w, resp) } } } diff --git a/app/file/api/internal/handler/file/getStorageConfigListHandler.go b/app/file/api/internal/handler/file/getStorageConfigListHandler.go new file mode 100644 index 0000000..1c00135 --- /dev/null +++ b/app/file/api/internal/handler/file/getStorageConfigListHandler.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "sundynix-micro-go/app/file/api/internal/logic/file" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/common/response" +) + +// 获取存储配置列表 +func GetStorageConfigListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StorageConfigListReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + + l := file.NewGetStorageConfigListLogic(r.Context(), svcCtx) + resp, err := l.GetStorageConfigList(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.OkWithData(w, resp) + } + } +} diff --git a/app/file/api/internal/handler/file/setDefaultStorageConfigHandler.go b/app/file/api/internal/handler/file/setDefaultStorageConfigHandler.go new file mode 100644 index 0000000..8acc0a8 --- /dev/null +++ b/app/file/api/internal/handler/file/setDefaultStorageConfigHandler.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "sundynix-micro-go/app/file/api/internal/logic/file" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/common/response" +) + +// 设置默认存储配置 +func SetDefaultStorageConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.SetDefaultStorageConfigReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + + l := file.NewSetDefaultStorageConfigLogic(r.Context(), svcCtx) + err := l.SetDefaultStorageConfig(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.OkWithData(w, nil) + } + } +} diff --git a/app/file/api/internal/handler/file/updateStorageConfigHandler.go b/app/file/api/internal/handler/file/updateStorageConfigHandler.go new file mode 100644 index 0000000..923ed79 --- /dev/null +++ b/app/file/api/internal/handler/file/updateStorageConfigHandler.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "sundynix-micro-go/app/file/api/internal/logic/file" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/common/response" +) + +// 更新存储配置 +func UpdateStorageConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateStorageConfigReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + + l := file.NewUpdateStorageConfigLogic(r.Context(), svcCtx) + err := l.UpdateStorageConfig(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.OkWithData(w, nil) + } + } +} diff --git a/app/file/api/internal/handler/file/uploadFileHandler.go b/app/file/api/internal/handler/file/uploadFileHandler.go index d09e6b6..5c1ff04 100644 --- a/app/file/api/internal/handler/file/uploadFileHandler.go +++ b/app/file/api/internal/handler/file/uploadFileHandler.go @@ -15,7 +15,7 @@ import ( func UploadFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { l := file.NewUploadFileLogic(r.Context(), svcCtx) - resp, err := l.UploadFile() + resp, err := l.UploadFile(r) if err != nil { response.Fail(w, err.Error()) } else { diff --git a/app/file/api/internal/handler/routes.go b/app/file/api/internal/handler/routes.go index a68f7b4..fc7faa4 100644 --- a/app/file/api/internal/handler/routes.go +++ b/app/file/api/internal/handler/routes.go @@ -21,12 +21,48 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/:id", Handler: file.GetFileByIdHandler(serverCtx), }, + { + // 创建存储配置 + Method: http.MethodPost, + Path: "/config/create", + Handler: file.CreateStorageConfigHandler(serverCtx), + }, + { + // 删除存储配置 + Method: http.MethodPost, + Path: "/config/delete", + Handler: file.DeleteStorageConfigHandler(serverCtx), + }, + { + // 获取存储配置列表 + Method: http.MethodPost, + Path: "/config/list", + Handler: file.GetStorageConfigListHandler(serverCtx), + }, + { + // 设置默认存储配置 + Method: http.MethodPost, + Path: "/config/setDefault", + Handler: file.SetDefaultStorageConfigHandler(serverCtx), + }, + { + // 更新存储配置 + Method: http.MethodPost, + Path: "/config/update", + Handler: file.UpdateStorageConfigHandler(serverCtx), + }, { // 删除文件 - Method: http.MethodDelete, + Method: http.MethodPost, Path: "/delete", Handler: file.DeleteFileHandler(serverCtx), }, + { + // 下载文件 + Method: http.MethodGet, + Path: "/download/:id", + Handler: file.DownloadFileHandler(serverCtx), + }, { // 文件列表 Method: http.MethodPost, diff --git a/app/file/api/internal/logic/file/createStorageConfigLogic.go b/app/file/api/internal/logic/file/createStorageConfigLogic.go new file mode 100644 index 0000000..3844c6c --- /dev/null +++ b/app/file/api/internal/logic/file/createStorageConfigLogic.go @@ -0,0 +1,48 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/app/file/rpc/fileservice" +) + +type CreateStorageConfigLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +// 创建存储配置 +func NewCreateStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateStorageConfigLogic { + return &CreateStorageConfigLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateStorageConfigLogic) CreateStorageConfig(req *types.CreateStorageConfigReq) error { + _, err := l.svcCtx.FileRpc.CreateStorageConfig(l.ctx, &fileservice.CreateStorageConfigReq{ + Type: req.Type, + Name: req.Name, + Endpoint: req.Endpoint, + AccessKeyId: req.AccessKeyId, + AccessKeySecret: req.AccessKeySecret, + BucketName: req.BucketName, + BucketUrl: req.BucketUrl, + Region: req.Region, + Status: int32(req.Status), + Remark: req.Remark, + }) + if err != nil { + return err + } + + return nil +} diff --git a/app/file/api/internal/logic/file/deleteFileLogic.go b/app/file/api/internal/logic/file/deleteFileLogic.go index bd2669d..820e734 100644 --- a/app/file/api/internal/logic/file/deleteFileLogic.go +++ b/app/file/api/internal/logic/file/deleteFileLogic.go @@ -6,10 +6,11 @@ package file import ( "context" + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/api/internal/oss_core" "sundynix-micro-go/app/file/api/internal/svc" "sundynix-micro-go/app/file/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/rpc/fileservice" ) type DeleteFileLogic struct { @@ -28,7 +29,33 @@ func NewDeleteFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delete } func (l *DeleteFileLogic) DeleteFile(req *types.IdsReq) error { - // todo: add your logic here and delete this line + if len(req.Ids) == 0 { + return nil + } - return nil + // 1. 查询文件记录获取OSS Key + resp, err := l.svcCtx.FileRpc.GetFilesByIds(l.ctx, &fileservice.GetFilesByIdsReq{ + Ids: req.Ids, + }) + if err != nil { + return err + } + + // 2. 从OSS物理删除 + factory := oss_core.NewOSSFactory(l.svcCtx.FileRpc) + uploader, err := factory.GetActiveUploader(l.ctx) + if err == nil && uploader != nil { + for _, file := range resp.Files { + if file.Key != "" { + _ = uploader.DeleteFile(l.ctx, file.Key) + } + } + } + + // 3. 从数据库删除 + _, err = l.svcCtx.FileRpc.DeleteFiles(l.ctx, &fileservice.DeleteFilesReq{ + Ids: req.Ids, + }) + + return err } diff --git a/app/file/api/internal/logic/file/deleteStorageConfigLogic.go b/app/file/api/internal/logic/file/deleteStorageConfigLogic.go new file mode 100644 index 0000000..b46d680 --- /dev/null +++ b/app/file/api/internal/logic/file/deleteStorageConfigLogic.go @@ -0,0 +1,39 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/app/file/rpc/fileservice" +) + +type DeleteStorageConfigLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +// 删除存储配置 +func NewDeleteStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteStorageConfigLogic { + return &DeleteStorageConfigLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteStorageConfigLogic) DeleteStorageConfig(req *types.IdsReq) error { + _, err := l.svcCtx.FileRpc.DeleteStorageConfig(l.ctx, &fileservice.DeleteFilesReq{ + Ids: req.Ids, + }) + if err != nil { + return err + } + + return nil +} diff --git a/app/file/api/internal/logic/file/downloadFileLogic.go b/app/file/api/internal/logic/file/downloadFileLogic.go new file mode 100644 index 0000000..0537b73 --- /dev/null +++ b/app/file/api/internal/logic/file/downloadFileLogic.go @@ -0,0 +1,62 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "context" + + "io" + "net/http" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/api/internal/oss_core" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/app/file/rpc/fileservice" +) + +type DownloadFileLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +// 下载文件 +func NewDownloadFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownloadFileLogic { + return &DownloadFileLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DownloadFileLogic) DownloadFile(w http.ResponseWriter, req *types.FileIdReq) error { + // 1. 获取文件记录 + resp, err := l.svcCtx.FileRpc.GetFileById(l.ctx, &fileservice.GetFileByIdReq{ + Id: req.Id, + }) + if err != nil { + return err + } + + // 2. 获取具体底层client + factory := oss_core.NewOSSFactory(l.svcCtx.FileRpc) + uploader, err := factory.GetActiveUploader(l.ctx) + if err != nil { + return err + } + + // 3. 读取流 + reader, err := uploader.DownloadFile(l.ctx, resp.File.Key) + if err != nil { + return err + } + defer reader.Close() + + // 4. 返回文件流 + w.Header().Set("Content-Disposition", "attachment; filename=\""+resp.File.Name+"\"") + w.Header().Set("Content-Type", "application/octet-stream") + _, err = io.Copy(w, reader) + return err +} diff --git a/app/file/api/internal/logic/file/getFileByIdLogic.go b/app/file/api/internal/logic/file/getFileByIdLogic.go index 71810c9..8b91ad3 100644 --- a/app/file/api/internal/logic/file/getFileByIdLogic.go +++ b/app/file/api/internal/logic/file/getFileByIdLogic.go @@ -6,10 +6,10 @@ package file import ( "context" + "github.com/zeromicro/go-zero/core/logx" "sundynix-micro-go/app/file/api/internal/svc" "sundynix-micro-go/app/file/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/rpc/fileservice" ) type GetFileByIdLogic struct { @@ -28,7 +28,20 @@ func NewGetFileByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFi } func (l *GetFileByIdLogic) GetFileById(req *types.FileIdReq) (resp *types.FileInfo, err error) { - // todo: add your logic here and delete this line + respRpc, err := l.svcCtx.FileRpc.GetFileById(l.ctx, &fileservice.GetFileByIdReq{ + Id: req.Id, + }) + if err != nil { + return nil, err + } - return + return &types.FileInfo{ + Id: respRpc.File.Id, + Name: respRpc.File.Name, + Url: respRpc.File.Url, + Tag: respRpc.File.Tag, + Key: respRpc.File.Key, + Suffix: respRpc.File.Suffix, + Md5: respRpc.File.Md5, + }, nil } diff --git a/app/file/api/internal/logic/file/getFileListLogic.go b/app/file/api/internal/logic/file/getFileListLogic.go index 21aee47..9c65924 100644 --- a/app/file/api/internal/logic/file/getFileListLogic.go +++ b/app/file/api/internal/logic/file/getFileListLogic.go @@ -6,10 +6,10 @@ package file import ( "context" + "github.com/zeromicro/go-zero/core/logx" "sundynix-micro-go/app/file/api/internal/svc" "sundynix-micro-go/app/file/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/rpc/fileservice" ) type GetFileListLogic struct { @@ -27,8 +27,31 @@ func NewGetFileListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFi } } -func (l *GetFileListLogic) GetFileList(req *types.FileListReq) error { - // todo: add your logic here and delete this line +func (l *GetFileListLogic) GetFileList(req *types.FileListReq) (resp *types.FileListResp, err error) { + respRpc, err := l.svcCtx.FileRpc.GetFileList(l.ctx, &fileservice.GetFileListReq{ + Current: int32(req.Current), + PageSize: int32(req.PageSize), + Name: req.Name, + }) + if err != nil { + return nil, err + } - return nil + var list []types.FileInfo + for _, item := range respRpc.List { + list = append(list, types.FileInfo{ + Id: item.Id, + Name: item.Name, + Url: item.Url, + Tag: item.Tag, + Key: item.Key, + Suffix: item.Suffix, + Md5: item.Md5, + }) + } + + return &types.FileListResp{ + List: list, + Total: respRpc.Total, + }, nil } diff --git a/app/file/api/internal/logic/file/getStorageConfigListLogic.go b/app/file/api/internal/logic/file/getStorageConfigListLogic.go new file mode 100644 index 0000000..7e4a590 --- /dev/null +++ b/app/file/api/internal/logic/file/getStorageConfigListLogic.go @@ -0,0 +1,63 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/app/file/rpc/fileservice" +) + +type GetStorageConfigListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +// 获取存储配置列表 +func NewGetStorageConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStorageConfigListLogic { + return &GetStorageConfigListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetStorageConfigListLogic) GetStorageConfigList(req *types.StorageConfigListReq) (resp *types.StorageConfigListResp, err error) { + respRpc, err := l.svcCtx.FileRpc.GetStorageConfigList(l.ctx, &fileservice.StorageConfigListReq{ + Current: int32(req.Current), + PageSize: int32(req.PageSize), + Type: req.Type, + Name: req.Name, + }) + if err != nil { + return nil, err + } + + var list []types.StorageConfigInfo + for _, item := range respRpc.List { + list = append(list, types.StorageConfigInfo{ + Id: item.Id, + Type: item.Type, + Name: item.Name, + Endpoint: item.Endpoint, + AccessKeyId: item.AccessKeyId, + AccessKeySecret: item.AccessKeySecret, + BucketName: item.BucketName, + BucketUrl: item.BucketUrl, + Region: item.Region, + IsDefault: int(item.IsDefault), + Status: int(item.Status), + Remark: item.Remark, + }) + } + + return &types.StorageConfigListResp{ + List: list, + Total: respRpc.Total, + }, nil +} diff --git a/app/file/api/internal/logic/file/setDefaultStorageConfigLogic.go b/app/file/api/internal/logic/file/setDefaultStorageConfigLogic.go new file mode 100644 index 0000000..2bbd9b7 --- /dev/null +++ b/app/file/api/internal/logic/file/setDefaultStorageConfigLogic.go @@ -0,0 +1,39 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/app/file/rpc/fileservice" +) + +type SetDefaultStorageConfigLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +// 设置默认存储配置 +func NewSetDefaultStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetDefaultStorageConfigLogic { + return &SetDefaultStorageConfigLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *SetDefaultStorageConfigLogic) SetDefaultStorageConfig(req *types.SetDefaultStorageConfigReq) error { + _, err := l.svcCtx.FileRpc.SetDefaultStorageConfig(l.ctx, &fileservice.SetDefaultStorageConfigReq{ + Id: req.Id, + }) + if err != nil { + return err + } + + return nil +} diff --git a/app/file/api/internal/logic/file/updateStorageConfigLogic.go b/app/file/api/internal/logic/file/updateStorageConfigLogic.go new file mode 100644 index 0000000..606421b --- /dev/null +++ b/app/file/api/internal/logic/file/updateStorageConfigLogic.go @@ -0,0 +1,49 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package file + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/api/internal/svc" + "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/app/file/rpc/fileservice" +) + +type UpdateStorageConfigLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +// 更新存储配置 +func NewUpdateStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStorageConfigLogic { + return &UpdateStorageConfigLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateStorageConfigLogic) UpdateStorageConfig(req *types.UpdateStorageConfigReq) error { + _, err := l.svcCtx.FileRpc.UpdateStorageConfig(l.ctx, &fileservice.UpdateStorageConfigReq{ + Id: req.Id, + Type: req.Type, + Name: req.Name, + Endpoint: req.Endpoint, + AccessKeyId: req.AccessKeyId, + AccessKeySecret: req.AccessKeySecret, + BucketName: req.BucketName, + BucketUrl: req.BucketUrl, + Region: req.Region, + Status: int32(req.Status), + Remark: req.Remark, + }) + if err != nil { + return err + } + + return nil +} diff --git a/app/file/api/internal/logic/file/uploadFileLogic.go b/app/file/api/internal/logic/file/uploadFileLogic.go index ddab9ee..5939735 100644 --- a/app/file/api/internal/logic/file/uploadFileLogic.go +++ b/app/file/api/internal/logic/file/uploadFileLogic.go @@ -5,9 +5,17 @@ package file import ( "context" + "crypto/md5" + "encoding/hex" + "fmt" + "io" + "net/http" + "path/filepath" + "sundynix-micro-go/app/file/api/internal/oss_core" "sundynix-micro-go/app/file/api/internal/svc" "sundynix-micro-go/app/file/api/internal/types" + "sundynix-micro-go/app/file/rpc/fileservice" "github.com/zeromicro/go-zero/core/logx" ) @@ -27,8 +35,84 @@ func NewUploadFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upload } } -func (l *UploadFileLogic) UploadFile() (resp *types.FileInfo, err error) { - // todo: add your logic here and delete this line +func (l *UploadFileLogic) UploadFile(r *http.Request) (resp *types.FileInfo, err error) { + err = r.ParseMultipartForm(32 << 20) // 32MB max memory + if err != nil { + return nil, fmt.Errorf("解析表单失败: %v", err) + } + file, fileHeader, err := r.FormFile("file") + if err != nil { + return nil, fmt.Errorf("获取文件失败: %v", err) + } + defer file.Close() - return + // 计算文件 MD5 + hash := md5.New() + if _, err := io.Copy(hash, file); err != nil { + return nil, fmt.Errorf("计算文件MD5失败: %v", err) + } + fileMd5 := hex.EncodeToString(hash.Sum(nil)) + + // 调用 RPC 检查文件是否已存在(秒传) + checkResp, err := l.svcCtx.FileRpc.CheckFileByMd5(l.ctx, &fileservice.CheckFileByMd5Req{Md5: fileMd5}) + if err != nil { + l.Logger.Errorf("调用FileRpc检查MD5失败: %v", err) + return nil, fmt.Errorf("服务器内部异常") + } + if checkResp.Exists && checkResp.File != nil { + l.Logger.Infof("文件已存在,触发秒传: %s", fileMd5) + return &types.FileInfo{ + Id: checkResp.File.Id, + Name: checkResp.File.Name, + Url: checkResp.File.Url, + Tag: checkResp.File.Tag, + Key: checkResp.File.Key, + Suffix: checkResp.File.Suffix, + Md5: checkResp.File.Md5, + }, nil + } + + // 此时需要真正上传,先将文件指针拨回开头 + if _, err := file.Seek(0, 0); err != nil { + return nil, fmt.Errorf("读取文件流失败: %v", err) + } + + factory := oss_core.NewOSSFactory(l.svcCtx.FileRpc) + uploader, err := factory.GetActiveUploader(l.ctx) + if err != nil { + l.Logger.Errorf("获取OSS客户端失败: %v", err) + return nil, fmt.Errorf("存储服务未配置或不可用") + } + + url, key, err := uploader.UploadFile(l.ctx, file, fileHeader) + if err != nil { + l.Logger.Errorf("上传文件失败: %v", err) + return nil, err + } + + ext := filepath.Ext(fileHeader.Filename) + + // 把记录存入数据库 + rpcResp, err := l.svcCtx.FileRpc.CreateFile(l.ctx, &fileservice.CreateFileReq{ + Name: fileHeader.Filename, + Url: url, + Tag: "default", + Key: key, + Suffix: ext, + Md5: fileMd5, // 保存计算出的MD5 + }) + if err != nil { + l.Logger.Errorf("调用FileRpc创建文件记录失败: %v", err) + return nil, fmt.Errorf("保存文件记录失败") + } + + return &types.FileInfo{ + Id: rpcResp.File.Id, + Name: rpcResp.File.Name, + Url: rpcResp.File.Url, + Tag: rpcResp.File.Tag, + Key: rpcResp.File.Key, + Suffix: rpcResp.File.Suffix, + Md5: rpcResp.File.Md5, + }, nil } diff --git a/app/file/api/internal/oss_core/aliyun.go b/app/file/api/internal/oss_core/aliyun.go new file mode 100644 index 0000000..6d75ecc --- /dev/null +++ b/app/file/api/internal/oss_core/aliyun.go @@ -0,0 +1,58 @@ +package oss_core + +import ( + "context" + "fmt" + "io" + "mime/multipart" + "path/filepath" + "strings" + "time" + + "github.com/aliyun/aliyun-oss-go-sdk/oss" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/common/utils/hash" +) + +type AliyunUploader struct { + bucket *oss.Bucket + config *file.StorageConfigInfo +} + +func NewAliyunUploader(conf *file.StorageConfigInfo) (Uploader, error) { + client, err := oss.New(conf.Endpoint, conf.AccessKeyId, conf.AccessKeySecret) + if err != nil { + return nil, err + } + bucket, err := client.Bucket(conf.BucketName) + if err != nil { + return nil, err + } + return &AliyunUploader{ + bucket: bucket, + config: conf, + }, nil +} + +func (a *AliyunUploader) UploadFile(ctx context.Context, file multipart.File, fileHeader *multipart.FileHeader) (string, string, error) { + ext := filepath.Ext(fileHeader.Filename) + filename := hash.MD5([]byte(strings.TrimSuffix(fileHeader.Filename, ext))) + ext + timestr := fmt.Sprintf("%d", time.Now().UnixMicro()) + objectKey := time.Now().Format("2006-01-02") + "/" + timestr + "-" + filename + + err := a.bucket.PutObject(objectKey, file) + if err != nil { + return "", "", fmt.Errorf("上传阿里云OSS失败: %v", err) + } + + url := a.config.BucketUrl + "/" + objectKey + return url, objectKey, nil +} + +func (a *AliyunUploader) DeleteFile(ctx context.Context, key string) error { + return a.bucket.DeleteObject(key) +} + +func (a *AliyunUploader) DownloadFile(ctx context.Context, key string) (io.ReadCloser, error) { + return a.bucket.GetObject(key) +} diff --git a/app/file/api/internal/oss_core/factory.go b/app/file/api/internal/oss_core/factory.go new file mode 100644 index 0000000..b362c19 --- /dev/null +++ b/app/file/api/internal/oss_core/factory.go @@ -0,0 +1,89 @@ +package oss_core + +import ( + "context" + "fmt" + "reflect" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/fileservice" + "sync" +) + +type CachedUploader struct { + Uploader Uploader + Config *file.StorageConfigInfo +} + +var ( + uploaderCache sync.Map // map[string]*CachedUploader + cacheMutex sync.Mutex +) + +// OSSFactory 工厂结构体 +type OSSFactory struct { + fileRpc fileservice.FileService +} + +func NewOSSFactory(fileRpc fileservice.FileService) *OSSFactory { + return &OSSFactory{ + fileRpc: fileRpc, + } +} + +// GetActiveUploader 获取当前激活的存储上传实例 +func (f *OSSFactory) GetActiveUploader(ctx context.Context) (Uploader, error) { + resp, err := f.fileRpc.GetDefaultStorageConfig(ctx, &fileservice.GetDefaultStorageConfigReq{}) + if err != nil || resp.Config == nil { + return nil, fmt.Errorf("未找到激活的存储配置: %v", err) + } + + conf := resp.Config + + // 1. 尝试从缓存获取 + if cachedVal, ok := uploaderCache.Load(conf.Id); ok { + cachedItem := cachedVal.(*CachedUploader) + // 优雅之处:深度对比配置是否发生变化,完美支持前端动态修改配置后实时热加载 + if reflect.DeepEqual(cachedItem.Config, conf) { + return cachedItem.Uploader, nil + } + } + + // 2. 加锁防止高并发下的重复实例化 + cacheMutex.Lock() + defer cacheMutex.Unlock() + + // 3. Double-Check + if cachedVal, ok := uploaderCache.Load(conf.Id); ok { + cachedItem := cachedVal.(*CachedUploader) + if reflect.DeepEqual(cachedItem.Config, conf) { + return cachedItem.Uploader, nil + } + } + + // 4. 实例化新的 Uploader + var uploader Uploader + switch conf.Type { + case "minio": + uploader, err = NewMinioUploader(conf) + case "aliyun": + uploader, err = NewAliyunUploader(conf) + case "tencent": + uploader, err = NewTencentUploader(conf) + case "qiniu": + uploader, err = NewQiniuUploader(conf) + default: + return nil, fmt.Errorf("不支持的存储类型: %s", conf.Type) + } + + if err != nil { + return nil, err + } + + // 5. 更新缓存 + uploaderCache.Store(conf.Id, &CachedUploader{ + Uploader: uploader, + Config: conf, + }) + + return uploader, nil +} diff --git a/app/file/api/internal/oss_core/minio.go b/app/file/api/internal/oss_core/minio.go new file mode 100644 index 0000000..cb4c72a --- /dev/null +++ b/app/file/api/internal/oss_core/minio.go @@ -0,0 +1,95 @@ +package oss_core + +import ( + "context" + "fmt" + "io" + "mime/multipart" + "path/filepath" + "strings" + "time" + + "github.com/minio/minio-go/v7" + "github.com/minio/minio-go/v7/pkg/credentials" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/common/utils/hash" +) + +type MinioUploader struct { + client *minio.Client + config *file.StorageConfigInfo +} + +func NewMinioUploader(conf *file.StorageConfigInfo) (Uploader, error) { + // 判断如果是 https 或者是类似云服务,可以根据 endpoint 后缀猜测 secure + useSSL := strings.HasPrefix(conf.Endpoint, "https://") || strings.Contains(conf.Endpoint, "aliyuncs.com") || conf.Endpoint == "oss-cn-hangzhou.aliyuncs.com" // 这里只是示例 + if strings.HasPrefix(conf.Endpoint, "http://") || strings.HasPrefix(conf.Endpoint, "https://") { + // 移除协议头给 minio 客户端 + conf.Endpoint = strings.TrimPrefix(conf.Endpoint, "http://") + conf.Endpoint = strings.TrimPrefix(conf.Endpoint, "https://") + } else { + // 默认非 SSL + useSSL = false + } + + client, err := minio.New(conf.Endpoint, &minio.Options{ + Creds: credentials.NewStaticV4(conf.AccessKeyId, conf.AccessKeySecret, ""), + Secure: useSSL, + }) + if err != nil { + return nil, err + } + + // 这里可以加上检查 bucket + return &MinioUploader{ + client: client, + config: conf, + }, nil +} + +func (m *MinioUploader) UploadFile(ctx context.Context, file multipart.File, fileHeader *multipart.FileHeader) (string, string, error) { + // 直接重置文件指针(保险起见) + file.Seek(0, 0) + + ext := filepath.Ext(fileHeader.Filename) + filename := hash.MD5([]byte(strings.TrimSuffix(fileHeader.Filename, ext))) + ext + timestr := fmt.Sprintf("%d", time.Now().UnixMicro()) + objectKey := time.Now().Format("2006-01-02") + "/" + timestr + "-" + filename + + bucketName := m.config.BucketName + + // 直接执行 PutObject(流式上传,不再全部读入内存) + info, err := m.client.PutObject(ctx, bucketName, objectKey, file, fileHeader.Size, minio.PutObjectOptions{ + ContentType: "application/octet-stream", + }) + + if err != nil { + // 如果是因为 bucket 不存在,则尝试创建并重试 + if minio.ToErrorResponse(err).Code == "NoSuchBucket" { + m.client.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{}) + // 重置文件流位置,准备重试 + file.Seek(0, 0) + info, err = m.client.PutObject(ctx, bucketName, objectKey, file, fileHeader.Size, minio.PutObjectOptions{ + ContentType: "application/octet-stream", + }) + } + if err != nil { + return "", "", fmt.Errorf("上传Minio失败: %v", err) + } + } + + url := m.config.BucketUrl + "/" + info.Key + return url, info.Key, nil +} + +func (m *MinioUploader) DeleteFile(ctx context.Context, key string) error { + return m.client.RemoveObject(ctx, m.config.BucketName, key, minio.RemoveObjectOptions{}) +} + +func (m *MinioUploader) DownloadFile(ctx context.Context, key string) (io.ReadCloser, error) { + obj, err := m.client.GetObject(ctx, m.config.BucketName, key, minio.GetObjectOptions{}) + if err != nil { + return nil, err + } + return obj, nil +} diff --git a/app/file/api/internal/oss_core/qiniu.go b/app/file/api/internal/oss_core/qiniu.go new file mode 100644 index 0000000..60804d7 --- /dev/null +++ b/app/file/api/internal/oss_core/qiniu.go @@ -0,0 +1,84 @@ +package oss_core + +import ( + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + "path/filepath" + "strings" + "time" + + "github.com/qiniu/go-sdk/v7/auth/qbox" + "github.com/qiniu/go-sdk/v7/storage" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/common/utils/hash" +) + +type QiniuUploader struct { + mac *qbox.Mac + config *file.StorageConfigInfo +} + +func NewQiniuUploader(conf *file.StorageConfigInfo) (Uploader, error) { + mac := qbox.NewMac(conf.AccessKeyId, conf.AccessKeySecret) + return &QiniuUploader{ + mac: mac, + config: conf, + }, nil +} + +func (q *QiniuUploader) UploadFile(ctx context.Context, file multipart.File, fileHeader *multipart.FileHeader) (string, string, error) { + ext := filepath.Ext(fileHeader.Filename) + filename := hash.MD5([]byte(strings.TrimSuffix(fileHeader.Filename, ext))) + ext + timestr := fmt.Sprintf("%d", time.Now().UnixMicro()) + objectKey := time.Now().Format("2006-01-02") + "/" + timestr + "-" + filename + + putPolicy := storage.PutPolicy{ + Scope: q.config.BucketName, + } + upToken := putPolicy.UploadToken(q.mac) + + cfg := storage.Config{} + // 根据配置中的 Region 判断 + // 这里简单写死,如果要自适应可以根据 config.Region 给定 + cfg.Zone = &storage.ZoneHuadong + cfg.UseHTTPS = false + cfg.UseCdnDomains = false + + formUploader := storage.NewFormUploader(&cfg) + ret := storage.PutRet{} + + err := formUploader.Put(ctx, &ret, upToken, objectKey, file, fileHeader.Size, nil) + if err != nil { + return "", "", fmt.Errorf("上传七牛云失败: %v", err) + } + + url := q.config.BucketUrl + "/" + ret.Key + return url, ret.Key, nil +} + +func (q *QiniuUploader) DeleteFile(ctx context.Context, key string) error { + cfg := storage.Config{} + cfg.Zone = &storage.ZoneHuadong + bucketManager := storage.NewBucketManager(q.mac, &cfg) + return bucketManager.Delete(q.config.BucketName, key) +} + +func (q *QiniuUploader) DownloadFile(ctx context.Context, key string) (io.ReadCloser, error) { + mac := qbox.NewMac(q.config.AccessKeyId, q.config.AccessKeySecret) + domain := q.config.BucketUrl + deadline := time.Now().Add(time.Second * 3600).Unix() // 1小时有效期 + privateAccessURL := storage.MakePrivateURL(mac, domain, key, deadline) + + resp, err := http.Get(privateAccessURL) + if err != nil { + return nil, err + } + if resp.StatusCode != http.StatusOK { + resp.Body.Close() + return nil, fmt.Errorf("qiniu download failed with status: %s", resp.Status) + } + return resp.Body, nil +} diff --git a/app/file/api/internal/oss_core/tencent.go b/app/file/api/internal/oss_core/tencent.go new file mode 100644 index 0000000..b47323a --- /dev/null +++ b/app/file/api/internal/oss_core/tencent.go @@ -0,0 +1,73 @@ +package oss_core + +import ( + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "path/filepath" + "strings" + "time" + + "github.com/tencentyun/cos-go-sdk-v5" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/common/utils/hash" +) + +type TencentUploader struct { + client *cos.Client + config *file.StorageConfigInfo +} + +func NewTencentUploader(conf *file.StorageConfigInfo) (Uploader, error) { + // Endpoint should be something like https://bucket-appid.cos.ap-guangzhou.myqcloud.com + // But usually users just put bucket name and region, here we assume endpoint is full bucket url + // Or we use bucketUrl as the endpoint for client initialization if endpoint is not formatted well + u, err := url.Parse(conf.Endpoint) + if err != nil { + return nil, fmt.Errorf("解析Endpoint失败: %v", err) + } + + b := &cos.BaseURL{BucketURL: u} + client := cos.NewClient(b, &http.Client{ + Transport: &cos.AuthorizationTransport{ + SecretID: conf.AccessKeyId, + SecretKey: conf.AccessKeySecret, + }, + }) + + return &TencentUploader{ + client: client, + config: conf, + }, nil +} + +func (t *TencentUploader) UploadFile(ctx context.Context, file multipart.File, fileHeader *multipart.FileHeader) (string, string, error) { + ext := filepath.Ext(fileHeader.Filename) + filename := hash.MD5([]byte(strings.TrimSuffix(fileHeader.Filename, ext))) + ext + timestr := fmt.Sprintf("%d", time.Now().UnixMicro()) + objectKey := time.Now().Format("2006-01-02") + "/" + timestr + "-" + filename + + _, err := t.client.Object.Put(ctx, objectKey, file, nil) + if err != nil { + return "", "", fmt.Errorf("上传腾讯云COS失败: %v", err) + } + + fileUrl := t.config.BucketUrl + "/" + objectKey + return fileUrl, objectKey, nil +} + +func (t *TencentUploader) DeleteFile(ctx context.Context, key string) error { + _, err := t.client.Object.Delete(ctx, key) + return err +} + +func (t *TencentUploader) DownloadFile(ctx context.Context, key string) (io.ReadCloser, error) { + resp, err := t.client.Object.Get(ctx, key, nil) + if err != nil { + return nil, err + } + return resp.Body, nil +} diff --git a/app/file/api/internal/oss_core/uploader.go b/app/file/api/internal/oss_core/uploader.go new file mode 100644 index 0000000..d2ca8b4 --- /dev/null +++ b/app/file/api/internal/oss_core/uploader.go @@ -0,0 +1,17 @@ +package oss_core + +import ( + "context" + "io" + "mime/multipart" +) + +// Uploader 统一存储上传接口 +type Uploader interface { + // UploadFile 接收文件流并上传,返回存储的具体url,标识key和可能的错误 + UploadFile(ctx context.Context, file multipart.File, fileHeader *multipart.FileHeader) (url string, key string, err error) + // DeleteFile 删除远端存储的文件 + DeleteFile(ctx context.Context, key string) error + // DownloadFile 获取文件下载的数据流 + DownloadFile(ctx context.Context, key string) (io.ReadCloser, error) +} diff --git a/app/file/api/internal/types/types.go b/app/file/api/internal/types/types.go index 18c263c..a2671c1 100644 --- a/app/file/api/internal/types/types.go +++ b/app/file/api/internal/types/types.go @@ -3,6 +3,19 @@ package types +type CreateStorageConfigReq struct { + Type string `json:"type"` + Name string `json:"name"` + Endpoint string `json:"endpoint"` + AccessKeyId string `json:"accessKeyId"` + AccessKeySecret string `json:"accessKeySecret"` + BucketName string `json:"bucketName"` + BucketUrl string `json:"bucketUrl"` + Region string `json:"region,optional"` + Status int `json:"status,optional"` + Remark string `json:"remark,optional"` +} + type FileIdReq struct { Id string `path:"id"` } @@ -23,6 +36,56 @@ type FileListReq struct { Name string `json:"name,optional"` } +type FileListResp struct { + List []FileInfo `json:"list"` + Total int64 `json:"total"` +} + type IdsReq struct { Ids []string `json:"ids"` } + +type SetDefaultStorageConfigReq struct { + Id string `json:"id"` +} + +type StorageConfigInfo struct { + Id string `json:"id"` + Type string `json:"type"` + Name string `json:"name"` + Endpoint string `json:"endpoint"` + AccessKeyId string `json:"accessKeyId"` + AccessKeySecret string `json:"accessKeySecret"` + BucketName string `json:"bucketName"` + BucketUrl string `json:"bucketUrl"` + Region string `json:"region"` + IsDefault int `json:"isDefault"` + Status int `json:"status"` + Remark string `json:"remark"` +} + +type StorageConfigListReq struct { + Current int `json:"current,optional"` + PageSize int `json:"pageSize,optional"` + Type string `json:"type,optional"` + Name string `json:"name,optional"` +} + +type StorageConfigListResp struct { + List []StorageConfigInfo `json:"list"` + Total int64 `json:"total"` +} + +type UpdateStorageConfigReq struct { + Id string `json:"id"` + Type string `json:"type"` + Name string `json:"name"` + Endpoint string `json:"endpoint"` + AccessKeyId string `json:"accessKeyId"` + AccessKeySecret string `json:"accessKeySecret"` + BucketName string `json:"bucketName"` + BucketUrl string `json:"bucketUrl"` + Region string `json:"region,optional"` + Status int `json:"status,optional"` + Remark string `json:"remark,optional"` +} diff --git a/app/file/model/storage_config_model.go b/app/file/model/storage_config_model.go new file mode 100644 index 0000000..39a63f3 --- /dev/null +++ b/app/file/model/storage_config_model.go @@ -0,0 +1,26 @@ +package model + +import ( + "sundynix-micro-go/common/model" +) + +// StorageConfig 动态存储配置表 +type StorageConfig struct { + model.BaseModel + Type string `json:"type" gorm:"column:type;type:varchar(20);comment:存储类型(minio,aliyun,tencent,qiniu)"` + Name string `json:"name" gorm:"column:name;type:varchar(50);comment:配置名称"` + Endpoint string `json:"endpoint" gorm:"column:endpoint;type:varchar(100);comment:访问端点"` + AccessKeyId string `json:"accessKeyId" gorm:"column:access_key_id;type:varchar(100);comment:访问秘钥ID"` + AccessKeySecret string `json:"accessKeySecret" gorm:"column:access_key_secret;type:varchar(200);comment:访问秘钥"` + BucketName string `json:"bucketName" gorm:"column:bucket_name;type:varchar(50);comment:存储桶名称"` + BucketUrl string `json:"bucketUrl" gorm:"column:bucket_url;type:varchar(100);comment:绑定的外部访问域名"` + Region string `json:"region" gorm:"column:region;type:varchar(50);comment:地域节点"` + IsDefault int `json:"isDefault" gorm:"column:is_default;type:tinyint(1);default:0;comment:是否默认激活(1=是,0=否)"` + Status int `json:"status" gorm:"column:status;type:tinyint(1);default:1;comment:状态(1=启用,0=禁用)"` + Remark string `json:"remark" gorm:"column:remark;type:varchar(255);comment:备注"` +} + +// TableName 指定表名 +func (StorageConfig) TableName() string { + return "sundynix_storage_config" +} diff --git a/app/file/rpc/file/file.pb.go b/app/file/rpc/file/file.pb.go index df26d04..31e7050 100644 --- a/app/file/rpc/file/file.pb.go +++ b/app/file/rpc/file/file.pb.go @@ -349,6 +349,1002 @@ func (x *GetFilesByIdsResp) GetFiles() []*FileInfo { return nil } +type StorageConfigInfo struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Endpoint string `protobuf:"bytes,4,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + AccessKeyId string `protobuf:"bytes,5,opt,name=accessKeyId,proto3" json:"accessKeyId,omitempty"` + AccessKeySecret string `protobuf:"bytes,6,opt,name=accessKeySecret,proto3" json:"accessKeySecret,omitempty"` + BucketName string `protobuf:"bytes,7,opt,name=bucketName,proto3" json:"bucketName,omitempty"` + BucketUrl string `protobuf:"bytes,8,opt,name=bucketUrl,proto3" json:"bucketUrl,omitempty"` + Region string `protobuf:"bytes,9,opt,name=region,proto3" json:"region,omitempty"` + IsDefault int32 `protobuf:"varint,10,opt,name=isDefault,proto3" json:"isDefault,omitempty"` + Status int32 `protobuf:"varint,11,opt,name=status,proto3" json:"status,omitempty"` + Remark string `protobuf:"bytes,12,opt,name=remark,proto3" json:"remark,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StorageConfigInfo) Reset() { + *x = StorageConfigInfo{} + mi := &file_pb_file_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StorageConfigInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StorageConfigInfo) ProtoMessage() {} + +func (x *StorageConfigInfo) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StorageConfigInfo.ProtoReflect.Descriptor instead. +func (*StorageConfigInfo) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{6} +} + +func (x *StorageConfigInfo) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *StorageConfigInfo) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *StorageConfigInfo) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *StorageConfigInfo) GetEndpoint() string { + if x != nil { + return x.Endpoint + } + return "" +} + +func (x *StorageConfigInfo) GetAccessKeyId() string { + if x != nil { + return x.AccessKeyId + } + return "" +} + +func (x *StorageConfigInfo) GetAccessKeySecret() string { + if x != nil { + return x.AccessKeySecret + } + return "" +} + +func (x *StorageConfigInfo) GetBucketName() string { + if x != nil { + return x.BucketName + } + return "" +} + +func (x *StorageConfigInfo) GetBucketUrl() string { + if x != nil { + return x.BucketUrl + } + return "" +} + +func (x *StorageConfigInfo) GetRegion() string { + if x != nil { + return x.Region + } + return "" +} + +func (x *StorageConfigInfo) GetIsDefault() int32 { + if x != nil { + return x.IsDefault + } + return 0 +} + +func (x *StorageConfigInfo) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *StorageConfigInfo) GetRemark() string { + if x != nil { + return x.Remark + } + return "" +} + +type CreateStorageConfigReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Endpoint string `protobuf:"bytes,3,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + AccessKeyId string `protobuf:"bytes,4,opt,name=accessKeyId,proto3" json:"accessKeyId,omitempty"` + AccessKeySecret string `protobuf:"bytes,5,opt,name=accessKeySecret,proto3" json:"accessKeySecret,omitempty"` + BucketName string `protobuf:"bytes,6,opt,name=bucketName,proto3" json:"bucketName,omitempty"` + BucketUrl string `protobuf:"bytes,7,opt,name=bucketUrl,proto3" json:"bucketUrl,omitempty"` + Region string `protobuf:"bytes,8,opt,name=region,proto3" json:"region,omitempty"` + Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` + Remark string `protobuf:"bytes,10,opt,name=remark,proto3" json:"remark,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateStorageConfigReq) Reset() { + *x = CreateStorageConfigReq{} + mi := &file_pb_file_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateStorageConfigReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateStorageConfigReq) ProtoMessage() {} + +func (x *CreateStorageConfigReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateStorageConfigReq.ProtoReflect.Descriptor instead. +func (*CreateStorageConfigReq) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{7} +} + +func (x *CreateStorageConfigReq) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *CreateStorageConfigReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateStorageConfigReq) GetEndpoint() string { + if x != nil { + return x.Endpoint + } + return "" +} + +func (x *CreateStorageConfigReq) GetAccessKeyId() string { + if x != nil { + return x.AccessKeyId + } + return "" +} + +func (x *CreateStorageConfigReq) GetAccessKeySecret() string { + if x != nil { + return x.AccessKeySecret + } + return "" +} + +func (x *CreateStorageConfigReq) GetBucketName() string { + if x != nil { + return x.BucketName + } + return "" +} + +func (x *CreateStorageConfigReq) GetBucketUrl() string { + if x != nil { + return x.BucketUrl + } + return "" +} + +func (x *CreateStorageConfigReq) GetRegion() string { + if x != nil { + return x.Region + } + return "" +} + +func (x *CreateStorageConfigReq) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *CreateStorageConfigReq) GetRemark() string { + if x != nil { + return x.Remark + } + return "" +} + +type UpdateStorageConfigReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Endpoint string `protobuf:"bytes,4,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + AccessKeyId string `protobuf:"bytes,5,opt,name=accessKeyId,proto3" json:"accessKeyId,omitempty"` + AccessKeySecret string `protobuf:"bytes,6,opt,name=accessKeySecret,proto3" json:"accessKeySecret,omitempty"` + BucketName string `protobuf:"bytes,7,opt,name=bucketName,proto3" json:"bucketName,omitempty"` + BucketUrl string `protobuf:"bytes,8,opt,name=bucketUrl,proto3" json:"bucketUrl,omitempty"` + Region string `protobuf:"bytes,9,opt,name=region,proto3" json:"region,omitempty"` + Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"` + Remark string `protobuf:"bytes,11,opt,name=remark,proto3" json:"remark,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateStorageConfigReq) Reset() { + *x = UpdateStorageConfigReq{} + mi := &file_pb_file_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateStorageConfigReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateStorageConfigReq) ProtoMessage() {} + +func (x *UpdateStorageConfigReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateStorageConfigReq.ProtoReflect.Descriptor instead. +func (*UpdateStorageConfigReq) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{8} +} + +func (x *UpdateStorageConfigReq) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *UpdateStorageConfigReq) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *UpdateStorageConfigReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UpdateStorageConfigReq) GetEndpoint() string { + if x != nil { + return x.Endpoint + } + return "" +} + +func (x *UpdateStorageConfigReq) GetAccessKeyId() string { + if x != nil { + return x.AccessKeyId + } + return "" +} + +func (x *UpdateStorageConfigReq) GetAccessKeySecret() string { + if x != nil { + return x.AccessKeySecret + } + return "" +} + +func (x *UpdateStorageConfigReq) GetBucketName() string { + if x != nil { + return x.BucketName + } + return "" +} + +func (x *UpdateStorageConfigReq) GetBucketUrl() string { + if x != nil { + return x.BucketUrl + } + return "" +} + +func (x *UpdateStorageConfigReq) GetRegion() string { + if x != nil { + return x.Region + } + return "" +} + +func (x *UpdateStorageConfigReq) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *UpdateStorageConfigReq) GetRemark() string { + if x != nil { + return x.Remark + } + return "" +} + +type SetDefaultStorageConfigReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SetDefaultStorageConfigReq) Reset() { + *x = SetDefaultStorageConfigReq{} + mi := &file_pb_file_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetDefaultStorageConfigReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetDefaultStorageConfigReq) ProtoMessage() {} + +func (x *SetDefaultStorageConfigReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetDefaultStorageConfigReq.ProtoReflect.Descriptor instead. +func (*SetDefaultStorageConfigReq) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{9} +} + +func (x *SetDefaultStorageConfigReq) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type StorageConfigListReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Current int32 `protobuf:"varint,1,opt,name=current,proto3" json:"current,omitempty"` + PageSize int32 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StorageConfigListReq) Reset() { + *x = StorageConfigListReq{} + mi := &file_pb_file_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StorageConfigListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StorageConfigListReq) ProtoMessage() {} + +func (x *StorageConfigListReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StorageConfigListReq.ProtoReflect.Descriptor instead. +func (*StorageConfigListReq) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{10} +} + +func (x *StorageConfigListReq) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *StorageConfigListReq) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *StorageConfigListReq) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *StorageConfigListReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type StorageConfigListResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + List []*StorageConfigInfo `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` + Total int64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StorageConfigListResp) Reset() { + *x = StorageConfigListResp{} + mi := &file_pb_file_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StorageConfigListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StorageConfigListResp) ProtoMessage() {} + +func (x *StorageConfigListResp) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StorageConfigListResp.ProtoReflect.Descriptor instead. +func (*StorageConfigListResp) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{11} +} + +func (x *StorageConfigListResp) GetList() []*StorageConfigInfo { + if x != nil { + return x.List + } + return nil +} + +func (x *StorageConfigListResp) GetTotal() int64 { + if x != nil { + return x.Total + } + return 0 +} + +type GetDefaultStorageConfigReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDefaultStorageConfigReq) Reset() { + *x = GetDefaultStorageConfigReq{} + mi := &file_pb_file_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDefaultStorageConfigReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDefaultStorageConfigReq) ProtoMessage() {} + +func (x *GetDefaultStorageConfigReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetDefaultStorageConfigReq.ProtoReflect.Descriptor instead. +func (*GetDefaultStorageConfigReq) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{12} +} + +type GetDefaultStorageConfigResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Config *StorageConfigInfo `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDefaultStorageConfigResp) Reset() { + *x = GetDefaultStorageConfigResp{} + mi := &file_pb_file_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDefaultStorageConfigResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDefaultStorageConfigResp) ProtoMessage() {} + +func (x *GetDefaultStorageConfigResp) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetDefaultStorageConfigResp.ProtoReflect.Descriptor instead. +func (*GetDefaultStorageConfigResp) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{13} +} + +func (x *GetDefaultStorageConfigResp) GetConfig() *StorageConfigInfo { + if x != nil { + return x.Config + } + return nil +} + +type CreateFileReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + Tag string `protobuf:"bytes,3,opt,name=tag,proto3" json:"tag,omitempty"` + Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` + Suffix string `protobuf:"bytes,5,opt,name=suffix,proto3" json:"suffix,omitempty"` + Md5 string `protobuf:"bytes,6,opt,name=md5,proto3" json:"md5,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateFileReq) Reset() { + *x = CreateFileReq{} + mi := &file_pb_file_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateFileReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateFileReq) ProtoMessage() {} + +func (x *CreateFileReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateFileReq.ProtoReflect.Descriptor instead. +func (*CreateFileReq) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{14} +} + +func (x *CreateFileReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateFileReq) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *CreateFileReq) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + +func (x *CreateFileReq) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *CreateFileReq) GetSuffix() string { + if x != nil { + return x.Suffix + } + return "" +} + +func (x *CreateFileReq) GetMd5() string { + if x != nil { + return x.Md5 + } + return "" +} + +type CreateFileResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + File *FileInfo `protobuf:"bytes,1,opt,name=file,proto3" json:"file,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateFileResp) Reset() { + *x = CreateFileResp{} + mi := &file_pb_file_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateFileResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateFileResp) ProtoMessage() {} + +func (x *CreateFileResp) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateFileResp.ProtoReflect.Descriptor instead. +func (*CreateFileResp) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{15} +} + +func (x *CreateFileResp) GetFile() *FileInfo { + if x != nil { + return x.File + } + return nil +} + +type CheckFileByMd5Req struct { + state protoimpl.MessageState `protogen:"open.v1"` + Md5 string `protobuf:"bytes,1,opt,name=md5,proto3" json:"md5,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CheckFileByMd5Req) Reset() { + *x = CheckFileByMd5Req{} + mi := &file_pb_file_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CheckFileByMd5Req) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckFileByMd5Req) ProtoMessage() {} + +func (x *CheckFileByMd5Req) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckFileByMd5Req.ProtoReflect.Descriptor instead. +func (*CheckFileByMd5Req) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{16} +} + +func (x *CheckFileByMd5Req) GetMd5() string { + if x != nil { + return x.Md5 + } + return "" +} + +type CheckFileByMd5Resp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Exists bool `protobuf:"varint,1,opt,name=exists,proto3" json:"exists,omitempty"` + File *FileInfo `protobuf:"bytes,2,opt,name=file,proto3" json:"file,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CheckFileByMd5Resp) Reset() { + *x = CheckFileByMd5Resp{} + mi := &file_pb_file_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CheckFileByMd5Resp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckFileByMd5Resp) ProtoMessage() {} + +func (x *CheckFileByMd5Resp) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckFileByMd5Resp.ProtoReflect.Descriptor instead. +func (*CheckFileByMd5Resp) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{17} +} + +func (x *CheckFileByMd5Resp) GetExists() bool { + if x != nil { + return x.Exists + } + return false +} + +func (x *CheckFileByMd5Resp) GetFile() *FileInfo { + if x != nil { + return x.File + } + return nil +} + +type DeleteFilesReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteFilesReq) Reset() { + *x = DeleteFilesReq{} + mi := &file_pb_file_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteFilesReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteFilesReq) ProtoMessage() {} + +func (x *DeleteFilesReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteFilesReq.ProtoReflect.Descriptor instead. +func (*DeleteFilesReq) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{18} +} + +func (x *DeleteFilesReq) GetIds() []string { + if x != nil { + return x.Ids + } + return nil +} + +type GetFileListReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Current int32 `protobuf:"varint,1,opt,name=current,proto3" json:"current,omitempty"` + PageSize int32 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetFileListReq) Reset() { + *x = GetFileListReq{} + mi := &file_pb_file_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetFileListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFileListReq) ProtoMessage() {} + +func (x *GetFileListReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFileListReq.ProtoReflect.Descriptor instead. +func (*GetFileListReq) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{19} +} + +func (x *GetFileListReq) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *GetFileListReq) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *GetFileListReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type GetFileListResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + List []*FileInfo `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` + Total int64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetFileListResp) Reset() { + *x = GetFileListResp{} + mi := &file_pb_file_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetFileListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFileListResp) ProtoMessage() {} + +func (x *GetFileListResp) ProtoReflect() protoreflect.Message { + mi := &file_pb_file_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFileListResp.ProtoReflect.Descriptor instead. +func (*GetFileListResp) Descriptor() ([]byte, []int) { + return file_pb_file_proto_rawDescGZIP(), []int{20} +} + +func (x *GetFileListResp) GetList() []*FileInfo { + if x != nil { + return x.List + } + return nil +} + +func (x *GetFileListResp) GetTotal() int64 { + if x != nil { + return x.Total + } + return 0 +} + var File_pb_file_proto protoreflect.FileDescriptor const file_pb_file_proto_rawDesc = "" + @@ -374,10 +1370,102 @@ const file_pb_file_proto_rawDesc = "" + "\x10GetFilesByIdsReq\x12\x10\n" + "\x03ids\x18\x01 \x03(\tR\x03ids\"9\n" + "\x11GetFilesByIdsResp\x12$\n" + - "\x05files\x18\x01 \x03(\v2\x0e.file.FileInfoR\x05files2\x8b\x01\n" + + "\x05files\x18\x01 \x03(\v2\x0e.file.FileInfoR\x05files\"\xd7\x02\n" + + "\x11StorageConfigInfo\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04type\x18\x02 \x01(\tR\x04type\x12\x12\n" + + "\x04name\x18\x03 \x01(\tR\x04name\x12\x1a\n" + + "\bendpoint\x18\x04 \x01(\tR\bendpoint\x12 \n" + + "\vaccessKeyId\x18\x05 \x01(\tR\vaccessKeyId\x12(\n" + + "\x0faccessKeySecret\x18\x06 \x01(\tR\x0faccessKeySecret\x12\x1e\n" + + "\n" + + "bucketName\x18\a \x01(\tR\n" + + "bucketName\x12\x1c\n" + + "\tbucketUrl\x18\b \x01(\tR\tbucketUrl\x12\x16\n" + + "\x06region\x18\t \x01(\tR\x06region\x12\x1c\n" + + "\tisDefault\x18\n" + + " \x01(\x05R\tisDefault\x12\x16\n" + + "\x06status\x18\v \x01(\x05R\x06status\x12\x16\n" + + "\x06remark\x18\f \x01(\tR\x06remark\"\xae\x02\n" + + "\x16CreateStorageConfigReq\x12\x12\n" + + "\x04type\x18\x01 \x01(\tR\x04type\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12\x1a\n" + + "\bendpoint\x18\x03 \x01(\tR\bendpoint\x12 \n" + + "\vaccessKeyId\x18\x04 \x01(\tR\vaccessKeyId\x12(\n" + + "\x0faccessKeySecret\x18\x05 \x01(\tR\x0faccessKeySecret\x12\x1e\n" + + "\n" + + "bucketName\x18\x06 \x01(\tR\n" + + "bucketName\x12\x1c\n" + + "\tbucketUrl\x18\a \x01(\tR\tbucketUrl\x12\x16\n" + + "\x06region\x18\b \x01(\tR\x06region\x12\x16\n" + + "\x06status\x18\t \x01(\x05R\x06status\x12\x16\n" + + "\x06remark\x18\n" + + " \x01(\tR\x06remark\"\xbe\x02\n" + + "\x16UpdateStorageConfigReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04type\x18\x02 \x01(\tR\x04type\x12\x12\n" + + "\x04name\x18\x03 \x01(\tR\x04name\x12\x1a\n" + + "\bendpoint\x18\x04 \x01(\tR\bendpoint\x12 \n" + + "\vaccessKeyId\x18\x05 \x01(\tR\vaccessKeyId\x12(\n" + + "\x0faccessKeySecret\x18\x06 \x01(\tR\x0faccessKeySecret\x12\x1e\n" + + "\n" + + "bucketName\x18\a \x01(\tR\n" + + "bucketName\x12\x1c\n" + + "\tbucketUrl\x18\b \x01(\tR\tbucketUrl\x12\x16\n" + + "\x06region\x18\t \x01(\tR\x06region\x12\x16\n" + + "\x06status\x18\n" + + " \x01(\x05R\x06status\x12\x16\n" + + "\x06remark\x18\v \x01(\tR\x06remark\",\n" + + "\x1aSetDefaultStorageConfigReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\"t\n" + + "\x14StorageConfigListReq\x12\x18\n" + + "\acurrent\x18\x01 \x01(\x05R\acurrent\x12\x1a\n" + + "\bpageSize\x18\x02 \x01(\x05R\bpageSize\x12\x12\n" + + "\x04type\x18\x03 \x01(\tR\x04type\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\"Z\n" + + "\x15StorageConfigListResp\x12+\n" + + "\x04list\x18\x01 \x03(\v2\x17.file.StorageConfigInfoR\x04list\x12\x14\n" + + "\x05total\x18\x02 \x01(\x03R\x05total\"\x1c\n" + + "\x1aGetDefaultStorageConfigReq\"N\n" + + "\x1bGetDefaultStorageConfigResp\x12/\n" + + "\x06config\x18\x01 \x01(\v2\x17.file.StorageConfigInfoR\x06config\"\x83\x01\n" + + "\rCreateFileReq\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x10\n" + + "\x03url\x18\x02 \x01(\tR\x03url\x12\x10\n" + + "\x03tag\x18\x03 \x01(\tR\x03tag\x12\x10\n" + + "\x03key\x18\x04 \x01(\tR\x03key\x12\x16\n" + + "\x06suffix\x18\x05 \x01(\tR\x06suffix\x12\x10\n" + + "\x03md5\x18\x06 \x01(\tR\x03md5\"4\n" + + "\x0eCreateFileResp\x12\"\n" + + "\x04file\x18\x01 \x01(\v2\x0e.file.FileInfoR\x04file\"%\n" + + "\x11CheckFileByMd5Req\x12\x10\n" + + "\x03md5\x18\x01 \x01(\tR\x03md5\"P\n" + + "\x12CheckFileByMd5Resp\x12\x16\n" + + "\x06exists\x18\x01 \x01(\bR\x06exists\x12\"\n" + + "\x04file\x18\x02 \x01(\v2\x0e.file.FileInfoR\x04file\"\"\n" + + "\x0eDeleteFilesReq\x12\x10\n" + + "\x03ids\x18\x01 \x03(\tR\x03ids\"Z\n" + + "\x0eGetFileListReq\x12\x18\n" + + "\acurrent\x18\x01 \x01(\x05R\acurrent\x12\x1a\n" + + "\bpageSize\x18\x02 \x01(\x05R\bpageSize\x12\x12\n" + + "\x04name\x18\x03 \x01(\tR\x04name\"K\n" + + "\x0fGetFileListResp\x12\"\n" + + "\x04list\x18\x01 \x03(\v2\x0e.file.FileInfoR\x04list\x12\x14\n" + + "\x05total\x18\x02 \x01(\x03R\x05total2\xc9\x06\n" + "\vFileService\x12:\n" + "\vGetFileById\x12\x14.file.GetFileByIdReq\x1a\x15.file.GetFileByIdResp\x12@\n" + - "\rGetFilesByIds\x12\x16.file.GetFilesByIdsReq\x1a\x17.file.GetFilesByIdsRespB\bZ\x06./fileb\x06proto3" + "\rGetFilesByIds\x12\x16.file.GetFilesByIdsReq\x1a\x17.file.GetFilesByIdsResp\x127\n" + + "\n" + + "CreateFile\x12\x13.file.CreateFileReq\x1a\x14.file.CreateFileResp\x12C\n" + + "\x0eCheckFileByMd5\x12\x17.file.CheckFileByMd5Req\x1a\x18.file.CheckFileByMd5Resp\x125\n" + + "\vDeleteFiles\x12\x14.file.DeleteFilesReq\x1a\x10.file.CommonResp\x12:\n" + + "\vGetFileList\x12\x14.file.GetFileListReq\x1a\x15.file.GetFileListResp\x12E\n" + + "\x13CreateStorageConfig\x12\x1c.file.CreateStorageConfigReq\x1a\x10.file.CommonResp\x12E\n" + + "\x13UpdateStorageConfig\x12\x1c.file.UpdateStorageConfigReq\x1a\x10.file.CommonResp\x12=\n" + + "\x13DeleteStorageConfig\x12\x14.file.DeleteFilesReq\x1a\x10.file.CommonResp\x12M\n" + + "\x17SetDefaultStorageConfig\x12 .file.SetDefaultStorageConfigReq\x1a\x10.file.CommonResp\x12O\n" + + "\x14GetStorageConfigList\x12\x1a.file.StorageConfigListReq\x1a\x1b.file.StorageConfigListResp\x12^\n" + + "\x17GetDefaultStorageConfig\x12 .file.GetDefaultStorageConfigReq\x1a!.file.GetDefaultStorageConfigRespB\bZ\x06./fileb\x06proto3" var ( file_pb_file_proto_rawDescOnce sync.Once @@ -391,27 +1479,67 @@ func file_pb_file_proto_rawDescGZIP() []byte { return file_pb_file_proto_rawDescData } -var file_pb_file_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_pb_file_proto_msgTypes = make([]protoimpl.MessageInfo, 21) var file_pb_file_proto_goTypes = []any{ - (*CommonResp)(nil), // 0: file.CommonResp - (*FileInfo)(nil), // 1: file.FileInfo - (*GetFileByIdReq)(nil), // 2: file.GetFileByIdReq - (*GetFileByIdResp)(nil), // 3: file.GetFileByIdResp - (*GetFilesByIdsReq)(nil), // 4: file.GetFilesByIdsReq - (*GetFilesByIdsResp)(nil), // 5: file.GetFilesByIdsResp + (*CommonResp)(nil), // 0: file.CommonResp + (*FileInfo)(nil), // 1: file.FileInfo + (*GetFileByIdReq)(nil), // 2: file.GetFileByIdReq + (*GetFileByIdResp)(nil), // 3: file.GetFileByIdResp + (*GetFilesByIdsReq)(nil), // 4: file.GetFilesByIdsReq + (*GetFilesByIdsResp)(nil), // 5: file.GetFilesByIdsResp + (*StorageConfigInfo)(nil), // 6: file.StorageConfigInfo + (*CreateStorageConfigReq)(nil), // 7: file.CreateStorageConfigReq + (*UpdateStorageConfigReq)(nil), // 8: file.UpdateStorageConfigReq + (*SetDefaultStorageConfigReq)(nil), // 9: file.SetDefaultStorageConfigReq + (*StorageConfigListReq)(nil), // 10: file.StorageConfigListReq + (*StorageConfigListResp)(nil), // 11: file.StorageConfigListResp + (*GetDefaultStorageConfigReq)(nil), // 12: file.GetDefaultStorageConfigReq + (*GetDefaultStorageConfigResp)(nil), // 13: file.GetDefaultStorageConfigResp + (*CreateFileReq)(nil), // 14: file.CreateFileReq + (*CreateFileResp)(nil), // 15: file.CreateFileResp + (*CheckFileByMd5Req)(nil), // 16: file.CheckFileByMd5Req + (*CheckFileByMd5Resp)(nil), // 17: file.CheckFileByMd5Resp + (*DeleteFilesReq)(nil), // 18: file.DeleteFilesReq + (*GetFileListReq)(nil), // 19: file.GetFileListReq + (*GetFileListResp)(nil), // 20: file.GetFileListResp } var file_pb_file_proto_depIdxs = []int32{ - 1, // 0: file.GetFileByIdResp.file:type_name -> file.FileInfo - 1, // 1: file.GetFilesByIdsResp.files:type_name -> file.FileInfo - 2, // 2: file.FileService.GetFileById:input_type -> file.GetFileByIdReq - 4, // 3: file.FileService.GetFilesByIds:input_type -> file.GetFilesByIdsReq - 3, // 4: file.FileService.GetFileById:output_type -> file.GetFileByIdResp - 5, // 5: file.FileService.GetFilesByIds:output_type -> file.GetFilesByIdsResp - 4, // [4:6] is the sub-list for method output_type - 2, // [2:4] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 1, // 0: file.GetFileByIdResp.file:type_name -> file.FileInfo + 1, // 1: file.GetFilesByIdsResp.files:type_name -> file.FileInfo + 6, // 2: file.StorageConfigListResp.list:type_name -> file.StorageConfigInfo + 6, // 3: file.GetDefaultStorageConfigResp.config:type_name -> file.StorageConfigInfo + 1, // 4: file.CreateFileResp.file:type_name -> file.FileInfo + 1, // 5: file.CheckFileByMd5Resp.file:type_name -> file.FileInfo + 1, // 6: file.GetFileListResp.list:type_name -> file.FileInfo + 2, // 7: file.FileService.GetFileById:input_type -> file.GetFileByIdReq + 4, // 8: file.FileService.GetFilesByIds:input_type -> file.GetFilesByIdsReq + 14, // 9: file.FileService.CreateFile:input_type -> file.CreateFileReq + 16, // 10: file.FileService.CheckFileByMd5:input_type -> file.CheckFileByMd5Req + 18, // 11: file.FileService.DeleteFiles:input_type -> file.DeleteFilesReq + 19, // 12: file.FileService.GetFileList:input_type -> file.GetFileListReq + 7, // 13: file.FileService.CreateStorageConfig:input_type -> file.CreateStorageConfigReq + 8, // 14: file.FileService.UpdateStorageConfig:input_type -> file.UpdateStorageConfigReq + 18, // 15: file.FileService.DeleteStorageConfig:input_type -> file.DeleteFilesReq + 9, // 16: file.FileService.SetDefaultStorageConfig:input_type -> file.SetDefaultStorageConfigReq + 10, // 17: file.FileService.GetStorageConfigList:input_type -> file.StorageConfigListReq + 12, // 18: file.FileService.GetDefaultStorageConfig:input_type -> file.GetDefaultStorageConfigReq + 3, // 19: file.FileService.GetFileById:output_type -> file.GetFileByIdResp + 5, // 20: file.FileService.GetFilesByIds:output_type -> file.GetFilesByIdsResp + 15, // 21: file.FileService.CreateFile:output_type -> file.CreateFileResp + 17, // 22: file.FileService.CheckFileByMd5:output_type -> file.CheckFileByMd5Resp + 0, // 23: file.FileService.DeleteFiles:output_type -> file.CommonResp + 20, // 24: file.FileService.GetFileList:output_type -> file.GetFileListResp + 0, // 25: file.FileService.CreateStorageConfig:output_type -> file.CommonResp + 0, // 26: file.FileService.UpdateStorageConfig:output_type -> file.CommonResp + 0, // 27: file.FileService.DeleteStorageConfig:output_type -> file.CommonResp + 0, // 28: file.FileService.SetDefaultStorageConfig:output_type -> file.CommonResp + 11, // 29: file.FileService.GetStorageConfigList:output_type -> file.StorageConfigListResp + 13, // 30: file.FileService.GetDefaultStorageConfig:output_type -> file.GetDefaultStorageConfigResp + 19, // [19:31] is the sub-list for method output_type + 7, // [7:19] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_pb_file_proto_init() } @@ -425,7 +1553,7 @@ func file_pb_file_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_pb_file_proto_rawDesc), len(file_pb_file_proto_rawDesc)), NumEnums: 0, - NumMessages: 6, + NumMessages: 21, NumExtensions: 0, NumServices: 1, }, diff --git a/app/file/rpc/file/file_grpc.pb.go b/app/file/rpc/file/file_grpc.pb.go index 7a12f81..76e9cab 100644 --- a/app/file/rpc/file/file_grpc.pb.go +++ b/app/file/rpc/file/file_grpc.pb.go @@ -19,8 +19,18 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - FileService_GetFileById_FullMethodName = "/file.FileService/GetFileById" - FileService_GetFilesByIds_FullMethodName = "/file.FileService/GetFilesByIds" + FileService_GetFileById_FullMethodName = "/file.FileService/GetFileById" + FileService_GetFilesByIds_FullMethodName = "/file.FileService/GetFilesByIds" + FileService_CreateFile_FullMethodName = "/file.FileService/CreateFile" + FileService_CheckFileByMd5_FullMethodName = "/file.FileService/CheckFileByMd5" + FileService_DeleteFiles_FullMethodName = "/file.FileService/DeleteFiles" + FileService_GetFileList_FullMethodName = "/file.FileService/GetFileList" + FileService_CreateStorageConfig_FullMethodName = "/file.FileService/CreateStorageConfig" + FileService_UpdateStorageConfig_FullMethodName = "/file.FileService/UpdateStorageConfig" + FileService_DeleteStorageConfig_FullMethodName = "/file.FileService/DeleteStorageConfig" + FileService_SetDefaultStorageConfig_FullMethodName = "/file.FileService/SetDefaultStorageConfig" + FileService_GetStorageConfigList_FullMethodName = "/file.FileService/GetStorageConfigList" + FileService_GetDefaultStorageConfig_FullMethodName = "/file.FileService/GetDefaultStorageConfig" ) // FileServiceClient is the client API for FileService service. @@ -31,6 +41,21 @@ type FileServiceClient interface { GetFileById(ctx context.Context, in *GetFileByIdReq, opts ...grpc.CallOption) (*GetFileByIdResp, error) // 根据ID列表批量获取文件信息 GetFilesByIds(ctx context.Context, in *GetFilesByIdsReq, opts ...grpc.CallOption) (*GetFilesByIdsResp, error) + // 创建文件记录 + CreateFile(ctx context.Context, in *CreateFileReq, opts ...grpc.CallOption) (*CreateFileResp, error) + // 通过MD5检查文件是否存在 + CheckFileByMd5(ctx context.Context, in *CheckFileByMd5Req, opts ...grpc.CallOption) (*CheckFileByMd5Resp, error) + // 删除文件记录 + DeleteFiles(ctx context.Context, in *DeleteFilesReq, opts ...grpc.CallOption) (*CommonResp, error) + // 获取文件列表 + GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error) + // ---------- 存储配置 ---------- + CreateStorageConfig(ctx context.Context, in *CreateStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) + UpdateStorageConfig(ctx context.Context, in *UpdateStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) + DeleteStorageConfig(ctx context.Context, in *DeleteFilesReq, opts ...grpc.CallOption) (*CommonResp, error) + SetDefaultStorageConfig(ctx context.Context, in *SetDefaultStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) + GetStorageConfigList(ctx context.Context, in *StorageConfigListReq, opts ...grpc.CallOption) (*StorageConfigListResp, error) + GetDefaultStorageConfig(ctx context.Context, in *GetDefaultStorageConfigReq, opts ...grpc.CallOption) (*GetDefaultStorageConfigResp, error) } type fileServiceClient struct { @@ -61,6 +86,106 @@ func (c *fileServiceClient) GetFilesByIds(ctx context.Context, in *GetFilesByIds return out, nil } +func (c *fileServiceClient) CreateFile(ctx context.Context, in *CreateFileReq, opts ...grpc.CallOption) (*CreateFileResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateFileResp) + err := c.cc.Invoke(ctx, FileService_CreateFile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) CheckFileByMd5(ctx context.Context, in *CheckFileByMd5Req, opts ...grpc.CallOption) (*CheckFileByMd5Resp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CheckFileByMd5Resp) + err := c.cc.Invoke(ctx, FileService_CheckFileByMd5_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) DeleteFiles(ctx context.Context, in *DeleteFilesReq, opts ...grpc.CallOption) (*CommonResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CommonResp) + err := c.cc.Invoke(ctx, FileService_DeleteFiles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetFileListResp) + err := c.cc.Invoke(ctx, FileService_GetFileList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) CreateStorageConfig(ctx context.Context, in *CreateStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CommonResp) + err := c.cc.Invoke(ctx, FileService_CreateStorageConfig_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) UpdateStorageConfig(ctx context.Context, in *UpdateStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CommonResp) + err := c.cc.Invoke(ctx, FileService_UpdateStorageConfig_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) DeleteStorageConfig(ctx context.Context, in *DeleteFilesReq, opts ...grpc.CallOption) (*CommonResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CommonResp) + err := c.cc.Invoke(ctx, FileService_DeleteStorageConfig_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) SetDefaultStorageConfig(ctx context.Context, in *SetDefaultStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CommonResp) + err := c.cc.Invoke(ctx, FileService_SetDefaultStorageConfig_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) GetStorageConfigList(ctx context.Context, in *StorageConfigListReq, opts ...grpc.CallOption) (*StorageConfigListResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(StorageConfigListResp) + err := c.cc.Invoke(ctx, FileService_GetStorageConfigList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *fileServiceClient) GetDefaultStorageConfig(ctx context.Context, in *GetDefaultStorageConfigReq, opts ...grpc.CallOption) (*GetDefaultStorageConfigResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetDefaultStorageConfigResp) + err := c.cc.Invoke(ctx, FileService_GetDefaultStorageConfig_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // FileServiceServer is the server API for FileService service. // All implementations must embed UnimplementedFileServiceServer // for forward compatibility. @@ -69,6 +194,21 @@ type FileServiceServer interface { GetFileById(context.Context, *GetFileByIdReq) (*GetFileByIdResp, error) // 根据ID列表批量获取文件信息 GetFilesByIds(context.Context, *GetFilesByIdsReq) (*GetFilesByIdsResp, error) + // 创建文件记录 + CreateFile(context.Context, *CreateFileReq) (*CreateFileResp, error) + // 通过MD5检查文件是否存在 + CheckFileByMd5(context.Context, *CheckFileByMd5Req) (*CheckFileByMd5Resp, error) + // 删除文件记录 + DeleteFiles(context.Context, *DeleteFilesReq) (*CommonResp, error) + // 获取文件列表 + GetFileList(context.Context, *GetFileListReq) (*GetFileListResp, error) + // ---------- 存储配置 ---------- + CreateStorageConfig(context.Context, *CreateStorageConfigReq) (*CommonResp, error) + UpdateStorageConfig(context.Context, *UpdateStorageConfigReq) (*CommonResp, error) + DeleteStorageConfig(context.Context, *DeleteFilesReq) (*CommonResp, error) + SetDefaultStorageConfig(context.Context, *SetDefaultStorageConfigReq) (*CommonResp, error) + GetStorageConfigList(context.Context, *StorageConfigListReq) (*StorageConfigListResp, error) + GetDefaultStorageConfig(context.Context, *GetDefaultStorageConfigReq) (*GetDefaultStorageConfigResp, error) mustEmbedUnimplementedFileServiceServer() } @@ -85,6 +225,36 @@ func (UnimplementedFileServiceServer) GetFileById(context.Context, *GetFileByIdR func (UnimplementedFileServiceServer) GetFilesByIds(context.Context, *GetFilesByIdsReq) (*GetFilesByIdsResp, error) { return nil, status.Error(codes.Unimplemented, "method GetFilesByIds not implemented") } +func (UnimplementedFileServiceServer) CreateFile(context.Context, *CreateFileReq) (*CreateFileResp, error) { + return nil, status.Error(codes.Unimplemented, "method CreateFile not implemented") +} +func (UnimplementedFileServiceServer) CheckFileByMd5(context.Context, *CheckFileByMd5Req) (*CheckFileByMd5Resp, error) { + return nil, status.Error(codes.Unimplemented, "method CheckFileByMd5 not implemented") +} +func (UnimplementedFileServiceServer) DeleteFiles(context.Context, *DeleteFilesReq) (*CommonResp, error) { + return nil, status.Error(codes.Unimplemented, "method DeleteFiles not implemented") +} +func (UnimplementedFileServiceServer) GetFileList(context.Context, *GetFileListReq) (*GetFileListResp, error) { + return nil, status.Error(codes.Unimplemented, "method GetFileList not implemented") +} +func (UnimplementedFileServiceServer) CreateStorageConfig(context.Context, *CreateStorageConfigReq) (*CommonResp, error) { + return nil, status.Error(codes.Unimplemented, "method CreateStorageConfig not implemented") +} +func (UnimplementedFileServiceServer) UpdateStorageConfig(context.Context, *UpdateStorageConfigReq) (*CommonResp, error) { + return nil, status.Error(codes.Unimplemented, "method UpdateStorageConfig not implemented") +} +func (UnimplementedFileServiceServer) DeleteStorageConfig(context.Context, *DeleteFilesReq) (*CommonResp, error) { + return nil, status.Error(codes.Unimplemented, "method DeleteStorageConfig not implemented") +} +func (UnimplementedFileServiceServer) SetDefaultStorageConfig(context.Context, *SetDefaultStorageConfigReq) (*CommonResp, error) { + return nil, status.Error(codes.Unimplemented, "method SetDefaultStorageConfig not implemented") +} +func (UnimplementedFileServiceServer) GetStorageConfigList(context.Context, *StorageConfigListReq) (*StorageConfigListResp, error) { + return nil, status.Error(codes.Unimplemented, "method GetStorageConfigList not implemented") +} +func (UnimplementedFileServiceServer) GetDefaultStorageConfig(context.Context, *GetDefaultStorageConfigReq) (*GetDefaultStorageConfigResp, error) { + return nil, status.Error(codes.Unimplemented, "method GetDefaultStorageConfig not implemented") +} func (UnimplementedFileServiceServer) mustEmbedUnimplementedFileServiceServer() {} func (UnimplementedFileServiceServer) testEmbeddedByValue() {} @@ -142,6 +312,186 @@ func _FileService_GetFilesByIds_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _FileService_CreateFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateFileReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).CreateFile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_CreateFile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).CreateFile(ctx, req.(*CreateFileReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_CheckFileByMd5_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CheckFileByMd5Req) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).CheckFileByMd5(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_CheckFileByMd5_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).CheckFileByMd5(ctx, req.(*CheckFileByMd5Req)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_DeleteFiles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteFilesReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).DeleteFiles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_DeleteFiles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).DeleteFiles(ctx, req.(*DeleteFilesReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_GetFileList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetFileListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).GetFileList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_GetFileList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).GetFileList(ctx, req.(*GetFileListReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_CreateStorageConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateStorageConfigReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).CreateStorageConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_CreateStorageConfig_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).CreateStorageConfig(ctx, req.(*CreateStorageConfigReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_UpdateStorageConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateStorageConfigReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).UpdateStorageConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_UpdateStorageConfig_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).UpdateStorageConfig(ctx, req.(*UpdateStorageConfigReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_DeleteStorageConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteFilesReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).DeleteStorageConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_DeleteStorageConfig_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).DeleteStorageConfig(ctx, req.(*DeleteFilesReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_SetDefaultStorageConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetDefaultStorageConfigReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).SetDefaultStorageConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_SetDefaultStorageConfig_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).SetDefaultStorageConfig(ctx, req.(*SetDefaultStorageConfigReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_GetStorageConfigList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StorageConfigListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).GetStorageConfigList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_GetStorageConfigList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).GetStorageConfigList(ctx, req.(*StorageConfigListReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _FileService_GetDefaultStorageConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDefaultStorageConfigReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FileServiceServer).GetDefaultStorageConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FileService_GetDefaultStorageConfig_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FileServiceServer).GetDefaultStorageConfig(ctx, req.(*GetDefaultStorageConfigReq)) + } + return interceptor(ctx, in, info, handler) +} + // FileService_ServiceDesc is the grpc.ServiceDesc for FileService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -157,6 +507,46 @@ var FileService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetFilesByIds", Handler: _FileService_GetFilesByIds_Handler, }, + { + MethodName: "CreateFile", + Handler: _FileService_CreateFile_Handler, + }, + { + MethodName: "CheckFileByMd5", + Handler: _FileService_CheckFileByMd5_Handler, + }, + { + MethodName: "DeleteFiles", + Handler: _FileService_DeleteFiles_Handler, + }, + { + MethodName: "GetFileList", + Handler: _FileService_GetFileList_Handler, + }, + { + MethodName: "CreateStorageConfig", + Handler: _FileService_CreateStorageConfig_Handler, + }, + { + MethodName: "UpdateStorageConfig", + Handler: _FileService_UpdateStorageConfig_Handler, + }, + { + MethodName: "DeleteStorageConfig", + Handler: _FileService_DeleteStorageConfig_Handler, + }, + { + MethodName: "SetDefaultStorageConfig", + Handler: _FileService_SetDefaultStorageConfig_Handler, + }, + { + MethodName: "GetStorageConfigList", + Handler: _FileService_GetStorageConfigList_Handler, + }, + { + MethodName: "GetDefaultStorageConfig", + Handler: _FileService_GetDefaultStorageConfig_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "pb/file.proto", diff --git a/app/file/rpc/fileservice/fileService.go b/app/file/rpc/fileservice/fileService.go index aa0e594..33a2204 100644 --- a/app/file/rpc/fileservice/fileService.go +++ b/app/file/rpc/fileservice/fileService.go @@ -14,18 +14,48 @@ import ( ) type ( - CommonResp = file.CommonResp - FileInfo = file.FileInfo - GetFileByIdReq = file.GetFileByIdReq - GetFileByIdResp = file.GetFileByIdResp - GetFilesByIdsReq = file.GetFilesByIdsReq - GetFilesByIdsResp = file.GetFilesByIdsResp + CheckFileByMd5Req = file.CheckFileByMd5Req + CheckFileByMd5Resp = file.CheckFileByMd5Resp + CommonResp = file.CommonResp + CreateFileReq = file.CreateFileReq + CreateFileResp = file.CreateFileResp + CreateStorageConfigReq = file.CreateStorageConfigReq + DeleteFilesReq = file.DeleteFilesReq + FileInfo = file.FileInfo + GetDefaultStorageConfigReq = file.GetDefaultStorageConfigReq + GetDefaultStorageConfigResp = file.GetDefaultStorageConfigResp + GetFileByIdReq = file.GetFileByIdReq + GetFileByIdResp = file.GetFileByIdResp + GetFileListReq = file.GetFileListReq + GetFileListResp = file.GetFileListResp + GetFilesByIdsReq = file.GetFilesByIdsReq + GetFilesByIdsResp = file.GetFilesByIdsResp + SetDefaultStorageConfigReq = file.SetDefaultStorageConfigReq + StorageConfigInfo = file.StorageConfigInfo + StorageConfigListReq = file.StorageConfigListReq + StorageConfigListResp = file.StorageConfigListResp + UpdateStorageConfigReq = file.UpdateStorageConfigReq FileService interface { // 根据ID获取文件信息 GetFileById(ctx context.Context, in *GetFileByIdReq, opts ...grpc.CallOption) (*GetFileByIdResp, error) // 根据ID列表批量获取文件信息 GetFilesByIds(ctx context.Context, in *GetFilesByIdsReq, opts ...grpc.CallOption) (*GetFilesByIdsResp, error) + // 创建文件记录 + CreateFile(ctx context.Context, in *CreateFileReq, opts ...grpc.CallOption) (*CreateFileResp, error) + // 通过MD5检查文件是否存在 + CheckFileByMd5(ctx context.Context, in *CheckFileByMd5Req, opts ...grpc.CallOption) (*CheckFileByMd5Resp, error) + // 删除文件记录 + DeleteFiles(ctx context.Context, in *DeleteFilesReq, opts ...grpc.CallOption) (*CommonResp, error) + // 获取文件列表 + GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error) + // ---------- 存储配置 ---------- + CreateStorageConfig(ctx context.Context, in *CreateStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) + UpdateStorageConfig(ctx context.Context, in *UpdateStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) + DeleteStorageConfig(ctx context.Context, in *DeleteFilesReq, opts ...grpc.CallOption) (*CommonResp, error) + SetDefaultStorageConfig(ctx context.Context, in *SetDefaultStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) + GetStorageConfigList(ctx context.Context, in *StorageConfigListReq, opts ...grpc.CallOption) (*StorageConfigListResp, error) + GetDefaultStorageConfig(ctx context.Context, in *GetDefaultStorageConfigReq, opts ...grpc.CallOption) (*GetDefaultStorageConfigResp, error) } defaultFileService struct { @@ -50,3 +80,58 @@ func (m *defaultFileService) GetFilesByIds(ctx context.Context, in *GetFilesById client := file.NewFileServiceClient(m.cli.Conn()) return client.GetFilesByIds(ctx, in, opts...) } + +// 创建文件记录 +func (m *defaultFileService) CreateFile(ctx context.Context, in *CreateFileReq, opts ...grpc.CallOption) (*CreateFileResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.CreateFile(ctx, in, opts...) +} + +// 通过MD5检查文件是否存在 +func (m *defaultFileService) CheckFileByMd5(ctx context.Context, in *CheckFileByMd5Req, opts ...grpc.CallOption) (*CheckFileByMd5Resp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.CheckFileByMd5(ctx, in, opts...) +} + +// 删除文件记录 +func (m *defaultFileService) DeleteFiles(ctx context.Context, in *DeleteFilesReq, opts ...grpc.CallOption) (*CommonResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.DeleteFiles(ctx, in, opts...) +} + +// 获取文件列表 +func (m *defaultFileService) GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.GetFileList(ctx, in, opts...) +} + +// ---------- 存储配置 ---------- +func (m *defaultFileService) CreateStorageConfig(ctx context.Context, in *CreateStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.CreateStorageConfig(ctx, in, opts...) +} + +func (m *defaultFileService) UpdateStorageConfig(ctx context.Context, in *UpdateStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.UpdateStorageConfig(ctx, in, opts...) +} + +func (m *defaultFileService) DeleteStorageConfig(ctx context.Context, in *DeleteFilesReq, opts ...grpc.CallOption) (*CommonResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.DeleteStorageConfig(ctx, in, opts...) +} + +func (m *defaultFileService) SetDefaultStorageConfig(ctx context.Context, in *SetDefaultStorageConfigReq, opts ...grpc.CallOption) (*CommonResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.SetDefaultStorageConfig(ctx, in, opts...) +} + +func (m *defaultFileService) GetStorageConfigList(ctx context.Context, in *StorageConfigListReq, opts ...grpc.CallOption) (*StorageConfigListResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.GetStorageConfigList(ctx, in, opts...) +} + +func (m *defaultFileService) GetDefaultStorageConfig(ctx context.Context, in *GetDefaultStorageConfigReq, opts ...grpc.CallOption) (*GetDefaultStorageConfigResp, error) { + client := file.NewFileServiceClient(m.cli.Conn()) + return client.GetDefaultStorageConfig(ctx, in, opts...) +} diff --git a/app/file/rpc/internal/logic/checkfilebymd5logic.go b/app/file/rpc/internal/logic/checkfilebymd5logic.go new file mode 100644 index 0000000..e735a2b --- /dev/null +++ b/app/file/rpc/internal/logic/checkfilebymd5logic.go @@ -0,0 +1,57 @@ +package logic + +import ( + "context" + + "errors" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "gorm.io/gorm" +) + +type CheckFileByMd5Logic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewCheckFileByMd5Logic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckFileByMd5Logic { + return &CheckFileByMd5Logic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// 通过MD5检查文件是否存在 +func (l *CheckFileByMd5Logic) CheckFileByMd5(in *file.CheckFileByMd5Req) (*file.CheckFileByMd5Resp, error) { + if in.Md5 == "" { + return &file.CheckFileByMd5Resp{Exists: false}, nil + } + + var ossRecord model.SundynixOss + err := l.svcCtx.DB.Where("md5 = ?", in.Md5).First(&ossRecord).Error + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return &file.CheckFileByMd5Resp{Exists: false}, nil + } + return nil, err + } + + return &file.CheckFileByMd5Resp{ + Exists: true, + File: &file.FileInfo{ + Id: ossRecord.ID, + Name: ossRecord.Name, + Url: ossRecord.Url, + Tag: ossRecord.Tag, + Key: ossRecord.Key, + Suffix: ossRecord.Suffix, + Md5: ossRecord.MD5, + CreatedAt: ossRecord.CreatedAt.Unix(), + }, + }, nil +} diff --git a/app/file/rpc/internal/logic/createFileLogic.go b/app/file/rpc/internal/logic/createFileLogic.go new file mode 100644 index 0000000..87c6536 --- /dev/null +++ b/app/file/rpc/internal/logic/createFileLogic.go @@ -0,0 +1,54 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type CreateFileLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewCreateFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFileLogic { + return &CreateFileLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// 创建文件记录 +func (l *CreateFileLogic) CreateFile(in *file.CreateFileReq) (*file.CreateFileResp, error) { + ossRecord := &model.SundynixOss{ + Name: in.Name, + Url: in.Url, + Tag: in.Tag, + Key: in.Key, + Suffix: in.Suffix, + MD5: in.Md5, + } + + err := l.svcCtx.DB.Create(ossRecord).Error + if err != nil { + return nil, err + } + + return &file.CreateFileResp{ + File: &file.FileInfo{ + Id: ossRecord.ID, + Name: ossRecord.Name, + Url: ossRecord.Url, + Tag: ossRecord.Tag, + Key: ossRecord.Key, + Suffix: ossRecord.Suffix, + Md5: ossRecord.MD5, + CreatedAt: ossRecord.CreatedAt.Unix(), + }, + }, nil +} diff --git a/app/file/rpc/internal/logic/createStorageConfigLogic.go b/app/file/rpc/internal/logic/createStorageConfigLogic.go new file mode 100644 index 0000000..15d4876 --- /dev/null +++ b/app/file/rpc/internal/logic/createStorageConfigLogic.go @@ -0,0 +1,48 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type CreateStorageConfigLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewCreateStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateStorageConfigLogic { + return &CreateStorageConfigLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// ---------- 存储配置 ---------- +func (l *CreateStorageConfigLogic) CreateStorageConfig(in *file.CreateStorageConfigReq) (*file.CommonResp, error) { + conf := &model.StorageConfig{ + Type: in.Type, + Name: in.Name, + Endpoint: in.Endpoint, + AccessKeyId: in.AccessKeyId, + AccessKeySecret: in.AccessKeySecret, + BucketName: in.BucketName, + BucketUrl: in.BucketUrl, + Region: in.Region, + IsDefault: 0, // 默认不激活,除非通过 setDefault + Status: int(in.Status), + Remark: in.Remark, + } + + err := l.svcCtx.DB.Create(conf).Error + if err != nil { + return nil, err + } + + return &file.CommonResp{Code: 0, Msg: "创建成功"}, nil +} diff --git a/app/file/rpc/internal/logic/deleteFilesLogic.go b/app/file/rpc/internal/logic/deleteFilesLogic.go new file mode 100644 index 0000000..d45d49b --- /dev/null +++ b/app/file/rpc/internal/logic/deleteFilesLogic.go @@ -0,0 +1,39 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type DeleteFilesLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewDeleteFilesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFilesLogic { + return &DeleteFilesLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// 删除文件记录 +func (l *DeleteFilesLogic) DeleteFiles(in *file.DeleteFilesReq) (*file.CommonResp, error) { + if len(in.Ids) == 0 { + return &file.CommonResp{Code: 400, Msg: "ids不能为空"}, nil + } + + // 这里的删除只删数据库记录,真实文件的删除由 file-api 在调用这个 RPC 之前处理 + err := l.svcCtx.DB.Where("id IN ?", in.Ids).Delete(&model.SundynixOss{}).Error + if err != nil { + return nil, err + } + + return &file.CommonResp{Code: 0, Msg: "删除成功"}, nil +} diff --git a/app/file/rpc/internal/logic/deleteStorageConfigLogic.go b/app/file/rpc/internal/logic/deleteStorageConfigLogic.go new file mode 100644 index 0000000..73ff79a --- /dev/null +++ b/app/file/rpc/internal/logic/deleteStorageConfigLogic.go @@ -0,0 +1,36 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type DeleteStorageConfigLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewDeleteStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteStorageConfigLogic { + return &DeleteStorageConfigLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *DeleteStorageConfigLogic) DeleteStorageConfig(in *file.DeleteFilesReq) (*file.CommonResp, error) { + if len(in.Ids) == 0 { + return &file.CommonResp{Code: 400, Msg: "ids不能为空"}, nil + } + err := l.svcCtx.DB.Where("id IN ?", in.Ids).Delete(&model.StorageConfig{}).Error + if err != nil { + return nil, err + } + + return &file.CommonResp{Code: 0, Msg: "删除成功"}, nil +} diff --git a/app/file/rpc/internal/logic/getDefaultStorageConfigLogic.go b/app/file/rpc/internal/logic/getDefaultStorageConfigLogic.go new file mode 100644 index 0000000..d64d8f1 --- /dev/null +++ b/app/file/rpc/internal/logic/getDefaultStorageConfigLogic.go @@ -0,0 +1,49 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type GetDefaultStorageConfigLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGetDefaultStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDefaultStorageConfigLogic { + return &GetDefaultStorageConfigLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GetDefaultStorageConfigLogic) GetDefaultStorageConfig(in *file.GetDefaultStorageConfigReq) (*file.GetDefaultStorageConfigResp, error) { + conf := &model.StorageConfig{} + err := l.svcCtx.DB.Where("is_default = ?", 1).First(conf).Error + if err != nil { + return nil, err // let the factory handle the error + } + + return &file.GetDefaultStorageConfigResp{ + Config: &file.StorageConfigInfo{ + Id: conf.ID, + Type: conf.Type, + Name: conf.Name, + Endpoint: conf.Endpoint, + AccessKeyId: conf.AccessKeyId, + AccessKeySecret: conf.AccessKeySecret, + BucketName: conf.BucketName, + BucketUrl: conf.BucketUrl, + Region: conf.Region, + IsDefault: int32(conf.IsDefault), + Status: int32(conf.Status), + Remark: conf.Remark, + }, + }, nil +} diff --git a/app/file/rpc/internal/logic/getFileByIdLogic.go b/app/file/rpc/internal/logic/getFileByIdLogic.go index d51a797..9655d2e 100644 --- a/app/file/rpc/internal/logic/getFileByIdLogic.go +++ b/app/file/rpc/internal/logic/getFileByIdLogic.go @@ -3,14 +3,13 @@ package logic import ( "context" - fileModel "sundynix-micro-go/app/file/model" - "sundynix-micro-go/app/file/rpc/file" - "sundynix-micro-go/app/file/rpc/internal/svc" - "github.com/zeromicro/go-zero/core/logx" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "gorm.io/gorm" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" ) type GetFileByIdLogic struct { @@ -29,7 +28,7 @@ func NewGetFileByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFi // 根据ID获取文件信息 func (l *GetFileByIdLogic) GetFileById(in *file.GetFileByIdReq) (*file.GetFileByIdResp, error) { - var oss fileModel.SundynixOss + var oss model.SundynixOss err := l.svcCtx.DB.Where("id = ?", in.Id).First(&oss).Error if err != nil { if err == gorm.ErrRecordNotFound { @@ -44,7 +43,7 @@ func (l *GetFileByIdLogic) GetFileById(in *file.GetFileByIdReq) (*file.GetFileBy }, nil } -func convertOssToProto(oss *fileModel.SundynixOss) *file.FileInfo { +func convertOssToProto(oss *model.SundynixOss) *file.FileInfo { return &file.FileInfo{ Id: oss.ID, Name: oss.Name, diff --git a/app/file/rpc/internal/logic/getFileListLogic.go b/app/file/rpc/internal/logic/getFileListLogic.go new file mode 100644 index 0000000..66baabf --- /dev/null +++ b/app/file/rpc/internal/logic/getFileListLogic.go @@ -0,0 +1,65 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type GetFileListLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGetFileListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFileListLogic { + return &GetFileListLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// 获取文件列表 +func (l *GetFileListLogic) GetFileList(in *file.GetFileListReq) (*file.GetFileListResp, error) { + var list []model.SundynixOss + var total int64 + + db := l.svcCtx.DB.Model(&model.SundynixOss{}) + if in.Name != "" { + db = db.Where("name LIKE ?", "%"+in.Name+"%") + } + + db.Count(&total) + + if in.Current > 0 && in.PageSize > 0 { + offset := (in.Current - 1) * in.PageSize + db = db.Offset(int(offset)).Limit(int(in.PageSize)) + } + + if err := db.Find(&list).Error; err != nil { + return nil, err + } + + var respList []*file.FileInfo + for _, item := range list { + respList = append(respList, &file.FileInfo{ + Id: item.ID, + Name: item.Name, + Url: item.Url, + Tag: item.Tag, + Key: item.Key, + Suffix: item.Suffix, + Md5: item.MD5, + CreatedAt: item.CreatedAt.Unix(), + }) + } + + return &file.GetFileListResp{ + List: respList, + Total: total, + }, nil +} diff --git a/app/file/rpc/internal/logic/getFilesByIdsLogic.go b/app/file/rpc/internal/logic/getFilesByIdsLogic.go index 1529f25..5e2f543 100644 --- a/app/file/rpc/internal/logic/getFilesByIdsLogic.go +++ b/app/file/rpc/internal/logic/getFilesByIdsLogic.go @@ -3,13 +3,12 @@ package logic import ( "context" - fileModel "sundynix-micro-go/app/file/model" - "sundynix-micro-go/app/file/rpc/file" - "sundynix-micro-go/app/file/rpc/internal/svc" - "github.com/zeromicro/go-zero/core/logx" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" ) type GetFilesByIdsLogic struct { @@ -32,7 +31,7 @@ func (l *GetFilesByIdsLogic) GetFilesByIds(in *file.GetFilesByIdsReq) (*file.Get return &file.GetFilesByIdsResp{Files: []*file.FileInfo{}}, nil } - var ossList []fileModel.SundynixOss + var ossList []model.SundynixOss err := l.svcCtx.DB.Where("id IN ?", in.Ids).Find(&ossList).Error if err != nil { l.Errorf("批量查询文件失败: %v", err) diff --git a/app/file/rpc/internal/logic/getStorageConfigListLogic.go b/app/file/rpc/internal/logic/getStorageConfigListLogic.go new file mode 100644 index 0000000..765b97c --- /dev/null +++ b/app/file/rpc/internal/logic/getStorageConfigListLogic.go @@ -0,0 +1,71 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type GetStorageConfigListLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGetStorageConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStorageConfigListLogic { + return &GetStorageConfigListLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GetStorageConfigListLogic) GetStorageConfigList(in *file.StorageConfigListReq) (*file.StorageConfigListResp, error) { + var list []model.StorageConfig + var total int64 + + db := l.svcCtx.DB.Model(&model.StorageConfig{}) + if in.Type != "" { + db = db.Where("type = ?", in.Type) + } + if in.Name != "" { + db = db.Where("name LIKE ?", "%"+in.Name+"%") + } + + db.Count(&total) + + if in.Current > 0 && in.PageSize > 0 { + offset := (in.Current - 1) * in.PageSize + db = db.Offset(int(offset)).Limit(int(in.PageSize)) + } + + if err := db.Find(&list).Error; err != nil { + return nil, err + } + + var respList []*file.StorageConfigInfo + for _, item := range list { + respList = append(respList, &file.StorageConfigInfo{ + Id: item.ID, + Type: item.Type, + Name: item.Name, + Endpoint: item.Endpoint, + AccessKeyId: item.AccessKeyId, + AccessKeySecret: item.AccessKeySecret, + BucketName: item.BucketName, + BucketUrl: item.BucketUrl, + Region: item.Region, + IsDefault: int32(item.IsDefault), + Status: int32(item.Status), + Remark: item.Remark, + }) + } + + return &file.StorageConfigListResp{ + List: respList, + Total: total, + }, nil +} diff --git a/app/file/rpc/internal/logic/setDefaultStorageConfigLogic.go b/app/file/rpc/internal/logic/setDefaultStorageConfigLogic.go new file mode 100644 index 0000000..919a383 --- /dev/null +++ b/app/file/rpc/internal/logic/setDefaultStorageConfigLogic.go @@ -0,0 +1,39 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type SetDefaultStorageConfigLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewSetDefaultStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetDefaultStorageConfigLogic { + return &SetDefaultStorageConfigLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *SetDefaultStorageConfigLogic) SetDefaultStorageConfig(in *file.SetDefaultStorageConfigReq) (*file.CommonResp, error) { + tx := l.svcCtx.DB.Begin() + if err := tx.Model(&model.StorageConfig{}).Where("1 = 1").Update("is_default", 0).Error; err != nil { + tx.Rollback() + return nil, err + } + if err := tx.Model(&model.StorageConfig{}).Where("id = ?", in.Id).Update("is_default", 1).Error; err != nil { + tx.Rollback() + return nil, err + } + tx.Commit() + + return &file.CommonResp{Code: 0, Msg: "设置成功"}, nil +} diff --git a/app/file/rpc/internal/logic/updateStorageConfigLogic.go b/app/file/rpc/internal/logic/updateStorageConfigLogic.go new file mode 100644 index 0000000..4af4ae7 --- /dev/null +++ b/app/file/rpc/internal/logic/updateStorageConfigLogic.go @@ -0,0 +1,48 @@ +package logic + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/file/model" + "sundynix-micro-go/app/file/rpc/file" + "sundynix-micro-go/app/file/rpc/internal/svc" +) + +type UpdateStorageConfigLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewUpdateStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStorageConfigLogic { + return &UpdateStorageConfigLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *UpdateStorageConfigLogic) UpdateStorageConfig(in *file.UpdateStorageConfigReq) (*file.CommonResp, error) { + conf := &model.StorageConfig{} + if err := l.svcCtx.DB.Where("id = ?", in.Id).First(conf).Error; err != nil { + return nil, err + } + + conf.Type = in.Type + conf.Name = in.Name + conf.Endpoint = in.Endpoint + conf.AccessKeyId = in.AccessKeyId + conf.AccessKeySecret = in.AccessKeySecret + conf.BucketName = in.BucketName + conf.BucketUrl = in.BucketUrl + conf.Region = in.Region + conf.Status = int(in.Status) + conf.Remark = in.Remark + + if err := l.svcCtx.DB.Save(conf).Error; err != nil { + return nil, err + } + + return &file.CommonResp{Code: 0, Msg: "更新成功"}, nil +} diff --git a/app/file/rpc/internal/server/fileServiceServer.go b/app/file/rpc/internal/server/fileServiceServer.go index 3b3118a..c7700c0 100644 --- a/app/file/rpc/internal/server/fileServiceServer.go +++ b/app/file/rpc/internal/server/fileServiceServer.go @@ -34,3 +34,58 @@ func (s *FileServiceServer) GetFilesByIds(ctx context.Context, in *file.GetFiles l := logic.NewGetFilesByIdsLogic(ctx, s.svcCtx) return l.GetFilesByIds(in) } + +// 创建文件记录 +func (s *FileServiceServer) CreateFile(ctx context.Context, in *file.CreateFileReq) (*file.CreateFileResp, error) { + l := logic.NewCreateFileLogic(ctx, s.svcCtx) + return l.CreateFile(in) +} + +// 通过MD5检查文件是否存在 +func (s *FileServiceServer) CheckFileByMd5(ctx context.Context, in *file.CheckFileByMd5Req) (*file.CheckFileByMd5Resp, error) { + l := logic.NewCheckFileByMd5Logic(ctx, s.svcCtx) + return l.CheckFileByMd5(in) +} + +// 删除文件记录 +func (s *FileServiceServer) DeleteFiles(ctx context.Context, in *file.DeleteFilesReq) (*file.CommonResp, error) { + l := logic.NewDeleteFilesLogic(ctx, s.svcCtx) + return l.DeleteFiles(in) +} + +// 获取文件列表 +func (s *FileServiceServer) GetFileList(ctx context.Context, in *file.GetFileListReq) (*file.GetFileListResp, error) { + l := logic.NewGetFileListLogic(ctx, s.svcCtx) + return l.GetFileList(in) +} + +// ---------- 存储配置 ---------- +func (s *FileServiceServer) CreateStorageConfig(ctx context.Context, in *file.CreateStorageConfigReq) (*file.CommonResp, error) { + l := logic.NewCreateStorageConfigLogic(ctx, s.svcCtx) + return l.CreateStorageConfig(in) +} + +func (s *FileServiceServer) UpdateStorageConfig(ctx context.Context, in *file.UpdateStorageConfigReq) (*file.CommonResp, error) { + l := logic.NewUpdateStorageConfigLogic(ctx, s.svcCtx) + return l.UpdateStorageConfig(in) +} + +func (s *FileServiceServer) DeleteStorageConfig(ctx context.Context, in *file.DeleteFilesReq) (*file.CommonResp, error) { + l := logic.NewDeleteStorageConfigLogic(ctx, s.svcCtx) + return l.DeleteStorageConfig(in) +} + +func (s *FileServiceServer) SetDefaultStorageConfig(ctx context.Context, in *file.SetDefaultStorageConfigReq) (*file.CommonResp, error) { + l := logic.NewSetDefaultStorageConfigLogic(ctx, s.svcCtx) + return l.SetDefaultStorageConfig(in) +} + +func (s *FileServiceServer) GetStorageConfigList(ctx context.Context, in *file.StorageConfigListReq) (*file.StorageConfigListResp, error) { + l := logic.NewGetStorageConfigListLogic(ctx, s.svcCtx) + return l.GetStorageConfigList(in) +} + +func (s *FileServiceServer) GetDefaultStorageConfig(ctx context.Context, in *file.GetDefaultStorageConfigReq) (*file.GetDefaultStorageConfigResp, error) { + l := logic.NewGetDefaultStorageConfigLogic(ctx, s.svcCtx) + return l.GetDefaultStorageConfig(in) +} diff --git a/app/file/rpc/internal/svc/serviceContext.go b/app/file/rpc/internal/svc/serviceContext.go index 4a300fe..9e3e153 100644 --- a/app/file/rpc/internal/svc/serviceContext.go +++ b/app/file/rpc/internal/svc/serviceContext.go @@ -25,7 +25,10 @@ func NewServiceContext(c config.Config) *ServiceContext { panic(err) } // 自动迁移 - if err := db.AutoMigrate(&fileModel.SundynixOss{}); err != nil { + if err := db.AutoMigrate( + &fileModel.SundynixOss{}, + &fileModel.StorageConfig{}, + ); err != nil { logx.Errorf("数据库迁移失败: %v", err) } diff --git a/app/file/rpc/pb/file.proto b/app/file/rpc/pb/file.proto index d1be143..288e6cc 100644 --- a/app/file/rpc/pb/file.proto +++ b/app/file/rpc/pb/file.proto @@ -42,6 +42,108 @@ message GetFilesByIdsResp { repeated FileInfo files = 1; } +// ---------- 存储配置 ---------- + +message StorageConfigInfo { + string id = 1; + string type = 2; + string name = 3; + string endpoint = 4; + string accessKeyId = 5; + string accessKeySecret = 6; + string bucketName = 7; + string bucketUrl = 8; + string region = 9; + int32 isDefault = 10; + int32 status = 11; + string remark = 12; +} + +message CreateStorageConfigReq { + string type = 1; + string name = 2; + string endpoint = 3; + string accessKeyId = 4; + string accessKeySecret = 5; + string bucketName = 6; + string bucketUrl = 7; + string region = 8; + int32 status = 9; + string remark = 10; +} + +message UpdateStorageConfigReq { + string id = 1; + string type = 2; + string name = 3; + string endpoint = 4; + string accessKeyId = 5; + string accessKeySecret = 6; + string bucketName = 7; + string bucketUrl = 8; + string region = 9; + int32 status = 10; + string remark = 11; +} + +message SetDefaultStorageConfigReq { + string id = 1; +} + +message StorageConfigListReq { + int32 current = 1; + int32 pageSize = 2; + string type = 3; + string name = 4; +} + +message StorageConfigListResp { + repeated StorageConfigInfo list = 1; + int64 total = 2; +} + +message GetDefaultStorageConfigReq {} +message GetDefaultStorageConfigResp { + StorageConfigInfo config = 1; +} + +message CreateFileReq { + string name = 1; + string url = 2; + string tag = 3; + string key = 4; + string suffix = 5; + string md5 = 6; +} + +message CreateFileResp { + FileInfo file = 1; +} + +message CheckFileByMd5Req { + string md5 = 1; +} + +message CheckFileByMd5Resp { + bool exists = 1; + FileInfo file = 2; +} + +message DeleteFilesReq { + repeated string ids = 1; +} + +message GetFileListReq { + int32 current = 1; + int32 pageSize = 2; + string name = 3; +} + +message GetFileListResp { + repeated FileInfo list = 1; + int64 total = 2; +} + // ---------- 服务定义 ---------- service FileService { @@ -49,4 +151,20 @@ service FileService { rpc GetFileById(GetFileByIdReq) returns (GetFileByIdResp); // 根据ID列表批量获取文件信息 rpc GetFilesByIds(GetFilesByIdsReq) returns (GetFilesByIdsResp); + // 创建文件记录 + rpc CreateFile(CreateFileReq) returns (CreateFileResp); + // 通过MD5检查文件是否存在 + rpc CheckFileByMd5(CheckFileByMd5Req) returns (CheckFileByMd5Resp); + // 删除文件记录 + rpc DeleteFiles(DeleteFilesReq) returns (CommonResp); + // 获取文件列表 + rpc GetFileList(GetFileListReq) returns (GetFileListResp); + + // ---------- 存储配置 ---------- + rpc CreateStorageConfig(CreateStorageConfigReq) returns (CommonResp); + rpc UpdateStorageConfig(UpdateStorageConfigReq) returns (CommonResp); + rpc DeleteStorageConfig(DeleteFilesReq) returns (CommonResp); // 复用idsReq + rpc SetDefaultStorageConfig(SetDefaultStorageConfigReq) returns (CommonResp); + rpc GetStorageConfigList(StorageConfigListReq) returns (StorageConfigListResp); + rpc GetDefaultStorageConfig(GetDefaultStorageConfigReq) returns (GetDefaultStorageConfigResp); } diff --git a/app/system/api/internal/handler/role/assignRoleMenusHandler.go b/app/system/api/internal/handler/role/assignRoleMenusHandler.go new file mode 100644 index 0000000..0bbe096 --- /dev/null +++ b/app/system/api/internal/handler/role/assignRoleMenusHandler.go @@ -0,0 +1,29 @@ +package role + +import ( + "net/http" + + "sundynix-micro-go/app/system/api/internal/logic/role" + "sundynix-micro-go/app/system/api/internal/svc" + "sundynix-micro-go/app/system/api/internal/types" + "sundynix-micro-go/common/response" + + "github.com/zeromicro/go-zero/rest/httpx" +) + +func AssignRoleMenusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AssignRoleMenusReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + l := role.NewAssignRoleMenusLogic(r.Context(), svcCtx) + err := l.AssignRoleMenus(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.Ok(w) + } + } +} diff --git a/app/system/api/internal/handler/role/getRoleDetailHandler.go b/app/system/api/internal/handler/role/getRoleDetailHandler.go new file mode 100644 index 0000000..f788245 --- /dev/null +++ b/app/system/api/internal/handler/role/getRoleDetailHandler.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package role + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "sundynix-micro-go/app/system/api/internal/logic/role" + "sundynix-micro-go/app/system/api/internal/svc" + "sundynix-micro-go/app/system/api/internal/types" + "sundynix-micro-go/common/response" +) + +// 角色详情(含已授权菜单) +func GetRoleDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.IdQueryReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + + l := role.NewGetRoleDetailLogic(r.Context(), svcCtx) + resp, err := l.GetRoleDetail(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.OkWithData(w, resp) + } + } +} diff --git a/app/system/api/internal/handler/routes.go b/app/system/api/internal/handler/routes.go index a325f85..752403d 100644 --- a/app/system/api/internal/handler/routes.go +++ b/app/system/api/internal/handler/routes.go @@ -138,6 +138,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { server.AddRoutes( []rest.Route{ + { + // 角色授权菜单 + Method: http.MethodPost, + Path: "/role/assignMenus", + Handler: role.AssignRoleMenusHandler(serverCtx), + }, { // 创建角色 Method: http.MethodPost, @@ -150,6 +156,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/role/delete", Handler: role.DeleteRoleHandler(serverCtx), }, + { + // 角色详情(含已授权菜单) + Method: http.MethodGet, + Path: "/role/detail", + Handler: role.GetRoleDetailHandler(serverCtx), + }, { // 角色列表 Method: http.MethodPost, @@ -169,6 +181,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { server.AddRoutes( []rest.Route{ + { + // 用户授权角色 + Method: http.MethodPost, + Path: "/user/assignRoles", + Handler: user.AssignUserRolesHandler(serverCtx), + }, { // 创建用户 Method: http.MethodPost, @@ -181,6 +199,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/user/delete", Handler: user.DeleteUserHandler(serverCtx), }, + { + // 用户详情(含角色信息) + Method: http.MethodGet, + Path: "/user/detail", + Handler: user.GetUserDetailHandler(serverCtx), + }, { // 用户列表 Method: http.MethodPost, diff --git a/app/system/api/internal/handler/user/assignUserRolesHandler.go b/app/system/api/internal/handler/user/assignUserRolesHandler.go new file mode 100644 index 0000000..1bdff56 --- /dev/null +++ b/app/system/api/internal/handler/user/assignUserRolesHandler.go @@ -0,0 +1,29 @@ +package user + +import ( + "net/http" + + "sundynix-micro-go/app/system/api/internal/logic/user" + "sundynix-micro-go/app/system/api/internal/svc" + "sundynix-micro-go/app/system/api/internal/types" + "sundynix-micro-go/common/response" + + "github.com/zeromicro/go-zero/rest/httpx" +) + +func AssignUserRolesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AssignUserRolesReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + l := user.NewAssignUserRolesLogic(r.Context(), svcCtx) + err := l.AssignUserRoles(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.Ok(w) + } + } +} diff --git a/app/system/api/internal/handler/user/getUserDetailHandler.go b/app/system/api/internal/handler/user/getUserDetailHandler.go new file mode 100644 index 0000000..67040c5 --- /dev/null +++ b/app/system/api/internal/handler/user/getUserDetailHandler.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package user + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "sundynix-micro-go/app/system/api/internal/logic/user" + "sundynix-micro-go/app/system/api/internal/svc" + "sundynix-micro-go/app/system/api/internal/types" + "sundynix-micro-go/common/response" +) + +// 用户详情(含角色信息) +func GetUserDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.IdQueryReq + if err := httpx.Parse(r, &req); err != nil { + response.Fail(w, err.Error()) + return + } + + l := user.NewGetUserDetailLogic(r.Context(), svcCtx) + resp, err := l.GetUserDetail(&req) + if err != nil { + response.Fail(w, err.Error()) + } else { + response.OkWithData(w, resp) + } + } +} diff --git a/app/system/api/internal/logic/role/assignRoleMenusLogic.go b/app/system/api/internal/logic/role/assignRoleMenusLogic.go new file mode 100644 index 0000000..01b401d --- /dev/null +++ b/app/system/api/internal/logic/role/assignRoleMenusLogic.go @@ -0,0 +1,29 @@ +package role + +import ( + "context" + + "sundynix-micro-go/app/system/api/internal/svc" + "sundynix-micro-go/app/system/api/internal/types" + "sundynix-micro-go/app/system/rpc/system" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AssignRoleMenusLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAssignRoleMenusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssignRoleMenusLogic { + return &AssignRoleMenusLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} +} + +func (l *AssignRoleMenusLogic) AssignRoleMenus(req *types.AssignRoleMenusReq) error { + _, err := l.svcCtx.SystemRpc.AssignRoleMenus(l.ctx, &system.AssignRoleMenusReq{ + RoleId: req.RoleId, + MenuIds: req.MenuIds, + }) + return err +} diff --git a/app/system/api/internal/logic/role/getRoleDetailLogic.go b/app/system/api/internal/logic/role/getRoleDetailLogic.go new file mode 100644 index 0000000..c47ce80 --- /dev/null +++ b/app/system/api/internal/logic/role/getRoleDetailLogic.go @@ -0,0 +1,46 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package role + +import ( + "context" + + "sundynix-micro-go/app/system/api/internal/svc" + "sundynix-micro-go/app/system/api/internal/types" + "sundynix-micro-go/app/system/rpc/system" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetRoleDetailLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +// 角色详情(含已授权菜单) +func NewGetRoleDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRoleDetailLogic { + return &GetRoleDetailLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetRoleDetailLogic) GetRoleDetail(req *types.IdQueryReq) (resp *types.RoleDetailResp, err error) { + rpcResp, err := l.svcCtx.SystemRpc.GetRoleDetail(l.ctx, &system.GetRoleDetailReq{ + Id: req.Id, + }) + if err != nil { + return nil, err + } + + return &types.RoleDetailResp{ + Id: rpcResp.Id, + Name: rpcResp.Name, + Code: rpcResp.Code, + Sort: int(rpcResp.Sort), + MenuIds: rpcResp.MenuIds, + }, nil +} diff --git a/app/system/api/internal/logic/role/updateRoleLogic.go b/app/system/api/internal/logic/role/updateRoleLogic.go index 8b4732d..f1fb6be 100644 --- a/app/system/api/internal/logic/role/updateRoleLogic.go +++ b/app/system/api/internal/logic/role/updateRoleLogic.go @@ -20,7 +20,7 @@ func NewUpdateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Update func (l *UpdateRoleLogic) UpdateRole(req *types.RoleUpdateReq) error { _, err := l.svcCtx.SystemRpc.UpdateRole(l.ctx, &system.RoleUpdateReq{ - Id: req.Id, Name: req.Name, Code: req.Code, Sort: int32(req.Sort), MenuIds: req.MenuIds, + Id: req.Id, Name: req.Name, Code: req.Code, Sort: int32(req.Sort), }) return err } diff --git a/app/system/api/internal/logic/user/assignUserRolesLogic.go b/app/system/api/internal/logic/user/assignUserRolesLogic.go new file mode 100644 index 0000000..9816264 --- /dev/null +++ b/app/system/api/internal/logic/user/assignUserRolesLogic.go @@ -0,0 +1,29 @@ +package user + +import ( + "context" + + "sundynix-micro-go/app/system/api/internal/svc" + "sundynix-micro-go/app/system/api/internal/types" + "sundynix-micro-go/app/system/rpc/system" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AssignUserRolesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAssignUserRolesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssignUserRolesLogic { + return &AssignUserRolesLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} +} + +func (l *AssignUserRolesLogic) AssignUserRoles(req *types.AssignUserRolesReq) error { + _, err := l.svcCtx.SystemRpc.AssignUserRoles(l.ctx, &system.AssignUserRolesReq{ + UserId: req.UserId, + RoleIds: req.RoleIds, + }) + return err +} diff --git a/app/system/api/internal/logic/user/createUserLogic.go b/app/system/api/internal/logic/user/createUserLogic.go index cff0bf6..609a655 100644 --- a/app/system/api/internal/logic/user/createUserLogic.go +++ b/app/system/api/internal/logic/user/createUserLogic.go @@ -21,11 +21,21 @@ func NewCreateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create } func (l *CreateUserLogic) CreateUser(req *types.UserCreateReq) error { - _, err := l.svcCtx.SystemRpc.CreateUser(l.ctx, &system.CreateUserReq{ + resp, err := l.svcCtx.SystemRpc.CreateUser(l.ctx, &system.CreateUserReq{ Name: req.Name, Account: req.Account, Password: req.Password, Phone: req.Phone, }) + if err != nil { + return err + } + // 创建完成后立即绑定角色 + if len(req.RoleIds) > 0 && resp != nil { + _, err = l.svcCtx.SystemRpc.AssignUserRoles(l.ctx, &system.AssignUserRolesReq{ + UserId: resp.User.Id, + RoleIds: req.RoleIds, + }) + } return err } diff --git a/app/system/api/internal/logic/user/getUserDetailLogic.go b/app/system/api/internal/logic/user/getUserDetailLogic.go new file mode 100644 index 0000000..191cc06 --- /dev/null +++ b/app/system/api/internal/logic/user/getUserDetailLogic.go @@ -0,0 +1,47 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.10.1 + +package user + +import ( + "context" + + "sundynix-micro-go/app/system/api/internal/svc" + "sundynix-micro-go/app/system/api/internal/types" + "sundynix-micro-go/app/system/rpc/system" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetUserDetailLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +// 用户详情(含角色信息) +func NewGetUserDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserDetailLogic { + return &GetUserDetailLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetUserDetailLogic) GetUserDetail(req *types.IdQueryReq) (resp *types.UserDetailResp, err error) { + rpcResp, err := l.svcCtx.SystemRpc.GetUserDetail(l.ctx, &system.GetUserDetailReq{ + Id: req.Id, + }) + if err != nil { + return nil, err + } + + return &types.UserDetailResp{ + Id: rpcResp.Id, + Name: rpcResp.Name, + Account: rpcResp.Account, + NickName: rpcResp.NickName, + Phone: rpcResp.Phone, + RoleIds: rpcResp.RoleIds, + }, nil +} diff --git a/app/system/api/internal/logic/user/getUserListLogic.go b/app/system/api/internal/logic/user/getUserListLogic.go index af13727..bc148af 100644 --- a/app/system/api/internal/logic/user/getUserListLogic.go +++ b/app/system/api/internal/logic/user/getUserListLogic.go @@ -32,6 +32,15 @@ func (l *GetUserListLogic) GetUserList(req *types.UserListReq) (resp interface{} } var list []map[string]interface{} for _, u := range rpcResp.List { + var roles []map[string]interface{} + for _, r := range u.Roles { + roles = append(roles, map[string]interface{}{ + "id": r.Id, + "name": r.Name, + "code": r.Code, + }) + } + list = append(list, map[string]interface{}{ "id": u.Id, "name": u.Name, @@ -40,6 +49,7 @@ func (l *GetUserListLogic) GetUserList(req *types.UserListReq) (resp interface{} "phone": u.Phone, "gender": u.Gender, "createdAt": u.CreatedAt, + "roles": roles, }) } return map[string]interface{}{"list": list, "total": rpcResp.Total}, nil diff --git a/app/system/api/internal/types/types.go b/app/system/api/internal/types/types.go index 5282b50..498d4bb 100644 --- a/app/system/api/internal/types/types.go +++ b/app/system/api/internal/types/types.go @@ -3,6 +3,16 @@ package types +type AssignRoleMenusReq struct { + RoleId string `json:"roleId"` + MenuIds []string `json:"menuIds"` +} + +type AssignUserRolesReq struct { + UserId string `json:"userId"` + RoleIds []string `json:"roleIds"` +} + type ClientListReq struct { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` @@ -49,6 +59,10 @@ type DictUpdateReq struct { Desc string `json:"desc,optional"` } +type IdQueryReq struct { + Id string `form:"id"` +} + type IdReq struct { Id string `json:"id"` } @@ -103,6 +117,14 @@ type ResetPasswordReq struct { Password string `json:"password"` } +type RoleDetailResp struct { + Id string `json:"id"` + Name string `json:"name"` + Code string `json:"code"` + Sort int `json:"sort"` + MenuIds []string `json:"menuIds"` +} + type RoleListReq struct { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` @@ -117,11 +139,10 @@ type RoleReq struct { } type RoleUpdateReq struct { - Id string `json:"id"` - Name string `json:"name,optional"` - Code string `json:"code,optional"` - Sort int `json:"sort,optional"` - MenuIds []string `json:"menuIds,optional"` + Id string `json:"id"` + Name string `json:"name,optional"` + Code string `json:"code,optional"` + Sort int `json:"sort,optional"` } type UserCreateReq struct { @@ -133,6 +154,15 @@ type UserCreateReq struct { RoleIds []string `json:"roleIds,optional"` } +type UserDetailResp struct { + Id string `json:"id"` + Name string `json:"name"` + Account string `json:"account"` + NickName string `json:"nickName"` + Phone string `json:"phone"` + RoleIds []string `json:"roleIds"` +} + type UserListReq struct { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` @@ -141,10 +171,9 @@ type UserListReq struct { } type UserUpdateReq struct { - Id string `json:"id"` - Name string `json:"name,optional"` - Account string `json:"account,optional"` - Phone string `json:"phone,optional"` - NickName string `json:"nickName,optional"` - RoleIds []string `json:"roleIds,optional"` + Id string `json:"id"` + Name string `json:"name,optional"` + Account string `json:"account,optional"` + Phone string `json:"phone,optional"` + NickName string `json:"nickName,optional"` } diff --git a/app/system/api/system.api b/app/system/api/system.api index 833d9ca..9d4084e 100644 --- a/app/system/api/system.api +++ b/app/system/api/system.api @@ -12,6 +12,9 @@ type ( IdReq { Id string `json:"id"` } + IdQueryReq { + Id string `form:"id"` + } IdsReq { Ids []string `json:"ids"` } @@ -49,17 +52,27 @@ type ( MenuIds []string `json:"menuIds,optional"` } RoleUpdateReq { - Id string `json:"id"` - Name string `json:"name,optional"` - Code string `json:"code,optional"` - Sort int `json:"sort,optional"` - MenuIds []string `json:"menuIds,optional"` + Id string `json:"id"` + Name string `json:"name,optional"` + Code string `json:"code,optional"` + Sort int `json:"sort,optional"` } RoleListReq { Current int `json:"current,optional"` PageSize int `json:"pageSize,optional"` Name string `json:"name,optional"` } + RoleDetailResp { + Id string `json:"id"` + Name string `json:"name"` + Code string `json:"code"` + Sort int `json:"sort"` + MenuIds []string `json:"menuIds"` + } + AssignRoleMenusReq { + RoleId string `json:"roleId"` + MenuIds []string `json:"menuIds"` + } // ---------- 菜单 ---------- MenuReq { ParentId string `json:"parentId,optional"` @@ -125,12 +138,11 @@ type ( RoleIds []string `json:"roleIds,optional"` } UserUpdateReq { - Id string `json:"id"` - Name string `json:"name,optional"` - Account string `json:"account,optional"` - Phone string `json:"phone,optional"` - NickName string `json:"nickName,optional"` - RoleIds []string `json:"roleIds,optional"` + Id string `json:"id"` + Name string `json:"name,optional"` + Account string `json:"account,optional"` + Phone string `json:"phone,optional"` + NickName string `json:"nickName,optional"` } UserListReq { Current int `json:"current,optional"` @@ -138,10 +150,22 @@ type ( Name string `json:"name,optional"` Account string `json:"account,optional"` } + UserDetailResp { + Id string `json:"id"` + Name string `json:"name"` + Account string `json:"account"` + NickName string `json:"nickName"` + Phone string `json:"phone"` + RoleIds []string `json:"roleIds"` + } ResetPasswordReq { Id string `json:"id"` Password string `json:"password"` } + AssignUserRolesReq { + UserId string `json:"userId"` + RoleIds []string `json:"roleIds"` + } ) // ========== 需要鉴权的接口 ========== @@ -189,6 +213,14 @@ service system-api { @doc "角色列表" @handler GetRoleList post /role/list (RoleListReq) + + @doc "角色详情(含已授权菜单)" + @handler GetRoleDetail + get /role/detail (IdQueryReq) returns (RoleDetailResp) + + @doc "角色授权菜单" + @handler AssignRoleMenus + post /role/assignMenus (AssignRoleMenusReq) } @server ( @@ -266,6 +298,10 @@ service system-api { @handler GetUserList post /user/list (UserListReq) + @doc "用户详情(含角色信息)" + @handler GetUserDetail + get /user/detail (IdQueryReq) returns (UserDetailResp) + @doc "创建用户" @handler CreateUser post /user/create (UserCreateReq) @@ -281,5 +317,9 @@ service system-api { @doc "重置密码" @handler ResetPassword post /user/resetPassword (ResetPasswordReq) + + @doc "用户授权角色" + @handler AssignUserRoles + post /user/assignRoles (AssignUserRolesReq) } diff --git a/app/system/model/system_model.go b/app/system/model/system_model.go index d6d112d..1743787 100644 --- a/app/system/model/system_model.go +++ b/app/system/model/system_model.go @@ -25,7 +25,7 @@ type SundynixRole struct { Name string `gorm:"size:20;column:name" json:"name"` Code string `gorm:"size:20;column:code" json:"code"` Sort int `gorm:"column:sort" json:"sort"` - Menus []*SundynixMenu `gorm:"many2many:sundynix_role_menu;" json:"menus"` + Menus []*SundynixMenu `gorm:"many2many:sundynix_role_menu;joinForeignKey:role_id;joinReferences:menu_id" json:"menus"` } func (SundynixRole) TableName() string { @@ -114,6 +114,8 @@ type SundynixUser struct { Gender int `gorm:"default:0;column:gender" json:"gender"` LastLoginIP string `gorm:"size:20;column:last_login_ip" json:"lastLoginIp"` LastLoginAt *time.Time `gorm:"column:last_login_at" json:"lastLoginAt"` + + Roles []*SundynixRole `gorm:"many2many:sundynix_user_role;joinForeignKey:user_id;joinReferences:role_id" json:"roles"` } func (SundynixUser) TableName() string { diff --git a/app/system/rpc/internal/logic/assignRoleMenusLogic.go b/app/system/rpc/internal/logic/assignRoleMenusLogic.go new file mode 100644 index 0000000..400fefd --- /dev/null +++ b/app/system/rpc/internal/logic/assignRoleMenusLogic.go @@ -0,0 +1,44 @@ +package logic + +import ( + "context" + "fmt" + + sysModel "sundynix-micro-go/app/system/model" + "sundynix-micro-go/app/system/rpc/internal/svc" + "sundynix-micro-go/app/system/rpc/system" + + "github.com/zeromicro/go-zero/core/logx" + "gorm.io/gorm" +) + +type AssignRoleMenusLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewAssignRoleMenusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssignRoleMenusLogic { + return &AssignRoleMenusLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)} +} + +// AssignRoleMenus 给角色授权菜单(全量替换) +func (l *AssignRoleMenusLogic) AssignRoleMenus(in *system.AssignRoleMenusReq) (*system.CommonResp, error) { + err := l.svcCtx.DB.Transaction(func(tx *gorm.DB) error { + // 先清除旧的菜单关联 + if err := tx.Where("role_id = ?", in.RoleId).Delete(&sysModel.SundynixRoleMenu{}).Error; err != nil { + return fmt.Errorf("清除菜单关联失败: %w", err) + } + // 重新批量写入 + for _, mid := range in.MenuIds { + if err := tx.Create(&sysModel.SundynixRoleMenu{RoleID: in.RoleId, MenuID: mid}).Error; err != nil { + return fmt.Errorf("关联菜单失败: %w", err) + } + } + return nil + }) + if err != nil { + return nil, err + } + return &system.CommonResp{Code: 200, Msg: "success"}, nil +} diff --git a/app/system/rpc/internal/logic/assignUserRolesLogic.go b/app/system/rpc/internal/logic/assignUserRolesLogic.go new file mode 100644 index 0000000..60dfe85 --- /dev/null +++ b/app/system/rpc/internal/logic/assignUserRolesLogic.go @@ -0,0 +1,44 @@ +package logic + +import ( + "context" + "fmt" + + sysModel "sundynix-micro-go/app/system/model" + "sundynix-micro-go/app/system/rpc/internal/svc" + "sundynix-micro-go/app/system/rpc/system" + + "github.com/zeromicro/go-zero/core/logx" + "gorm.io/gorm" +) + +type AssignUserRolesLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewAssignUserRolesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssignUserRolesLogic { + return &AssignUserRolesLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)} +} + +// AssignUserRoles 给用户授权角色(全量替换) +func (l *AssignUserRolesLogic) AssignUserRoles(in *system.AssignUserRolesReq) (*system.CommonResp, error) { + err := l.svcCtx.DB.Transaction(func(tx *gorm.DB) error { + // 先清除旧的角色关联 + if err := tx.Where("user_id = ?", in.UserId).Delete(&sysModel.SundynixUserRole{}).Error; err != nil { + return fmt.Errorf("清除角色关联失败: %w", err) + } + // 重新批量写入 + for _, rid := range in.RoleIds { + if err := tx.Create(&sysModel.SundynixUserRole{UserID: in.UserId, RoleID: rid}).Error; err != nil { + return fmt.Errorf("关联角色失败: %w", err) + } + } + return nil + }) + if err != nil { + return nil, err + } + return &system.CommonResp{Code: 200, Msg: "success"}, nil +} diff --git a/app/system/rpc/internal/logic/createRoleLogic.go b/app/system/rpc/internal/logic/createRoleLogic.go index 7f2e8ed..c3394c8 100644 --- a/app/system/rpc/internal/logic/createRoleLogic.go +++ b/app/system/rpc/internal/logic/createRoleLogic.go @@ -28,7 +28,6 @@ func (l *CreateRoleLogic) CreateRole(in *system.RoleReq) (*system.CommonResp, er if err := tx.Create(&role).Error; err != nil { return fmt.Errorf("创建角色失败: %w", err) } - // 关联菜单 for _, mid := range in.MenuIds { if err := tx.Create(&sysModel.SundynixRoleMenu{RoleID: role.ID, MenuID: mid}).Error; err != nil { return fmt.Errorf("关联菜单失败: %w", err) diff --git a/app/system/rpc/internal/logic/getRoleDetailLogic.go b/app/system/rpc/internal/logic/getRoleDetailLogic.go new file mode 100644 index 0000000..69e120c --- /dev/null +++ b/app/system/rpc/internal/logic/getRoleDetailLogic.go @@ -0,0 +1,46 @@ +package logic + +import ( + "context" + "fmt" + + sysModel "sundynix-micro-go/app/system/model" + "sundynix-micro-go/app/system/rpc/internal/svc" + "sundynix-micro-go/app/system/rpc/system" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetRoleDetailLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGetRoleDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRoleDetailLogic { + return &GetRoleDetailLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GetRoleDetailLogic) GetRoleDetail(in *system.GetRoleDetailReq) (*system.RoleDetailResp, error) { + var role sysModel.SundynixRole + if err := l.svcCtx.DB.Preload("Menus").Where("id = ?", in.Id).First(&role).Error; err != nil { + return nil, fmt.Errorf("获取角色详情失败: %w", err) + } + + var menuIds []string + for _, menu := range role.Menus { + menuIds = append(menuIds, menu.ID) + } + + return &system.RoleDetailResp{ + Id: role.ID, + Name: role.Name, + Code: role.Code, + Sort: int32(role.Sort), + MenuIds: menuIds, + }, nil +} diff --git a/app/system/rpc/internal/logic/getRoleListLogic.go b/app/system/rpc/internal/logic/getRoleListLogic.go index 4f81e22..7cdfd89 100644 --- a/app/system/rpc/internal/logic/getRoleListLogic.go +++ b/app/system/rpc/internal/logic/getRoleListLogic.go @@ -39,7 +39,13 @@ func (l *GetRoleListLogic) GetRoleList(in *system.RoleListReq) (*system.RoleList } var items []*system.RoleInfo for _, r := range list { - items = append(items, &system.RoleInfo{Id: r.ID, Name: r.Name, Code: r.Code, Sort: int32(r.Sort)}) + items = append(items, &system.RoleInfo{ + Id: r.ID, + Name: r.Name, + Code: r.Code, + Sort: int32(r.Sort), + CreatedAt: r.CreatedAt.Unix(), + }) } return &system.RoleListResp{List: items, Total: total}, nil } diff --git a/app/system/rpc/internal/logic/getUserDetailLogic.go b/app/system/rpc/internal/logic/getUserDetailLogic.go new file mode 100644 index 0000000..b863608 --- /dev/null +++ b/app/system/rpc/internal/logic/getUserDetailLogic.go @@ -0,0 +1,47 @@ +package logic + +import ( + "context" + "fmt" + + sysModel "sundynix-micro-go/app/system/model" + "sundynix-micro-go/app/system/rpc/internal/svc" + "sundynix-micro-go/app/system/rpc/system" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetUserDetailLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGetUserDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserDetailLogic { + return &GetUserDetailLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GetUserDetailLogic) GetUserDetail(in *system.GetUserDetailReq) (*system.UserDetailResp, error) { + var user sysModel.SundynixUser + if err := l.svcCtx.DB.Preload("Roles").Where("id = ?", in.Id).First(&user).Error; err != nil { + return nil, fmt.Errorf("获取用户详情失败: %w", err) + } + + var roleIds []string + for _, role := range user.Roles { + roleIds = append(roleIds, role.ID) + } + + return &system.UserDetailResp{ + Id: user.ID, + Name: user.Name, + Account: user.Account, + NickName: user.NickName, + Phone: user.Phone, + RoleIds: roleIds, + }, nil +} diff --git a/app/system/rpc/internal/logic/getUserListLogic.go b/app/system/rpc/internal/logic/getUserListLogic.go index cc377e7..5b0d76b 100644 --- a/app/system/rpc/internal/logic/getUserListLogic.go +++ b/app/system/rpc/internal/logic/getUserListLogic.go @@ -41,7 +41,7 @@ func (l *GetUserListLogic) GetUserList(in *system.GetUserListReq) (*system.GetUs if current <= 0 { current = 1 } - db.Offset((current - 1) * pageSize).Limit(pageSize).Order("created_at DESC").Find(&list) + db.Preload("Roles").Offset((current - 1) * pageSize).Limit(pageSize).Order("created_at DESC").Find(&list) var protoList []*system.UserInfo for _, u := range list { diff --git a/app/system/rpc/internal/logic/updateRoleLogic.go b/app/system/rpc/internal/logic/updateRoleLogic.go index 93edfdb..d953dbd 100644 --- a/app/system/rpc/internal/logic/updateRoleLogic.go +++ b/app/system/rpc/internal/logic/updateRoleLogic.go @@ -9,7 +9,6 @@ import ( "sundynix-micro-go/app/system/rpc/system" "github.com/zeromicro/go-zero/core/logx" - "gorm.io/gorm" ) type UpdateRoleLogic struct { @@ -23,26 +22,10 @@ func NewUpdateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Update } func (l *UpdateRoleLogic) UpdateRole(in *system.RoleUpdateReq) (*system.CommonResp, error) { - err := l.svcCtx.DB.Transaction(func(tx *gorm.DB) error { - if err := tx.Model(&sysModel.SundynixRole{}).Where("id = ?", in.Id).Updates(map[string]interface{}{ - "name": in.Name, "code": in.Code, "sort": in.Sort, - }).Error; err != nil { - return fmt.Errorf("更新角色失败: %w", err) - } - // 先删除旧的菜单关联 - if err := tx.Where("role_id = ?", in.Id).Delete(&sysModel.SundynixRoleMenu{}).Error; err != nil { - return fmt.Errorf("清除菜单关联失败: %w", err) - } - // 重新关联菜单 - for _, mid := range in.MenuIds { - if err := tx.Create(&sysModel.SundynixRoleMenu{RoleID: in.Id, MenuID: mid}).Error; err != nil { - return fmt.Errorf("关联菜单失败: %w", err) - } - } - return nil - }) - if err != nil { - return nil, err + if err := l.svcCtx.DB.Model(&sysModel.SundynixRole{}).Where("id = ?", in.Id).Updates(map[string]interface{}{ + "name": in.Name, "code": in.Code, "sort": in.Sort, + }).Error; err != nil { + return nil, fmt.Errorf("更新角色失败: %w", err) } return &system.CommonResp{Code: 200, Msg: "success"}, nil } diff --git a/app/system/rpc/internal/logic/userHelper.go b/app/system/rpc/internal/logic/userHelper.go index 4335d67..3d68725 100644 --- a/app/system/rpc/internal/logic/userHelper.go +++ b/app/system/rpc/internal/logic/userHelper.go @@ -27,5 +27,15 @@ func convertUserToProto(u *sysModel.SundynixUser) *system.UserInfo { if u.LastLoginAt != nil { info.LastLoginAt = u.LastLoginAt.Unix() } + + for _, r := range u.Roles { + info.Roles = append(info.Roles, &system.RoleInfo{ + Id: r.ID, + Name: r.Name, + Code: r.Code, + Sort: int32(r.Sort), + }) + } + return info } diff --git a/app/system/rpc/internal/server/systemServiceServer.go b/app/system/rpc/internal/server/systemServiceServer.go index 1e167eb..e01c26b 100644 --- a/app/system/rpc/internal/server/systemServiceServer.go +++ b/app/system/rpc/internal/server/systemServiceServer.go @@ -54,6 +54,11 @@ func (s *SystemServiceServer) GetUserList(ctx context.Context, in *system.GetUse return l.GetUserList(in) } +func (s *SystemServiceServer) GetUserDetail(ctx context.Context, in *system.GetUserDetailReq) (*system.UserDetailResp, error) { + l := logic.NewGetUserDetailLogic(ctx, s.svcCtx) + return l.GetUserDetail(in) +} + func (s *SystemServiceServer) DeleteUser(ctx context.Context, in *system.DeleteUserReq) (*system.CommonResp, error) { l := logic.NewDeleteUserLogic(ctx, s.svcCtx) return l.DeleteUser(in) @@ -90,6 +95,22 @@ func (s *SystemServiceServer) GetRoleList(ctx context.Context, in *system.RoleLi return l.GetRoleList(in) } +func (s *SystemServiceServer) GetRoleDetail(ctx context.Context, in *system.GetRoleDetailReq) (*system.RoleDetailResp, error) { + l := logic.NewGetRoleDetailLogic(ctx, s.svcCtx) + return l.GetRoleDetail(in) +} + +func (s *SystemServiceServer) AssignRoleMenus(ctx context.Context, in *system.AssignRoleMenusReq) (*system.CommonResp, error) { + l := logic.NewAssignRoleMenusLogic(ctx, s.svcCtx) + return l.AssignRoleMenus(in) +} + +// --- RBAC 用户授权 --- +func (s *SystemServiceServer) AssignUserRoles(ctx context.Context, in *system.AssignUserRolesReq) (*system.CommonResp, error) { + l := logic.NewAssignUserRolesLogic(ctx, s.svcCtx) + return l.AssignUserRoles(in) +} + // --- 菜单 --- func (s *SystemServiceServer) GetMenusByRoleId(ctx context.Context, in *system.GetMenusByRoleIdReq) (*system.GetMenusByRoleIdResp, error) { l := logic.NewGetMenusByRoleIdLogic(ctx, s.svcCtx) diff --git a/app/system/rpc/internal/task/clean_oper_log.go b/app/system/rpc/internal/task/clean_oper_log.go new file mode 100644 index 0000000..11bf29d --- /dev/null +++ b/app/system/rpc/internal/task/clean_oper_log.go @@ -0,0 +1,39 @@ +package task + +import ( + "context" + "time" + + "github.com/zeromicro/go-zero/core/logx" + "sundynix-micro-go/app/system/rpc/internal/svc" +) + +// CleanOperLogJob 定义清理操作日志的定时任务 +type CleanOperLogJob struct { + svcCtx *svc.ServiceContext +} + +func NewCleanOperLogJob(svcCtx *svc.ServiceContext) *CleanOperLogJob { + return &CleanOperLogJob{ + svcCtx: svcCtx, + } +} + +func (j *CleanOperLogJob) Run() { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) + defer cancel() + + logx.WithContext(ctx).Infof("[CRON] 开始执行定时清理操作日志任务") + + // 删除 3 天前的日志 + threeDaysAgo := time.Now().AddDate(0, 0, -3) + + // 执行硬删除 + res := j.svcCtx.DB.WithContext(ctx).Exec("DELETE FROM sundynix_operation_record WHERE created_at < ?", threeDaysAgo) + if res.Error != nil { + logx.WithContext(ctx).Errorf("[CRON] 清理操作日志失败: %v", res.Error) + return + } + + logx.WithContext(ctx).Infof("[CRON] 定时清理操作日志完成,共删除了 %d 条数据", res.RowsAffected) +} diff --git a/app/system/rpc/pb/system.proto b/app/system/rpc/pb/system.proto index 9004b3e..5129359 100644 --- a/app/system/rpc/pb/system.proto +++ b/app/system/rpc/pb/system.proto @@ -27,6 +27,7 @@ message RoleInfo { string code = 3; int32 sort = 4; repeated string menuIds = 5; + int64 createdAt = 6; } message RoleReq { @@ -41,7 +42,17 @@ message RoleUpdateReq { string name = 2; string code = 3; int32 sort = 4; - repeated string menuIds = 5; +} + +// RBAC 授权 +message AssignRoleMenusReq { + string roleId = 1; + repeated string menuIds = 2; +} + +message AssignUserRolesReq { + string userId = 1; + repeated string roleIds = 2; } message RoleListReq { @@ -55,6 +66,18 @@ message RoleListResp { int64 total = 2; } +message GetRoleDetailReq { + string id = 1; +} + +message RoleDetailResp { + string id = 1; + string name = 2; + string code = 3; + int32 sort = 4; + repeated string menuIds = 5; +} + // ========== 菜单 ========== message MenuInfo { @@ -253,6 +276,7 @@ message UserInfo { int64 createdAt = 22; int64 updatedAt = 23; string avatarUrl = 24; + repeated RoleInfo roles = 25; } message GetUserByIdReq { @@ -315,6 +339,19 @@ message GetUserListResp { int64 total = 2; } +message GetUserDetailReq { + string id = 1; +} + +message UserDetailResp { + string id = 1; + string name = 2; + string account = 3; + string nickName = 4; + string phone = 5; + repeated string roleIds = 6; +} + message DeleteUserReq { repeated string ids = 1; } @@ -360,6 +397,7 @@ service SystemService { rpc CreateUser(CreateUserReq) returns (CreateUserResp); rpc UpdateUser(UpdateUserReq) returns (CommonResp); rpc GetUserList(GetUserListReq) returns (GetUserListResp); + rpc GetUserDetail(GetUserDetailReq) returns (UserDetailResp); rpc DeleteUser(DeleteUserReq) returns (CommonResp); rpc ResetPassword(ResetPasswordReq) returns (CommonResp); @@ -369,6 +407,11 @@ service SystemService { rpc UpdateRole(RoleUpdateReq) returns (CommonResp); rpc DeleteRole(IdsReq) returns (CommonResp); rpc GetRoleList(RoleListReq) returns (RoleListResp); + rpc GetRoleDetail(GetRoleDetailReq) returns (RoleDetailResp); + rpc AssignRoleMenus(AssignRoleMenusReq) returns (CommonResp); + + // --- RBAC 用户授权 --- + rpc AssignUserRoles(AssignUserRolesReq) returns (CommonResp); // --- 菜单 --- rpc GetMenusByRoleId(GetMenusByRoleIdReq) returns (GetMenusByRoleIdResp); diff --git a/app/system/rpc/system.go b/app/system/rpc/system.go index 1a4767b..b9b39ef 100644 --- a/app/system/rpc/system.go +++ b/app/system/rpc/system.go @@ -7,9 +7,12 @@ import ( "sundynix-micro-go/app/system/rpc/internal/config" "sundynix-micro-go/app/system/rpc/internal/server" "sundynix-micro-go/app/system/rpc/internal/svc" + "sundynix-micro-go/app/system/rpc/internal/task" "sundynix-micro-go/app/system/rpc/system" + "sundynix-micro-go/common/utils/timer" "github.com/zeromicro/go-zero/core/conf" + "github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/service" "github.com/zeromicro/go-zero/core/stat" "github.com/zeromicro/go-zero/zrpc" @@ -36,6 +39,19 @@ func main() { }) defer s.Stop() + // 初始化定时任务系统 + cronTimer := timer.NewTimerTask() + defer cronTimer.Close() + + // 注册定时清理操作日志任务 (每天凌晨 3:00 执行) + cleanJob := task.NewCleanOperLogJob(ctx) + _, err := cronTimer.AddTaskByJob("systemCron", "0 3 * * *", cleanJob, "cleanOperLogTask") + if err != nil { + logx.Errorf("❌ 注册定时清理操作日志任务失败: %v", err) + } else { + logx.Infof("✅ 注册定时清理操作日志任务成功 (每天凌晨3点)") + } + fmt.Printf("Starting rpc server at %s...\n", c.ListenOn) s.Start() } diff --git a/app/system/rpc/system/system.pb.go b/app/system/rpc/system/system.pb.go index 0e38b79..7b6c208 100644 --- a/app/system/rpc/system/system.pb.go +++ b/app/system/rpc/system/system.pb.go @@ -168,6 +168,7 @@ type RoleInfo struct { Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` Sort int32 `protobuf:"varint,4,opt,name=sort,proto3" json:"sort,omitempty"` MenuIds []string `protobuf:"bytes,5,rep,name=menuIds,proto3" json:"menuIds,omitempty"` + CreatedAt int64 `protobuf:"varint,6,opt,name=createdAt,proto3" json:"createdAt,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -237,6 +238,13 @@ func (x *RoleInfo) GetMenuIds() []string { return nil } +func (x *RoleInfo) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + type RoleReq struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -311,7 +319,6 @@ type RoleUpdateReq struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` Sort int32 `protobuf:"varint,4,opt,name=sort,proto3" json:"sort,omitempty"` - MenuIds []string `protobuf:"bytes,5,rep,name=menuIds,proto3" json:"menuIds,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -374,13 +381,111 @@ func (x *RoleUpdateReq) GetSort() int32 { return 0 } -func (x *RoleUpdateReq) GetMenuIds() []string { +// RBAC 授权 +type AssignRoleMenusReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + RoleId string `protobuf:"bytes,1,opt,name=roleId,proto3" json:"roleId,omitempty"` + MenuIds []string `protobuf:"bytes,2,rep,name=menuIds,proto3" json:"menuIds,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AssignRoleMenusReq) Reset() { + *x = AssignRoleMenusReq{} + mi := &file_pb_system_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AssignRoleMenusReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AssignRoleMenusReq) ProtoMessage() {} + +func (x *AssignRoleMenusReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_system_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AssignRoleMenusReq.ProtoReflect.Descriptor instead. +func (*AssignRoleMenusReq) Descriptor() ([]byte, []int) { + return file_pb_system_proto_rawDescGZIP(), []int{6} +} + +func (x *AssignRoleMenusReq) GetRoleId() string { + if x != nil { + return x.RoleId + } + return "" +} + +func (x *AssignRoleMenusReq) GetMenuIds() []string { if x != nil { return x.MenuIds } return nil } +type AssignUserRolesReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` + RoleIds []string `protobuf:"bytes,2,rep,name=roleIds,proto3" json:"roleIds,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AssignUserRolesReq) Reset() { + *x = AssignUserRolesReq{} + mi := &file_pb_system_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AssignUserRolesReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AssignUserRolesReq) ProtoMessage() {} + +func (x *AssignUserRolesReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_system_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AssignUserRolesReq.ProtoReflect.Descriptor instead. +func (*AssignUserRolesReq) Descriptor() ([]byte, []int) { + return file_pb_system_proto_rawDescGZIP(), []int{7} +} + +func (x *AssignUserRolesReq) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *AssignUserRolesReq) GetRoleIds() []string { + if x != nil { + return x.RoleIds + } + return nil +} + type RoleListReq struct { state protoimpl.MessageState `protogen:"open.v1"` Current int32 `protobuf:"varint,1,opt,name=current,proto3" json:"current,omitempty"` @@ -392,7 +497,7 @@ type RoleListReq struct { func (x *RoleListReq) Reset() { *x = RoleListReq{} - mi := &file_pb_system_proto_msgTypes[6] + mi := &file_pb_system_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -404,7 +509,7 @@ func (x *RoleListReq) String() string { func (*RoleListReq) ProtoMessage() {} func (x *RoleListReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[6] + mi := &file_pb_system_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -417,7 +522,7 @@ func (x *RoleListReq) ProtoReflect() protoreflect.Message { // Deprecated: Use RoleListReq.ProtoReflect.Descriptor instead. func (*RoleListReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{6} + return file_pb_system_proto_rawDescGZIP(), []int{8} } func (x *RoleListReq) GetCurrent() int32 { @@ -451,7 +556,7 @@ type RoleListResp struct { func (x *RoleListResp) Reset() { *x = RoleListResp{} - mi := &file_pb_system_proto_msgTypes[7] + mi := &file_pb_system_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -463,7 +568,7 @@ func (x *RoleListResp) String() string { func (*RoleListResp) ProtoMessage() {} func (x *RoleListResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[7] + mi := &file_pb_system_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -476,7 +581,7 @@ func (x *RoleListResp) ProtoReflect() protoreflect.Message { // Deprecated: Use RoleListResp.ProtoReflect.Descriptor instead. func (*RoleListResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{7} + return file_pb_system_proto_rawDescGZIP(), []int{9} } func (x *RoleListResp) GetList() []*RoleInfo { @@ -493,6 +598,126 @@ func (x *RoleListResp) GetTotal() int64 { return 0 } +type GetRoleDetailReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRoleDetailReq) Reset() { + *x = GetRoleDetailReq{} + mi := &file_pb_system_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRoleDetailReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRoleDetailReq) ProtoMessage() {} + +func (x *GetRoleDetailReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_system_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRoleDetailReq.ProtoReflect.Descriptor instead. +func (*GetRoleDetailReq) Descriptor() ([]byte, []int) { + return file_pb_system_proto_rawDescGZIP(), []int{10} +} + +func (x *GetRoleDetailReq) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type RoleDetailResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` + Sort int32 `protobuf:"varint,4,opt,name=sort,proto3" json:"sort,omitempty"` + MenuIds []string `protobuf:"bytes,5,rep,name=menuIds,proto3" json:"menuIds,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleDetailResp) Reset() { + *x = RoleDetailResp{} + mi := &file_pb_system_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleDetailResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleDetailResp) ProtoMessage() {} + +func (x *RoleDetailResp) ProtoReflect() protoreflect.Message { + mi := &file_pb_system_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoleDetailResp.ProtoReflect.Descriptor instead. +func (*RoleDetailResp) Descriptor() ([]byte, []int) { + return file_pb_system_proto_rawDescGZIP(), []int{11} +} + +func (x *RoleDetailResp) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *RoleDetailResp) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *RoleDetailResp) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +func (x *RoleDetailResp) GetSort() int32 { + if x != nil { + return x.Sort + } + return 0 +} + +func (x *RoleDetailResp) GetMenuIds() []string { + if x != nil { + return x.MenuIds + } + return nil +} + type MenuInfo struct { state protoimpl.MessageState `protogen:"open.v1"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` @@ -513,7 +738,7 @@ type MenuInfo struct { func (x *MenuInfo) Reset() { *x = MenuInfo{} - mi := &file_pb_system_proto_msgTypes[8] + mi := &file_pb_system_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -525,7 +750,7 @@ func (x *MenuInfo) String() string { func (*MenuInfo) ProtoMessage() {} func (x *MenuInfo) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[8] + mi := &file_pb_system_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -538,7 +763,7 @@ func (x *MenuInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use MenuInfo.ProtoReflect.Descriptor instead. func (*MenuInfo) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{8} + return file_pb_system_proto_rawDescGZIP(), []int{12} } func (x *MenuInfo) GetId() string { @@ -643,7 +868,7 @@ type MenuReq struct { func (x *MenuReq) Reset() { *x = MenuReq{} - mi := &file_pb_system_proto_msgTypes[9] + mi := &file_pb_system_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -655,7 +880,7 @@ func (x *MenuReq) String() string { func (*MenuReq) ProtoMessage() {} func (x *MenuReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[9] + mi := &file_pb_system_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -668,7 +893,7 @@ func (x *MenuReq) ProtoReflect() protoreflect.Message { // Deprecated: Use MenuReq.ProtoReflect.Descriptor instead. func (*MenuReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{9} + return file_pb_system_proto_rawDescGZIP(), []int{13} } func (x *MenuReq) GetParentId() string { @@ -760,7 +985,7 @@ type MenuUpdateReq struct { func (x *MenuUpdateReq) Reset() { *x = MenuUpdateReq{} - mi := &file_pb_system_proto_msgTypes[10] + mi := &file_pb_system_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -772,7 +997,7 @@ func (x *MenuUpdateReq) String() string { func (*MenuUpdateReq) ProtoMessage() {} func (x *MenuUpdateReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[10] + mi := &file_pb_system_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -785,7 +1010,7 @@ func (x *MenuUpdateReq) ProtoReflect() protoreflect.Message { // Deprecated: Use MenuUpdateReq.ProtoReflect.Descriptor instead. func (*MenuUpdateReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{10} + return file_pb_system_proto_rawDescGZIP(), []int{14} } func (x *MenuUpdateReq) GetId() string { @@ -874,7 +1099,7 @@ type MenuListResp struct { func (x *MenuListResp) Reset() { *x = MenuListResp{} - mi := &file_pb_system_proto_msgTypes[11] + mi := &file_pb_system_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -886,7 +1111,7 @@ func (x *MenuListResp) String() string { func (*MenuListResp) ProtoMessage() {} func (x *MenuListResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[11] + mi := &file_pb_system_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -899,7 +1124,7 @@ func (x *MenuListResp) ProtoReflect() protoreflect.Message { // Deprecated: Use MenuListResp.ProtoReflect.Descriptor instead. func (*MenuListResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{11} + return file_pb_system_proto_rawDescGZIP(), []int{15} } func (x *MenuListResp) GetMenus() []*MenuInfo { @@ -923,7 +1148,7 @@ type ClientInfo struct { func (x *ClientInfo) Reset() { *x = ClientInfo{} - mi := &file_pb_system_proto_msgTypes[12] + mi := &file_pb_system_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -935,7 +1160,7 @@ func (x *ClientInfo) String() string { func (*ClientInfo) ProtoMessage() {} func (x *ClientInfo) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[12] + mi := &file_pb_system_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -948,7 +1173,7 @@ func (x *ClientInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use ClientInfo.ProtoReflect.Descriptor instead. func (*ClientInfo) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{12} + return file_pb_system_proto_rawDescGZIP(), []int{16} } func (x *ClientInfo) GetId() string { @@ -1006,7 +1231,7 @@ type ClientReq struct { func (x *ClientReq) Reset() { *x = ClientReq{} - mi := &file_pb_system_proto_msgTypes[13] + mi := &file_pb_system_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1018,7 +1243,7 @@ func (x *ClientReq) String() string { func (*ClientReq) ProtoMessage() {} func (x *ClientReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[13] + mi := &file_pb_system_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1031,7 +1256,7 @@ func (x *ClientReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ClientReq.ProtoReflect.Descriptor instead. func (*ClientReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{13} + return file_pb_system_proto_rawDescGZIP(), []int{17} } func (x *ClientReq) GetClientId() string { @@ -1083,7 +1308,7 @@ type ClientUpdateReq struct { func (x *ClientUpdateReq) Reset() { *x = ClientUpdateReq{} - mi := &file_pb_system_proto_msgTypes[14] + mi := &file_pb_system_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1095,7 +1320,7 @@ func (x *ClientUpdateReq) String() string { func (*ClientUpdateReq) ProtoMessage() {} func (x *ClientUpdateReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[14] + mi := &file_pb_system_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1108,7 +1333,7 @@ func (x *ClientUpdateReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ClientUpdateReq.ProtoReflect.Descriptor instead. func (*ClientUpdateReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{14} + return file_pb_system_proto_rawDescGZIP(), []int{18} } func (x *ClientUpdateReq) GetId() string { @@ -1164,7 +1389,7 @@ type ClientListReq struct { func (x *ClientListReq) Reset() { *x = ClientListReq{} - mi := &file_pb_system_proto_msgTypes[15] + mi := &file_pb_system_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1176,7 +1401,7 @@ func (x *ClientListReq) String() string { func (*ClientListReq) ProtoMessage() {} func (x *ClientListReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[15] + mi := &file_pb_system_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1189,7 +1414,7 @@ func (x *ClientListReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ClientListReq.ProtoReflect.Descriptor instead. func (*ClientListReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{15} + return file_pb_system_proto_rawDescGZIP(), []int{19} } func (x *ClientListReq) GetCurrent() int32 { @@ -1223,7 +1448,7 @@ type ClientListResp struct { func (x *ClientListResp) Reset() { *x = ClientListResp{} - mi := &file_pb_system_proto_msgTypes[16] + mi := &file_pb_system_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1235,7 +1460,7 @@ func (x *ClientListResp) String() string { func (*ClientListResp) ProtoMessage() {} func (x *ClientListResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[16] + mi := &file_pb_system_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1248,7 +1473,7 @@ func (x *ClientListResp) ProtoReflect() protoreflect.Message { // Deprecated: Use ClientListResp.ProtoReflect.Descriptor instead. func (*ClientListResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{16} + return file_pb_system_proto_rawDescGZIP(), []int{20} } func (x *ClientListResp) GetList() []*ClientInfo { @@ -1279,7 +1504,7 @@ type DictInfo struct { func (x *DictInfo) Reset() { *x = DictInfo{} - mi := &file_pb_system_proto_msgTypes[17] + mi := &file_pb_system_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1291,7 +1516,7 @@ func (x *DictInfo) String() string { func (*DictInfo) ProtoMessage() {} func (x *DictInfo) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[17] + mi := &file_pb_system_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1304,7 +1529,7 @@ func (x *DictInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use DictInfo.ProtoReflect.Descriptor instead. func (*DictInfo) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{17} + return file_pb_system_proto_rawDescGZIP(), []int{21} } func (x *DictInfo) GetId() string { @@ -1362,7 +1587,7 @@ type DictReq struct { func (x *DictReq) Reset() { *x = DictReq{} - mi := &file_pb_system_proto_msgTypes[18] + mi := &file_pb_system_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1374,7 +1599,7 @@ func (x *DictReq) String() string { func (*DictReq) ProtoMessage() {} func (x *DictReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[18] + mi := &file_pb_system_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1387,7 +1612,7 @@ func (x *DictReq) ProtoReflect() protoreflect.Message { // Deprecated: Use DictReq.ProtoReflect.Descriptor instead. func (*DictReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{18} + return file_pb_system_proto_rawDescGZIP(), []int{22} } func (x *DictReq) GetType() string { @@ -1439,7 +1664,7 @@ type DictUpdateReq struct { func (x *DictUpdateReq) Reset() { *x = DictUpdateReq{} - mi := &file_pb_system_proto_msgTypes[19] + mi := &file_pb_system_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1451,7 +1676,7 @@ func (x *DictUpdateReq) String() string { func (*DictUpdateReq) ProtoMessage() {} func (x *DictUpdateReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[19] + mi := &file_pb_system_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1464,7 +1689,7 @@ func (x *DictUpdateReq) ProtoReflect() protoreflect.Message { // Deprecated: Use DictUpdateReq.ProtoReflect.Descriptor instead. func (*DictUpdateReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{19} + return file_pb_system_proto_rawDescGZIP(), []int{23} } func (x *DictUpdateReq) GetId() string { @@ -1520,7 +1745,7 @@ type DictListReq struct { func (x *DictListReq) Reset() { *x = DictListReq{} - mi := &file_pb_system_proto_msgTypes[20] + mi := &file_pb_system_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1532,7 +1757,7 @@ func (x *DictListReq) String() string { func (*DictListReq) ProtoMessage() {} func (x *DictListReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[20] + mi := &file_pb_system_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1545,7 +1770,7 @@ func (x *DictListReq) ProtoReflect() protoreflect.Message { // Deprecated: Use DictListReq.ProtoReflect.Descriptor instead. func (*DictListReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{20} + return file_pb_system_proto_rawDescGZIP(), []int{24} } func (x *DictListReq) GetCurrent() int32 { @@ -1579,7 +1804,7 @@ type DictListResp struct { func (x *DictListResp) Reset() { *x = DictListResp{} - mi := &file_pb_system_proto_msgTypes[21] + mi := &file_pb_system_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1591,7 +1816,7 @@ func (x *DictListResp) String() string { func (*DictListResp) ProtoMessage() {} func (x *DictListResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[21] + mi := &file_pb_system_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1604,7 +1829,7 @@ func (x *DictListResp) ProtoReflect() protoreflect.Message { // Deprecated: Use DictListResp.ProtoReflect.Descriptor instead. func (*DictListResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{21} + return file_pb_system_proto_rawDescGZIP(), []int{25} } func (x *DictListResp) GetList() []*DictInfo { @@ -1642,7 +1867,7 @@ type OperationRecordInfo struct { func (x *OperationRecordInfo) Reset() { *x = OperationRecordInfo{} - mi := &file_pb_system_proto_msgTypes[22] + mi := &file_pb_system_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1654,7 +1879,7 @@ func (x *OperationRecordInfo) String() string { func (*OperationRecordInfo) ProtoMessage() {} func (x *OperationRecordInfo) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[22] + mi := &file_pb_system_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1667,7 +1892,7 @@ func (x *OperationRecordInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use OperationRecordInfo.ProtoReflect.Descriptor instead. func (*OperationRecordInfo) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{22} + return file_pb_system_proto_rawDescGZIP(), []int{26} } func (x *OperationRecordInfo) GetId() string { @@ -1780,7 +2005,7 @@ type CreateOperationRecordReq struct { func (x *CreateOperationRecordReq) Reset() { *x = CreateOperationRecordReq{} - mi := &file_pb_system_proto_msgTypes[23] + mi := &file_pb_system_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1792,7 +2017,7 @@ func (x *CreateOperationRecordReq) String() string { func (*CreateOperationRecordReq) ProtoMessage() {} func (x *CreateOperationRecordReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[23] + mi := &file_pb_system_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1805,7 +2030,7 @@ func (x *CreateOperationRecordReq) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateOperationRecordReq.ProtoReflect.Descriptor instead. func (*CreateOperationRecordReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{23} + return file_pb_system_proto_rawDescGZIP(), []int{27} } func (x *CreateOperationRecordReq) GetClientId() string { @@ -1898,7 +2123,7 @@ type OperationRecordListReq struct { func (x *OperationRecordListReq) Reset() { *x = OperationRecordListReq{} - mi := &file_pb_system_proto_msgTypes[24] + mi := &file_pb_system_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1910,7 +2135,7 @@ func (x *OperationRecordListReq) String() string { func (*OperationRecordListReq) ProtoMessage() {} func (x *OperationRecordListReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[24] + mi := &file_pb_system_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1923,7 +2148,7 @@ func (x *OperationRecordListReq) ProtoReflect() protoreflect.Message { // Deprecated: Use OperationRecordListReq.ProtoReflect.Descriptor instead. func (*OperationRecordListReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{24} + return file_pb_system_proto_rawDescGZIP(), []int{28} } func (x *OperationRecordListReq) GetCurrent() int32 { @@ -1971,7 +2196,7 @@ type OperationRecordListResp struct { func (x *OperationRecordListResp) Reset() { *x = OperationRecordListResp{} - mi := &file_pb_system_proto_msgTypes[25] + mi := &file_pb_system_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1983,7 +2208,7 @@ func (x *OperationRecordListResp) String() string { func (*OperationRecordListResp) ProtoMessage() {} func (x *OperationRecordListResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[25] + mi := &file_pb_system_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1996,7 +2221,7 @@ func (x *OperationRecordListResp) ProtoReflect() protoreflect.Message { // Deprecated: Use OperationRecordListResp.ProtoReflect.Descriptor instead. func (*OperationRecordListResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{25} + return file_pb_system_proto_rawDescGZIP(), []int{29} } func (x *OperationRecordListResp) GetList() []*OperationRecordInfo { @@ -2039,13 +2264,14 @@ type UserInfo struct { CreatedAt int64 `protobuf:"varint,22,opt,name=createdAt,proto3" json:"createdAt,omitempty"` UpdatedAt int64 `protobuf:"varint,23,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"` AvatarUrl string `protobuf:"bytes,24,opt,name=avatarUrl,proto3" json:"avatarUrl,omitempty"` + Roles []*RoleInfo `protobuf:"bytes,25,rep,name=roles,proto3" json:"roles,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *UserInfo) Reset() { *x = UserInfo{} - mi := &file_pb_system_proto_msgTypes[26] + mi := &file_pb_system_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2057,7 +2283,7 @@ func (x *UserInfo) String() string { func (*UserInfo) ProtoMessage() {} func (x *UserInfo) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[26] + mi := &file_pb_system_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2070,7 +2296,7 @@ func (x *UserInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use UserInfo.ProtoReflect.Descriptor instead. func (*UserInfo) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{26} + return file_pb_system_proto_rawDescGZIP(), []int{30} } func (x *UserInfo) GetId() string { @@ -2241,6 +2467,13 @@ func (x *UserInfo) GetAvatarUrl() string { return "" } +func (x *UserInfo) GetRoles() []*RoleInfo { + if x != nil { + return x.Roles + } + return nil +} + type GetUserByIdReq struct { state protoimpl.MessageState `protogen:"open.v1"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` @@ -2250,7 +2483,7 @@ type GetUserByIdReq struct { func (x *GetUserByIdReq) Reset() { *x = GetUserByIdReq{} - mi := &file_pb_system_proto_msgTypes[27] + mi := &file_pb_system_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2262,7 +2495,7 @@ func (x *GetUserByIdReq) String() string { func (*GetUserByIdReq) ProtoMessage() {} func (x *GetUserByIdReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[27] + mi := &file_pb_system_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2275,7 +2508,7 @@ func (x *GetUserByIdReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserByIdReq.ProtoReflect.Descriptor instead. func (*GetUserByIdReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{27} + return file_pb_system_proto_rawDescGZIP(), []int{31} } func (x *GetUserByIdReq) GetId() string { @@ -2294,7 +2527,7 @@ type GetUserByIdResp struct { func (x *GetUserByIdResp) Reset() { *x = GetUserByIdResp{} - mi := &file_pb_system_proto_msgTypes[28] + mi := &file_pb_system_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2306,7 +2539,7 @@ func (x *GetUserByIdResp) String() string { func (*GetUserByIdResp) ProtoMessage() {} func (x *GetUserByIdResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[28] + mi := &file_pb_system_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2319,7 +2552,7 @@ func (x *GetUserByIdResp) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserByIdResp.ProtoReflect.Descriptor instead. func (*GetUserByIdResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{28} + return file_pb_system_proto_rawDescGZIP(), []int{32} } func (x *GetUserByIdResp) GetUser() *UserInfo { @@ -2338,7 +2571,7 @@ type GetUserByOpenIdReq struct { func (x *GetUserByOpenIdReq) Reset() { *x = GetUserByOpenIdReq{} - mi := &file_pb_system_proto_msgTypes[29] + mi := &file_pb_system_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2350,7 +2583,7 @@ func (x *GetUserByOpenIdReq) String() string { func (*GetUserByOpenIdReq) ProtoMessage() {} func (x *GetUserByOpenIdReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[29] + mi := &file_pb_system_proto_msgTypes[33] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2363,7 +2596,7 @@ func (x *GetUserByOpenIdReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserByOpenIdReq.ProtoReflect.Descriptor instead. func (*GetUserByOpenIdReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{29} + return file_pb_system_proto_rawDescGZIP(), []int{33} } func (x *GetUserByOpenIdReq) GetOpenId() string { @@ -2382,7 +2615,7 @@ type GetUserByOpenIdResp struct { func (x *GetUserByOpenIdResp) Reset() { *x = GetUserByOpenIdResp{} - mi := &file_pb_system_proto_msgTypes[30] + mi := &file_pb_system_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2394,7 +2627,7 @@ func (x *GetUserByOpenIdResp) String() string { func (*GetUserByOpenIdResp) ProtoMessage() {} func (x *GetUserByOpenIdResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[30] + mi := &file_pb_system_proto_msgTypes[34] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2407,7 +2640,7 @@ func (x *GetUserByOpenIdResp) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserByOpenIdResp.ProtoReflect.Descriptor instead. func (*GetUserByOpenIdResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{30} + return file_pb_system_proto_rawDescGZIP(), []int{34} } func (x *GetUserByOpenIdResp) GetUser() *UserInfo { @@ -2432,7 +2665,7 @@ type CreateUserReq struct { func (x *CreateUserReq) Reset() { *x = CreateUserReq{} - mi := &file_pb_system_proto_msgTypes[31] + mi := &file_pb_system_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2444,7 +2677,7 @@ func (x *CreateUserReq) String() string { func (*CreateUserReq) ProtoMessage() {} func (x *CreateUserReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[31] + mi := &file_pb_system_proto_msgTypes[35] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2457,7 +2690,7 @@ func (x *CreateUserReq) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateUserReq.ProtoReflect.Descriptor instead. func (*CreateUserReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{31} + return file_pb_system_proto_rawDescGZIP(), []int{35} } func (x *CreateUserReq) GetName() string { @@ -2518,7 +2751,7 @@ type CreateUserResp struct { func (x *CreateUserResp) Reset() { *x = CreateUserResp{} - mi := &file_pb_system_proto_msgTypes[32] + mi := &file_pb_system_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2530,7 +2763,7 @@ func (x *CreateUserResp) String() string { func (*CreateUserResp) ProtoMessage() {} func (x *CreateUserResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[32] + mi := &file_pb_system_proto_msgTypes[36] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2543,7 +2776,7 @@ func (x *CreateUserResp) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateUserResp.ProtoReflect.Descriptor instead. func (*CreateUserResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{32} + return file_pb_system_proto_rawDescGZIP(), []int{36} } func (x *CreateUserResp) GetUser() *UserInfo { @@ -2567,7 +2800,7 @@ type UpdateUserReq struct { func (x *UpdateUserReq) Reset() { *x = UpdateUserReq{} - mi := &file_pb_system_proto_msgTypes[33] + mi := &file_pb_system_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2579,7 +2812,7 @@ func (x *UpdateUserReq) String() string { func (*UpdateUserReq) ProtoMessage() {} func (x *UpdateUserReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[33] + mi := &file_pb_system_proto_msgTypes[37] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2592,7 +2825,7 @@ func (x *UpdateUserReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateUserReq.ProtoReflect.Descriptor instead. func (*UpdateUserReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{33} + return file_pb_system_proto_rawDescGZIP(), []int{37} } func (x *UpdateUserReq) GetId() string { @@ -2647,7 +2880,7 @@ type LoginByAccountReq struct { func (x *LoginByAccountReq) Reset() { *x = LoginByAccountReq{} - mi := &file_pb_system_proto_msgTypes[34] + mi := &file_pb_system_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2659,7 +2892,7 @@ func (x *LoginByAccountReq) String() string { func (*LoginByAccountReq) ProtoMessage() {} func (x *LoginByAccountReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[34] + mi := &file_pb_system_proto_msgTypes[38] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2672,7 +2905,7 @@ func (x *LoginByAccountReq) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginByAccountReq.ProtoReflect.Descriptor instead. func (*LoginByAccountReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{34} + return file_pb_system_proto_rawDescGZIP(), []int{38} } func (x *LoginByAccountReq) GetAccount() string { @@ -2698,7 +2931,7 @@ type LoginByAccountResp struct { func (x *LoginByAccountResp) Reset() { *x = LoginByAccountResp{} - mi := &file_pb_system_proto_msgTypes[35] + mi := &file_pb_system_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2710,7 +2943,7 @@ func (x *LoginByAccountResp) String() string { func (*LoginByAccountResp) ProtoMessage() {} func (x *LoginByAccountResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[35] + mi := &file_pb_system_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2723,7 +2956,7 @@ func (x *LoginByAccountResp) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginByAccountResp.ProtoReflect.Descriptor instead. func (*LoginByAccountResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{35} + return file_pb_system_proto_rawDescGZIP(), []int{39} } func (x *LoginByAccountResp) GetUser() *UserInfo { @@ -2745,7 +2978,7 @@ type GetUserListReq struct { func (x *GetUserListReq) Reset() { *x = GetUserListReq{} - mi := &file_pb_system_proto_msgTypes[36] + mi := &file_pb_system_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2757,7 +2990,7 @@ func (x *GetUserListReq) String() string { func (*GetUserListReq) ProtoMessage() {} func (x *GetUserListReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[36] + mi := &file_pb_system_proto_msgTypes[40] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2770,7 +3003,7 @@ func (x *GetUserListReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserListReq.ProtoReflect.Descriptor instead. func (*GetUserListReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{36} + return file_pb_system_proto_rawDescGZIP(), []int{40} } func (x *GetUserListReq) GetCurrent() int32 { @@ -2811,7 +3044,7 @@ type GetUserListResp struct { func (x *GetUserListResp) Reset() { *x = GetUserListResp{} - mi := &file_pb_system_proto_msgTypes[37] + mi := &file_pb_system_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2823,7 +3056,7 @@ func (x *GetUserListResp) String() string { func (*GetUserListResp) ProtoMessage() {} func (x *GetUserListResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[37] + mi := &file_pb_system_proto_msgTypes[41] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2836,7 +3069,7 @@ func (x *GetUserListResp) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserListResp.ProtoReflect.Descriptor instead. func (*GetUserListResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{37} + return file_pb_system_proto_rawDescGZIP(), []int{41} } func (x *GetUserListResp) GetList() []*UserInfo { @@ -2853,6 +3086,134 @@ func (x *GetUserListResp) GetTotal() int64 { return 0 } +type GetUserDetailReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserDetailReq) Reset() { + *x = GetUserDetailReq{} + mi := &file_pb_system_proto_msgTypes[42] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserDetailReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserDetailReq) ProtoMessage() {} + +func (x *GetUserDetailReq) ProtoReflect() protoreflect.Message { + mi := &file_pb_system_proto_msgTypes[42] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUserDetailReq.ProtoReflect.Descriptor instead. +func (*GetUserDetailReq) Descriptor() ([]byte, []int) { + return file_pb_system_proto_rawDescGZIP(), []int{42} +} + +func (x *GetUserDetailReq) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type UserDetailResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Account string `protobuf:"bytes,3,opt,name=account,proto3" json:"account,omitempty"` + NickName string `protobuf:"bytes,4,opt,name=nickName,proto3" json:"nickName,omitempty"` + Phone string `protobuf:"bytes,5,opt,name=phone,proto3" json:"phone,omitempty"` + RoleIds []string `protobuf:"bytes,6,rep,name=roleIds,proto3" json:"roleIds,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserDetailResp) Reset() { + *x = UserDetailResp{} + mi := &file_pb_system_proto_msgTypes[43] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserDetailResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserDetailResp) ProtoMessage() {} + +func (x *UserDetailResp) ProtoReflect() protoreflect.Message { + mi := &file_pb_system_proto_msgTypes[43] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserDetailResp.ProtoReflect.Descriptor instead. +func (*UserDetailResp) Descriptor() ([]byte, []int) { + return file_pb_system_proto_rawDescGZIP(), []int{43} +} + +func (x *UserDetailResp) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *UserDetailResp) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UserDetailResp) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +func (x *UserDetailResp) GetNickName() string { + if x != nil { + return x.NickName + } + return "" +} + +func (x *UserDetailResp) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *UserDetailResp) GetRoleIds() []string { + if x != nil { + return x.RoleIds + } + return nil +} + type DeleteUserReq struct { state protoimpl.MessageState `protogen:"open.v1"` Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"` @@ -2862,7 +3223,7 @@ type DeleteUserReq struct { func (x *DeleteUserReq) Reset() { *x = DeleteUserReq{} - mi := &file_pb_system_proto_msgTypes[38] + mi := &file_pb_system_proto_msgTypes[44] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2874,7 +3235,7 @@ func (x *DeleteUserReq) String() string { func (*DeleteUserReq) ProtoMessage() {} func (x *DeleteUserReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[38] + mi := &file_pb_system_proto_msgTypes[44] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2887,7 +3248,7 @@ func (x *DeleteUserReq) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteUserReq.ProtoReflect.Descriptor instead. func (*DeleteUserReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{38} + return file_pb_system_proto_rawDescGZIP(), []int{44} } func (x *DeleteUserReq) GetIds() []string { @@ -2907,7 +3268,7 @@ type ResetPasswordReq struct { func (x *ResetPasswordReq) Reset() { *x = ResetPasswordReq{} - mi := &file_pb_system_proto_msgTypes[39] + mi := &file_pb_system_proto_msgTypes[45] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2919,7 +3280,7 @@ func (x *ResetPasswordReq) String() string { func (*ResetPasswordReq) ProtoMessage() {} func (x *ResetPasswordReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[39] + mi := &file_pb_system_proto_msgTypes[45] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2932,7 +3293,7 @@ func (x *ResetPasswordReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ResetPasswordReq.ProtoReflect.Descriptor instead. func (*ResetPasswordReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{39} + return file_pb_system_proto_rawDescGZIP(), []int{45} } func (x *ResetPasswordReq) GetId() string { @@ -2958,7 +3319,7 @@ type GetRolesByUserIdReq struct { func (x *GetRolesByUserIdReq) Reset() { *x = GetRolesByUserIdReq{} - mi := &file_pb_system_proto_msgTypes[40] + mi := &file_pb_system_proto_msgTypes[46] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2970,7 +3331,7 @@ func (x *GetRolesByUserIdReq) String() string { func (*GetRolesByUserIdReq) ProtoMessage() {} func (x *GetRolesByUserIdReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[40] + mi := &file_pb_system_proto_msgTypes[46] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2983,7 +3344,7 @@ func (x *GetRolesByUserIdReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRolesByUserIdReq.ProtoReflect.Descriptor instead. func (*GetRolesByUserIdReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{40} + return file_pb_system_proto_rawDescGZIP(), []int{46} } func (x *GetRolesByUserIdReq) GetUserId() string { @@ -3002,7 +3363,7 @@ type GetRolesByUserIdResp struct { func (x *GetRolesByUserIdResp) Reset() { *x = GetRolesByUserIdResp{} - mi := &file_pb_system_proto_msgTypes[41] + mi := &file_pb_system_proto_msgTypes[47] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3014,7 +3375,7 @@ func (x *GetRolesByUserIdResp) String() string { func (*GetRolesByUserIdResp) ProtoMessage() {} func (x *GetRolesByUserIdResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[41] + mi := &file_pb_system_proto_msgTypes[47] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3027,7 +3388,7 @@ func (x *GetRolesByUserIdResp) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRolesByUserIdResp.ProtoReflect.Descriptor instead. func (*GetRolesByUserIdResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{41} + return file_pb_system_proto_rawDescGZIP(), []int{47} } func (x *GetRolesByUserIdResp) GetRoles() []*RoleInfo { @@ -3046,7 +3407,7 @@ type GetMenusByRoleIdReq struct { func (x *GetMenusByRoleIdReq) Reset() { *x = GetMenusByRoleIdReq{} - mi := &file_pb_system_proto_msgTypes[42] + mi := &file_pb_system_proto_msgTypes[48] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3058,7 +3419,7 @@ func (x *GetMenusByRoleIdReq) String() string { func (*GetMenusByRoleIdReq) ProtoMessage() {} func (x *GetMenusByRoleIdReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[42] + mi := &file_pb_system_proto_msgTypes[48] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3071,7 +3432,7 @@ func (x *GetMenusByRoleIdReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetMenusByRoleIdReq.ProtoReflect.Descriptor instead. func (*GetMenusByRoleIdReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{42} + return file_pb_system_proto_rawDescGZIP(), []int{48} } func (x *GetMenusByRoleIdReq) GetRoleId() string { @@ -3090,7 +3451,7 @@ type GetMenusByRoleIdResp struct { func (x *GetMenusByRoleIdResp) Reset() { *x = GetMenusByRoleIdResp{} - mi := &file_pb_system_proto_msgTypes[43] + mi := &file_pb_system_proto_msgTypes[49] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3102,7 +3463,7 @@ func (x *GetMenusByRoleIdResp) String() string { func (*GetMenusByRoleIdResp) ProtoMessage() {} func (x *GetMenusByRoleIdResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[43] + mi := &file_pb_system_proto_msgTypes[49] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3115,7 +3476,7 @@ func (x *GetMenusByRoleIdResp) ProtoReflect() protoreflect.Message { // Deprecated: Use GetMenusByRoleIdResp.ProtoReflect.Descriptor instead. func (*GetMenusByRoleIdResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{43} + return file_pb_system_proto_rawDescGZIP(), []int{49} } func (x *GetMenusByRoleIdResp) GetMenus() []*MenuInfo { @@ -3134,7 +3495,7 @@ type GetClientByIdReq struct { func (x *GetClientByIdReq) Reset() { *x = GetClientByIdReq{} - mi := &file_pb_system_proto_msgTypes[44] + mi := &file_pb_system_proto_msgTypes[50] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3146,7 +3507,7 @@ func (x *GetClientByIdReq) String() string { func (*GetClientByIdReq) ProtoMessage() {} func (x *GetClientByIdReq) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[44] + mi := &file_pb_system_proto_msgTypes[50] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3159,7 +3520,7 @@ func (x *GetClientByIdReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetClientByIdReq.ProtoReflect.Descriptor instead. func (*GetClientByIdReq) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{44} + return file_pb_system_proto_rawDescGZIP(), []int{50} } func (x *GetClientByIdReq) GetClientId() string { @@ -3178,7 +3539,7 @@ type GetClientByIdResp struct { func (x *GetClientByIdResp) Reset() { *x = GetClientByIdResp{} - mi := &file_pb_system_proto_msgTypes[45] + mi := &file_pb_system_proto_msgTypes[51] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3190,7 +3551,7 @@ func (x *GetClientByIdResp) String() string { func (*GetClientByIdResp) ProtoMessage() {} func (x *GetClientByIdResp) ProtoReflect() protoreflect.Message { - mi := &file_pb_system_proto_msgTypes[45] + mi := &file_pb_system_proto_msgTypes[51] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3203,7 +3564,7 @@ func (x *GetClientByIdResp) ProtoReflect() protoreflect.Message { // Deprecated: Use GetClientByIdResp.ProtoReflect.Descriptor instead. func (*GetClientByIdResp) Descriptor() ([]byte, []int) { - return file_pb_system_proto_rawDescGZIP(), []int{45} + return file_pb_system_proto_rawDescGZIP(), []int{51} } func (x *GetClientByIdResp) GetClient() *ClientInfo { @@ -3225,31 +3586,45 @@ const file_pb_system_proto_rawDesc = "" + "\x05IdReq\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\"\x1a\n" + "\x06IdsReq\x12\x10\n" + - "\x03ids\x18\x01 \x03(\tR\x03ids\"p\n" + + "\x03ids\x18\x01 \x03(\tR\x03ids\"\x8e\x01\n" + "\bRoleInfo\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" + "\x04code\x18\x03 \x01(\tR\x04code\x12\x12\n" + "\x04sort\x18\x04 \x01(\x05R\x04sort\x12\x18\n" + - "\amenuIds\x18\x05 \x03(\tR\amenuIds\"_\n" + + "\amenuIds\x18\x05 \x03(\tR\amenuIds\x12\x1c\n" + + "\tcreatedAt\x18\x06 \x01(\x03R\tcreatedAt\"_\n" + "\aRoleReq\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n" + "\x04code\x18\x02 \x01(\tR\x04code\x12\x12\n" + "\x04sort\x18\x03 \x01(\x05R\x04sort\x12\x18\n" + - "\amenuIds\x18\x04 \x03(\tR\amenuIds\"u\n" + + "\amenuIds\x18\x04 \x03(\tR\amenuIds\"[\n" + "\rRoleUpdateReq\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" + "\x04code\x18\x03 \x01(\tR\x04code\x12\x12\n" + - "\x04sort\x18\x04 \x01(\x05R\x04sort\x12\x18\n" + - "\amenuIds\x18\x05 \x03(\tR\amenuIds\"W\n" + + "\x04sort\x18\x04 \x01(\x05R\x04sort\"F\n" + + "\x12AssignRoleMenusReq\x12\x16\n" + + "\x06roleId\x18\x01 \x01(\tR\x06roleId\x12\x18\n" + + "\amenuIds\x18\x02 \x03(\tR\amenuIds\"F\n" + + "\x12AssignUserRolesReq\x12\x16\n" + + "\x06userId\x18\x01 \x01(\tR\x06userId\x12\x18\n" + + "\aroleIds\x18\x02 \x03(\tR\aroleIds\"W\n" + "\vRoleListReq\x12\x18\n" + "\acurrent\x18\x01 \x01(\x05R\acurrent\x12\x1a\n" + "\bpageSize\x18\x02 \x01(\x05R\bpageSize\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\"J\n" + "\fRoleListResp\x12$\n" + "\x04list\x18\x01 \x03(\v2\x10.system.RoleInfoR\x04list\x12\x14\n" + - "\x05total\x18\x02 \x01(\x03R\x05total\"\xb2\x02\n" + + "\x05total\x18\x02 \x01(\x03R\x05total\"\"\n" + + "\x10GetRoleDetailReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\"v\n" + + "\x0eRoleDetailResp\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" + + "\x04code\x18\x03 \x01(\tR\x04code\x12\x12\n" + + "\x04sort\x18\x04 \x01(\x05R\x04sort\x12\x18\n" + + "\amenuIds\x18\x05 \x03(\tR\amenuIds\"\xb2\x02\n" + "\bMenuInfo\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x1a\n" + "\bparentId\x18\x02 \x01(\tR\bparentId\x12\x1a\n" + @@ -3388,7 +3763,7 @@ const file_pb_system_proto_rawDesc = "" + "\x06status\x18\x05 \x01(\x05R\x06status\"`\n" + "\x17OperationRecordListResp\x12/\n" + "\x04list\x18\x01 \x03(\v2\x1b.system.OperationRecordInfoR\x04list\x12\x14\n" + - "\x05total\x18\x02 \x01(\x03R\x05total\"\x90\x05\n" + + "\x05total\x18\x02 \x01(\x03R\x05total\"\xb8\x05\n" + "\bUserInfo\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x1a\n" + "\btenantId\x18\x02 \x01(\tR\btenantId\x12\x1a\n" + @@ -3416,7 +3791,8 @@ const file_pb_system_proto_rawDesc = "" + "\vlastLoginAt\x18\x15 \x01(\x03R\vlastLoginAt\x12\x1c\n" + "\tcreatedAt\x18\x16 \x01(\x03R\tcreatedAt\x12\x1c\n" + "\tupdatedAt\x18\x17 \x01(\x03R\tupdatedAt\x12\x1c\n" + - "\tavatarUrl\x18\x18 \x01(\tR\tavatarUrl\" \n" + + "\tavatarUrl\x18\x18 \x01(\tR\tavatarUrl\x12&\n" + + "\x05roles\x18\x19 \x03(\v2\x10.system.RoleInfoR\x05roles\" \n" + "\x0eGetUserByIdReq\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\"7\n" + "\x0fGetUserByIdResp\x12$\n" + @@ -3456,7 +3832,16 @@ const file_pb_system_proto_rawDesc = "" + "\aaccount\x18\x04 \x01(\tR\aaccount\"M\n" + "\x0fGetUserListResp\x12$\n" + "\x04list\x18\x01 \x03(\v2\x10.system.UserInfoR\x04list\x12\x14\n" + - "\x05total\x18\x02 \x01(\x03R\x05total\"!\n" + + "\x05total\x18\x02 \x01(\x03R\x05total\"\"\n" + + "\x10GetUserDetailReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\"\x9a\x01\n" + + "\x0eUserDetailResp\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12\x18\n" + + "\aaccount\x18\x03 \x01(\tR\aaccount\x12\x1a\n" + + "\bnickName\x18\x04 \x01(\tR\bnickName\x12\x14\n" + + "\x05phone\x18\x05 \x01(\tR\x05phone\x12\x18\n" + + "\aroleIds\x18\x06 \x03(\tR\aroleIds\"!\n" + "\rDeleteUserReq\x12\x10\n" + "\x03ids\x18\x01 \x03(\tR\x03ids\">\n" + "\x10ResetPasswordReq\x12\x0e\n" + @@ -3473,7 +3858,7 @@ const file_pb_system_proto_rawDesc = "" + "\x10GetClientByIdReq\x12\x1a\n" + "\bclientId\x18\x01 \x01(\tR\bclientId\"?\n" + "\x11GetClientByIdResp\x12*\n" + - "\x06client\x18\x01 \x01(\v2\x12.system.ClientInfoR\x06client2\xc7\x0e\n" + + "\x06client\x18\x01 \x01(\v2\x12.system.ClientInfoR\x06client2\xd3\x10\n" + "\rSystemService\x12>\n" + "\vGetUserById\x12\x16.system.GetUserByIdReq\x1a\x17.system.GetUserByIdResp\x12J\n" + "\x0fGetUserByOpenId\x12\x1a.system.GetUserByOpenIdReq\x1a\x1b.system.GetUserByOpenIdResp\x12G\n" + @@ -3482,7 +3867,8 @@ const file_pb_system_proto_rawDesc = "" + "CreateUser\x12\x15.system.CreateUserReq\x1a\x16.system.CreateUserResp\x127\n" + "\n" + "UpdateUser\x12\x15.system.UpdateUserReq\x1a\x12.system.CommonResp\x12>\n" + - "\vGetUserList\x12\x16.system.GetUserListReq\x1a\x17.system.GetUserListResp\x127\n" + + "\vGetUserList\x12\x16.system.GetUserListReq\x1a\x17.system.GetUserListResp\x12A\n" + + "\rGetUserDetail\x12\x18.system.GetUserDetailReq\x1a\x16.system.UserDetailResp\x127\n" + "\n" + "DeleteUser\x12\x15.system.DeleteUserReq\x1a\x12.system.CommonResp\x12=\n" + "\rResetPassword\x12\x18.system.ResetPasswordReq\x1a\x12.system.CommonResp\x12M\n" + @@ -3493,7 +3879,10 @@ const file_pb_system_proto_rawDesc = "" + "UpdateRole\x12\x15.system.RoleUpdateReq\x1a\x12.system.CommonResp\x120\n" + "\n" + "DeleteRole\x12\x0e.system.IdsReq\x1a\x12.system.CommonResp\x128\n" + - "\vGetRoleList\x12\x13.system.RoleListReq\x1a\x14.system.RoleListResp\x12M\n" + + "\vGetRoleList\x12\x13.system.RoleListReq\x1a\x14.system.RoleListResp\x12A\n" + + "\rGetRoleDetail\x12\x18.system.GetRoleDetailReq\x1a\x16.system.RoleDetailResp\x12A\n" + + "\x0fAssignRoleMenus\x12\x1a.system.AssignRoleMenusReq\x1a\x12.system.CommonResp\x12A\n" + + "\x0fAssignUserRoles\x12\x1a.system.AssignUserRolesReq\x1a\x12.system.CommonResp\x12M\n" + "\x10GetMenusByRoleId\x12\x1b.system.GetMenusByRoleIdReq\x1a\x1c.system.GetMenusByRoleIdResp\x121\n" + "\n" + "CreateMenu\x12\x0f.system.MenuReq\x1a\x12.system.CommonResp\x127\n" + @@ -3531,7 +3920,7 @@ func file_pb_system_proto_rawDescGZIP() []byte { return file_pb_system_proto_rawDescData } -var file_pb_system_proto_msgTypes = make([]protoimpl.MessageInfo, 46) +var file_pb_system_proto_msgTypes = make([]protoimpl.MessageInfo, 52) var file_pb_system_proto_goTypes = []any{ (*CommonResp)(nil), // 0: system.CommonResp (*IdReq)(nil), // 1: system.IdReq @@ -3539,127 +3928,142 @@ var file_pb_system_proto_goTypes = []any{ (*RoleInfo)(nil), // 3: system.RoleInfo (*RoleReq)(nil), // 4: system.RoleReq (*RoleUpdateReq)(nil), // 5: system.RoleUpdateReq - (*RoleListReq)(nil), // 6: system.RoleListReq - (*RoleListResp)(nil), // 7: system.RoleListResp - (*MenuInfo)(nil), // 8: system.MenuInfo - (*MenuReq)(nil), // 9: system.MenuReq - (*MenuUpdateReq)(nil), // 10: system.MenuUpdateReq - (*MenuListResp)(nil), // 11: system.MenuListResp - (*ClientInfo)(nil), // 12: system.ClientInfo - (*ClientReq)(nil), // 13: system.ClientReq - (*ClientUpdateReq)(nil), // 14: system.ClientUpdateReq - (*ClientListReq)(nil), // 15: system.ClientListReq - (*ClientListResp)(nil), // 16: system.ClientListResp - (*DictInfo)(nil), // 17: system.DictInfo - (*DictReq)(nil), // 18: system.DictReq - (*DictUpdateReq)(nil), // 19: system.DictUpdateReq - (*DictListReq)(nil), // 20: system.DictListReq - (*DictListResp)(nil), // 21: system.DictListResp - (*OperationRecordInfo)(nil), // 22: system.OperationRecordInfo - (*CreateOperationRecordReq)(nil), // 23: system.CreateOperationRecordReq - (*OperationRecordListReq)(nil), // 24: system.OperationRecordListReq - (*OperationRecordListResp)(nil), // 25: system.OperationRecordListResp - (*UserInfo)(nil), // 26: system.UserInfo - (*GetUserByIdReq)(nil), // 27: system.GetUserByIdReq - (*GetUserByIdResp)(nil), // 28: system.GetUserByIdResp - (*GetUserByOpenIdReq)(nil), // 29: system.GetUserByOpenIdReq - (*GetUserByOpenIdResp)(nil), // 30: system.GetUserByOpenIdResp - (*CreateUserReq)(nil), // 31: system.CreateUserReq - (*CreateUserResp)(nil), // 32: system.CreateUserResp - (*UpdateUserReq)(nil), // 33: system.UpdateUserReq - (*LoginByAccountReq)(nil), // 34: system.LoginByAccountReq - (*LoginByAccountResp)(nil), // 35: system.LoginByAccountResp - (*GetUserListReq)(nil), // 36: system.GetUserListReq - (*GetUserListResp)(nil), // 37: system.GetUserListResp - (*DeleteUserReq)(nil), // 38: system.DeleteUserReq - (*ResetPasswordReq)(nil), // 39: system.ResetPasswordReq - (*GetRolesByUserIdReq)(nil), // 40: system.GetRolesByUserIdReq - (*GetRolesByUserIdResp)(nil), // 41: system.GetRolesByUserIdResp - (*GetMenusByRoleIdReq)(nil), // 42: system.GetMenusByRoleIdReq - (*GetMenusByRoleIdResp)(nil), // 43: system.GetMenusByRoleIdResp - (*GetClientByIdReq)(nil), // 44: system.GetClientByIdReq - (*GetClientByIdResp)(nil), // 45: system.GetClientByIdResp + (*AssignRoleMenusReq)(nil), // 6: system.AssignRoleMenusReq + (*AssignUserRolesReq)(nil), // 7: system.AssignUserRolesReq + (*RoleListReq)(nil), // 8: system.RoleListReq + (*RoleListResp)(nil), // 9: system.RoleListResp + (*GetRoleDetailReq)(nil), // 10: system.GetRoleDetailReq + (*RoleDetailResp)(nil), // 11: system.RoleDetailResp + (*MenuInfo)(nil), // 12: system.MenuInfo + (*MenuReq)(nil), // 13: system.MenuReq + (*MenuUpdateReq)(nil), // 14: system.MenuUpdateReq + (*MenuListResp)(nil), // 15: system.MenuListResp + (*ClientInfo)(nil), // 16: system.ClientInfo + (*ClientReq)(nil), // 17: system.ClientReq + (*ClientUpdateReq)(nil), // 18: system.ClientUpdateReq + (*ClientListReq)(nil), // 19: system.ClientListReq + (*ClientListResp)(nil), // 20: system.ClientListResp + (*DictInfo)(nil), // 21: system.DictInfo + (*DictReq)(nil), // 22: system.DictReq + (*DictUpdateReq)(nil), // 23: system.DictUpdateReq + (*DictListReq)(nil), // 24: system.DictListReq + (*DictListResp)(nil), // 25: system.DictListResp + (*OperationRecordInfo)(nil), // 26: system.OperationRecordInfo + (*CreateOperationRecordReq)(nil), // 27: system.CreateOperationRecordReq + (*OperationRecordListReq)(nil), // 28: system.OperationRecordListReq + (*OperationRecordListResp)(nil), // 29: system.OperationRecordListResp + (*UserInfo)(nil), // 30: system.UserInfo + (*GetUserByIdReq)(nil), // 31: system.GetUserByIdReq + (*GetUserByIdResp)(nil), // 32: system.GetUserByIdResp + (*GetUserByOpenIdReq)(nil), // 33: system.GetUserByOpenIdReq + (*GetUserByOpenIdResp)(nil), // 34: system.GetUserByOpenIdResp + (*CreateUserReq)(nil), // 35: system.CreateUserReq + (*CreateUserResp)(nil), // 36: system.CreateUserResp + (*UpdateUserReq)(nil), // 37: system.UpdateUserReq + (*LoginByAccountReq)(nil), // 38: system.LoginByAccountReq + (*LoginByAccountResp)(nil), // 39: system.LoginByAccountResp + (*GetUserListReq)(nil), // 40: system.GetUserListReq + (*GetUserListResp)(nil), // 41: system.GetUserListResp + (*GetUserDetailReq)(nil), // 42: system.GetUserDetailReq + (*UserDetailResp)(nil), // 43: system.UserDetailResp + (*DeleteUserReq)(nil), // 44: system.DeleteUserReq + (*ResetPasswordReq)(nil), // 45: system.ResetPasswordReq + (*GetRolesByUserIdReq)(nil), // 46: system.GetRolesByUserIdReq + (*GetRolesByUserIdResp)(nil), // 47: system.GetRolesByUserIdResp + (*GetMenusByRoleIdReq)(nil), // 48: system.GetMenusByRoleIdReq + (*GetMenusByRoleIdResp)(nil), // 49: system.GetMenusByRoleIdResp + (*GetClientByIdReq)(nil), // 50: system.GetClientByIdReq + (*GetClientByIdResp)(nil), // 51: system.GetClientByIdResp } var file_pb_system_proto_depIdxs = []int32{ 3, // 0: system.RoleListResp.list:type_name -> system.RoleInfo - 8, // 1: system.MenuInfo.children:type_name -> system.MenuInfo - 8, // 2: system.MenuListResp.menus:type_name -> system.MenuInfo - 12, // 3: system.ClientListResp.list:type_name -> system.ClientInfo - 17, // 4: system.DictListResp.list:type_name -> system.DictInfo - 22, // 5: system.OperationRecordListResp.list:type_name -> system.OperationRecordInfo - 26, // 6: system.GetUserByIdResp.user:type_name -> system.UserInfo - 26, // 7: system.GetUserByOpenIdResp.user:type_name -> system.UserInfo - 26, // 8: system.CreateUserResp.user:type_name -> system.UserInfo - 26, // 9: system.LoginByAccountResp.user:type_name -> system.UserInfo - 26, // 10: system.GetUserListResp.list:type_name -> system.UserInfo - 3, // 11: system.GetRolesByUserIdResp.roles:type_name -> system.RoleInfo - 8, // 12: system.GetMenusByRoleIdResp.menus:type_name -> system.MenuInfo - 12, // 13: system.GetClientByIdResp.client:type_name -> system.ClientInfo - 27, // 14: system.SystemService.GetUserById:input_type -> system.GetUserByIdReq - 29, // 15: system.SystemService.GetUserByOpenId:input_type -> system.GetUserByOpenIdReq - 34, // 16: system.SystemService.LoginByAccount:input_type -> system.LoginByAccountReq - 31, // 17: system.SystemService.CreateUser:input_type -> system.CreateUserReq - 33, // 18: system.SystemService.UpdateUser:input_type -> system.UpdateUserReq - 36, // 19: system.SystemService.GetUserList:input_type -> system.GetUserListReq - 38, // 20: system.SystemService.DeleteUser:input_type -> system.DeleteUserReq - 39, // 21: system.SystemService.ResetPassword:input_type -> system.ResetPasswordReq - 40, // 22: system.SystemService.GetRolesByUserId:input_type -> system.GetRolesByUserIdReq - 4, // 23: system.SystemService.CreateRole:input_type -> system.RoleReq - 5, // 24: system.SystemService.UpdateRole:input_type -> system.RoleUpdateReq - 2, // 25: system.SystemService.DeleteRole:input_type -> system.IdsReq - 6, // 26: system.SystemService.GetRoleList:input_type -> system.RoleListReq - 42, // 27: system.SystemService.GetMenusByRoleId:input_type -> system.GetMenusByRoleIdReq - 9, // 28: system.SystemService.CreateMenu:input_type -> system.MenuReq - 10, // 29: system.SystemService.UpdateMenu:input_type -> system.MenuUpdateReq - 2, // 30: system.SystemService.DeleteMenu:input_type -> system.IdsReq - 1, // 31: system.SystemService.GetMenuList:input_type -> system.IdReq - 44, // 32: system.SystemService.GetClientById:input_type -> system.GetClientByIdReq - 13, // 33: system.SystemService.CreateClient:input_type -> system.ClientReq - 14, // 34: system.SystemService.UpdateClient:input_type -> system.ClientUpdateReq - 2, // 35: system.SystemService.DeleteClient:input_type -> system.IdsReq - 15, // 36: system.SystemService.GetClientList:input_type -> system.ClientListReq - 18, // 37: system.SystemService.CreateDict:input_type -> system.DictReq - 19, // 38: system.SystemService.UpdateDict:input_type -> system.DictUpdateReq - 2, // 39: system.SystemService.DeleteDict:input_type -> system.IdsReq - 20, // 40: system.SystemService.GetDictList:input_type -> system.DictListReq - 23, // 41: system.SystemService.CreateOperationRecord:input_type -> system.CreateOperationRecordReq - 2, // 42: system.SystemService.DeleteOperationRecord:input_type -> system.IdsReq - 24, // 43: system.SystemService.GetOperationRecordList:input_type -> system.OperationRecordListReq - 28, // 44: system.SystemService.GetUserById:output_type -> system.GetUserByIdResp - 30, // 45: system.SystemService.GetUserByOpenId:output_type -> system.GetUserByOpenIdResp - 35, // 46: system.SystemService.LoginByAccount:output_type -> system.LoginByAccountResp - 32, // 47: system.SystemService.CreateUser:output_type -> system.CreateUserResp - 0, // 48: system.SystemService.UpdateUser:output_type -> system.CommonResp - 37, // 49: system.SystemService.GetUserList:output_type -> system.GetUserListResp - 0, // 50: system.SystemService.DeleteUser:output_type -> system.CommonResp - 0, // 51: system.SystemService.ResetPassword:output_type -> system.CommonResp - 41, // 52: system.SystemService.GetRolesByUserId:output_type -> system.GetRolesByUserIdResp - 0, // 53: system.SystemService.CreateRole:output_type -> system.CommonResp - 0, // 54: system.SystemService.UpdateRole:output_type -> system.CommonResp - 0, // 55: system.SystemService.DeleteRole:output_type -> system.CommonResp - 7, // 56: system.SystemService.GetRoleList:output_type -> system.RoleListResp - 43, // 57: system.SystemService.GetMenusByRoleId:output_type -> system.GetMenusByRoleIdResp - 0, // 58: system.SystemService.CreateMenu:output_type -> system.CommonResp - 0, // 59: system.SystemService.UpdateMenu:output_type -> system.CommonResp - 0, // 60: system.SystemService.DeleteMenu:output_type -> system.CommonResp - 11, // 61: system.SystemService.GetMenuList:output_type -> system.MenuListResp - 45, // 62: system.SystemService.GetClientById:output_type -> system.GetClientByIdResp - 0, // 63: system.SystemService.CreateClient:output_type -> system.CommonResp - 0, // 64: system.SystemService.UpdateClient:output_type -> system.CommonResp - 0, // 65: system.SystemService.DeleteClient:output_type -> system.CommonResp - 16, // 66: system.SystemService.GetClientList:output_type -> system.ClientListResp - 0, // 67: system.SystemService.CreateDict:output_type -> system.CommonResp - 0, // 68: system.SystemService.UpdateDict:output_type -> system.CommonResp - 0, // 69: system.SystemService.DeleteDict:output_type -> system.CommonResp - 21, // 70: system.SystemService.GetDictList:output_type -> system.DictListResp - 0, // 71: system.SystemService.CreateOperationRecord:output_type -> system.CommonResp - 0, // 72: system.SystemService.DeleteOperationRecord:output_type -> system.CommonResp - 25, // 73: system.SystemService.GetOperationRecordList:output_type -> system.OperationRecordListResp - 44, // [44:74] is the sub-list for method output_type - 14, // [14:44] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 12, // 1: system.MenuInfo.children:type_name -> system.MenuInfo + 12, // 2: system.MenuListResp.menus:type_name -> system.MenuInfo + 16, // 3: system.ClientListResp.list:type_name -> system.ClientInfo + 21, // 4: system.DictListResp.list:type_name -> system.DictInfo + 26, // 5: system.OperationRecordListResp.list:type_name -> system.OperationRecordInfo + 3, // 6: system.UserInfo.roles:type_name -> system.RoleInfo + 30, // 7: system.GetUserByIdResp.user:type_name -> system.UserInfo + 30, // 8: system.GetUserByOpenIdResp.user:type_name -> system.UserInfo + 30, // 9: system.CreateUserResp.user:type_name -> system.UserInfo + 30, // 10: system.LoginByAccountResp.user:type_name -> system.UserInfo + 30, // 11: system.GetUserListResp.list:type_name -> system.UserInfo + 3, // 12: system.GetRolesByUserIdResp.roles:type_name -> system.RoleInfo + 12, // 13: system.GetMenusByRoleIdResp.menus:type_name -> system.MenuInfo + 16, // 14: system.GetClientByIdResp.client:type_name -> system.ClientInfo + 31, // 15: system.SystemService.GetUserById:input_type -> system.GetUserByIdReq + 33, // 16: system.SystemService.GetUserByOpenId:input_type -> system.GetUserByOpenIdReq + 38, // 17: system.SystemService.LoginByAccount:input_type -> system.LoginByAccountReq + 35, // 18: system.SystemService.CreateUser:input_type -> system.CreateUserReq + 37, // 19: system.SystemService.UpdateUser:input_type -> system.UpdateUserReq + 40, // 20: system.SystemService.GetUserList:input_type -> system.GetUserListReq + 42, // 21: system.SystemService.GetUserDetail:input_type -> system.GetUserDetailReq + 44, // 22: system.SystemService.DeleteUser:input_type -> system.DeleteUserReq + 45, // 23: system.SystemService.ResetPassword:input_type -> system.ResetPasswordReq + 46, // 24: system.SystemService.GetRolesByUserId:input_type -> system.GetRolesByUserIdReq + 4, // 25: system.SystemService.CreateRole:input_type -> system.RoleReq + 5, // 26: system.SystemService.UpdateRole:input_type -> system.RoleUpdateReq + 2, // 27: system.SystemService.DeleteRole:input_type -> system.IdsReq + 8, // 28: system.SystemService.GetRoleList:input_type -> system.RoleListReq + 10, // 29: system.SystemService.GetRoleDetail:input_type -> system.GetRoleDetailReq + 6, // 30: system.SystemService.AssignRoleMenus:input_type -> system.AssignRoleMenusReq + 7, // 31: system.SystemService.AssignUserRoles:input_type -> system.AssignUserRolesReq + 48, // 32: system.SystemService.GetMenusByRoleId:input_type -> system.GetMenusByRoleIdReq + 13, // 33: system.SystemService.CreateMenu:input_type -> system.MenuReq + 14, // 34: system.SystemService.UpdateMenu:input_type -> system.MenuUpdateReq + 2, // 35: system.SystemService.DeleteMenu:input_type -> system.IdsReq + 1, // 36: system.SystemService.GetMenuList:input_type -> system.IdReq + 50, // 37: system.SystemService.GetClientById:input_type -> system.GetClientByIdReq + 17, // 38: system.SystemService.CreateClient:input_type -> system.ClientReq + 18, // 39: system.SystemService.UpdateClient:input_type -> system.ClientUpdateReq + 2, // 40: system.SystemService.DeleteClient:input_type -> system.IdsReq + 19, // 41: system.SystemService.GetClientList:input_type -> system.ClientListReq + 22, // 42: system.SystemService.CreateDict:input_type -> system.DictReq + 23, // 43: system.SystemService.UpdateDict:input_type -> system.DictUpdateReq + 2, // 44: system.SystemService.DeleteDict:input_type -> system.IdsReq + 24, // 45: system.SystemService.GetDictList:input_type -> system.DictListReq + 27, // 46: system.SystemService.CreateOperationRecord:input_type -> system.CreateOperationRecordReq + 2, // 47: system.SystemService.DeleteOperationRecord:input_type -> system.IdsReq + 28, // 48: system.SystemService.GetOperationRecordList:input_type -> system.OperationRecordListReq + 32, // 49: system.SystemService.GetUserById:output_type -> system.GetUserByIdResp + 34, // 50: system.SystemService.GetUserByOpenId:output_type -> system.GetUserByOpenIdResp + 39, // 51: system.SystemService.LoginByAccount:output_type -> system.LoginByAccountResp + 36, // 52: system.SystemService.CreateUser:output_type -> system.CreateUserResp + 0, // 53: system.SystemService.UpdateUser:output_type -> system.CommonResp + 41, // 54: system.SystemService.GetUserList:output_type -> system.GetUserListResp + 43, // 55: system.SystemService.GetUserDetail:output_type -> system.UserDetailResp + 0, // 56: system.SystemService.DeleteUser:output_type -> system.CommonResp + 0, // 57: system.SystemService.ResetPassword:output_type -> system.CommonResp + 47, // 58: system.SystemService.GetRolesByUserId:output_type -> system.GetRolesByUserIdResp + 0, // 59: system.SystemService.CreateRole:output_type -> system.CommonResp + 0, // 60: system.SystemService.UpdateRole:output_type -> system.CommonResp + 0, // 61: system.SystemService.DeleteRole:output_type -> system.CommonResp + 9, // 62: system.SystemService.GetRoleList:output_type -> system.RoleListResp + 11, // 63: system.SystemService.GetRoleDetail:output_type -> system.RoleDetailResp + 0, // 64: system.SystemService.AssignRoleMenus:output_type -> system.CommonResp + 0, // 65: system.SystemService.AssignUserRoles:output_type -> system.CommonResp + 49, // 66: system.SystemService.GetMenusByRoleId:output_type -> system.GetMenusByRoleIdResp + 0, // 67: system.SystemService.CreateMenu:output_type -> system.CommonResp + 0, // 68: system.SystemService.UpdateMenu:output_type -> system.CommonResp + 0, // 69: system.SystemService.DeleteMenu:output_type -> system.CommonResp + 15, // 70: system.SystemService.GetMenuList:output_type -> system.MenuListResp + 51, // 71: system.SystemService.GetClientById:output_type -> system.GetClientByIdResp + 0, // 72: system.SystemService.CreateClient:output_type -> system.CommonResp + 0, // 73: system.SystemService.UpdateClient:output_type -> system.CommonResp + 0, // 74: system.SystemService.DeleteClient:output_type -> system.CommonResp + 20, // 75: system.SystemService.GetClientList:output_type -> system.ClientListResp + 0, // 76: system.SystemService.CreateDict:output_type -> system.CommonResp + 0, // 77: system.SystemService.UpdateDict:output_type -> system.CommonResp + 0, // 78: system.SystemService.DeleteDict:output_type -> system.CommonResp + 25, // 79: system.SystemService.GetDictList:output_type -> system.DictListResp + 0, // 80: system.SystemService.CreateOperationRecord:output_type -> system.CommonResp + 0, // 81: system.SystemService.DeleteOperationRecord:output_type -> system.CommonResp + 29, // 82: system.SystemService.GetOperationRecordList:output_type -> system.OperationRecordListResp + 49, // [49:83] is the sub-list for method output_type + 15, // [15:49] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name } func init() { file_pb_system_proto_init() } @@ -3673,7 +4077,7 @@ func file_pb_system_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_pb_system_proto_rawDesc), len(file_pb_system_proto_rawDesc)), NumEnums: 0, - NumMessages: 46, + NumMessages: 52, NumExtensions: 0, NumServices: 1, }, diff --git a/app/system/rpc/system/system_grpc.pb.go b/app/system/rpc/system/system_grpc.pb.go index 3c431e2..7c2e165 100644 --- a/app/system/rpc/system/system_grpc.pb.go +++ b/app/system/rpc/system/system_grpc.pb.go @@ -25,6 +25,7 @@ const ( SystemService_CreateUser_FullMethodName = "/system.SystemService/CreateUser" SystemService_UpdateUser_FullMethodName = "/system.SystemService/UpdateUser" SystemService_GetUserList_FullMethodName = "/system.SystemService/GetUserList" + SystemService_GetUserDetail_FullMethodName = "/system.SystemService/GetUserDetail" SystemService_DeleteUser_FullMethodName = "/system.SystemService/DeleteUser" SystemService_ResetPassword_FullMethodName = "/system.SystemService/ResetPassword" SystemService_GetRolesByUserId_FullMethodName = "/system.SystemService/GetRolesByUserId" @@ -32,6 +33,9 @@ const ( SystemService_UpdateRole_FullMethodName = "/system.SystemService/UpdateRole" SystemService_DeleteRole_FullMethodName = "/system.SystemService/DeleteRole" SystemService_GetRoleList_FullMethodName = "/system.SystemService/GetRoleList" + SystemService_GetRoleDetail_FullMethodName = "/system.SystemService/GetRoleDetail" + SystemService_AssignRoleMenus_FullMethodName = "/system.SystemService/AssignRoleMenus" + SystemService_AssignUserRoles_FullMethodName = "/system.SystemService/AssignUserRoles" SystemService_GetMenusByRoleId_FullMethodName = "/system.SystemService/GetMenusByRoleId" SystemService_CreateMenu_FullMethodName = "/system.SystemService/CreateMenu" SystemService_UpdateMenu_FullMethodName = "/system.SystemService/UpdateMenu" @@ -62,6 +66,7 @@ type SystemServiceClient interface { CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error) UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error) GetUserList(ctx context.Context, in *GetUserListReq, opts ...grpc.CallOption) (*GetUserListResp, error) + GetUserDetail(ctx context.Context, in *GetUserDetailReq, opts ...grpc.CallOption) (*UserDetailResp, error) DeleteUser(ctx context.Context, in *DeleteUserReq, opts ...grpc.CallOption) (*CommonResp, error) ResetPassword(ctx context.Context, in *ResetPasswordReq, opts ...grpc.CallOption) (*CommonResp, error) // --- 角色 --- @@ -70,6 +75,10 @@ type SystemServiceClient interface { UpdateRole(ctx context.Context, in *RoleUpdateReq, opts ...grpc.CallOption) (*CommonResp, error) DeleteRole(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) GetRoleList(ctx context.Context, in *RoleListReq, opts ...grpc.CallOption) (*RoleListResp, error) + GetRoleDetail(ctx context.Context, in *GetRoleDetailReq, opts ...grpc.CallOption) (*RoleDetailResp, error) + AssignRoleMenus(ctx context.Context, in *AssignRoleMenusReq, opts ...grpc.CallOption) (*CommonResp, error) + // --- RBAC 用户授权 --- + AssignUserRoles(ctx context.Context, in *AssignUserRolesReq, opts ...grpc.CallOption) (*CommonResp, error) // --- 菜单 --- GetMenusByRoleId(ctx context.Context, in *GetMenusByRoleIdReq, opts ...grpc.CallOption) (*GetMenusByRoleIdResp, error) CreateMenu(ctx context.Context, in *MenuReq, opts ...grpc.CallOption) (*CommonResp, error) @@ -161,6 +170,16 @@ func (c *systemServiceClient) GetUserList(ctx context.Context, in *GetUserListRe return out, nil } +func (c *systemServiceClient) GetUserDetail(ctx context.Context, in *GetUserDetailReq, opts ...grpc.CallOption) (*UserDetailResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UserDetailResp) + err := c.cc.Invoke(ctx, SystemService_GetUserDetail_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *systemServiceClient) DeleteUser(ctx context.Context, in *DeleteUserReq, opts ...grpc.CallOption) (*CommonResp, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(CommonResp) @@ -231,6 +250,36 @@ func (c *systemServiceClient) GetRoleList(ctx context.Context, in *RoleListReq, return out, nil } +func (c *systemServiceClient) GetRoleDetail(ctx context.Context, in *GetRoleDetailReq, opts ...grpc.CallOption) (*RoleDetailResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RoleDetailResp) + err := c.cc.Invoke(ctx, SystemService_GetRoleDetail_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *systemServiceClient) AssignRoleMenus(ctx context.Context, in *AssignRoleMenusReq, opts ...grpc.CallOption) (*CommonResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CommonResp) + err := c.cc.Invoke(ctx, SystemService_AssignRoleMenus_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *systemServiceClient) AssignUserRoles(ctx context.Context, in *AssignUserRolesReq, opts ...grpc.CallOption) (*CommonResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CommonResp) + err := c.cc.Invoke(ctx, SystemService_AssignUserRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *systemServiceClient) GetMenusByRoleId(ctx context.Context, in *GetMenusByRoleIdReq, opts ...grpc.CallOption) (*GetMenusByRoleIdResp, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetMenusByRoleIdResp) @@ -412,6 +461,7 @@ type SystemServiceServer interface { CreateUser(context.Context, *CreateUserReq) (*CreateUserResp, error) UpdateUser(context.Context, *UpdateUserReq) (*CommonResp, error) GetUserList(context.Context, *GetUserListReq) (*GetUserListResp, error) + GetUserDetail(context.Context, *GetUserDetailReq) (*UserDetailResp, error) DeleteUser(context.Context, *DeleteUserReq) (*CommonResp, error) ResetPassword(context.Context, *ResetPasswordReq) (*CommonResp, error) // --- 角色 --- @@ -420,6 +470,10 @@ type SystemServiceServer interface { UpdateRole(context.Context, *RoleUpdateReq) (*CommonResp, error) DeleteRole(context.Context, *IdsReq) (*CommonResp, error) GetRoleList(context.Context, *RoleListReq) (*RoleListResp, error) + GetRoleDetail(context.Context, *GetRoleDetailReq) (*RoleDetailResp, error) + AssignRoleMenus(context.Context, *AssignRoleMenusReq) (*CommonResp, error) + // --- RBAC 用户授权 --- + AssignUserRoles(context.Context, *AssignUserRolesReq) (*CommonResp, error) // --- 菜单 --- GetMenusByRoleId(context.Context, *GetMenusByRoleIdReq) (*GetMenusByRoleIdResp, error) CreateMenu(context.Context, *MenuReq) (*CommonResp, error) @@ -469,6 +523,9 @@ func (UnimplementedSystemServiceServer) UpdateUser(context.Context, *UpdateUserR func (UnimplementedSystemServiceServer) GetUserList(context.Context, *GetUserListReq) (*GetUserListResp, error) { return nil, status.Error(codes.Unimplemented, "method GetUserList not implemented") } +func (UnimplementedSystemServiceServer) GetUserDetail(context.Context, *GetUserDetailReq) (*UserDetailResp, error) { + return nil, status.Error(codes.Unimplemented, "method GetUserDetail not implemented") +} func (UnimplementedSystemServiceServer) DeleteUser(context.Context, *DeleteUserReq) (*CommonResp, error) { return nil, status.Error(codes.Unimplemented, "method DeleteUser not implemented") } @@ -490,6 +547,15 @@ func (UnimplementedSystemServiceServer) DeleteRole(context.Context, *IdsReq) (*C func (UnimplementedSystemServiceServer) GetRoleList(context.Context, *RoleListReq) (*RoleListResp, error) { return nil, status.Error(codes.Unimplemented, "method GetRoleList not implemented") } +func (UnimplementedSystemServiceServer) GetRoleDetail(context.Context, *GetRoleDetailReq) (*RoleDetailResp, error) { + return nil, status.Error(codes.Unimplemented, "method GetRoleDetail not implemented") +} +func (UnimplementedSystemServiceServer) AssignRoleMenus(context.Context, *AssignRoleMenusReq) (*CommonResp, error) { + return nil, status.Error(codes.Unimplemented, "method AssignRoleMenus not implemented") +} +func (UnimplementedSystemServiceServer) AssignUserRoles(context.Context, *AssignUserRolesReq) (*CommonResp, error) { + return nil, status.Error(codes.Unimplemented, "method AssignUserRoles not implemented") +} func (UnimplementedSystemServiceServer) GetMenusByRoleId(context.Context, *GetMenusByRoleIdReq) (*GetMenusByRoleIdResp, error) { return nil, status.Error(codes.Unimplemented, "method GetMenusByRoleId not implemented") } @@ -670,6 +736,24 @@ func _SystemService_GetUserList_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _SystemService_GetUserDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserDetailReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServiceServer).GetUserDetail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SystemService_GetUserDetail_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServiceServer).GetUserDetail(ctx, req.(*GetUserDetailReq)) + } + return interceptor(ctx, in, info, handler) +} + func _SystemService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(DeleteUserReq) if err := dec(in); err != nil { @@ -796,6 +880,60 @@ func _SystemService_GetRoleList_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _SystemService_GetRoleDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRoleDetailReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServiceServer).GetRoleDetail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SystemService_GetRoleDetail_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServiceServer).GetRoleDetail(ctx, req.(*GetRoleDetailReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _SystemService_AssignRoleMenus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AssignRoleMenusReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServiceServer).AssignRoleMenus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SystemService_AssignRoleMenus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServiceServer).AssignRoleMenus(ctx, req.(*AssignRoleMenusReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _SystemService_AssignUserRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AssignUserRolesReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SystemServiceServer).AssignUserRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SystemService_AssignUserRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SystemServiceServer).AssignUserRoles(ctx, req.(*AssignUserRolesReq)) + } + return interceptor(ctx, in, info, handler) +} + func _SystemService_GetMenusByRoleId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetMenusByRoleIdReq) if err := dec(in); err != nil { @@ -1133,6 +1271,10 @@ var SystemService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetUserList", Handler: _SystemService_GetUserList_Handler, }, + { + MethodName: "GetUserDetail", + Handler: _SystemService_GetUserDetail_Handler, + }, { MethodName: "DeleteUser", Handler: _SystemService_DeleteUser_Handler, @@ -1161,6 +1303,18 @@ var SystemService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetRoleList", Handler: _SystemService_GetRoleList_Handler, }, + { + MethodName: "GetRoleDetail", + Handler: _SystemService_GetRoleDetail_Handler, + }, + { + MethodName: "AssignRoleMenus", + Handler: _SystemService_AssignRoleMenus_Handler, + }, + { + MethodName: "AssignUserRoles", + Handler: _SystemService_AssignUserRoles_Handler, + }, { MethodName: "GetMenusByRoleId", Handler: _SystemService_GetMenusByRoleId_Handler, diff --git a/app/system/rpc/systemservice/systemService.go b/app/system/rpc/systemservice/systemService.go index 804edbe..bd2224a 100644 --- a/app/system/rpc/systemservice/systemService.go +++ b/app/system/rpc/systemservice/systemService.go @@ -14,6 +14,8 @@ import ( ) type ( + AssignRoleMenusReq = system.AssignRoleMenusReq + AssignUserRolesReq = system.AssignUserRolesReq ClientInfo = system.ClientInfo ClientListReq = system.ClientListReq ClientListResp = system.ClientListResp @@ -33,12 +35,16 @@ type ( GetClientByIdResp = system.GetClientByIdResp GetMenusByRoleIdReq = system.GetMenusByRoleIdReq GetMenusByRoleIdResp = system.GetMenusByRoleIdResp + GetRoleDetailReq = system.GetRoleDetailReq + GetRoleListReq = system.RoleListReq + GetRoleListResp = system.RoleListResp GetRolesByUserIdReq = system.GetRolesByUserIdReq GetRolesByUserIdResp = system.GetRolesByUserIdResp GetUserByIdReq = system.GetUserByIdReq GetUserByIdResp = system.GetUserByIdResp GetUserByOpenIdReq = system.GetUserByOpenIdReq GetUserByOpenIdResp = system.GetUserByOpenIdResp + GetUserDetailReq = system.GetUserDetailReq GetUserListReq = system.GetUserListReq GetUserListResp = system.GetUserListResp IdReq = system.IdReq @@ -53,12 +59,14 @@ type ( OperationRecordListReq = system.OperationRecordListReq OperationRecordListResp = system.OperationRecordListResp ResetPasswordReq = system.ResetPasswordReq + RoleDetailResp = system.RoleDetailResp RoleInfo = system.RoleInfo RoleListReq = system.RoleListReq RoleListResp = system.RoleListResp RoleReq = system.RoleReq RoleUpdateReq = system.RoleUpdateReq UpdateUserReq = system.UpdateUserReq + UserDetailResp = system.UserDetailResp UserInfo = system.UserInfo SystemService interface { @@ -69,6 +77,7 @@ type ( CreateUser(ctx context.Context, in *CreateUserReq, opts ...grpc.CallOption) (*CreateUserResp, error) UpdateUser(ctx context.Context, in *UpdateUserReq, opts ...grpc.CallOption) (*CommonResp, error) GetUserList(ctx context.Context, in *GetUserListReq, opts ...grpc.CallOption) (*GetUserListResp, error) + GetUserDetail(ctx context.Context, in *GetUserDetailReq, opts ...grpc.CallOption) (*UserDetailResp, error) DeleteUser(ctx context.Context, in *DeleteUserReq, opts ...grpc.CallOption) (*CommonResp, error) ResetPassword(ctx context.Context, in *ResetPasswordReq, opts ...grpc.CallOption) (*CommonResp, error) // --- 角色 --- @@ -77,6 +86,10 @@ type ( UpdateRole(ctx context.Context, in *RoleUpdateReq, opts ...grpc.CallOption) (*CommonResp, error) DeleteRole(ctx context.Context, in *IdsReq, opts ...grpc.CallOption) (*CommonResp, error) GetRoleList(ctx context.Context, in *RoleListReq, opts ...grpc.CallOption) (*RoleListResp, error) + GetRoleDetail(ctx context.Context, in *GetRoleDetailReq, opts ...grpc.CallOption) (*RoleDetailResp, error) + AssignRoleMenus(ctx context.Context, in *AssignRoleMenusReq, opts ...grpc.CallOption) (*CommonResp, error) + // --- RBAC 用户授权 --- + AssignUserRoles(ctx context.Context, in *AssignUserRolesReq, opts ...grpc.CallOption) (*CommonResp, error) // --- 菜单 --- GetMenusByRoleId(ctx context.Context, in *GetMenusByRoleIdReq, opts ...grpc.CallOption) (*GetMenusByRoleIdResp, error) CreateMenu(ctx context.Context, in *MenuReq, opts ...grpc.CallOption) (*CommonResp, error) @@ -142,6 +155,11 @@ func (m *defaultSystemService) GetUserList(ctx context.Context, in *GetUserListR return client.GetUserList(ctx, in, opts...) } +func (m *defaultSystemService) GetUserDetail(ctx context.Context, in *GetUserDetailReq, opts ...grpc.CallOption) (*UserDetailResp, error) { + client := system.NewSystemServiceClient(m.cli.Conn()) + return client.GetUserDetail(ctx, in, opts...) +} + func (m *defaultSystemService) DeleteUser(ctx context.Context, in *DeleteUserReq, opts ...grpc.CallOption) (*CommonResp, error) { client := system.NewSystemServiceClient(m.cli.Conn()) return client.DeleteUser(ctx, in, opts...) @@ -178,6 +196,22 @@ func (m *defaultSystemService) GetRoleList(ctx context.Context, in *RoleListReq, return client.GetRoleList(ctx, in, opts...) } +func (m *defaultSystemService) GetRoleDetail(ctx context.Context, in *GetRoleDetailReq, opts ...grpc.CallOption) (*RoleDetailResp, error) { + client := system.NewSystemServiceClient(m.cli.Conn()) + return client.GetRoleDetail(ctx, in, opts...) +} + +func (m *defaultSystemService) AssignRoleMenus(ctx context.Context, in *AssignRoleMenusReq, opts ...grpc.CallOption) (*CommonResp, error) { + client := system.NewSystemServiceClient(m.cli.Conn()) + return client.AssignRoleMenus(ctx, in, opts...) +} + +// --- RBAC 用户授权 --- +func (m *defaultSystemService) AssignUserRoles(ctx context.Context, in *AssignUserRolesReq, opts ...grpc.CallOption) (*CommonResp, error) { + client := system.NewSystemServiceClient(m.cli.Conn()) + return client.AssignUserRoles(ctx, in, opts...) +} + // --- 菜单 --- func (m *defaultSystemService) GetMenusByRoleId(ctx context.Context, in *GetMenusByRoleIdReq, opts ...grpc.CallOption) (*GetMenusByRoleIdResp, error) { client := system.NewSystemServiceClient(m.cli.Conn()) diff --git a/common/utils/timer/timed_task.go b/common/utils/timer/timed_task.go new file mode 100644 index 0000000..0a93dd2 --- /dev/null +++ b/common/utils/timer/timed_task.go @@ -0,0 +1,219 @@ +package timer + +import ( + "sync" + + "github.com/robfig/cron/v3" +) + +type Timer interface { + FindCronList() map[string]*taskManager + AddTaskByFuncWithSecond(cronName string, spec string, fun func(), taskName string, options ...cron.Option) (cron.EntryID, error) // 添加Task Func以秒的形式加入 + AddTaskByJobWithSecond(cronName string, spec string, job interface{ Run() }, taskName string, options ...cron.Option) (cron.EntryID, error) // 添加Task Job以秒的形式加入 + AddTaskByFunc(cronName string, spec string, task func(), taskName string, options ...cron.Option) (cron.EntryID, error) // 添加Task Func加入 + AddTaskByJob(cronName string, spec string, job interface{ Run() }, taskName string, options ...cron.Option) (cron.EntryID, error) // 添加Task Job加入 + FindCron(cronName string) (*taskManager, bool) //获取对应taskName的cron 可能会为空 + StartCron(cronName string) // 启动对应cron + StopCron(cronName string) // 停止对应cron + FindTask(cronName string, taskName string) (*task, bool) //获取对应taskName的task + RemoveTask(cronName string, id int) //删除对应taskName的task + RemoveTaskByName(cronName string, taskName string) //删除对应taskName的task + Clear(cronName string) //清空对应cronName的task + Close() // 关闭所有定时任务 +} + +type task struct { + EntryId cron.EntryID + Spec string + TaskName string +} +type taskManager struct { + corn *cron.Cron + tasks map[cron.EntryID]*task +} + +// timer 定时任务管理 +type timer struct { + cronList map[string]*taskManager + sync.Mutex +} + +// AddTaskByFuncWithSecond 通过函数的方法使用WithSeconds添加任务 +func (t *timer) AddTaskByFuncWithSecond(cronName string, spec string, fun func(), taskName string, option ...cron.Option) (cron.EntryID, error) { + t.Lock() + defer t.Unlock() + option = append(option, cron.WithSeconds()) + if _, ok := t.cronList[cronName]; !ok { + tasks := make(map[cron.EntryID]*task) + t.cronList[cronName] = &taskManager{ + corn: cron.New(option...), + tasks: tasks, + } + } + id, err := t.cronList[cronName].corn.AddFunc(spec, fun) + t.cronList[cronName].corn.Start() + t.cronList[cronName].tasks[id] = &task{ + EntryId: id, + Spec: spec, + TaskName: taskName, + } + return id, err +} + +// AddTaskByFunc 通过函数的方法添加任务 +func (t *timer) AddTaskByFunc(cronName string, spec string, fun func(), taskName string, option ...cron.Option) (cron.EntryID, error) { + t.Lock() + defer t.Unlock() + if _, ok := t.cronList[cronName]; !ok { + tasks := make(map[cron.EntryID]*task) + t.cronList[cronName] = &taskManager{ + corn: cron.New(option...), + tasks: tasks, + } + } + id, err := t.cronList[cronName].corn.AddFunc(spec, fun) + t.cronList[cronName].corn.Start() + t.cronList[cronName].tasks[id] = &task{ + EntryId: id, + Spec: spec, + TaskName: taskName, + } + return id, err +} + +// AddTaskByJobWithSecond 通过Job的方法使用WithSeconds添加任务 +func (t *timer) AddTaskByJobWithSecond(cronName string, spec string, job interface{ Run() }, taskName string, option ...cron.Option) (cron.EntryID, error) { + t.Lock() + defer t.Unlock() + option = append(option, cron.WithSeconds()) + if _, ok := t.cronList[cronName]; !ok { + tasks := make(map[cron.EntryID]*task) + t.cronList[cronName] = &taskManager{ + corn: cron.New(option...), + tasks: tasks, + } + } + id, err := t.cronList[cronName].corn.AddJob(spec, job) + t.cronList[cronName].corn.Start() + t.cronList[cronName].tasks[id] = &task{ + EntryId: id, + Spec: spec, + TaskName: taskName, + } + return id, err +} + +// AddTaskByJob 通过Job的方法添加任务 +func (t *timer) AddTaskByJob(cronName string, spec string, job interface{ Run() }, taskName string, option ...cron.Option) (cron.EntryID, error) { + t.Lock() + defer t.Unlock() + if _, ok := t.cronList[cronName]; !ok { + tasks := make(map[cron.EntryID]*task) + t.cronList[cronName] = &taskManager{ + corn: cron.New(option...), + tasks: tasks, + } + } + id, err := t.cronList[cronName].corn.AddJob(spec, job) + t.cronList[cronName].corn.Start() + t.cronList[cronName].tasks[id] = &task{ + EntryId: id, + Spec: spec, + TaskName: taskName, + } + return id, err +} + +// FindCron 获取对应cronName的cron 可能会为空 +func (t *timer) FindCron(cronName string) (*taskManager, bool) { + t.Lock() + defer t.Unlock() + v, ok := t.cronList[cronName] + return v, ok +} + +// FindTask 获取对应taskName的task +func (t *timer) FindTask(cronName string, taskName string) (*task, bool) { + t.Lock() + defer t.Unlock() + v, ok := t.cronList[cronName] + if !ok { + return nil, false + } + for _, t2 := range v.tasks { + if t2.TaskName == taskName { + return t2, true + } + } + return nil, false +} + +// FindCronList 获取所有cron +func (t *timer) FindCronList() map[string]*taskManager { + t.Lock() + defer t.Unlock() + return t.cronList +} + +// StartCron 启动对应cron +func (t *timer) StartCron(cronName string) { + t.Lock() + defer t.Unlock() + if v, ok := t.cronList[cronName]; ok { + v.corn.Start() + } +} + +// StopCron 停止对应cron +func (t *timer) StopCron(cronName string) { + t.Lock() + defer t.Unlock() + if v, ok := t.cronList[cronName]; ok { + v.corn.Stop() + } +} + +// RemoveTask 从cronName 删除指定任务 +func (t *timer) RemoveTask(cronName string, id int) { + t.Lock() + defer t.Unlock() + if v, ok := t.cronList[cronName]; ok { + v.corn.Remove(cron.EntryID(id)) + delete(v.tasks, cron.EntryID(id)) + } +} + +// RemoveTaskByName 从cronName 删除指定任务 +func (t *timer) RemoveTaskByName(cronName string, taskName string) { + fTask, ok := t.FindTask(cronName, taskName) + if !ok { + return + } + t.RemoveTask(cronName, int(fTask.EntryId)) +} + +// Clear 清空对应cronName的task +func (t *timer) Clear(cronName string) { + t.Lock() + defer t.Unlock() + if v, ok := t.cronList[cronName]; ok { + v.corn.Stop() + delete(t.cronList, cronName) + } +} + +// Close 关闭所有定时任务 释放资源 +func (t *timer) Close() { + t.Lock() + defer t.Unlock() + for _, v := range t.cronList { + v.corn.Stop() + } +} + +// NewTimerTask 创建定时任务 +func NewTimerTask() Timer { + return &timer{ + cronList: make(map[string]*taskManager), + } +} diff --git a/go.mod b/go.mod index 1eeb96b..43ad591 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,14 @@ module sundynix-micro-go go 1.26.2 require ( + github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/golang-jwt/jwt/v5 v5.3.1 github.com/google/uuid v1.6.0 - github.com/minio/minio-go/v7 v7.0.100 + github.com/minio/minio-go/v7 v7.1.0 github.com/mojocn/base64Captcha v1.3.8 + github.com/qiniu/go-sdk/v7 v7.26.10 github.com/redis/go-redis/v9 v9.18.0 + github.com/tencentyun/cos-go-sdk-v5 v0.7.73 github.com/zeromicro/go-zero v1.10.1 golang.org/x/crypto v0.50.0 google.golang.org/grpc v1.80.0 @@ -18,9 +21,12 @@ require ( require ( filippo.io/edwards25519 v1.1.0 // indirect + github.com/BurntSushi/toml v1.3.2 // indirect + github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v5 v5.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/clbanning/mxj v1.8.4 // indirect github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 // indirect github.com/coreos/go-semver v0.3.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect @@ -33,6 +39,7 @@ require ( github.com/fatih/color v1.18.0 // indirect github.com/fullstorydev/grpcurl v1.9.3 // indirect github.com/fxamacker/cbor/v2 v2.9.0 // indirect + github.com/gammazero/toposort v0.1.1 // indirect github.com/go-ini/ini v1.67.0 // indirect github.com/go-jose/go-jose/v4 v4.1.3 // indirect github.com/go-logr/logr v1.4.3 // indirect @@ -41,12 +48,14 @@ require ( github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-sql-driver/mysql v1.9.3 // indirect + github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.2 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.7.0 // indirect github.com/google/go-cmp v0.7.0 // indirect + github.com/google/go-querystring v1.0.0 // indirect github.com/grafana/pyroscope-go v1.2.8 // indirect github.com/grafana/pyroscope-go/godeltaprof v0.1.9 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 // indirect @@ -64,8 +73,10 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/minio/crc64nvme v1.1.1 // indirect github.com/minio/md5-simd v1.1.2 // indirect + github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect + github.com/mozillazg/go-httpheader v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/openzipkin/zipkin-go v0.4.3 // indirect github.com/pelletier/go-toml/v2 v2.3.0 // indirect @@ -78,12 +89,14 @@ require ( github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.66.1 // indirect github.com/prometheus/procfs v0.16.1 // indirect + github.com/robfig/cron/v3 v3.0.1 // indirect github.com/rs/xid v1.6.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spiffe/go-spiffe/v2 v2.6.0 // indirect github.com/tinylib/msgp v1.6.1 // indirect github.com/titanous/json5 v1.0.0 // indirect github.com/x448/float16 v0.8.4 // indirect + github.com/zeebo/xxh3 v1.1.0 // indirect go.etcd.io/etcd/api/v3 v3.5.21 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.21 // indirect go.etcd.io/etcd/client/v3 v3.5.21 // indirect @@ -125,6 +138,7 @@ require ( k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect k8s.io/utils v0.0.0-20260319190234-28399d86e0b5 // indirect + modernc.org/fileutil v1.0.0 // indirect sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect diff --git a/go.sum b/go.sum index 91a94fe..cc4eac6 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,13 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82 h1:7dONQ3WNZ1zy960TmkxJPuwoolZwL7xKtpcM04MBnt4= +github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82/go.mod h1:nLnM0KdK1CmygvjpDUO6m1TjSsiQtL61juhNsvV/JVI= github.com/alicebob/miniredis/v2 v2.37.0 h1:RheObYW32G1aiJIj81XVt78ZHJpHonHLHW7OLIshq68= github.com/alicebob/miniredis/v2 v2.37.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= +github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g= +github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -16,6 +22,8 @@ github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1x github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= +github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w= github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI= github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= @@ -42,6 +50,8 @@ github.com/fullstorydev/grpcurl v1.9.3 h1:PC1Xi3w+JAvEE2Tg2Gf2RfVgPbf9+tbuQr1Zky github.com/fullstorydev/grpcurl v1.9.3/go.mod h1:/b4Wxe8bG6ndAjlfSUjwseQReUDUvBJiFEB7UllOlUE= github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/gammazero/toposort v0.1.1 h1:OivGxsWxF3U3+U80VoLJ+f50HcPU1MIqE1JlKzoJ2Eg= +github.com/gammazero/toposort v0.1.1/go.mod h1:H2cozTnNpMw0hg2VHAYsAxmkHXBYroNangj2NTBQDvw= github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs= @@ -65,10 +75,13 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v5 v5.2.3/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= @@ -80,11 +93,16 @@ github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7O github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/grafana/pyroscope-go v1.2.8 h1:UvCwIhlx9DeV7F6TW/z8q1Mi4PIm3vuUJ2ZlCEvmA4M= github.com/grafana/pyroscope-go v1.2.8/go.mod h1:SSi59eQ1/zmKoY/BKwa5rSFsJaq+242Bcrr4wPix1g8= github.com/grafana/pyroscope-go/godeltaprof v0.1.9 h1:c1Us8i6eSmkW+Ez05d3co8kasnuOY813tbMN8i/a3Og= @@ -136,8 +154,10 @@ github.com/minio/crc64nvme v1.1.1 h1:8dwx/Pz49suywbO+auHCBpCtlW1OfpcLN7wYgVR6wAI github.com/minio/crc64nvme v1.1.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.0.100 h1:ShkWi8Tyj9RtU57OQB2HIXKz4bFgtVib0bbT1sbtLI8= -github.com/minio/minio-go/v7 v7.0.100/go.mod h1:EtGNKtlX20iL2yaYnxEigaIvj0G0GwSDnifnG8ClIdw= +github.com/minio/minio-go/v7 v7.1.0 h1:QEt5IStDpxgGjEdtOgpiZ5QhmSl3ax7qy61vi2SwHO8= +github.com/minio/minio-go/v7 v7.1.0/go.mod h1:Dm7WS1AgLmBa0NcQD6SeJnJf+K/EUW3GR7Ks6olB3OA= +github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= +github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -146,6 +166,8 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFd github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mojocn/base64Captcha v1.3.8 h1:rrN9BhCwXKS8ht1e21kvR3iTaMgf4qPC9sRoV52bqEg= github.com/mojocn/base64Captcha v1.3.8/go.mod h1:QFZy927L8HVP3+VV5z2b1EAEiv1KxVJKZbAucVgLUy4= +github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ= +github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= @@ -176,14 +198,19 @@ github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9Z github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg= github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is= +github.com/qiniu/go-sdk/v7 v7.26.10 h1:1c2c+grH7b8k5inIDKc95CI8+mAzB5YtfQ/dLOB2nNo= +github.com/qiniu/go-sdk/v7 v7.26.10/go.mod h1:ri7fGwbio0pRDFr8EK5TUpx0DbnpIMJ2bMSDxGWfCbk= github.com/redis/go-redis/v9 v9.18.0 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs= github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/robertkrimen/otto v0.2.1 h1:FVP0PJ0AHIjC+N4pKCG9yCDz6LHNPCwi/GKID5pGGF0= github.com/robertkrimen/otto v0.2.1/go.mod h1:UPwtJ1Xu7JrLcZjNWN8orJaM5n5YEtqL//farB5FlRY= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA= github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -203,6 +230,11 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0= +github.com/tencentyun/cos-go-sdk-v5 v0.7.73 h1:uFfgp1A7cQaAGR6QP9DsIkoEQ67b8ewj5r1RV6XB540= +github.com/tencentyun/cos-go-sdk-v5 v0.7.73/go.mod h1:STbTNaNKq03u+gscPEGOahKzLcGSYOj6Dzc5zNay7Pg= +github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20250515025012-e0eec8a5d123/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw= github.com/tinylib/msgp v1.6.1 h1:ESRv8eL3u+DNHUoSAAQRE50Hm162zqAnBoGv9PzScPY= github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA= github.com/titanous/json5 v1.0.0 h1:hJf8Su1d9NuI/ffpxgxQfxh/UiBFZX7bMPid0rIL/7s= @@ -214,8 +246,10 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= -github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= -github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= +github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= +github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= +github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs= +github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s= github.com/zeromicro/go-zero v1.10.1 h1:1nM3ilvYx97GUqyaNH2IQPtfNyK7tp5JvN63c7m6QKU= github.com/zeromicro/go-zero v1.10.1/go.mod h1:z41DXmO6gx/Se7Ow5UIwPxcUmpVj3ebhoNCcZ1gfp5k= go.etcd.io/etcd/api/v3 v3.5.21 h1:A6O2/JDb3tvHhiIz3xf9nJ7REHvtEFJJ3veW3FbCnS8= @@ -405,6 +439,8 @@ k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOP k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts= k8s.io/utils v0.0.0-20260319190234-28399d86e0b5 h1:kBawHLSnx/mYHmRnNUf9d4CpjREbeZuxoSGOX/J+aYM= k8s.io/utils v0.0.0-20260319190234-28399d86e0b5/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= +modernc.org/fileutil v1.0.0 h1:Z1AFLZwl6BO8A5NldQg/xTSjGLetp+1Ubvl4alfGx8w= +modernc.org/fileutil v1.0.0/go.mod h1:JHsWpkrk/CnVV1H/eGlFf85BEpfkrp56ro8nojIq9Q8= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=