From 6945277fdb4aef71f38015bb2d0dfd0efcf35801 Mon Sep 17 00:00:00 2001 From: PandaGoAdmin <18610165312@163.com> Date: Wed, 3 Aug 2022 16:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E6=9B=B4?= =?UTF-8?q?=E6=96=B0restful?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/develop/api/gen.go | 8 +- apps/develop/api/table.go | 26 +++--- apps/develop/router/gen.go | 33 ++++---- apps/develop/router/table.go | 11 +-- apps/job/api/job.go | 24 +++--- apps/job/router/job.go | 13 ++- apps/log/api/log_job.go | 12 +-- apps/log/api/log_login.go | 14 ++-- apps/log/api/log_oper.go | 15 ++-- apps/log/router/log.go | 11 +-- apps/resource/api/email.go | 21 +++-- apps/resource/api/oss.go | 29 ++++--- apps/resource/router/email.go | 11 +-- apps/resource/router/oss.go | 11 +-- apps/system/api/api.go | 81 +++---------------- apps/system/api/config.go | 72 +++-------------- apps/system/api/dept.go | 24 +++--- apps/system/api/dict.go | 45 +++++------ apps/system/api/menu.go | 21 ++--- apps/system/api/notice.go | 14 ++-- apps/system/api/post.go | 19 +++-- apps/system/api/role.go | 30 +++---- apps/system/api/system.go | 13 ++- apps/system/api/tenant.go | 58 ++------------ apps/system/api/user.go | 76 +++++++++--------- apps/system/router/api.go | 83 +++++++++++++------ apps/system/router/config.go | 73 ++++++++++++----- apps/system/router/dept.go | 86 ++++++++++++++------ apps/system/router/dict.go | 121 +++++++++++++++++++--------- apps/system/router/menu.go | 103 +++++++++++++++++------- apps/system/router/notice.go | 50 ++++++++---- apps/system/router/post.go | 61 +++++++++----- apps/system/router/role.go | 85 +++++++++++++------- apps/system/router/system.go | 15 ++-- apps/system/router/tenant.go | 71 +++++++++++----- apps/system/router/user.go | 147 +++++++++++++++++++++++----------- config.yml | 17 +--- go.mod | 19 +++-- go.sum | 126 +++++++++++++++++++++++++---- main.go | 17 +++- pkg/initialize/router.go | 81 ++++++------------- pkg/middleware/cors.go | 28 +++---- pkg/middleware/oper.go | 6 +- pkg/middleware/rate.go | 19 ++--- pkg/middleware/swagger.go | 44 ++++++++++ pkg/transport/grpc_server.go | 48 +++++++++++ pkg/transport/http_server.go | 59 ++++++++++++++ pkg/transport/transport.go | 19 +++++ 48 files changed, 1234 insertions(+), 836 deletions(-) create mode 100644 pkg/middleware/swagger.go create mode 100644 pkg/transport/grpc_server.go create mode 100644 pkg/transport/http_server.go create mode 100644 pkg/transport/transport.go diff --git a/apps/develop/api/gen.go b/apps/develop/api/gen.go index fc206cf..655e8e7 100644 --- a/apps/develop/api/gen.go +++ b/apps/develop/api/gen.go @@ -18,7 +18,7 @@ type GenApi struct { // @Router /develop/code/gen/preview/{tableId} [get] // @Security X-TOKEN func (e *GenApi) Preview(rc *restfulx.ReqCtx) { - tableId := restfulx.PathParamInt(rc.GinCtx, "tableId") + tableId := restfulx.PathParamInt(rc, "tableId") rc.ResData = gen.Preview(int64(tableId)) } @@ -30,7 +30,7 @@ func (e *GenApi) Preview(rc *restfulx.ReqCtx) { // @Router /develop/code/gen/code/{tableId} [get] // @Security X-TOKEN func (e *GenApi) GenCode(rc *restfulx.ReqCtx) { - tableId := restfulx.PathParamInt(rc.GinCtx, "tableId") + tableId := restfulx.PathParamInt(rc, "tableId") gen.GenCode(int64(tableId)) } @@ -42,7 +42,7 @@ func (e *GenApi) GenCode(rc *restfulx.ReqCtx) { // @Router /develop/code/gen/configure/{tableId} [get] // @Security X-TOKEN func (e *GenApi) GenConfigure(rc *restfulx.ReqCtx) { - tableId := restfulx.PathParamInt(rc.GinCtx, "tableId") - menuId := restfulx.QueryInt(rc.GinCtx, "menuId", 0) + tableId := restfulx.PathParamInt(rc, "tableId") + menuId := restfulx.QueryInt(rc, "menuId", 0) gen.GenConfigure(tableId, menuId) } diff --git a/apps/develop/api/table.go b/apps/develop/api/table.go index d7184f7..2afb168 100644 --- a/apps/develop/api/table.go +++ b/apps/develop/api/table.go @@ -23,9 +23,10 @@ type GenTableApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/table/db/list [get] func (g *GenTableApi) GetDBTableList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - tableName := rc.GinCtx.Query("tableName") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + tableName := restfulx.QueryParam(rc, "tableName") + list, total := g.GenTableApp.FindDbTablesListPage(pageNum, pageSize, entity.DBTables{TableName: tableName}) rc.ResData = map[string]any{ "data": list, @@ -45,10 +46,11 @@ func (g *GenTableApi) GetDBTableList(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/table/list [get] func (g *GenTableApi) GetTablePage(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - tableName := rc.GinCtx.Query("tableName") - tableComment := rc.GinCtx.Query("tableComment") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + tableName := restfulx.QueryParam(rc, "tableName") + tableComment := restfulx.QueryParam(rc, "tableComment") + list, total := g.GenTableApp.FindListPage(pageNum, pageSize, entity.DevGenTable{TableName: tableName, TableComment: tableComment}) rc.ResData = map[string]any{ "data": list, @@ -66,7 +68,7 @@ func (g *GenTableApi) GetTablePage(rc *restfulx.ReqCtx) { // @Router /develop/code/table/info/{tableId} [get] // @Security Bearer func (g *GenTableApi) GetTableInfo(rc *restfulx.ReqCtx) { - tableId := restfulx.PathParamInt(rc.GinCtx, "tableId") + tableId := restfulx.PathParamInt(rc, "tableId") result := g.GenTableApp.FindOne(entity.DevGenTable{TableId: int64(tableId)}, true) mp := make(map[string]any) mp["list"] = result.Columns @@ -82,7 +84,7 @@ func (g *GenTableApi) GetTableInfo(rc *restfulx.ReqCtx) { // @Router /develop/code/table/info/tableName [get] // @Security X-TOKEN func (g *GenTableApi) GetTableInfoByName(rc *restfulx.ReqCtx) { - tableName := rc.GinCtx.Query("tableName") + tableName := restfulx.QueryParam(rc, "tableName") result := g.GenTableApp.FindOne(entity.DevGenTable{TableName: tableName}, true) mp := make(map[string]any) mp["list"] = result.Columns @@ -111,7 +113,7 @@ func (g *GenTableApi) GetTableTree(rc *restfulx.ReqCtx) { // @Router /develop/code/table [post] // @Security Bearer func (g *GenTableApi) Insert(rc *restfulx.ReqCtx) { - tablesList := strings.Split(rc.GinCtx.Query("tables"), ",") + tablesList := strings.Split(restfulx.QueryParam(rc, "tables"), ",") wg := sync.WaitGroup{} for i := 0; i < len(tablesList); i++ { @@ -138,7 +140,7 @@ func (g *GenTableApi) Insert(rc *restfulx.ReqCtx) { // @Security Bearer func (g *GenTableApi) Update(rc *restfulx.ReqCtx) { var data entity.DevGenTable - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) g.GenTableApp.Update(data) } @@ -151,7 +153,7 @@ func (g *GenTableApi) Update(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": -1, "message": "删除失败"}" // @Router /develop/code/table/{tableId} [delete] func (g *GenTableApi) Delete(rc *restfulx.ReqCtx) { - tableIds := rc.GinCtx.Param("tableId") + tableIds := restfulx.PathParam(rc, "tableId") group := utils.IdsStrToIdsIntGroup(tableIds) g.GenTableApp.Delete(group) } diff --git a/apps/develop/router/gen.go b/apps/develop/router/gen.go index 30b41e3..32b81e4 100644 --- a/apps/develop/router/gen.go +++ b/apps/develop/router/gen.go @@ -1,28 +1,25 @@ package router import ( - "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" - "pandax/apps/develop/api" - "pandax/apps/develop/services" + "github.com/emicklei/go-restful/v3" ) -func InitGenRouter(router *gin.RouterGroup) { +func InitGenRouter(container *restful.Container) { // 登录日志 - genApi := &api.GenApi{ - GenTableApp: services.DevGenTableModelDao, - } - gen := router.Group("gen") + /* genApi := &api.GenApi{ + GenTableApp: services.DevGenTableModelDao, + } + gen := router.Group("gen") - gen.GET("preview/:tableId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取生成代码视图").Handle(genApi.Preview) - }) + gen.GET("preview/:tableId", func(c *gin.Context) { + restfulx.NewReqCtx(c).WithLog("获取生成代码视图").Handle(genApi.Preview) + }) - gen.GET("code/:tableId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("生成代码").Handle(genApi.GenCode) - }) + gen.GET("code/:tableId", func(c *gin.Context) { + restfulx.NewReqCtx(c).WithLog("生成代码").Handle(genApi.GenCode) + }) - gen.GET("configure/:tableId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("生成配置").Handle(genApi.GenConfigure) - }) + gen.GET("configure/:tableId", func(c *gin.Context) { + restfulx.NewReqCtx(c).WithLog("生成配置").Handle(genApi.GenConfigure) + })*/ } diff --git a/apps/develop/router/table.go b/apps/develop/router/table.go index 05dad44..acb8d9e 100644 --- a/apps/develop/router/table.go +++ b/apps/develop/router/table.go @@ -1,15 +1,12 @@ package router import ( - "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" - "pandax/apps/develop/api" - "pandax/apps/develop/services" + "github.com/emicklei/go-restful/v3" ) -func InitGenTableRouter(router *gin.RouterGroup) { +func InitGenTableRouter(container *restful.Container) { // 登录日志 - genApi := &api.GenTableApi{ + /*genApi := &api.GenTableApi{ GenTableApp: services.DevGenTableModelDao, } gen := router.Group("table") @@ -44,5 +41,5 @@ func InitGenTableRouter(router *gin.RouterGroup) { gen.DELETE(":tableId", func(c *gin.Context) { restfulx.NewReqCtx(c).WithLog("删除表").Handle(genApi.Delete) - }) + })*/ } diff --git a/apps/job/api/job.go b/apps/job/api/job.go index 93d27a6..f4b9957 100644 --- a/apps/job/api/job.go +++ b/apps/job/api/job.go @@ -26,7 +26,7 @@ type JobApi struct { // @Security X-TOKEN func (j *JobApi) CreateJob(rc *restfulx.ReqCtx) { var job entity.SysJob - restfulx.BindJsonAndValid(rc.GinCtx, &job) + restfulx.BindQuery(rc, &job) job.CreateBy = rc.LoginAccount.UserName j.JobApp.Insert(job) @@ -44,11 +44,11 @@ func (j *JobApi) CreateJob(rc *restfulx.ReqCtx) { // @Router /job/list [get] // @Security func (j *JobApi) GetJobList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - jobName := rc.GinCtx.Query("jobName") - jobGroup := rc.GinCtx.Query("jobGroup") - status := rc.GinCtx.Query("status") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + jobName := restfulx.QueryParam(rc, "jobName") + jobGroup := restfulx.QueryParam(rc, "jobGroup") + status := restfulx.QueryParam(rc, "status") list, total := j.JobApp.FindListPage(pageNum, pageSize, entity.SysJob{JobName: jobName, JobGroup: jobGroup, Status: status}) rc.ResData = map[string]any{ @@ -67,7 +67,7 @@ func (j *JobApi) GetJobList(rc *restfulx.ReqCtx) { // @Router /job/{jobId} [get] // @Security func (j *JobApi) GetJob(rc *restfulx.ReqCtx) { - jobId := restfulx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("jobId")) + jobId := restfulx.PathParamInt(rc, "jobId") rc.ResData = j.JobApp.FindOne(int64(jobId)) } @@ -83,7 +83,7 @@ func (j *JobApi) GetJob(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (l *JobApi) UpdateJob(rc *restfulx.ReqCtx) { var job entity.SysJob - restfulx.BindJsonAndValid(rc.GinCtx, &job) + restfulx.BindQuery(rc, &job) l.JobApp.Update(job) } @@ -95,7 +95,7 @@ func (l *JobApi) UpdateJob(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /job/{jobId} [delete] func (l *JobApi) DeleteJob(rc *restfulx.ReqCtx) { - jobIds := rc.GinCtx.Param("jobId") + jobIds := restfulx.PathParam(rc, "jobId") group := utils.IdsStrToIdsIntGroup(jobIds) l.JobApp.Delete(group) } @@ -108,7 +108,7 @@ func (l *JobApi) DeleteJob(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /job/stop/{jobId} [get] func (l *JobApi) StopJobForService(rc *restfulx.ReqCtx) { - jobId := restfulx.PathParamInt(rc.GinCtx, "jobId") + jobId := restfulx.PathParamInt(rc, "jobId") job := l.JobApp.FindOne(int64(jobId)) jobs.Remove(jobs.Crontab, job.EntryId) } @@ -120,7 +120,7 @@ func (l *JobApi) StopJobForService(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /job/stop/{jobId} [get] func (l *JobApi) StartJobForService(rc *restfulx.ReqCtx) { - jobId := restfulx.PathParamInt(rc.GinCtx, "jobId") + jobId := restfulx.PathParamInt(rc, "jobId") job := l.JobApp.FindOne(int64(jobId)) biz.IsTrue(job.Status == "0", "以关闭的任务不能开启") @@ -164,7 +164,7 @@ func (l *JobApi) StartJobForService(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (l *JobApi) UpdateStatusJob(rc *restfulx.ReqCtx) { var job from.JobStatus - restfulx.BindJsonAndValid(rc.GinCtx, &job) + restfulx.BindQuery(rc, &job) l.JobApp.Update(entity.SysJob{JobId: job.JobId, Status: job.Status}) } diff --git a/apps/job/router/job.go b/apps/job/router/job.go index 4408436..9a7e1a1 100644 --- a/apps/job/router/job.go +++ b/apps/job/router/job.go @@ -1,18 +1,15 @@ package router import ( - "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" - "pandax/apps/job/api" - "pandax/apps/job/services" + "github.com/emicklei/go-restful/v3" ) -func InitJobRouter(router *gin.RouterGroup) { +func InitJobRouter(container *restful.Container) { // 登录日志 - jobApi := &api.JobApi{ + /*jobApi := &api.JobApi{ JobApp: services.JobModelDao, } - job := router.Group("") + job := router.Group("job") job.GET("list", func(c *gin.Context) { restfulx.NewReqCtx(c).WithLog("获取Job列表").Handle(jobApi.GetJobList) @@ -44,5 +41,5 @@ func InitJobRouter(router *gin.RouterGroup) { job.PUT("/changeStatus", func(c *gin.Context) { restfulx.NewReqCtx(c).WithLog("修改状态").Handle(jobApi.UpdateStatusJob) - }) + })*/ } diff --git a/apps/log/api/log_job.go b/apps/log/api/log_job.go index 85d5fd2..322a7f0 100644 --- a/apps/log/api/log_job.go +++ b/apps/log/api/log_job.go @@ -23,11 +23,11 @@ type LogJobApi struct { // @Router /log/logJob/list [get] // @Security func (l *LogJobApi) GetJobLogList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - name := rc.GinCtx.Query("name") - jobGroup := rc.GinCtx.Query("jobGroup") - status := rc.GinCtx.Query("status") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + name := restfulx.QueryParam(rc, "name") + jobGroup := restfulx.QueryParam(rc, "jobGroup") + status := restfulx.QueryParam(rc, "status") list, total := l.LogJobApp.FindListPage(pageNum, pageSize, entity.LogJob{Name: name, JobGroup: jobGroup, Status: status}) rc.ResData = map[string]any{ @@ -46,7 +46,7 @@ func (l *LogJobApi) GetJobLogList(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logJob/{logId} [delete] func (l *LogJobApi) DeleteJobLog(rc *restfulx.ReqCtx) { - logIds := rc.GinCtx.Param("logId") + logIds := restfulx.QueryParam(rc, "logId") group := utils.IdsStrToIdsIntGroup(logIds) l.LogJobApp.Delete(group) } diff --git a/apps/log/api/log_login.go b/apps/log/api/log_login.go index f11d884..0e94069 100644 --- a/apps/log/api/log_login.go +++ b/apps/log/api/log_login.go @@ -22,10 +22,10 @@ type LogLoginApi struct { // @Router /log/logLogin/list [get] // @Security func (l *LogLoginApi) GetLoginLogList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - loginLocation := rc.GinCtx.Query("loginLocation") - username := rc.GinCtx.Query("username") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + loginLocation := restfulx.QueryParam(rc, "loginLocation") + username := restfulx.QueryParam(rc, "username") list, total := l.LogLoginApp.FindListPage(pageNum, pageSize, entity.LogLogin{LoginLocation: loginLocation, Username: username}) rc.ResData = map[string]any{ "data": list, @@ -43,7 +43,7 @@ func (l *LogLoginApi) GetLoginLogList(rc *restfulx.ReqCtx) { // @Router /log/logLogin/{infoId} [get] // @Security func (l *LogLoginApi) GetLoginLog(rc *restfulx.ReqCtx) { - infoId := restfulx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("infoId")) + infoId := restfulx.PathParamInt(rc, "infoId") rc.ResData = l.LogLoginApp.FindOne(int64(infoId)) } @@ -59,7 +59,7 @@ func (l *LogLoginApi) GetLoginLog(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (l *LogLoginApi) UpdateLoginLog(rc *restfulx.ReqCtx) { var log entity.LogLogin - restfulx.BindJsonAndValid(rc.GinCtx, &log) + restfulx.BindQuery(rc, &log) l.LogLoginApp.Update(log) } @@ -71,7 +71,7 @@ func (l *LogLoginApi) UpdateLoginLog(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logLogin/{infoId} [delete] func (l *LogLoginApi) DeleteLoginLog(rc *restfulx.ReqCtx) { - infoIds := rc.GinCtx.Param("infoId") + infoIds := restfulx.PathParam(rc, "infoId") group := utils.IdsStrToIdsIntGroup(infoIds) l.LogLoginApp.Delete(group) } diff --git a/apps/log/api/log_oper.go b/apps/log/api/log_oper.go index ce59179..f109db3 100644 --- a/apps/log/api/log_oper.go +++ b/apps/log/api/log_oper.go @@ -23,12 +23,11 @@ type LogOperApi struct { // @Router /log/logOper/list [get] // @Security func (l *LogOperApi) GetOperLogList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - - businessType := rc.GinCtx.Query("businessType") - operName := rc.GinCtx.Query("operName") - title := rc.GinCtx.Query("title") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + businessType := restfulx.QueryParam(rc, "businessType") + operName := restfulx.QueryParam(rc, "operName") + title := restfulx.QueryParam(rc, "title") list, total := l.LogOperApp.FindListPage(pageNum, pageSize, entity.LogOper{BusinessType: businessType, OperName: operName, Title: title}) rc.ResData = map[string]any{ "data": list, @@ -46,7 +45,7 @@ func (l *LogOperApi) GetOperLogList(rc *restfulx.ReqCtx) { // @Router /log/logOper/{operId} [get] // @Security func (l *LogOperApi) GetOperLog(rc *restfulx.ReqCtx) { - operId := restfulx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("operId")) + operId := restfulx.PathParamInt(rc, "operId") rc.ResData = l.LogOperApp.FindOne(int64(operId)) } @@ -58,7 +57,7 @@ func (l *LogOperApi) GetOperLog(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logOper/{operId} [delete] func (l *LogOperApi) DeleteOperLog(rc *restfulx.ReqCtx) { - operIds := rc.GinCtx.Param("operId") + operIds := restfulx.PathParam(rc, "operId") group := utils.IdsStrToIdsIntGroup(operIds) log.Println("group", group) l.LogOperApp.Delete(group) diff --git a/apps/log/router/log.go b/apps/log/router/log.go index 2636f48..b970079 100644 --- a/apps/log/router/log.go +++ b/apps/log/router/log.go @@ -1,14 +1,11 @@ package router import ( - "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" - "pandax/apps/log/api" - "pandax/apps/log/services" + "github.com/emicklei/go-restful/v3" ) -func InitLogRouter(router *gin.RouterGroup) { - // 登录日志 +func InitLogRouter(container *restful.Container) { + /*// 登录日志 login := &api.LogLoginApi{ LogLoginApp: services.LogLoginModelDao, } @@ -72,5 +69,5 @@ func InitLogRouter(router *gin.RouterGroup) { logJob.DELETE(":logId", func(c *gin.Context) { restfulx.NewReqCtx(c).WithLog("删除操作日志信息").Handle(job.DeleteJobLog) - }) + })*/ } diff --git a/apps/resource/api/email.go b/apps/resource/api/email.go index 91a3c7e..d289f3e 100644 --- a/apps/resource/api/email.go +++ b/apps/resource/api/email.go @@ -31,10 +31,10 @@ type ResEmailsApi struct { // @Security func (p *ResEmailsApi) GetResEmailsList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - status := rc.GinCtx.Query("status") - category := rc.GinCtx.Query("category") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + status := restfulx.QueryParam(rc, "status") + category := restfulx.QueryParam(rc, "category") data := entity.ResEmail{Status: status, Category: category} list, total := p.ResEmailsApp.FindListPage(pageNum, pageSize, data) @@ -60,7 +60,7 @@ func (p *ResEmailsApi) GetResEmailsList(rc *restfulx.ReqCtx) { // @Router /resource/email/{mailId} [get] // @Security func (p *ResEmailsApi) GetResEmails(rc *restfulx.ReqCtx) { - mailId := restfulx.PathParamInt(rc.GinCtx, "mailId") + mailId := restfulx.PathParamInt(rc, "mailId") p.ResEmailsApp.FindOne(int64(mailId)) } @@ -76,7 +76,7 @@ func (p *ResEmailsApi) GetResEmails(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *ResEmailsApi) InsertResEmails(rc *restfulx.ReqCtx) { var data entity.ResEmail - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) p.ResEmailsApp.Insert(data) } @@ -93,7 +93,7 @@ func (p *ResEmailsApi) InsertResEmails(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *ResEmailsApi) UpdateResEmails(rc *restfulx.ReqCtx) { var data entity.ResEmail - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) if utils.ISDdmMail(data.From) { data.From = "" } @@ -111,8 +111,7 @@ func (p *ResEmailsApi) UpdateResEmails(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /resource/email/{mailId} [delete] func (p *ResEmailsApi) DeleteResEmails(rc *restfulx.ReqCtx) { - - mailId := rc.GinCtx.Param("mailId") + mailId := restfulx.PathParam(rc, "mailId") mailIds := utils.IdsStrToIdsIntGroup(mailId) p.ResEmailsApp.Delete(mailIds) } @@ -129,7 +128,7 @@ func (p *ResEmailsApi) DeleteResEmails(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *ResEmailsApi) UpdateMailStatus(rc *restfulx.ReqCtx) { var data entity.ResEmail - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) p.ResEmailsApp.Update(entity.ResEmail{MailId: data.MailId, Status: data.Status}) } @@ -146,7 +145,7 @@ func (p *ResEmailsApi) UpdateMailStatus(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *ResEmailsApi) DebugMail(rc *restfulx.ReqCtx) { var data from.SendMail - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) one := p.ResEmailsApp.FindOne(data.MailId) ml := email.Mail{ diff --git a/apps/resource/api/oss.go b/apps/resource/api/oss.go index 3b8dcf9..5b2b37e 100644 --- a/apps/resource/api/oss.go +++ b/apps/resource/api/oss.go @@ -33,11 +33,11 @@ type ResOssesApi struct { // @Security func (p *ResOssesApi) GetResOssesList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - status := rc.GinCtx.Query("status") - category := rc.GinCtx.Query("category") - ossCode := rc.GinCtx.Query("ossCode") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + status := restfulx.QueryParam(rc, "status") + category := restfulx.QueryParam(rc, "category") + ossCode := restfulx.QueryParam(rc, "ossCode") data := entity.ResOss{Status: status, Category: category, OssCode: ossCode} list, total := p.ResOssesApp.FindListPage(pageNum, pageSize, data) @@ -63,7 +63,7 @@ func (p *ResOssesApi) GetResOssesList(rc *restfulx.ReqCtx) { // @Router /resource/oss/{ossId} [get] // @Security func (p *ResOssesApi) GetResOsses(rc *restfulx.ReqCtx) { - ossId := restfulx.PathParamInt(rc.GinCtx, "ossId") + ossId := restfulx.PathParamInt(rc, "ossId") p.ResOssesApp.FindOne(int64(ossId)) } @@ -79,7 +79,7 @@ func (p *ResOssesApi) GetResOsses(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *ResOssesApi) InsertResOsses(rc *restfulx.ReqCtx) { var data entity.ResOss - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) p.ResOssesApp.Insert(data) } @@ -96,7 +96,7 @@ func (p *ResOssesApi) InsertResOsses(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *ResOssesApi) UpdateResOsses(rc *restfulx.ReqCtx) { var data entity.ResOss - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) if utils.IsDdmKey(data.AccessKey) { data.AccessKey = "" } @@ -114,8 +114,7 @@ func (p *ResOssesApi) UpdateResOsses(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /resource/oss/{ossId} [delete] func (p *ResOssesApi) DeleteResOsses(rc *restfulx.ReqCtx) { - - ossId := rc.GinCtx.Param("ossId") + ossId := restfulx.PathParam(rc, "ossId") ossIds := utils.IdsStrToIdsIntGroup(ossId) p.ResOssesApp.Delete(ossIds) } @@ -127,13 +126,13 @@ func (p *ResOssesApi) DeleteResOsses(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /resource/oss/uploadFile [post] func (p *ResOssesApi) UplaodResOsses(rc *restfulx.ReqCtx) { - file, _ := rc.GinCtx.FormFile("file") - ossCode, _ := rc.GinCtx.GetQuery("ossCode") + _, handler, _ := rc.Request.Request.FormFile("file") + ossCode := restfulx.QueryParam(rc, "ossCode") list := p.ResOssesApp.FindList(entity.ResOss{OssCode: ossCode}) li := *list - yunFileTmpPath := "uploads/" + time.Now().Format("2006-01-02") + "/" + file.Filename + yunFileTmpPath := "uploads/" + time.Now().Format("2006-01-02") + "/" + handler.Filename // 读取本地文件。 - f, openError := file.Open() + f, openError := handler.Open() biz.ErrIsNil(openError, "function file.Open() Failed") biz.ErrIsNil(NewOss(li[0]).PutObj(yunFileTmpPath, f), "上传OSS失败") @@ -152,7 +151,7 @@ func (p *ResOssesApi) UplaodResOsses(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *ResOssesApi) UpdateOssStatus(rc *restfulx.ReqCtx) { var data entity.ResOss - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) p.ResOssesApp.Update(entity.ResOss{OssId: data.OssId, Status: data.Status}) } diff --git a/apps/resource/router/email.go b/apps/resource/router/email.go index f5c1228..222df56 100644 --- a/apps/resource/router/email.go +++ b/apps/resource/router/email.go @@ -1,10 +1,7 @@ package router import ( - "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" - "pandax/apps/resource/api" - "pandax/apps/resource/services" + "github.com/emicklei/go-restful/v3" ) /** @@ -13,8 +10,8 @@ import ( * @Date 2022/1/14 15:24 **/ -func InitResEmailsRouter(router *gin.RouterGroup) { - s := &api.ResEmailsApi{ +func InitResEmailsRouter(container *restful.Container) { + /*s := &api.ResEmailsApi{ ResEmailsApp: services.ResEmailsModelDao, } routerGroup := router.Group("email") @@ -45,5 +42,5 @@ func InitResEmailsRouter(router *gin.RouterGroup) { routerGroup.POST("debugMail", func(c *gin.Context) { restfulx.NewReqCtx(c).WithLog("修改状态").Handle(s.DebugMail) - }) + })*/ } diff --git a/apps/resource/router/oss.go b/apps/resource/router/oss.go index eac695b..6a6857d 100644 --- a/apps/resource/router/oss.go +++ b/apps/resource/router/oss.go @@ -1,10 +1,7 @@ package router import ( - "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" - "pandax/apps/resource/api" - "pandax/apps/resource/services" + "github.com/emicklei/go-restful/v3" ) /** @@ -13,8 +10,8 @@ import ( * @Date 2022/1/13 15:21 **/ -func InitResOssRouter(router *gin.RouterGroup) { - s := &api.ResOssesApi{ +func InitResOssRouter(container *restful.Container) { + /*s := &api.ResOssesApi{ ResOssesApp: services.ResOssesModelDao, } routerGroup := router.Group("oss") @@ -45,5 +42,5 @@ func InitResOssRouter(router *gin.RouterGroup) { routerGroup.PUT("/changeStatus", func(c *gin.Context) { restfulx.NewReqCtx(c).WithLog("修改状态").Handle(s.UpdateOssStatus) - }) + })*/ } diff --git a/apps/system/api/api.go b/apps/system/api/api.go index 4ebb369..5eaf5ec 100644 --- a/apps/system/api/api.go +++ b/apps/system/api/api.go @@ -14,53 +14,25 @@ type SystemApiApi struct { ApiApp services.SysApiModel } -// @Tags SysApi -// @Summary 创建基础api -// @Security X-TOKEN -// @accept application/json -// @Produce application/json -// @Param data body entity.SysApi true "api路径, api中文描述, api组, 方法" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" -// @Router /system/api [post] func (s *SystemApiApi) CreateApi(rc *restfulx.ReqCtx) { var api entity.SysApi - restfulx.BindJsonAndValid(rc.GinCtx, &api) + restfulx.BindQuery(rc, &api) log.Println(api) s.ApiApp.Insert(api) } -// @Tags SysApi -// @Summary 删除api -// @Security X-TOKEN -// @accept application/json -// @Produce application/json -// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" -// @Router /system/api/{id} [delete] func (s *SystemApiApi) DeleteApi(rc *restfulx.ReqCtx) { - ids := rc.GinCtx.Param("id") + ids := rc.Request.PathParameter("id") s.ApiApp.Delete(utils.IdsStrToIdsIntGroup(ids)) } -// @Tags SysApi -// @Summary 分页获取API列表 -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Param path query string false "path" -// @Param description query string false "description" -// @Param method query string false "method" -// @Param apiGroup query string false "apiGroup" -// @Param pageSize query int false "页条数" -// @Param pageNum query int false "页码" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" -// @Router /system/api/list [get] func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - path := rc.GinCtx.Query("path") - description := rc.GinCtx.Query("description") - method := rc.GinCtx.Query("method") - apiGroup := rc.GinCtx.Query("apiGroup") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + path := rc.Request.QueryParameter("path") + description := rc.Request.QueryParameter("description") + method := rc.Request.QueryParameter("method") + apiGroup := rc.Request.QueryParameter("apiGroup") api := entity.SysApi{Path: path, Description: description, Method: method, ApiGroup: apiGroup} list, total := s.ApiApp.FindListPage(pageNum, pageSize, api) rc.ResData = map[string]any{ @@ -71,55 +43,24 @@ func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) { } } -// @Tags SysApi -// @Summary 根据id获取api -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Param id path int true "根据id获取api" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" -// @Router /system/api/{id} [get] func (s *SystemApiApi) GetApiById(rc *restfulx.ReqCtx) { - id := restfulx.QueryInt(rc.GinCtx, "id", 0) + id := restfulx.QueryInt(rc, "id", 0) rc.ResData = s.ApiApp.FindOne(int64(id)) } -// @Tags SysApi -// @Summary 创建基础api -// @Security X-TOKEN -// @accept application/json -// @Produce application/json -// @Param data body entity.SysApi true "api路径, api中文描述, api组, 方法" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" -// @Router /api/api [put] func (s *SystemApiApi) UpdateApi(rc *restfulx.ReqCtx) { var api entity.SysApi - restfulx.BindJsonAndValid(rc.GinCtx, &api) + restfulx.BindQuery(rc, &api) s.ApiApp.Update(api) } -// @Tags SysApi -// @Summary 获取所有的Api 不分页 -// @Security ApiKeyAuth -// @accept application/json -// @Produce application/json -// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" -// @Router /system/api/all [get] func (s *SystemApiApi) GetAllApis(rc *restfulx.ReqCtx) { rc.ResData = s.ApiApp.FindList(entity.SysApi{}) } -// @Tags SysApi -// @Summary 获取Api权限列表 -// @Security X-TOKEN -// @accept application/json -// @Produce application/json -// @Param roleKey query string true "权限id, 权限模型列表" -// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" -// @Router /casbin/getPolicyPathByRoleId [get] func (s *SystemApiApi) GetPolicyPathByRoleId(rc *restfulx.ReqCtx) { - roleKey := rc.GinCtx.Query("roleKey") + roleKey := rc.Request.QueryParameter("roleKey") tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId)) rc.ResData = casbin.GetPolicyPathByRoleId(tenantId, roleKey) } diff --git a/apps/system/api/config.go b/apps/system/api/config.go index 0fa826b..8959bc8 100644 --- a/apps/system/api/config.go +++ b/apps/system/api/config.go @@ -12,23 +12,12 @@ type ConfigApi struct { ConfigApp services.SysConfigModel } -// @Summary 配置列表数据 -// @Description 获取JSON -// @Tags 配置 -// @Param configName query string false "configName" -// @Param configKey query string false "configKey" -// @Param configType query string false "configType" -// @Param pageSize query int false "页条数" -// @Param pageNum query int false "页码" -// @Success 200 {string} string "{"code": 200, "data": [...]}" -// @Router /system/config [get] -// @Security func (p *ConfigApi) GetConfigList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - configName := rc.GinCtx.Query("configName") - configKey := rc.GinCtx.Query("configKey") - configType := rc.GinCtx.Query("configType") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + configName := rc.Request.QueryParameter("configName") + configKey := rc.Request.QueryParameter("configKey") + configType := rc.Request.QueryParameter("configType") config := entity.SysConfig{ConfigName: configName, ConfigKey: configKey, ConfigType: configType} list, total := p.ConfigApp.FindListPage(pageNum, pageSize, config) @@ -40,72 +29,31 @@ func (p *ConfigApi) GetConfigList(rc *restfulx.ReqCtx) { } } -// @Summary 配置列表数据ByKey -// @Description 获取JSON -// @Tags 配置 -// @Param configKey query string false "configKey" -// @Success 200 {string} string "{"code": 200, "data": [...]}" -// @Router /system/config/configKey [get] -// @Security func (p *ConfigApi) GetConfigListByKey(rc *restfulx.ReqCtx) { - configKey := rc.GinCtx.Query("configKey") + configKey := rc.Request.QueryParameter("configKey") biz.IsTrue(configKey != "", "请传入配置Key") rc.ResData = p.ConfigApp.FindList(entity.SysConfig{ConfigKey: configKey}) } -// @Summary 获取配置 -// @Description 获取JSON -// @Tags 配置 -// @Param configId path int true "configId" -// @Success 200 {string} string "{"code": 200, "data": [...]}" -// @Router /system/config/{configId} [get] -// @Security func (p *ConfigApi) GetConfig(rc *restfulx.ReqCtx) { - id := restfulx.PathParamInt(rc.GinCtx, "configId") + id := restfulx.PathParamInt(rc, "configId") p.ConfigApp.FindOne(int64(id)) } -// @Summary 添加配置 -// @Description 获取JSON -// @Tags 配置 -// @Accept application/json -// @Product application/json -// @Param data body entity.SysConfig true "data" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": 400, "message": "添加失败"}" -// @Router /system/config [post] -// @Security X-TOKEN func (p *ConfigApi) InsertConfig(rc *restfulx.ReqCtx) { var config entity.SysConfig - restfulx.BindJsonAndValid(rc.GinCtx, &config) + restfulx.BindQuery(rc, &config) p.ConfigApp.Insert(config) } -// @Summary 修改配置 -// @Description 获取JSON -// @Tags 配置 -// @Accept application/json -// @Product application/json -// @Param data body entity.SysConfig true "body" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": 400, "message": "添加失败"}" -// @Router /system/config [put] -// @Security X-TOKEN func (p *ConfigApi) UpdateConfig(rc *restfulx.ReqCtx) { var post entity.SysConfig - restfulx.BindJsonAndValid(rc.GinCtx, &post) + restfulx.BindQuery(rc, &post) p.ConfigApp.Update(post) } -// @Summary 删除配置 -// @Description 删除数据 -// @Tags 配置 -// @Param configId path string true "configId 多个使用逗号分割" -// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" -// @Success 200 {string} string "{"code": 400, "message": "删除失败"}" -// @Router /system/config/{configId} [delete] func (p *ConfigApi) DeleteConfig(rc *restfulx.ReqCtx) { - configId := rc.GinCtx.Param("configId") + configId := rc.Request.PathParameter("configId") p.ConfigApp.Delete(utils.IdsStrToIdsIntGroup(configId)) } diff --git a/apps/system/api/dept.go b/apps/system/api/dept.go index f6b2b5b..cd8eb3d 100644 --- a/apps/system/api/dept.go +++ b/apps/system/api/dept.go @@ -26,7 +26,7 @@ type DeptApi struct { // @Router /system/menu/menuTreRoleSelect/{roleId} [get] // @Security X-TOKEN func (m *DeptApi) GetDeptTreeRoleSelect(rc *restfulx.ReqCtx) { - roleId := restfulx.PathParamInt(rc.GinCtx, "roleId") + roleId := restfulx.PathParamInt(rc, "roleId") var dept entity.SysDept if !IsTenantAdmin(rc.LoginAccount.TenantId) { dept.TenantId = rc.LoginAccount.TenantId @@ -55,9 +55,9 @@ func (m *DeptApi) GetDeptTreeRoleSelect(rc *restfulx.ReqCtx) { func (a *DeptApi) GetDeptList(rc *restfulx.ReqCtx) { //pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) //pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - deptName := rc.GinCtx.Query("deptName") - status := rc.GinCtx.Query("status") - deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0) + deptName := restfulx.QueryParam(rc, "deptName") + status := restfulx.QueryParam(rc, "status") + deptId := restfulx.QueryInt(rc, "deptId", 0) dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)} if !IsTenantAdmin(rc.LoginAccount.TenantId) { dept.TenantId = rc.LoginAccount.TenantId @@ -94,9 +94,9 @@ func (a *DeptApi) GetOrdinaryDeptList(rc *restfulx.ReqCtx) { // @Router /system/dept/deptTree [get] // @Security func (a *DeptApi) GetDeptTree(rc *restfulx.ReqCtx) { - deptName := rc.GinCtx.Query("deptName") - status := rc.GinCtx.Query("status") - deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0) + deptName := restfulx.QueryParam(rc, "deptName") + status := restfulx.QueryParam(rc, "status") + deptId := restfulx.QueryInt(rc, "deptId", 0) dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)} if !IsTenantAdmin(rc.LoginAccount.TenantId) { dept.TenantId = rc.LoginAccount.TenantId @@ -112,7 +112,7 @@ func (a *DeptApi) GetDeptTree(rc *restfulx.ReqCtx) { // @Router /system/dept/{deptId} [get] // @Security func (a *DeptApi) GetDept(rc *restfulx.ReqCtx) { - deptId := restfulx.PathParamInt(rc.GinCtx, "deptId") + deptId := restfulx.PathParamInt(rc, "deptId") rc.ResData = a.DeptApp.FindOne(int64(deptId)) } @@ -128,8 +128,7 @@ func (a *DeptApi) GetDept(rc *restfulx.ReqCtx) { // @Security Bearer func (a *DeptApi) InsertDept(rc *restfulx.ReqCtx) { var dept entity.SysDept - g := rc.GinCtx - restfulx.BindJsonAndValid(g, &dept) + restfulx.BindQuery(rc, &dept) dept.TenantId = rc.LoginAccount.TenantId dept.CreateBy = rc.LoginAccount.UserName a.DeptApp.Insert(dept) @@ -147,8 +146,7 @@ func (a *DeptApi) InsertDept(rc *restfulx.ReqCtx) { // @Security Bearer func (a *DeptApi) UpdateDept(rc *restfulx.ReqCtx) { var dept entity.SysDept - g := rc.GinCtx - restfulx.BindJsonAndValid(g, &dept) + restfulx.BindQuery(rc, &dept) dept.UpdateBy = rc.LoginAccount.UserName a.DeptApp.Update(dept) @@ -162,7 +160,7 @@ func (a *DeptApi) UpdateDept(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dept/{deptId} [delete] func (a *DeptApi) DeleteDept(rc *restfulx.ReqCtx) { - deptId := rc.GinCtx.Param("deptId") + deptId := restfulx.PathParam(rc, "deptId") deptIds := utils.IdsStrToIdsIntGroup(deptId) deList := make([]int64, 0) diff --git a/apps/system/api/dict.go b/apps/system/api/dict.go index 74bc0e8..c4021a9 100644 --- a/apps/system/api/dict.go +++ b/apps/system/api/dict.go @@ -27,11 +27,11 @@ type DictApi struct { // @Router /system/dict/type/list [get] // @Security func (p *DictApi) GetDictTypeList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - status := rc.GinCtx.Query("status") - dictName := rc.GinCtx.Query("dictName") - dictType := rc.GinCtx.Query("dictType") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + status := restfulx.QueryParam(rc, "status") + dictName := restfulx.QueryParam(rc, "dictName") + dictType := restfulx.QueryParam(rc, "dictType") list, total := p.DictType.FindListPage(pageNum, pageSize, entity.SysDictType{Status: status, DictName: dictName, DictType: dictType}) rc.ResData = map[string]any{ @@ -50,7 +50,7 @@ func (p *DictApi) GetDictTypeList(rc *restfulx.ReqCtx) { // @Router /system/dict/type/{dictId} [get] // @Security func (p *DictApi) GetDictType(rc *restfulx.ReqCtx) { - dictId := restfulx.PathParamInt(rc.GinCtx, "dictId") + dictId := restfulx.PathParamInt(rc, "dictId") p.DictType.FindOne(int64(dictId)) } @@ -66,7 +66,7 @@ func (p *DictApi) GetDictType(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *DictApi) InsertDictType(rc *restfulx.ReqCtx) { var dict entity.SysDictType - restfulx.BindJsonAndValid(rc.GinCtx, &dict) + restfulx.BindQuery(rc, &dict) dict.CreateBy = rc.LoginAccount.UserName p.DictType.Insert(dict) @@ -84,7 +84,7 @@ func (p *DictApi) InsertDictType(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *DictApi) UpdateDictType(rc *restfulx.ReqCtx) { var dict entity.SysDictType - restfulx.BindJsonAndValid(rc.GinCtx, &dict) + restfulx.BindQuery(rc, &dict) dict.CreateBy = rc.LoginAccount.UserName p.DictType.Update(dict) @@ -98,7 +98,7 @@ func (p *DictApi) UpdateDictType(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/type/{dictId} [delete] func (p *DictApi) DeleteDictType(rc *restfulx.ReqCtx) { - dictId := rc.GinCtx.Param("dictId") + dictId := restfulx.PathParam(rc, "dictId") dictIds := utils.IdsStrToIdsIntGroup(dictId) deList := make([]int64, 0) @@ -124,10 +124,10 @@ func (p *DictApi) DeleteDictType(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/type/export [get] func (p *DictApi) ExportDictType(rc *restfulx.ReqCtx) { - filename := rc.GinCtx.Query("filename") - status := rc.GinCtx.Query("status") - dictName := rc.GinCtx.Query("dictName") - dictType := rc.GinCtx.Query("dictType") + filename := restfulx.QueryParam(rc, "filename") + status := restfulx.QueryParam(rc, "status") + dictName := restfulx.QueryParam(rc, "dictName") + dictType := restfulx.QueryParam(rc, "dictType") list := p.DictType.FindList(entity.SysDictType{Status: status, DictName: dictName, DictType: dictType}) fileName := utils.GetFileName(global.Conf.Server.ExcelDir, filename) @@ -145,9 +145,9 @@ func (p *DictApi) ExportDictType(rc *restfulx.ReqCtx) { // @Router /system/dict/data/list [get] // @Security func (p *DictApi) GetDictDataList(rc *restfulx.ReqCtx) { - dictLabel := rc.GinCtx.Query("dictLabel") - dictType := rc.GinCtx.Query("dictType") - status := rc.GinCtx.Query("status") + dictLabel := restfulx.QueryParam(rc, "dictLabel") + dictType := restfulx.QueryParam(rc, "dictType") + status := restfulx.QueryParam(rc, "status") rc.ResData = p.DictData.FindList(entity.SysDictData{Status: status, DictType: dictType, DictLabel: dictLabel}) } @@ -159,7 +159,7 @@ func (p *DictApi) GetDictDataList(rc *restfulx.ReqCtx) { // @Router /system/dict/data/type [get] // @Security func (p *DictApi) GetDictDataListByDictType(rc *restfulx.ReqCtx) { - dictType := rc.GinCtx.Query("dictType") + dictType := restfulx.QueryParam(rc, "dictType") biz.IsTrue(dictType != "", "请传入字典类型") rc.ResData = p.DictData.FindList(entity.SysDictData{DictType: dictType}) } @@ -172,7 +172,7 @@ func (p *DictApi) GetDictDataListByDictType(rc *restfulx.ReqCtx) { // @Router /system/dict/data/{dictCode} [get] // @Security func (p *DictApi) GetDictData(rc *restfulx.ReqCtx) { - dictCode := restfulx.PathParamInt(rc.GinCtx, "dictCode") + dictCode := restfulx.PathParamInt(rc, "dictCode") p.DictData.FindOne(int64(dictCode)) } @@ -188,8 +188,7 @@ func (p *DictApi) GetDictData(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *DictApi) InsertDictData(rc *restfulx.ReqCtx) { var data entity.SysDictData - restfulx.BindJsonAndValid(rc.GinCtx, &data) - + restfulx.BindQuery(rc, &data) data.CreateBy = rc.LoginAccount.UserName p.DictData.Insert(data) } @@ -206,7 +205,7 @@ func (p *DictApi) InsertDictData(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *DictApi) UpdateDictData(rc *restfulx.ReqCtx) { var data entity.SysDictData - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) data.CreateBy = rc.LoginAccount.UserName p.DictData.Update(data) @@ -220,6 +219,6 @@ func (p *DictApi) UpdateDictData(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/data/{dictCode} [delete] func (p *DictApi) DeleteDictData(rc *restfulx.ReqCtx) { - param := rc.GinCtx.Param("dictCode") - p.DictData.Delete(utils.IdsStrToIdsIntGroup(param)) + dictCode := restfulx.PathParam(rc, "dictCode") + p.DictData.Delete(utils.IdsStrToIdsIntGroup(dictCode)) } diff --git a/apps/system/api/menu.go b/apps/system/api/menu.go index bdb43ee..fbff885 100644 --- a/apps/system/api/menu.go +++ b/apps/system/api/menu.go @@ -3,6 +3,7 @@ package api import ( "github.com/XM-GO/PandaKit/biz" "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" entity "pandax/apps/system/entity" services "pandax/apps/system/services" ) @@ -35,7 +36,7 @@ func (m *MenuApi) GetMenuTreeSelect(rc *restfulx.ReqCtx) { // @Router /system/menu/menuRole [get] // @Security X-TOKEN func (m *MenuApi) GetMenuRole(rc *restfulx.ReqCtx) { - roleKey := rc.GinCtx.Query("roleKey") + roleKey := restfulx.QueryParam(rc, "roleKey") biz.IsTrue(roleKey != "", "请传入角色Key") rc.ResData = Build(*m.MenuApp.SelectMenuRole(roleKey)) } @@ -49,7 +50,7 @@ func (m *MenuApi) GetMenuRole(rc *restfulx.ReqCtx) { // @Router /system/menu/menuTreRoleSelect/{roleId} [get] // @Security X-TOKEN func (m *MenuApi) GetMenuTreeRoleSelect(rc *restfulx.ReqCtx) { - roleId := restfulx.PathParamInt(rc.GinCtx, "roleId") + roleId := restfulx.PathParamInt(rc, "roleId") result := m.MenuApp.SelectMenuLable(entity.SysMenu{}) menuIds := make([]int64, 0) @@ -71,7 +72,7 @@ func (m *MenuApi) GetMenuTreeRoleSelect(rc *restfulx.ReqCtx) { // @Router /system/menu/menuPaths [get] // @Security X-TOKEN func (m *MenuApi) GetMenuPaths(rc *restfulx.ReqCtx) { - roleKey := rc.GinCtx.Query("roleKey") + roleKey := restfulx.QueryParam(rc, "roleKey") biz.IsTrue(roleKey != "", "请传入角色Key") rc.ResData = m.RoleMenuApp.GetMenuPaths(entity.SysRoleMenu{RoleName: roleKey}) } @@ -87,8 +88,8 @@ func (m *MenuApi) GetMenuPaths(rc *restfulx.ReqCtx) { // @Router /system/menu/menuList [get] // @Security Bearer func (m *MenuApi) GetMenuList(rc *restfulx.ReqCtx) { - menuName := rc.GinCtx.Query("menuName") - status := rc.GinCtx.Query("status") + menuName := restfulx.QueryParam(rc, "menuName") + status := restfulx.QueryParam(rc, "status") menu := entity.SysMenu{MenuName: menuName, Status: status} if menu.MenuName == "" { @@ -107,7 +108,7 @@ func (m *MenuApi) GetMenuList(rc *restfulx.ReqCtx) { // @Router /system/menu/{menuId} [get] // @Security Bearer func (m *MenuApi) GetMenu(rc *restfulx.ReqCtx) { - menuId := restfulx.PathParamInt(rc.GinCtx, "menuId") + menuId := restfulx.PathParamInt(rc, "menuId") rc.ResData = m.MenuApp.FindOne(int64(menuId)) } @@ -122,7 +123,7 @@ func (m *MenuApi) GetMenu(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) { var menu entity.SysMenu - restfulx.BindJsonAndValid(rc.GinCtx, &menu) + restfulx.BindQuery(rc, &menu) menu.CreateBy = rc.LoginAccount.UserName m.MenuApp.Insert(menu) permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId) @@ -143,7 +144,7 @@ func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) { var menu entity.SysMenu - restfulx.BindJsonAndValid(rc.GinCtx, &menu) + restfulx.BindQuery(rc, &menu) menu.UpdateBy = rc.LoginAccount.UserName m.MenuApp.Update(menu) permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId) @@ -162,6 +163,6 @@ func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/menu/{menuId} [delete] func (m *MenuApi) DeleteMenu(rc *restfulx.ReqCtx) { - menuId := restfulx.PathParamInt(rc.GinCtx, "menuId") - m.MenuApp.Delete([]int64{int64(menuId)}) + menuId := restfulx.PathParam(rc, "menuId") + m.MenuApp.Delete(utils.IdsStrToIdsIntGroup(menuId)) } diff --git a/apps/system/api/notice.go b/apps/system/api/notice.go index bcbe200..9803409 100644 --- a/apps/system/api/notice.go +++ b/apps/system/api/notice.go @@ -24,10 +24,10 @@ type NoticeApi struct { // @Router /system/post [get] // @Security func (p *NoticeApi) GetNoticeList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - noticeType := rc.GinCtx.Query("noticeType") - title := rc.GinCtx.Query("title") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + noticeType := restfulx.QueryParam(rc, "noticeType") + title := restfulx.QueryParam(rc, "title") // 获取部门的子部门id one := p.DeptApp.FindOne(rc.LoginAccount.DeptId) @@ -57,7 +57,7 @@ func (p *NoticeApi) GetNoticeList(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *NoticeApi) InsertNotice(rc *restfulx.ReqCtx) { var notice entity.SysNotice - restfulx.BindJsonAndValid(rc.GinCtx, ¬ice) + restfulx.BindQuery(rc, ¬ice) notice.UserName = rc.LoginAccount.UserName p.NoticeApp.Insert(notice) } @@ -74,7 +74,7 @@ func (p *NoticeApi) InsertNotice(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *NoticeApi) UpdateNotice(rc *restfulx.ReqCtx) { var notice entity.SysNotice - restfulx.BindJsonAndValid(rc.GinCtx, ¬ice) + restfulx.BindQuery(rc, ¬ice) p.NoticeApp.Update(notice) } @@ -87,7 +87,7 @@ func (p *NoticeApi) UpdateNotice(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/notice/{noticeId} [delete] func (p *NoticeApi) DeleteNotice(rc *restfulx.ReqCtx) { - noticeId := rc.GinCtx.Param("noticeId") + noticeId := restfulx.PathParam(rc, "noticeId") noticeIds := utils.IdsStrToIdsIntGroup(noticeId) p.NoticeApp.Delete(noticeIds) } diff --git a/apps/system/api/post.go b/apps/system/api/post.go index 45b6da0..4b03682 100644 --- a/apps/system/api/post.go +++ b/apps/system/api/post.go @@ -30,11 +30,11 @@ type PostApi struct { // @Security func (p *PostApi) GetPostList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - status := rc.GinCtx.Query("status") - postName := rc.GinCtx.Query("postName") - postCode := rc.GinCtx.Query("postCode") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + status := restfulx.QueryParam(rc, "status") + postName := restfulx.QueryParam(rc, "postName") + postCode := restfulx.QueryParam(rc, "postCode") post := entity.SysPost{Status: status, PostName: postName, PostCode: postCode} if !IsTenantAdmin(rc.LoginAccount.TenantId) { @@ -59,7 +59,7 @@ func (p *PostApi) GetPostList(rc *restfulx.ReqCtx) { // @Router /system/post/{postId} [get] // @Security func (p *PostApi) GetPost(rc *restfulx.ReqCtx) { - postId := restfulx.PathParamInt(rc.GinCtx, "postId") + postId := restfulx.PathParamInt(rc, "postId") p.PostApp.FindOne(int64(postId)) } @@ -75,7 +75,7 @@ func (p *PostApi) GetPost(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *PostApi) InsertPost(rc *restfulx.ReqCtx) { var post entity.SysPost - restfulx.BindJsonAndValid(rc.GinCtx, &post) + restfulx.BindQuery(rc, &post) post.TenantId = rc.LoginAccount.TenantId post.CreateBy = rc.LoginAccount.UserName p.PostApp.Insert(post) @@ -93,7 +93,7 @@ func (p *PostApi) InsertPost(rc *restfulx.ReqCtx) { // @Security X-TOKEN func (p *PostApi) UpdatePost(rc *restfulx.ReqCtx) { var post entity.SysPost - restfulx.BindJsonAndValid(rc.GinCtx, &post) + restfulx.BindQuery(rc, &post) post.CreateBy = rc.LoginAccount.UserName p.PostApp.Update(post) @@ -107,8 +107,7 @@ func (p *PostApi) UpdatePost(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/post/{postId} [delete] func (p *PostApi) DeletePost(rc *restfulx.ReqCtx) { - - postId := rc.GinCtx.Param("postId") + postId := restfulx.PathParam(rc, "postId") postIds := utils.IdsStrToIdsIntGroup(postId) deList := make([]int64, 0) diff --git a/apps/system/api/role.go b/apps/system/api/role.go index e54e6ff..e9c8c0c 100644 --- a/apps/system/api/role.go +++ b/apps/system/api/role.go @@ -32,11 +32,11 @@ type RoleApi struct { // @Router /system/role/rolelist [get] // @Security func (r *RoleApi) GetRoleList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - status := rc.GinCtx.Query("status") - roleName := rc.GinCtx.Query("roleName") - roleKey := rc.GinCtx.Query("roleKey") + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + status := restfulx.QueryParam(rc, "status") + roleName := restfulx.QueryParam(rc, "roleName") + roleKey := restfulx.QueryParam(rc, "roleKey") role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey} if !IsTenantAdmin(rc.LoginAccount.TenantId) { @@ -62,7 +62,7 @@ func (r *RoleApi) GetRoleList(rc *restfulx.ReqCtx) { // @Router /system/role [get] // @Security X-TOKEN func (r *RoleApi) GetRole(rc *restfulx.ReqCtx) { - roleId := restfulx.PathParamInt(rc.GinCtx, "roleId") + roleId := restfulx.PathParamInt(rc, "roleId") role := r.RoleApp.FindOne(int64(roleId)) role.MenuIds = r.RoleApp.GetRoleMeunId(entity.SysRole{RoleId: int64(roleId)}) @@ -80,7 +80,7 @@ func (r *RoleApi) GetRole(rc *restfulx.ReqCtx) { // @Router /system/role [post] func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) { var role entity.SysRole - restfulx.BindJsonAndValid(rc.GinCtx, &role) + restfulx.BindQuery(rc, &role) role.CreateBy = rc.LoginAccount.UserName role.TenantId = rc.LoginAccount.TenantId insert := r.RoleApp.Insert(role) @@ -102,7 +102,7 @@ func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) { // @Router /system/role [put] func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) { var role entity.SysRole - restfulx.BindJsonAndValid(rc.GinCtx, &role) + restfulx.BindQuery(rc, &role) role.UpdateBy = rc.LoginAccount.UserName // 修改角色 r.RoleApp.Update(role) @@ -126,7 +126,7 @@ func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) { // @Router /system/role/changeStatus [put] func (r *RoleApi) UpdateRoleStatus(rc *restfulx.ReqCtx) { var role entity.SysRole - restfulx.BindJsonAndValid(rc.GinCtx, &role) + restfulx.BindQuery(rc, &role) role.UpdateBy = rc.LoginAccount.UserName // 修改角色 r.RoleApp.Update(role) @@ -143,7 +143,7 @@ func (r *RoleApi) UpdateRoleStatus(rc *restfulx.ReqCtx) { // @Router /system/role/dataScope [put] func (r *RoleApi) UpdateRoleDataScope(rc *restfulx.ReqCtx) { var role entity.SysRole - restfulx.BindJsonAndValid(rc.GinCtx, &role) + restfulx.BindQuery(rc, &role) role.UpdateBy = rc.LoginAccount.UserName // 修改角色 update := r.RoleApp.Update(role) @@ -163,7 +163,7 @@ func (r *RoleApi) UpdateRoleDataScope(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/role/{roleId} [delete] func (r *RoleApi) DeleteRole(rc *restfulx.ReqCtx) { - roleId := rc.GinCtx.Param("roleId") + roleId := restfulx.PathParam(rc, "roleId") roleIds := utils.IdsStrToIdsIntGroup(roleId) user := entity.SysUser{} @@ -198,10 +198,10 @@ func (r *RoleApi) DeleteRole(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/type/export [get] func (p *RoleApi) ExportRole(rc *restfulx.ReqCtx) { - filename := rc.GinCtx.Query("filename") - status := rc.GinCtx.Query("status") - roleName := rc.GinCtx.Query("roleName") - roleKey := rc.GinCtx.Query("roleKey") + filename := restfulx.QueryParam(rc, "filename") + status := restfulx.QueryParam(rc, "status") + roleName := restfulx.QueryParam(rc, "roleName") + roleKey := restfulx.QueryParam(rc, "roleKey") role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey} if !IsTenantAdmin(rc.LoginAccount.TenantId) { role.TenantId = rc.LoginAccount.TenantId diff --git a/apps/system/api/system.go b/apps/system/api/system.go index e6e8806..8a5d6b1 100644 --- a/apps/system/api/system.go +++ b/apps/system/api/system.go @@ -5,10 +5,9 @@ import ( "github.com/XM-GO/PandaKit/biz" "github.com/XM-GO/PandaKit/restfulx" "github.com/XM-GO/PandaKit/ws" - "github.com/gin-gonic/gin" + "github.com/emicklei/go-restful/v3" "github.com/gorilla/websocket" "github.com/kakuilan/kgo" - "net/http" "runtime" ) @@ -21,7 +20,7 @@ const ( GB = 1024 * MB ) -func (s *System) ServerInfo(g *gin.Context) { +func (s *System) ServerInfo(request *restful.Request, response *restful.Response) { osDic := make(map[string]any, 0) osDic["goOs"] = runtime.GOOS osDic["arch"] = runtime.GOARCH @@ -48,7 +47,7 @@ func (s *System) ServerInfo(g *gin.Context) { cpuDic["used"] = fmt.Sprintf("%.2f", info.CpuUser*100) cpuDic["free"] = fmt.Sprintf("%.2f", info.CpuFree*100) - g.JSON(http.StatusOK, gin.H{ + response.WriteEntity(map[string]any{ "code": 200, "os": osDic, "mem": memDic, @@ -58,8 +57,8 @@ func (s *System) ServerInfo(g *gin.Context) { } // 连接websocket -func (s *System) ConnectWs(g *gin.Context) { - wsConn, err := ws.Upgrader.Upgrade(g.Writer, g.Request, nil) +func (s *System) ConnectWs(request *restful.Request, response *restful.Response) { + wsConn, err := ws.Upgrader.Upgrade(response, request.Request, nil) defer func() { if err := recover(); &err != nil { wsConn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("websocket 失败: %v", err))) @@ -71,7 +70,7 @@ func (s *System) ConnectWs(g *gin.Context) { panic(any(biz.NewBizErr("升级websocket失败"))) } // 权限校验 - rc := restfulx.NewReqCtx(g) + rc := restfulx.NewReqCtx(request, response) if err = restfulx.PermissionHandler(rc); err != nil { panic(any(biz.NewBizErr("没有权限"))) } diff --git a/apps/system/api/tenant.go b/apps/system/api/tenant.go index 6586f19..5073fe7 100644 --- a/apps/system/api/tenant.go +++ b/apps/system/api/tenant.go @@ -16,17 +16,10 @@ type SysTenantsApi struct { SysTenantsApp services.SysTenantsModel } -// @Summary SysTenants列表数据 -// @Tags SysTenants -// @Param pageSize query int false "页条数" -// @Param pageNum query int false "页码" -// @Success 200 {string} string "{"code": 200, "data": [...]}" -// @Router /system/tenant/list [get] -// @Security func (p *SysTenantsApi) GetSysTenantsList(rc *restfulx.ReqCtx) { data := entity.SysTenants{} - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) list, total := p.SysTenantsApp.FindListPage(pageNum, pageSize, data) @@ -38,11 +31,6 @@ func (p *SysTenantsApi) GetSysTenantsList(rc *restfulx.ReqCtx) { } } -// @Summary SysTenants列表数据 -// @Tags SysTenants -// @Success 200 {string} string "{"code": 200, "data": [...]}" -// @Router /system/tenant/lists [get] -// @Security func (p *SysTenantsApi) GetSysTenantsAll(rc *restfulx.ReqCtx) { list := make([]entity.SysTenants, 0) if rc.LoginAccount.RoleKey == "admin" { @@ -54,61 +42,27 @@ func (p *SysTenantsApi) GetSysTenantsAll(rc *restfulx.ReqCtx) { rc.ResData = list } -// @Summary 获取SysTenants -// @Description 获取JSON -// @Tags SysTenants -// @Param tenantId path int true "tenantId" -// @Success 200 {string} string "{"code": 200, "data": [...]}" -// @Router /system/tenant/{tenantId} [get] -// @Security func (p *SysTenantsApi) GetSysTenants(rc *restfulx.ReqCtx) { - tenantId := restfulx.PathParamInt(rc.GinCtx, "tenantId") + tenantId := restfulx.PathParamInt(rc, "tenantId") p.SysTenantsApp.FindOne(int64(tenantId)) } -// @Summary 添加SysTenants -// @Description 获取JSON -// @Tags SysTenants -// @Accept application/json -// @Product application/json -// @Param data body entity.SysTenants true "data" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": 400, "message": "添加失败"}" -// @Router /system/tenant [post] -// @Security X-TOKEN func (p *SysTenantsApi) InsertSysTenants(rc *restfulx.ReqCtx) { var data entity.SysTenants - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) p.SysTenantsApp.Insert(data) } -// @Summary 修改SysTenants -// @Description 获取JSON -// @Tags SysTenants -// @Accept application/json -// @Product application/json -// @Param data body entity.SysTenants true "body" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": 400, "message": "添加失败"}" -// @Router /system/tenant [put] -// @Security X-TOKEN func (p *SysTenantsApi) UpdateSysTenants(rc *restfulx.ReqCtx) { var data entity.SysTenants - restfulx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindQuery(rc, &data) p.SysTenantsApp.Update(data) } -// @Summary 删除SysTenants -// @Description 删除数据 -// @Tags SysTenants -// @Param tenantId path string true "tenantId" -// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" -// @Success 200 {string} string "{"code": 400, "message": "删除失败"}" -// @Router /system/tenant/{tenantId} [delete] func (p *SysTenantsApi) DeleteSysTenants(rc *restfulx.ReqCtx) { - tenantId := rc.GinCtx.Param("tenantId") + tenantId := rc.Request.PathParameter("tenantId") tenantIds := utils.IdsStrToIdsIntGroup(tenantId) p.SysTenantsApp.Delete(tenantIds) } diff --git a/apps/system/api/user.go b/apps/system/api/user.go index d1d78ac..b5954a8 100644 --- a/apps/system/api/user.go +++ b/apps/system/api/user.go @@ -3,10 +3,11 @@ package api import ( "github.com/XM-GO/PandaKit/token" "github.com/dgrijalva/jwt-go" - "github.com/gin-gonic/gin" + "github.com/emicklei/go-restful/v3" "github.com/kakuilan/kgo" "github.com/mssola/user_agent" - "net/http" + "log" + "pandax/apps/system/api/form" "pandax/apps/system/api/vo" "pandax/apps/system/entity" @@ -16,6 +17,7 @@ import ( "github.com/XM-GO/PandaKit/biz" "github.com/XM-GO/PandaKit/captcha" + filek "github.com/XM-GO/PandaKit/file" "github.com/XM-GO/PandaKit/restfulx" "github.com/XM-GO/PandaKit/utils" "pandax/apps/system/services" @@ -39,9 +41,9 @@ type UserApi struct { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}" // @Router /system/user/getCaptcha [get] -func (u *UserApi) GenerateCaptcha(c *gin.Context) { +func (u *UserApi) GenerateCaptcha(request *restful.Request, response *restful.Response) { id, image := captcha.Generate() - c.JSON(http.StatusOK, map[string]any{"base64Captcha": image, "captchaId": id}) + response.WriteEntity(map[string]any{"base64Captcha": image, "captchaId": id}) } // @Tags Base @@ -50,7 +52,7 @@ func (u *UserApi) GenerateCaptcha(c *gin.Context) { // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}" // @Router /system/user/refreshToken [get] func (u *UserApi) RefreshToken(rc *restfulx.ReqCtx) { - tokenStr := rc.GinCtx.Request.Header.Get("X-TOKEN") + tokenStr := rc.Request.Request.Header.Get("X-TOKEN") j := token.NewJWT("", []byte(global.Conf.Jwt.Key), jwt.SigningMethodHS256) token, err := j.RefreshToken(tokenStr) biz.ErrIsNil(err, "刷新token失败") @@ -65,7 +67,8 @@ func (u *UserApi) RefreshToken(rc *restfulx.ReqCtx) { // @Router /system/user/login [post] func (u *UserApi) Login(rc *restfulx.ReqCtx) { var l form.Login - restfulx.BindJsonAndValid(rc.GinCtx, &l) + restfulx.BindQuery(rc, &l) + log.Println(l) biz.IsTrue(captcha.Verify(l.CaptchaId, l.Captcha), "验证码认证失败") login := u.UserApp.Login(entity.Login{Username: l.Username, Password: l.Password}) @@ -93,12 +96,12 @@ func (u *UserApi) Login(rc *restfulx.ReqCtx) { } var loginLog logEntity.LogLogin - ua := user_agent.New(rc.GinCtx.Request.UserAgent()) - loginLog.Ipaddr = rc.GinCtx.ClientIP() - loginLog.LoginLocation = utils.GetRealAddressByIP(rc.GinCtx.ClientIP()) + ua := user_agent.New(rc.Request.Request.UserAgent()) + loginLog.Ipaddr = rc.Request.Request.RemoteAddr + loginLog.LoginLocation = utils.GetRealAddressByIP(rc.Request.Request.RemoteAddr) loginLog.LoginTime = time.Now() loginLog.Status = "0" - loginLog.Remark = rc.GinCtx.Request.UserAgent() + loginLog.Remark = rc.Request.Request.UserAgent() browserName, browserVersion := ua.Browser() loginLog.Browser = browserName + " " + browserVersion loginLog.Os = ua.OS() @@ -116,7 +119,7 @@ func (u *UserApi) Login(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"success":true,"data":{},"msg":"成功"}" // @Router /system/user/auth [get] func (u *UserApi) Auth(rc *restfulx.ReqCtx) { - userName := rc.GinCtx.Query("username") + userName := restfulx.QueryParam(rc, "username") biz.NotEmpty(userName, "用户名必传") var user entity.SysUser user.Username = userName @@ -141,11 +144,11 @@ func (u *UserApi) Auth(rc *restfulx.ReqCtx) { // @Router /system/user/logout [post] func (u *UserApi) LogOut(rc *restfulx.ReqCtx) { var loginLog logEntity.LogLogin - ua := user_agent.New(rc.GinCtx.Request.UserAgent()) - loginLog.Ipaddr = rc.GinCtx.ClientIP() + ua := user_agent.New(rc.Request.Request.UserAgent()) + loginLog.Ipaddr = rc.Request.Request.RemoteAddr loginLog.LoginTime = time.Now() loginLog.Status = "0" - loginLog.Remark = rc.GinCtx.Request.UserAgent() + loginLog.Remark = rc.Request.Request.UserAgent() browserName, browserVersion := ua.Browser() loginLog.Browser = browserName + " " + browserVersion loginLog.Os = ua.OS() @@ -168,15 +171,16 @@ func (u *UserApi) LogOut(rc *restfulx.ReqCtx) { // @Router /system/user/sysUserList [get] // @Security X-TOKEN func (u *UserApi) GetSysUserList(rc *restfulx.ReqCtx) { - pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) - status := rc.GinCtx.Query("status") - userName := rc.GinCtx.Query("username") - phone := rc.GinCtx.Query("phone") - deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0) + pageNum := restfulx.QueryInt(rc, "pageNum", 1) + pageSize := restfulx.QueryInt(rc, "pageSize", 10) + status := restfulx.QueryParam(rc, "status") + username := restfulx.QueryParam(rc, "username") + phone := restfulx.QueryParam(rc, "phone") + + deptId := restfulx.QueryInt(rc, "deptId", 0) var user entity.SysUser user.Status = status - user.Username = userName + user.Username = username user.Phone = phone user.DeptId = int64(deptId) @@ -236,8 +240,7 @@ func (u *UserApi) GetSysUserProfile(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /system/user/profileAvatar [post] func (u *UserApi) InsetSysUserAvatar(rc *restfulx.ReqCtx) { - form, err := rc.GinCtx.MultipartForm() - biz.ErrIsNil(err, "头像上传失败") + form := rc.Request.Request.MultipartForm files := form.File["upload[]"] guid, _ := kgo.KStr.UuidV4() @@ -245,7 +248,7 @@ func (u *UserApi) InsetSysUserAvatar(rc *restfulx.ReqCtx) { for _, file := range files { global.Log.Info(file.Filename) // 上传文件至指定目录 - biz.ErrIsNil(rc.GinCtx.SaveUploadedFile(file, filPath), "保存头像失败") + biz.ErrIsNil(filek.SaveUploadedFile(file, filPath), "保存头像失败") } sysuser := entity.SysUser{} sysuser.UserId = rc.LoginAccount.UserId @@ -264,7 +267,7 @@ func (u *UserApi) InsetSysUserAvatar(rc *restfulx.ReqCtx) { // @Router /system/user/updatePwd [post] func (u *UserApi) SysUserUpdatePwd(rc *restfulx.ReqCtx) { var pws entity.SysUserPwd - restfulx.BindJsonAndValid(rc.GinCtx, &pws) + restfulx.BindQuery(rc, &pws) user := entity.SysUser{} user.UserId = rc.LoginAccount.UserId @@ -279,7 +282,7 @@ func (u *UserApi) SysUserUpdatePwd(rc *restfulx.ReqCtx) { // @Router /system/user/sysUser/{userId} [get] // @Security func (u *UserApi) GetSysUser(rc *restfulx.ReqCtx) { - userId := restfulx.PathParamInt(rc.GinCtx, "userId") + userId := restfulx.PathParamInt(rc, "userId") user := entity.SysUser{} user.UserId = int64(userId) @@ -369,7 +372,7 @@ func (u *UserApi) GetUserRolePost(rc *restfulx.ReqCtx) { // @Router /system/user/sysUser [post] func (u *UserApi) InsertSysUser(rc *restfulx.ReqCtx) { var sysUser entity.SysUser - restfulx.BindJsonAndValid(rc.GinCtx, &sysUser) + restfulx.BindQuery(rc, &sysUser) sysUser.CreateBy = rc.LoginAccount.UserName u.UserApp.Insert(sysUser) } @@ -385,7 +388,7 @@ func (u *UserApi) InsertSysUser(rc *restfulx.ReqCtx) { // @Router /system/user/sysUser [put] func (u *UserApi) UpdateSysUser(rc *restfulx.ReqCtx) { var sysUser entity.SysUser - restfulx.BindJsonAndValid(rc.GinCtx, &sysUser) + restfulx.BindQuery(rc, &sysUser) sysUser.CreateBy = rc.LoginAccount.UserName u.UserApp.Update(sysUser) } @@ -401,7 +404,7 @@ func (u *UserApi) UpdateSysUser(rc *restfulx.ReqCtx) { // @Router /system/user/sysUser [put] func (u *UserApi) UpdateSysUserStu(rc *restfulx.ReqCtx) { var sysUser entity.SysUser - restfulx.BindJsonAndValid(rc.GinCtx, &sysUser) + restfulx.BindQuery(rc, &sysUser) sysUser.CreateBy = rc.LoginAccount.UserName u.UserApp.Update(sysUser) } @@ -414,9 +417,8 @@ func (u *UserApi) UpdateSysUserStu(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/user/sysuser/{userId} [delete] func (u *UserApi) DeleteSysUser(rc *restfulx.ReqCtx) { - userIds := rc.GinCtx.Param("userId") - us := utils.IdsStrToIdsIntGroup(userIds) - u.UserApp.Delete(us) + userIds := restfulx.PathParam(rc, "userId") + u.UserApp.Delete(utils.IdsStrToIdsIntGroup(userIds)) } // @Summary 导出用户 @@ -429,14 +431,14 @@ func (u *UserApi) DeleteSysUser(rc *restfulx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/type/export [get] func (u *UserApi) ExportUser(rc *restfulx.ReqCtx) { - filename := rc.GinCtx.Query("filename") - status := rc.GinCtx.Query("status") - userName := rc.GinCtx.Query("username") - phone := rc.GinCtx.Query("phone") + filename := restfulx.QueryParam(rc, "filename") + status := restfulx.QueryParam(rc, "status") + username := restfulx.QueryParam(rc, "username") + phone := restfulx.QueryParam(rc, "phone") var user entity.SysUser user.Status = status - user.Username = userName + user.Username = username user.Phone = phone if !IsTenantAdmin(rc.LoginAccount.TenantId) { diff --git a/apps/system/router/api.go b/apps/system/router/api.go index 571ec71..213b798 100644 --- a/apps/system/router/api.go +++ b/apps/system/router/api.go @@ -1,43 +1,78 @@ package router import ( + "github.com/XM-GO/PandaKit/casbin" "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitApiRouter(router *gin.RouterGroup) { +func InitApiRouter(container *restful.Container) { s := &api.SystemApiApi{ ApiApp: services.SysApiModelDao, } - api := router.Group("api") - api.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取api分页列表").Handle(s.GetApiList) - }) + ws := new(restful.WebService) + ws.Path("/system/api").Produces(restful.MIME_JSON) + tags := []string{"api"} - api.GET("all", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取所有api").Handle(s.GetAllApis) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取api分页列表").Handle(s.GetApiList) + }). + Doc("获取api分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysApi{}). + Returns(200, "OK", []entity.SysApi{})) - api.GET("getPolicyPathByRoleId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取角色拥有的api权限").Handle(s.GetPolicyPathByRoleId) - }) + ws.Route(ws.GET("/all").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取所有api").Handle(s.GetAllApis) + }). + Doc("获取所有api"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysApi{}). + Returns(200, "OK", []entity.SysApi{})) - api.GET(":id", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取api信息").Handle(s.GetApiById) - }) + ws.Route(ws.GET("/getPolicyPathByRoleId").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取角色拥有的api权限").Handle(s.GetPolicyPathByRoleId) + }). + Doc("获取角色拥有的api权限"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]casbin.CasbinRule{}). + Returns(200, "OK", []casbin.CasbinRule{})) - api.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加api信息").Handle(s.CreateApi) - }) + ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取api信息").Handle(s.GetApiById) + }). + Doc("获取api信息"). + Param(ws.PathParameter("id", "Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysApi{}). // on the response + Returns(200, "OK", entity.SysApi{}). + Returns(404, "Not Found", nil)) - api.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改api信息").Handle(s.UpdateApi) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加api信息").Handle(s.CreateApi) + }). + Doc("添加api信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysApi{})) - api.DELETE(":id", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除api信息").Handle(s.DeleteApi) - }) + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改api信息").Handle(s.UpdateApi) + }). + Doc("修改api信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysApi{})) // from the request + + ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除api信息").Handle(s.DeleteApi) + }). + Doc("删除api信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("id", "id").DataType("int"))) + + container.Add(ws) } diff --git a/apps/system/router/config.go b/apps/system/router/config.go index 88c4b21..0e81bd3 100644 --- a/apps/system/router/config.go +++ b/apps/system/router/config.go @@ -2,38 +2,69 @@ package router import ( "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitConfigRouter(router *gin.RouterGroup) { +func InitConfigRouter(container *restful.Container) { s := &api.ConfigApi{ ConfigApp: services.SysSysConfigModelDao, } - config := router.Group("config") - config.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取配置分页列表").Handle(s.GetConfigList) - }) + ws := new(restful.WebService) + ws.Path("/system/config").Produces(restful.MIME_JSON) + tags := []string{"config"} - config.GET("configKey", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取配置列表通过ConfigKey").Handle(s.GetConfigListByKey) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取配置分页列表").Handle(s.GetConfigList) + }). + Doc("获取配置分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysConfig{}). + Returns(200, "OK", []entity.SysConfig{})) - config.GET(":configId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取配置信息").Handle(s.GetConfig) - }) + ws.Route(ws.GET("/configKey").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取配置列表通过ConfigKey").Handle(s.GetConfigListByKey) + }). + Doc("获取配置列表通过ConfigKey"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysConfig{}). + Returns(200, "OK", []entity.SysConfig{})) - config.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加配置信息").Handle(s.InsertConfig) - }) + ws.Route(ws.GET("/{configId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取配置信息").Handle(s.GetConfig) + }). + Doc("获取配置信息"). + Param(ws.PathParameter("configId", "configId").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysConfig{}). // on the response + Returns(200, "OK", entity.SysConfig{}). + Returns(404, "Not Found", nil)) - config.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改配置信息").Handle(s.UpdateConfig) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加配置信息").Handle(s.InsertConfig) + }). + Doc("添加配置信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysConfig{})) // from the request + + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改配置信息").Handle(s.UpdateConfig) + }). + Doc("修改配置信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysConfig{})) // from the request + + ws.Route(ws.DELETE("/{configId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除配置信息").Handle(s.DeleteConfig) + }). + Doc("删除配置信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("configId", "多id 1,2,3").DataType("string"))) + + container.Add(ws) - config.DELETE(":configId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除配置信息").Handle(s.DeleteConfig) - }) } diff --git a/apps/system/router/dept.go b/apps/system/router/dept.go index 6438c13..278e098 100644 --- a/apps/system/router/dept.go +++ b/apps/system/router/dept.go @@ -2,44 +2,80 @@ package router import ( "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitDeptRouter(router *gin.RouterGroup) { - r := &api.DeptApi{ +func InitDeptRouter(container *restful.Container) { + s := &api.DeptApi{ DeptApp: services.SysDeptModelDao, RoleApp: services.SysRoleModelDao, UserApp: services.SysUserModelDao, } - dept := router.Group("dept") - dept.GET("roleDeptTreeSelect/:roleId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取角色部门树").Handle(r.GetDeptTreeRoleSelect) - }) + ws := new(restful.WebService) + ws.Path("/system/dept").Produces(restful.MIME_JSON) + tags := []string{"dept"} - dept.GET("deptTree", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取所有部门树").Handle(r.GetDeptTree) - }) + ws.Route(ws.GET("/roleDeptTreeSelect/{roleId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取角色部门树").Handle(s.GetDeptTreeRoleSelect) + }). + Doc("获取角色部门树"). + Param(ws.PathParameter("roleId", "角色Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(map[string]any{}). // on the response + Returns(404, "Not Found", nil)) - dept.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取部门列表").Handle(r.GetDeptList) - }) + ws.Route(ws.GET("/deptTree").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取所有部门树").Handle(s.GetDeptTree) + }). + Doc("获取所有部门树"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysDept{}). // on the response + Returns(404, "Not Found", nil)) - dept.GET(":deptId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取部门信息").Handle(r.GetDept) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取部门列表").Handle(s.GetDeptList) + }). + Doc("获取部门列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysDept{}). + Returns(200, "OK", []entity.SysDept{})) - dept.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加部门信息").Handle(r.InsertDept) - }) + ws.Route(ws.GET("/{deptId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取部门信息").Handle(s.GetDept) + }). + Doc("获取部门信息"). + Param(ws.PathParameter("deptId", "部门Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysDept{}). // on the response + Returns(200, "OK", entity.SysDept{}). + Returns(404, "Not Found", nil)) - dept.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改部门信息").Handle(r.UpdateDept) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加部门信息").Handle(s.InsertDept) + }). + Doc("添加部门信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysDept{})) // from the request + + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改部门信息").Handle(s.UpdateDept) + }). + Doc("修改部门信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysDept{})) // from the request + + ws.Route(ws.DELETE("/{deptId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除部门信息").Handle(s.DeleteDept) + }). + Doc("删除部门信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("deptId", "多id 1,2,3").DataType("int"))) + + container.Add(ws) - dept.DELETE(":deptId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除部门信息").Handle(r.DeleteDept) - }) } diff --git a/apps/system/router/dict.go b/apps/system/router/dict.go index e407a08..eb1f0cc 100644 --- a/apps/system/router/dict.go +++ b/apps/system/router/dict.go @@ -2,64 +2,107 @@ package router import ( "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitDictRouter(router *gin.RouterGroup) { +func InitDictRouter(container *restful.Container) { s := &api.DictApi{ DictType: services.SysDictTypeModelDao, DictData: services.SysDictDataModelDao, } - dict := router.Group("dict") + ws := new(restful.WebService) + ws.Path("/system/dict").Produces(restful.MIME_JSON) + tags := []string{"dict"} - dict.GET("type/list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取字典类型分页列表").Handle(s.GetDictTypeList) - }) + ws.Route(ws.GET("/type/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取字典类型分页列表").Handle(s.GetDictTypeList) + }). + Doc("获取字典类型分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Returns(200, "OK", []entity.SysDictType{})) - dict.GET("type/:dictId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取字典类型信息").Handle(s.GetDictType) - }) + ws.Route(ws.GET("/type/{dictId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取字典类型信息").Handle(s.GetDictType) + }). + Doc("获取字典类型信息"). + Param(ws.PathParameter("dictId", "Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Returns(200, "OK", []entity.SysDictType{})) - dict.POST("type", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加字典类型信息").Handle(s.InsertDictType) - }) + ws.Route(ws.POST("/type").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加字典类型信息").Handle(s.InsertDictType) + }). + Doc("添加字典类型信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysDictType{})) - dict.PUT("type", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改字典类型信息").Handle(s.UpdateDictType) - }) + ws.Route(ws.PUT("/type").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改字典类型信息").Handle(s.UpdateDictType) + }). + Doc("修改字典类型信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysDictType{})) - dict.DELETE("type/:dictId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除字典类型信息").Handle(s.DeleteDictType) - }) + ws.Route(ws.DELETE("/type/{dictId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除字典类型信息").Handle(s.DeleteDictType) + }). + Doc("删除字典类型信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("dictId", "多id 1,2,3").DataType("string"))) - dict.GET("type/export", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("导出字典类型信息").Handle(s.ExportDictType) - }) + ws.Route(ws.GET("/type/export").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("导出字典类型信息").Handle(s.ExportDictType) + }). + Doc("导出字典类型信息"). + Metadata(restfulspec.KeyOpenAPITags, tags)) - dict.GET("data/list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取字典数据分页列表").Handle(s.GetDictDataList) - }) + ws.Route(ws.GET("/data/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取字典数据分页列表").Handle(s.GetDictDataList) + }). + Doc("获取字典数据分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Returns(200, "OK", []entity.SysDictData{})) - dict.GET("data/type", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取字典数据列表通过字典类型").Handle(s.GetDictDataListByDictType) - }) + ws.Route(ws.GET("/data/type").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取字典数据列表通过字典类型").Handle(s.GetDictDataListByDictType) + }). + Doc("获取字典数据列表通过字典类型"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Returns(200, "OK", []entity.SysDictType{})) - dict.GET("data/:dictCode", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取字典数据信息").Handle(s.GetDictData) - }) + ws.Route(ws.GET("/data/{dictCode}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取字典数据信息").Handle(s.GetDictData) + }). + Doc("获取字典数据信息"). + Param(ws.PathParameter("dictCode", "dictCode").DataType("string")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Returns(200, "OK", []entity.SysDictType{})) - dict.POST("data", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加字典数据信息").Handle(s.InsertDictData) - }) + ws.Route(ws.POST("/data").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加字典数据信息").Handle(s.InsertDictData) + }). + Doc("添加字典数据信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysDictData{})) - dict.PUT("data", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改字典数据信息").Handle(s.UpdateDictData) - }) + ws.Route(ws.PUT("/data").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改字典数据信息").Handle(s.UpdateDictData) + }). + Doc("修改字典数据信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysDictData{})) - dict.DELETE("data/:dictCode", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除字典数据信息").Handle(s.DeleteDictData) - }) + ws.Route(ws.DELETE("data/{dictCode}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除字典数据信息").Handle(s.DeleteDictData) + }). + Doc("删除字典数据信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("dictCode", "多id 1,2,3").DataType("string"))) + + container.Add(ws) } diff --git a/apps/system/router/menu.go b/apps/system/router/menu.go index cdc7106..cd62196 100644 --- a/apps/system/router/menu.go +++ b/apps/system/router/menu.go @@ -2,53 +2,96 @@ package router import ( "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitMenuRouter(router *gin.RouterGroup) { +func InitMenuRouter(container *restful.Container) { s := &api.MenuApi{ MenuApp: services.SysMenuModelDao, RoleApp: services.SysRoleModelDao, RoleMenuApp: services.SysRoleMenuModelDao, DeptApp: services.SysDeptModelDao, } - menu := router.Group("menu") + ws := new(restful.WebService) + ws.Path("/system/menu").Produces(restful.MIME_JSON) + tags := []string{"menu"} - menu.GET("menuTreeSelect", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取菜单树").WithNeedToken(false).WithNeedCasbin(false).Handle(s.GetMenuTreeSelect) - }) + ws.Route(ws.GET("/menuTreeSelect").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取菜单树").WithNeedToken(false).WithNeedCasbin(false).Handle(s.GetMenuTreeSelect) + }). + Doc("获取菜单树"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysMenu{}). + Returns(200, "OK", []entity.SysMenu{})) - menu.GET("menuRole", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取角色菜单").Handle(s.GetMenuRole) - }) + ws.Route(ws.GET("/menuRole").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取角色菜单").Handle(s.GetMenuRole) + }). + Doc("获取角色菜单"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.MenuRole{}). + Returns(200, "OK", []entity.MenuRole{})) - menu.GET("roleMenuTreeSelect/:roleId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取角色菜单树").Handle(s.GetMenuTreeRoleSelect) - }) + ws.Route(ws.GET("/roleMenuTreeSelect/{roleId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取角色菜单树").Handle(s.GetMenuTreeRoleSelect) + }). + Doc("获取角色菜单树"). + Param(ws.PathParameter("roleId", "Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysMenu{}). // on the response + Returns(200, "OK", entity.SysMenu{}). + Returns(404, "Not Found", nil)) - menu.GET("menuPaths", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取角色菜单路径列表").Handle(s.GetMenuPaths) - }) + ws.Route(ws.GET("/menuPaths").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取角色菜单路径列表").Handle(s.GetMenuPaths) + }). + Doc("获取角色菜单"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.MenuPath{}). + Returns(200, "OK", []entity.MenuPath{})) - menu.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取菜单列表").Handle(s.GetMenuList) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取菜单列表").Handle(s.GetMenuList) + }). + Doc("获取菜单列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysMenu{}). + Returns(200, "OK", []entity.SysMenu{})) - menu.GET(":menuId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取菜单信息").Handle(s.GetMenu) - }) + ws.Route(ws.GET("/{menuId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取菜单信息").Handle(s.GetMenu) + }). + Doc("获取菜单信息"). + Param(ws.PathParameter("menuId", "Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysMenu{}). // on the response + Returns(200, "OK", entity.SysMenu{}). + Returns(404, "Not Found", nil)) - menu.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加菜单信息").Handle(s.InsertMenu) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加菜单信息").Handle(s.InsertMenu) + }). + Doc("添加菜单信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysMenu{})) // from the request - menu.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改菜单信息").Handle(s.UpdateMenu) - }) + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改菜单信息").Handle(s.UpdateMenu) + }). + Doc("修改菜单信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysMenu{})) // from the request - menu.DELETE(":menuId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除菜单信息").Handle(s.DeleteMenu) - }) + ws.Route(ws.DELETE("/{menuId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除菜单信息").Handle(s.DeleteMenu) + }). + Doc("删除SysTenant信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("menuId", "多id 1,2,3").DataType("string"))) + + container.Add(ws) } diff --git a/apps/system/router/notice.go b/apps/system/router/notice.go index f5f448c..90a41c3 100644 --- a/apps/system/router/notice.go +++ b/apps/system/router/notice.go @@ -2,31 +2,51 @@ package router import ( "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitNoticeRouter(router *gin.RouterGroup) { +func InitNoticeRouter(container *restful.Container) { s := &api.NoticeApi{ DeptApp: services.SysDeptModelDao, NoticeApp: services.SysNoticeModelDao, } - notice := router.Group("notice") + ws := new(restful.WebService) + ws.Path("/system/notice").Produces(restful.MIME_JSON) + tags := []string{"notice"} - notice.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取通知分页列表").Handle(s.GetNoticeList) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取通知分页列表").Handle(s.GetNoticeList) + }). + Doc("获取通知分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysNotice{}). + Returns(200, "OK", []entity.SysNotice{})) - notice.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加通知信息").Handle(s.InsertNotice) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加通知信息").Handle(s.InsertNotice) + }). + Doc("添加通知信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysNotice{})) // from the request - notice.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改通知信息").Handle(s.UpdateNotice) - }) + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改通知信息").Handle(s.UpdateNotice) + }). + Doc("修改通知信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysNotice{})) // from the request + + ws.Route(ws.DELETE("/{noticeId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除通知信息").Handle(s.DeleteNotice) + }). + Doc("删除通知信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("noticeId", "多id 1,2,3").DataType("string"))) + + container.Add(ws) - notice.DELETE(":noticeId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除通知信息").Handle(s.DeleteNotice) - }) } diff --git a/apps/system/router/post.go b/apps/system/router/post.go index 5baf738..32de1b9 100644 --- a/apps/system/router/post.go +++ b/apps/system/router/post.go @@ -2,36 +2,61 @@ package router import ( "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitPostRouter(router *gin.RouterGroup) { +func InitPostRouter(container *restful.Container) { s := &api.PostApi{ PostApp: services.SysPostModelDao, UserApp: services.SysUserModelDao, RoleApp: services.SysRoleModelDao, } - post := router.Group("post") + ws := new(restful.WebService) + ws.Path("/system/post").Produces(restful.MIME_JSON) + tags := []string{"post"} - post.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取岗位分页列表").Handle(s.GetPostList) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取岗位分页列表").Handle(s.GetPostList) + }). + Doc("获取岗位分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysPost{}). + Returns(200, "OK", []entity.SysPost{})) - post.GET(":postId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取岗位信息").Handle(s.GetPost) - }) + ws.Route(ws.GET("/{postId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取岗位信息").Handle(s.GetPost) + }). + Doc("获取岗位信息"). + Param(ws.PathParameter("postId", "Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysPost{}). // on the response + Returns(200, "OK", entity.SysPost{}). + Returns(404, "Not Found", nil)) - post.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加岗位信息").Handle(s.InsertPost) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加岗位信息").Handle(s.InsertPost) + }). + Doc("添加岗位信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysPost{})) // from the request - post.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改岗位信息").Handle(s.UpdatePost) - }) + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改岗位信息").Handle(s.UpdatePost) + }). + Doc("修改岗位信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysPost{})) // from the request - post.DELETE(":postId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除岗位信息").Handle(s.DeletePost) - }) + ws.Route(ws.DELETE("/{postId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除岗位信息").Handle(s.DeletePost) + }). + Doc("删除岗位信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("postId", "多id 1,2,3").DataType("string"))) + + container.Add(ws) } diff --git a/apps/system/router/role.go b/apps/system/router/role.go index 2e865ee..bca81ad 100644 --- a/apps/system/router/role.go +++ b/apps/system/router/role.go @@ -2,49 +2,80 @@ package router import ( "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitRoleRouter(router *gin.RouterGroup) { +func InitRoleRouter(container *restful.Container) { s := &api.RoleApi{ RoleApp: services.SysRoleModelDao, RoleMenuApp: services.SysRoleMenuModelDao, RoleDeptApp: services.SysRoleDeptModelDao, UserApp: services.SysUserModelDao, } - role := router.Group("role") + ws := new(restful.WebService) + ws.Path("/system/role").Produces(restful.MIME_JSON) + tags := []string{"role"} - role.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取角色分页列表").Handle(s.GetRoleList) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取角色分页列表").Handle(s.GetRoleList) + }). + Doc("获取角色分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysRole{}). + Returns(200, "OK", []entity.SysRole{})) - role.GET(":roleId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取角色信息").Handle(s.GetRole) - }) + ws.Route(ws.GET("/{roleId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取角色信息").Handle(s.GetRole) + }). + Doc("获取角色信息"). + Param(ws.PathParameter("roleId", "Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysRole{}). // on the response + Returns(200, "OK", entity.SysRole{}). + Returns(404, "Not Found", nil)) - role.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加角色信息").Handle(s.InsertRole) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加角色信息").Handle(s.InsertRole) + }). + Doc("添加角色信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysRole{})) // from the request - role.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改角色信息").Handle(s.UpdateRole) - }) + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改角色信息").Handle(s.UpdateRole) + }). + Doc("修改角色信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysRole{})) - role.PUT("changeStatus", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改角色状态").Handle(s.UpdateRoleStatus) - }) + ws.Route(ws.PUT("/changeStatus").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改角色状态").Handle(s.UpdateRoleStatus) + }). + Doc("修改角色状态"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysRole{})) - role.PUT("dataScope", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改角色部门权限").Handle(s.UpdateRoleDataScope) - }) + ws.Route(ws.PUT("/dataScope").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改角色部门权限").Handle(s.UpdateRoleDataScope) + }). + Doc("修改角色部门权限"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysRole{})) - role.DELETE(":roleId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除角色信息").Handle(s.DeleteRole) - }) + ws.Route(ws.DELETE("/{roleId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除角色信息").Handle(s.DeleteRole) + }). + Doc("删除角色信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("roleId", "多id 1,2,3").DataType("string"))) - role.GET("export", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("导出角色信息").Handle(s.ExportRole) - }) + ws.Route(ws.GET("/export").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("导出角色信息").Handle(s.ExportRole) + }). + Doc("导出角色信息"). + Metadata(restfulspec.KeyOpenAPITags, tags)) } diff --git a/apps/system/router/system.go b/apps/system/router/system.go index 0c186d8..40be1c2 100644 --- a/apps/system/router/system.go +++ b/apps/system/router/system.go @@ -1,16 +1,15 @@ package router import ( - "github.com/gin-gonic/gin" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" ) -func InitSystemRouter(router *gin.RouterGroup) { +func InitSystemRouter(container *restful.Container) { s := &api.System{} - sys := router.Group("") - - { - sys.GET("", s.ConnectWs) - sys.GET("server", s.ServerInfo) - } + ws := new(restful.WebService) + ws.Path("/system").Produces(restful.MIME_JSON) + ws.Route(ws.GET("/").To(s.ConnectWs)) + ws.Route(ws.GET("/server").To(s.ServerInfo)) + container.Add(ws) } diff --git a/apps/system/router/tenant.go b/apps/system/router/tenant.go index 668b32e..37986ad 100644 --- a/apps/system/router/tenant.go +++ b/apps/system/router/tenant.go @@ -8,38 +8,67 @@ package router import ( "github.com/XM-GO/PandaKit/restfulx" - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" ) -func InitSysTenantRouter(router *gin.RouterGroup) { +func InitSysTenantRouter(container *restful.Container) { s := &api.SysTenantsApi{ SysTenantsApp: services.SysTenantModelDao, } - routerGroup := router.Group("tenant") + ws := new(restful.WebService) + ws.Path("/system/tenant").Produces(restful.MIME_JSON) + tags := []string{"tenant"} - routerGroup.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取SysTenant分页列表").Handle(s.GetSysTenantsList) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取SysTenant分页列表").Handle(s.GetSysTenantsList) + }). + Doc("获取SysTenant分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysTenants{}). + Returns(200, "OK", []entity.SysTenants{})) - routerGroup.GET("lists", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取SysTenant列表").Handle(s.GetSysTenantsAll) - }) + ws.Route(ws.GET("/lists").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取SysTenant列表").Handle(s.GetSysTenantsAll) + }). + Doc("获取SysTenant列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysTenants{}). + Returns(200, "OK", []entity.SysTenants{})) - routerGroup.GET(":tenantId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取SysTenant信息").Handle(s.GetSysTenants) - }) + ws.Route(ws.GET("/{tenantId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取SysTenant信息").Handle(s.GetSysTenants) + }). + Doc("获取SysTenant信息"). + Param(ws.PathParameter("tenantId", "租户Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysTenants{}). // on the response + Returns(200, "OK", entity.SysTenants{}). + Returns(404, "Not Found", nil)) - routerGroup.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加SysTenant信息").Handle(s.InsertSysTenants) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加SysTenant信息").Handle(s.InsertSysTenants) + }). + Doc("添加SysTenant信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysTenants{})) // from the request - routerGroup.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改SysTenant信息").Handle(s.UpdateSysTenants) - }) + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改SysTenant信息").Handle(s.UpdateSysTenants) + }). + Doc("修改SysTenant信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysTenants{})) // from the request - routerGroup.DELETE(":tenantId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除SysTenant信息").Handle(s.DeleteSysTenants) - }) + ws.Route(ws.DELETE("/{tenantId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除SysTenant信息").Handle(s.DeleteSysTenants) + }). + Doc("删除SysTenant信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("tenantId", "多id 1,2,3").DataType("string"))) + + container.Add(ws) } diff --git a/apps/system/router/user.go b/apps/system/router/user.go index eae97cd..7539c37 100644 --- a/apps/system/router/user.go +++ b/apps/system/router/user.go @@ -1,15 +1,17 @@ package router import ( - "github.com/gin-gonic/gin" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "pandax/apps/system/api" + "pandax/apps/system/entity" "pandax/apps/system/services" "github.com/XM-GO/PandaKit/restfulx" logServices "pandax/apps/log/services" ) -func InitUserRouter(router *gin.RouterGroup) { +func InitUserRouter(container *restful.Container) { s := &api.UserApi{ RoleApp: services.SysRoleModelDao, MenuApp: services.SysMenuModelDao, @@ -19,61 +21,112 @@ func InitUserRouter(router *gin.RouterGroup) { DeptApp: services.SysDeptModelDao, PostApp: services.SysPostModelDao, } - user := router.Group("user") - // 获取验证码 - user.GET("getCaptcha", s.GenerateCaptcha) + ws := new(restful.WebService) + ws.Path("/system/user").Produces(restful.MIME_JSON) + tags := []string{"user"} - user.POST("login", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("登录").WithNeedToken(false).WithNeedCasbin(false).Handle(s.Login) - }) - user.GET("auth", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("认证信息").WithNeedCasbin(false).Handle(s.Auth) - }) - user.POST("logout", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("退出登录").WithNeedToken(false).WithNeedCasbin(false).Handle(s.LogOut) - }) + ws.Route(ws.GET("/getCaptcha").To(s.GenerateCaptcha).Doc("获取验证码")) - user.GET("list", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("得到用户分页列表").Handle(s.GetSysUserList) - }) + ws.Route(ws.POST("/login").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithNeedToken(false).WithNeedCasbin(false).WithLog("登录").Handle(s.Login) + }). + Doc("登录"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysUser{})) // from the request - user.POST("avatar", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改用户头像").Handle(s.InsetSysUserAvatar) - }) + ws.Route(ws.POST("/logout").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithNeedToken(false).WithNeedCasbin(false).WithLog("退出登录").Handle(s.LogOut) + }). + Doc("退出登录"). + Metadata(restfulspec.KeyOpenAPITags, tags)) - user.PUT("pwd", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改用户密码").Handle(s.SysUserUpdatePwd) - }) + ws.Route(ws.GET("/auth").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithNeedCasbin(false).WithLog("认证信息").Handle(s.Auth) + }). + Doc("认证信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysUser{}). + Returns(200, "OK", entity.SysUser{})) - user.GET("getById/:userId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取用户信息").Handle(s.GetSysUser) - }) + ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("得到用户分页列表").Handle(s.GetSysUserList) + }). + Doc("得到用户分页列表"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes([]entity.SysUser{}). + Returns(200, "OK", []entity.SysUser{})) - user.GET("getInit", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取初始化角色岗位信息(添加用户初始化)").Handle(s.GetSysUserInit) - }) + ws.Route(ws.GET("/getById/{userId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取用户信息").Handle(s.GetSysUser) + }). + Doc("获取用户信息"). + Param(ws.PathParameter("userId", "Id").DataType("int").DefaultValue("1")). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysUser{}). // on the response + Returns(200, "OK", entity.SysUser{}). + Returns(404, "Not Found", nil)) - user.GET("getRoPo", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("获取用户角色岗位信息(添加用户初始化)").Handle(s.GetUserRolePost) - }) + ws.Route(ws.GET("/getInit").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取初始化角色岗位信息(添加用户初始化)").Handle(s.GetSysUserInit) + }). + Doc("获取初始化角色岗位信息(添加用户初始化)"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Writes(entity.SysUser{}). // on the response + Returns(200, "OK", entity.SysUser{}). + Returns(404, "Not Found", nil)) - user.POST("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("添加用户信息").Handle(s.InsertSysUser) - }) + ws.Route(ws.GET("/getRoPo").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("获取用户角色岗位信息(添加用户初始化)").Handle(s.GetUserRolePost) + }). + Doc("获取用户角色岗位信息(添加用户初始化)"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Returns(200, "OK", entity.SysUser{}). + Returns(404, "Not Found", nil)) - user.PUT("", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改用户信息").Handle(s.UpdateSysUser) - }) + ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("添加用户信息").Handle(s.InsertSysUser) + }). + Doc("添加用户信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Reads(entity.SysUser{})) // from the request - user.PUT("changeStatus", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("修改用户状态").Handle(s.UpdateSysUserStu) - }) + ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改用户信息").Handle(s.UpdateSysUser) + }). + Doc("修改用户信息"). + Metadata(restfulspec.KeyOpenAPITags, tags)) // from the request - user.DELETE(":userId", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("删除用户信息").Handle(s.DeleteSysUser) - }) + ws.Route(ws.PUT("/changeStatus").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改用户状态").Handle(s.UpdateSysUserStu) + }). + Doc("修改用户状态"). + Metadata(restfulspec.KeyOpenAPITags, tags)) // from the request + + ws.Route(ws.DELETE("/{userId}").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("删除用户信息").Handle(s.DeleteSysUser) + }). + Doc("删除用户信息"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("userId", "多id 1,2,3").DataType("string"))) + + ws.Route(ws.POST("/avatar").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改用户头像").Handle(s.InsetSysUserAvatar) + }). + Doc("修改用户头像"). + Metadata(restfulspec.KeyOpenAPITags, tags)) + + ws.Route(ws.PUT("pwd").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("修改用户密码").Handle(s.SysUserUpdatePwd) + }). + Doc("修改用户密码"). + Metadata(restfulspec.KeyOpenAPITags, tags)) + + ws.Route(ws.GET("/export").To(func(request *restful.Request, response *restful.Response) { + restfulx.NewReqCtx(request, response).WithLog("导出用户信息").Handle(s.ExportUser) + }). + Doc("导出用户信息"). + Metadata(restfulspec.KeyOpenAPITags, tags)) + + container.Add(ws) - user.GET("export", func(c *gin.Context) { - restfulx.NewReqCtx(c).WithLog("导出用户信息").Handle(s.ExportUser) - }) } diff --git a/config.yml b/config.yml index 77d335e..19f8776 100644 --- a/config.yml +++ b/config.yml @@ -19,17 +19,6 @@ server: enable: false key-file: ./resource/default.key cert-file: ./resource/default.pem - # 静态资源 - static: - - relative-path: /assets - root: ./static/assets - # 静态文件 - static-file: - - relative-path: / - filepath: ./static/index.html - - relative-path: /favicon.ico - filepath: ./static/favicon.ico - jwt: key: mykey # 过期时间单位秒 7天 @@ -40,9 +29,9 @@ redis: port: 6379 mysql: - host: 127.0.0.1:3306 - username: root - password: 123456 + host: 47.104.252.2:3306 + username: pandax + password: pandax db-name: pandax config: charset=utf8&loc=Local&parseTime=true diff --git a/go.mod b/go.mod index 141bd77..f07ad9d 100644 --- a/go.mod +++ b/go.mod @@ -3,39 +3,41 @@ module pandax go 1.18 require ( - github.com/XM-GO/PandaKit v0.0.0-20220802093028-195951cd859d github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/didip/tollbooth v4.0.2+incompatible + github.com/emicklei/go-restful-openapi/v2 v2.9.0 + github.com/emicklei/go-restful/v3 v3.9.0 github.com/gin-gonic/gin v1.7.4 + github.com/go-openapi/spec v0.20.6 github.com/gorilla/websocket v1.4.2 github.com/kakuilan/kgo v0.1.8 github.com/mssola/user_agent v0.5.3 github.com/robfig/cron/v3 v3.0.1 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.5.0 - github.com/swaggo/gin-swagger v1.3.3 github.com/swaggo/swag v1.7.4 golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 + google.golang.org/grpc v1.48.0 gorm.io/gorm v1.22.3 ) require ( github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect github.com/KyleBanks/depth v1.2.1 // indirect - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect + github.com/XM-GO/PandaKit v0.0.0-20220803022710-dde3115ce2f9 // indirect github.com/aliyun/aliyun-oss-go-sdk v2.2.0+incompatible // indirect github.com/brianvoe/gofakeit/v6 v6.0.2 // indirect github.com/casbin/casbin/v2 v2.37.4 // indirect github.com/casbin/gorm-adapter/v3 v3.4.6 // indirect github.com/denisenkom/go-mssqldb v0.11.0 // indirect + github.com/emicklei/go-restful v2.16.0+incompatible // indirect + github.com/emicklei/go-restful-swagger12 v0.0.0-20201014110547-68ccff494617 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-ole/go-ole v1.2.5 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.19.5 // indirect - github.com/go-openapi/spec v0.20.3 // indirect - github.com/go-openapi/swag v0.19.14 // indirect + github.com/go-openapi/jsonreference v0.20.0 // indirect + github.com/go-openapi/swag v0.19.15 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.8.0 // indirect @@ -87,6 +89,7 @@ require ( golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect golang.org/x/tools v0.1.0 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0 // indirect @@ -95,3 +98,5 @@ require ( gorm.io/driver/sqlserver v1.2.1 // indirect gorm.io/plugin/dbresolver v1.1.0 // indirect ) + +replace github.com/XM-GO/PandaKit => D:\workspace\go\project\PandaX\PandaKit diff --git a/go.sum b/go.sum index 1de9e9d..dd6b153 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= @@ -5,17 +7,20 @@ github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY= github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/XM-GO/PandaKit v0.0.0-20220802093028-195951cd859d h1:fsnlIH5+QO4RzlfWDSzEdpqw7OisKtR4YHEWASAx7Fw= -github.com/XM-GO/PandaKit v0.0.0-20220802093028-195951cd859d/go.mod h1:st1syDrEJDdK/p3c3p72VLndebNFOVPKyC3AGYNBWng= +github.com/XM-GO/PandaKit v0.0.0-20220802142840-39f271c60434 h1:XNrFgNQKWuedkyKynY20P834mnmjl0i0TQqpNgqtLT4= +github.com/XM-GO/PandaKit v0.0.0-20220802142840-39f271c60434/go.mod h1:Z+TJfmc3yB/AbQP6LjqYe/XqLH596917qK0pUp0FEdA= +github.com/XM-GO/PandaKit v0.0.0-20220803000751-6f77cc922152 h1:6YCJQCEMcRu39INnV22uJhTyLfIOVeAe+ZAZOJ4of7A= +github.com/XM-GO/PandaKit v0.0.0-20220803000751-6f77cc922152/go.mod h1:A/0dFObLVa7Yzeq6cMmcjNUoajSgcLkEJglLc41BO3w= +github.com/XM-GO/PandaKit v0.0.0-20220803022710-dde3115ce2f9 h1:RwQ4AMAmkp9jE71iZ5vHEfRzYhkKXKyT9QOhVtTFMLg= +github.com/XM-GO/PandaKit v0.0.0-20220803022710-dde3115ce2f9/go.mod h1:A/0dFObLVa7Yzeq6cMmcjNUoajSgcLkEJglLc41BO3w= github.com/aliyun/aliyun-oss-go-sdk v2.2.0+incompatible h1:ht2+VfbXtNLGhCsnTMc6/N26nSTBK6qdhktjYyjJQkk= github.com/aliyun/aliyun-oss-go-sdk v2.2.0+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= github.com/brianvoe/gofakeit/v6 v6.0.2 h1:MDvplMAKJMcKZDwQvsIbhT7BV/8UF/3EEy2n14ynUyA= github.com/brianvoe/gofakeit/v6 v6.0.2/go.mod h1:palrJUk4Fyw38zIFB/uBZqsgzW5VsNllhHKKwAebzew= @@ -23,6 +28,15 @@ github.com/casbin/casbin/v2 v2.37.4 h1:RWSKPjaZ8JlOBlcW1bI/FTII8OPxvQ9jVy9JwyNL6 github.com/casbin/casbin/v2 v2.37.4/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/casbin/gorm-adapter/v3 v3.4.6 h1:JuLN3/CBTPPlvNyQqY3uXt4Zqnt+hs2sM353aCtLTP4= github.com/casbin/gorm-adapter/v3 v3.4.6/go.mod h1:6mIYgpByH/uSkfCv4G/vr/12cVZc3rXBQ9KrqS9oTUU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -40,14 +54,26 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumC github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/didip/tollbooth v4.0.2+incompatible h1:fVSa33JzSz0hoh2NxpwZtksAzAgd7zjmGO20HCZtF4M= github.com/didip/tollbooth v4.0.2+incompatible/go.mod h1:A9b0665CE6l1KmzpDws2++elm/CsuWBMa5Jv4WY0PEY= +github.com/emicklei/go-restful v2.16.0+incompatible h1:rgqiKNjTnFQA6kkhFe16D8epTksy9HQ1MyrbDXSdYhM= +github.com/emicklei/go-restful v2.16.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emicklei/go-restful-openapi/v2 v2.9.0 h1:djsWqjhI0EVYfkLCCX6jZxUkLmYUq2q9tt09ZbixfyE= +github.com/emicklei/go-restful-openapi/v2 v2.9.0/go.mod h1:VKNgZyYviM1hnyrjD9RDzP2RuE94xTXxV+u6MGN4v4k= +github.com/emicklei/go-restful-swagger12 v0.0.0-20201014110547-68ccff494617 h1:jri9taV4TK9oItoWJCofXJi21Dp/k25u32NnfphqLAY= +github.com/emicklei/go-restful-swagger12 v0.0.0-20201014110547-68ccff494617/go.mod h1:qr0VowGBT4CS4Q8vFF8BSeKz34PuqKGxs/L0IAQA9DQ= +github.com/emicklei/go-restful/v3 v3.7.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= +github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/gzip v0.0.3 h1:etUaeesHhEORpZMp18zoOhepboiWnFtXrBZxszWUn4k= -github.com/gin-contrib/gzip v0.0.3/go.mod h1:YxxswVZIqOvcHEQpsSn+QF5guQtO1dCfy0shBPy4jFc= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM= github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -57,13 +83,18 @@ github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.5 h1:1WJP/wi4OjB4iV8KVbH73rQaoialJrqv8gitZLxGLtM= github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= -github.com/go-openapi/spec v0.20.3 h1:uH9RQ6vdyPSs2pSy9fL8QPspDF2AMIMPtmK5coSSjtQ= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= github.com/go-openapi/spec v0.20.3/go.mod h1:gG4F8wdEDN+YPBMVnzE85Rbhf+Th2DTvA9nFPQ5AYEg= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/spec v0.20.6 h1:ich1RQ3WDbfoeTqTAb+5EIxNmpKVJZWBNah9RAT0jIQ= +github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng= github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -72,7 +103,6 @@ github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-playground/validator/v10 v10.8.0 h1:1kAa0fCrnpv+QYdkdcRzrRM7AyYs5o8+jZdJCz9xj6k= github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk= @@ -88,23 +118,43 @@ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= 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/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= @@ -231,6 +281,7 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdkk= github.com/qiniu/go-sdk/v7 v7.11.0 h1:Cdx/1E3ybv0OFKnkGwoDN/t6bCCntjrWhwWuRaqI3XQ= github.com/qiniu/go-sdk/v7 v7.11.0/go.mod h1:btsaOc8CA3hdVloULfFdDgDc+g4f3TDZEFsDY0BLE+w= @@ -241,6 +292,7 @@ github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9 github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= 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/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= @@ -274,9 +326,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= -github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= -github.com/swaggo/gin-swagger v1.3.3 h1:XHyYmeNVFG5PbyWHG4jXtxOm2P4kiZapDCWsyDDiQ/I= -github.com/swaggo/gin-swagger v1.3.3/go.mod h1:ymsZuGpbbu+S7ZoQ49QPpZoDBj6uqhb8WizgQPVgWl0= github.com/swaggo/swag v1.7.4 h1:up+ixy8yOqJKiFcuhMgkuYuF4xnevuhnFAXXF8OSfNg= github.com/swaggo/swag v1.7.4/go.mod h1:zD8h6h4SPv7t3l+4BKdRquqW1ASWjKZgT6Qv9z3kNqI= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= @@ -293,6 +342,7 @@ github.com/xuri/excelize/v2 v2.4.1 h1:veeeFLAJwsNEBPBlDepzPIYS1eLyBVcXNZUW79exZ1 github.com/xuri/excelize/v2 v2.4.1/go.mod h1:rSu0C3papjzxQA3sdK8cU544TebhrPUoTOaGPIh0Q1A= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -318,30 +368,46 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA= golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk= golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y= golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -354,9 +420,11 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -377,9 +445,12 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 h1:GZokNIeuVkl3aZHJchRrr13WCsols02MLUcz1U9is6M= golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -395,8 +466,33 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= +google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -435,4 +531,6 @@ gorm.io/gorm v1.22.3 h1:/JS6z+GStEQvJNW3t1FTwJwG/gZ+A7crFdRqtvG5ehA= gorm.io/gorm v1.22.3/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/plugin/dbresolver v1.1.0 h1:cegr4DeprR6SkLIQlKhJLYxH8muFbJ4SmnojXvoeb00= gorm.io/plugin/dbresolver v1.1.0/go.mod h1:tpImigFAEejCALOttyhWqsy4vfa2Uh/vAUVnL5IRF7Y= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/main.go b/main.go index 64fb13a..7b725e2 100644 --- a/main.go +++ b/main.go @@ -1,16 +1,20 @@ package main import ( + "context" "github.com/XM-GO/PandaKit/config" "github.com/XM-GO/PandaKit/logger" "github.com/XM-GO/PandaKit/restfulx" "github.com/XM-GO/PandaKit/starter" "github.com/spf13/cobra" + "log" "os" + "os/signal" "pandax/apps/job/jobs" "pandax/pkg/global" "pandax/pkg/initialize" "pandax/pkg/middleware" + "syscall" ) var ( @@ -41,7 +45,18 @@ var rootCmd = &cobra.Command{ jobs.InitJob() jobs.Setup() }() - starter.RunWebServer(initialize.InitRouter()) + + app := initialize.InitRouter() + + app.Start(context.TODO()) + stop := make(chan os.Signal, 1) + signal.Notify(stop, syscall.SIGTERM, os.Interrupt) + <-stop + + if err := app.Stop(context.TODO()); err != nil { + log.Fatal("fatal rudder app stop: %s", err) + os.Exit(-3) + } }, } diff --git a/pkg/initialize/router.go b/pkg/initialize/router.go index 88ca677..76c8844 100644 --- a/pkg/initialize/router.go +++ b/pkg/initialize/router.go @@ -1,83 +1,47 @@ package initialize import ( - "fmt" "pandax/pkg/global" + "pandax/pkg/transport" - ginSwagger "github.com/swaggo/gin-swagger" - - "github.com/swaggo/gin-swagger/swaggerFiles" - - devRouter "pandax/apps/develop/router" - jobRouter "pandax/apps/job/router" - logRouter "pandax/apps/log/router" - resRouter "pandax/apps/resource/router" sysRouter "pandax/apps/system/router" "pandax/pkg/middleware" _ "pandax/docs" - - "net/http" - - "github.com/gin-gonic/gin" ) -func InitRouter() *gin.Engine { +func InitRouter() *transport.HttpServer { // server配置 serverConfig := global.Conf.Server - gin.SetMode(serverConfig.Model) + server := transport.NewHttpServer(serverConfig.GetPort()) - var router = gin.New() - router.MaxMultipartMemory = 8 << 20 - - // 没有路由即 404返回 - router.NoRoute(func(g *gin.Context) { - g.JSON(http.StatusNotFound, gin.H{"code": 404, "msg": fmt.Sprintf("not found '%s:%s'", g.Request.Method, g.Request.URL.Path)}) - }) - - // 设置静态资源 - if staticConfs := serverConfig.Static; staticConfs != nil { - for _, scs := range *staticConfs { - router.Static(scs.RelativePath, scs.Root) - } - - } - // 设置静态文件 - if staticFileConfs := serverConfig.StaticFile; staticFileConfs != nil { - for _, sfs := range *staticFileConfs { - router.StaticFile(sfs.RelativePath, sfs.Filepath) - } - } + container := server.Container // 是否允许跨域 if serverConfig.Cors { - router.Use(middleware.Cors()) + container.Filter(middleware.Cors(container).Filter) } // 流量限制 if serverConfig.Rate.Enable { - router.Use(middleware.Rate()) + container.Filter(middleware.Rate) } - // api接口 - router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) // 设置路由组 - sys := router.Group("system") { - sysRouter.InitSysTenantRouter(sys) - sysRouter.InitSystemRouter(sys) - sysRouter.InitDeptRouter(sys) - sysRouter.InitConfigRouter(sys) - sysRouter.InitApiRouter(sys) - sysRouter.InitDictRouter(sys) - sysRouter.InitMenuRouter(sys) - sysRouter.InitRoleRouter(sys) - sysRouter.InitPostRouter(sys) - sysRouter.InitUserRouter(sys) - sysRouter.InitNoticeRouter(sys) + sysRouter.InitSysTenantRouter(container) + sysRouter.InitSystemRouter(container) + sysRouter.InitDeptRouter(container) + sysRouter.InitConfigRouter(container) + sysRouter.InitApiRouter(container) + sysRouter.InitDictRouter(container) + sysRouter.InitMenuRouter(container) + sysRouter.InitRoleRouter(container) + sysRouter.InitPostRouter(container) + sysRouter.InitUserRouter(container) + sysRouter.InitNoticeRouter(container) } - // 任务 - job := router.Group("job") + /*// 任务 { - jobRouter.InitJobRouter(job) + jobRouter.InitJobRouter() } //日志系统 log := router.Group("log") @@ -95,6 +59,9 @@ func InitRouter() *gin.Engine { { resRouter.InitResOssRouter(res) resRouter.InitResEmailsRouter(res) - } - return router + }*/ + // api接口 + middleware.SwaggerConfig(container) + //http.Handle("/apidocs/", http.StripPrefix("/apidocs/", http.FileServer(http.Dir("/Users/emicklei/Projects/swagger-ui/dist")))) + return server } diff --git a/pkg/middleware/cors.go b/pkg/middleware/cors.go index fcc4cca..24cf4d9 100644 --- a/pkg/middleware/cors.go +++ b/pkg/middleware/cors.go @@ -1,27 +1,17 @@ package middleware import ( - "net/http" - - "github.com/gin-gonic/gin" + "github.com/emicklei/go-restful/v3" ) // 处理跨域请求,支持options访问 -func Cors() gin.HandlerFunc { - return func(c *gin.Context) { - method := c.Request.Method - origin := c.Request.Header.Get("Origin") - c.Header("Access-Control-Allow-Origin", origin) - c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id") - c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT") - c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type") - c.Header("Access-Control-Allow-Credentials", "true") +func Cors(wsContainer *restful.Container) restful.CrossOriginResourceSharing { + cors := restful.CrossOriginResourceSharing{ + ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"}, + AllowedHeaders: []string{"Content-Type", "AccessToken", "X-CSRF-Token", "Authorization", "Token", "X-Token", "X-User-Id"}, + AllowedMethods: []string{"POST", "GET", "OPTIONS", "DELETE", "PUT"}, + CookiesAllowed: false, + Container: wsContainer} - // 放行所有OPTIONS方法 - if method == "OPTIONS" { - c.AbortWithStatus(http.StatusNoContent) - } - // 处理请求 - c.Next() - } + return cors } diff --git a/pkg/middleware/oper.go b/pkg/middleware/oper.go index 08d33ba..5bf0833 100644 --- a/pkg/middleware/oper.go +++ b/pkg/middleware/oper.go @@ -9,7 +9,7 @@ import ( ) func OperationHandler(rc *restfulx.ReqCtx) error { - c := rc.GinCtx + c := rc.Request // 请求操作不做记录 if c.Request.Method == http.MethodGet || rc.LoginAccount == nil { return nil @@ -23,8 +23,8 @@ func OperationHandler(rc *restfulx.ReqCtx) error { Method: c.Request.Method, OperName: rc.LoginAccount.UserName, OperUrl: c.Request.URL.Path, - OperIp: c.ClientIP(), - OperLocation: utils.GetRealAddressByIP(c.ClientIP()), + OperIp: c.Request.RemoteAddr, + OperLocation: utils.GetRealAddressByIP(c.Request.RemoteAddr), OperParam: "", Status: "0", } diff --git a/pkg/middleware/rate.go b/pkg/middleware/rate.go index a63d505..075827f 100644 --- a/pkg/middleware/rate.go +++ b/pkg/middleware/rate.go @@ -2,7 +2,7 @@ package middleware import ( "github.com/didip/tollbooth" - "github.com/gin-gonic/gin" + "github.com/emicklei/go-restful/v3" "pandax/pkg/global" ) @@ -12,17 +12,14 @@ import ( * @Date 2022/1/19 8:28 **/ -//限流中间件 -func Rate() gin.HandlerFunc { +//Rate 限流中间件 +func Rate(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) { lmt := tollbooth.NewLimiter(global.Conf.Server.Rate.RateNum, nil) lmt.SetMessage("已经超出接口请求限制,稍后再试.") - return func(c *gin.Context) { - httpError := tollbooth.LimitByRequest(lmt, c.Writer, c.Request) - if httpError != nil { - c.Data(httpError.StatusCode, lmt.GetMessageContentType(), []byte(httpError.Message)) - c.Abort() - } else { - c.Next() - } + httpError := tollbooth.LimitByRequest(lmt, resp, req.Request) + if httpError != nil { + resp.WriteErrorString(httpError.StatusCode, httpError.Message) + return } + chain.ProcessFilter(req, resp) } diff --git a/pkg/middleware/swagger.go b/pkg/middleware/swagger.go new file mode 100644 index 0000000..34d53af --- /dev/null +++ b/pkg/middleware/swagger.go @@ -0,0 +1,44 @@ +package middleware + +import ( + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" + "github.com/go-openapi/spec" +) + +/** + * @Description + * @Author 熊猫 + * @Date 2022/8/3 9:16 + **/ + +func SwaggerConfig(wsContainer *restful.Container) { + config := restfulspec.Config{ + WebServices: wsContainer.RegisteredWebServices(), + APIPath: "/apidocs.json", + PostBuildSwaggerObjectHandler: enrichSwaggerObject} + wsContainer.Add(restfulspec.NewOpenAPIService(config)) +} + +func enrichSwaggerObject(swo *spec.Swagger) { + swo.Info = &spec.Info{ + InfoProps: spec.InfoProps{ + Title: "Pandax API", + Description: "Restful Api", + Contact: &spec.ContactInfo{ + ContactInfoProps: spec.ContactInfoProps{ + Name: "PandaX", + Email: "PandaX@doe.rp", + URL: "https://github.com/XM-GO/PandaX", + }, + }, + License: &spec.License{ + LicenseProps: spec.LicenseProps{ + Name: "MIT", + URL: "https://github.com/XM-GO/PandaX", + }, + }, + Version: "1.0.0", + }, + } +} diff --git a/pkg/transport/grpc_server.go b/pkg/transport/grpc_server.go new file mode 100644 index 0000000..a5321fb --- /dev/null +++ b/pkg/transport/grpc_server.go @@ -0,0 +1,48 @@ +package transport + +import ( + "context" + "fmt" + "google.golang.org/grpc" + "net" + "pandax/pkg/global" +) + +type GrpcServer struct { + Addr string + srv *grpc.Server +} + +func NewServer(addr string) *GrpcServer { + return &GrpcServer{ + Addr: addr, + srv: grpc.NewServer(), + } +} + +func (s *GrpcServer) GetServe() *grpc.Server { + return s.srv +} + +func (s *GrpcServer) Type() Type { + return TypeGRPC +} + +func (s *GrpcServer) Start(ctx context.Context) error { + l, err := net.Listen("tcp", s.Addr) + if err != nil { + return fmt.Errorf("error listen addr: %w", err) + } + global.Log.Debugf("GRPC Server listen: %s", s.Addr) + go func() { + if err := s.srv.Serve(l); err != nil { + global.Log.Errorf("error http serve: %s", err) + } + }() + return nil +} + +func (s *GrpcServer) Stop(ctx context.Context) error { + s.srv.Stop() + return nil +} diff --git a/pkg/transport/http_server.go b/pkg/transport/http_server.go new file mode 100644 index 0000000..3dd40c7 --- /dev/null +++ b/pkg/transport/http_server.go @@ -0,0 +1,59 @@ +package transport + +import ( + "context" + "github.com/XM-GO/PandaKit/logger" + "github.com/emicklei/go-restful/v3" + "net/http" + "pandax/pkg/global" +) + +type HttpServer struct { + Addr string + srv *http.Server + + Container *restful.Container +} + +func NewHttpServer(addr string) *HttpServer { + c := restful.NewContainer() + c.EnableContentEncoding(true) + restful.TraceLogger(&httpLog{}) + restful.SetLogger(&httpLog{}) + return &HttpServer{ + Addr: addr, + Container: c, + srv: &http.Server{ + Addr: addr, + Handler: c, + }, + } +} + +func (s *HttpServer) Type() Type { + return TypeHTTP +} + +func (s *HttpServer) Start(ctx context.Context) error { + global.Log.Debugf("HTTP Server listen: %s", s.Addr) + go func() { + if err := s.srv.ListenAndServe(); err != nil { + global.Log.Errorf("error http serve: %s", err) + } + }() + return nil +} + +func (s *HttpServer) Stop(ctx context.Context) error { + return s.srv.Shutdown(ctx) +} + +type httpLog struct{} + +func (t *httpLog) Print(v ...any) { + logger.Log.Debug(v...) +} + +func (t *httpLog) Printf(format string, v ...any) { + logger.Log.Debugf(format, v...) +} diff --git a/pkg/transport/transport.go b/pkg/transport/transport.go new file mode 100644 index 0000000..7693fed --- /dev/null +++ b/pkg/transport/transport.go @@ -0,0 +1,19 @@ +package transport + +import ( + "context" +) + +type Type string + +const ( + TypeHTTP Type = "HTTP" + TypeGRPC Type = "GRPC" +) + +// Server is transport server. +type Server interface { + Type() Type + Start(context.Context) error + Stop(context.Context) error +}