diff --git a/README.md b/README.md index a62a755..02ba5a3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## 🌈平台简介 -* 采用前后端分离的模式,后端采用GO语言,通过对GIn自封装框架ginx,代码更简洁,逻辑更清晰 +* 采用前后端分离的模式,后端采用GO语言,通过对GIn自封装框架restfulx,代码更简洁,逻辑更清晰 * 前端采用VUE3.0+ TypeScript + vite2 + Element-plus:[PandaUI](https://github.com/PandaGoAdmin/PandaUi),适配手机、平板、pc 内置多种ui功能减少开发量 * 高效率的开发,使用代码生成器可以一键生成前后端代码,可在线预览代码,减少代码开发量。。 * 完善的权限认证系统:完善的权限认证系统,包含,菜单按钮权限,api权限,部门权限。 @@ -101,7 +101,7 @@ | 项目 | 说明 | | --- | --- | -| `base` | 自封装ginx和工具类 | +| `base` | 自封装restfulx和工具类 | | `docs` | api接口文档 | | `initialize` | 初始化 | | `resource` | 文件导出目录 | diff --git a/apps/develop/api/gen.go b/apps/develop/api/gen.go index e04bb48..fc206cf 100644 --- a/apps/develop/api/gen.go +++ b/apps/develop/api/gen.go @@ -1,9 +1,9 @@ package api import ( + "github.com/XM-GO/PandaKit/restfulx" "pandax/apps/develop/gen" "pandax/apps/develop/services" - "pandax/base/ginx" ) type GenApi struct { @@ -17,8 +17,8 @@ type GenApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/gen/preview/{tableId} [get] // @Security X-TOKEN -func (e *GenApi) Preview(rc *ginx.ReqCtx) { - tableId := ginx.PathParamInt(rc.GinCtx, "tableId") +func (e *GenApi) Preview(rc *restfulx.ReqCtx) { + tableId := restfulx.PathParamInt(rc.GinCtx, "tableId") rc.ResData = gen.Preview(int64(tableId)) } @@ -29,8 +29,8 @@ func (e *GenApi) Preview(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/gen/code/{tableId} [get] // @Security X-TOKEN -func (e *GenApi) GenCode(rc *ginx.ReqCtx) { - tableId := ginx.PathParamInt(rc.GinCtx, "tableId") +func (e *GenApi) GenCode(rc *restfulx.ReqCtx) { + tableId := restfulx.PathParamInt(rc.GinCtx, "tableId") gen.GenCode(int64(tableId)) } @@ -41,8 +41,8 @@ func (e *GenApi) GenCode(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/gen/configure/{tableId} [get] // @Security X-TOKEN -func (e *GenApi) GenConfigure(rc *ginx.ReqCtx) { - tableId := ginx.PathParamInt(rc.GinCtx, "tableId") - menuId := ginx.QueryInt(rc.GinCtx, "menuId", 0) +func (e *GenApi) GenConfigure(rc *restfulx.ReqCtx) { + tableId := restfulx.PathParamInt(rc.GinCtx, "tableId") + menuId := restfulx.QueryInt(rc.GinCtx, "menuId", 0) gen.GenConfigure(tableId, menuId) } diff --git a/apps/develop/api/table.go b/apps/develop/api/table.go index a100e6c..d7184f7 100644 --- a/apps/develop/api/table.go +++ b/apps/develop/api/table.go @@ -1,11 +1,11 @@ package api import ( + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/develop/entity" "pandax/apps/develop/gen" "pandax/apps/develop/services" - "pandax/base/ginx" - "pandax/base/utils" "strings" "sync" ) @@ -22,9 +22,9 @@ type GenTableApi struct { // @Param pageNum query int false "pageNum / 页码" // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/table/db/list [get] -func (g *GenTableApi) GetDBTableList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") list, total := g.GenTableApp.FindDbTablesListPage(pageNum, pageSize, entity.DBTables{TableName: tableName}) rc.ResData = map[string]any{ @@ -44,9 +44,9 @@ func (g *GenTableApi) GetDBTableList(rc *ginx.ReqCtx) { // @Param pageIndex query int false "pageIndex / 页码" // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/table/list [get] -func (g *GenTableApi) GetTablePage(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") list, total := g.GenTableApp.FindListPage(pageNum, pageSize, entity.DevGenTable{TableName: tableName, TableComment: tableComment}) @@ -65,8 +65,8 @@ func (g *GenTableApi) GetTablePage(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/table/info/{tableId} [get] // @Security Bearer -func (g *GenTableApi) GetTableInfo(rc *ginx.ReqCtx) { - tableId := ginx.PathParamInt(rc.GinCtx, "tableId") +func (g *GenTableApi) GetTableInfo(rc *restfulx.ReqCtx) { + tableId := restfulx.PathParamInt(rc.GinCtx, "tableId") result := g.GenTableApp.FindOne(entity.DevGenTable{TableId: int64(tableId)}, true) mp := make(map[string]any) mp["list"] = result.Columns @@ -81,7 +81,7 @@ func (g *GenTableApi) GetTableInfo(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/table/info/tableName [get] // @Security X-TOKEN -func (g *GenTableApi) GetTableInfoByName(rc *ginx.ReqCtx) { +func (g *GenTableApi) GetTableInfoByName(rc *restfulx.ReqCtx) { tableName := rc.GinCtx.Query("tableName") result := g.GenTableApp.FindOne(entity.DevGenTable{TableName: tableName}, true) mp := make(map[string]any) @@ -96,7 +96,7 @@ func (g *GenTableApi) GetTableInfoByName(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /develop/code/table/tableTree [get] // @Security X-TOKEN -func (g *GenTableApi) GetTableTree(rc *ginx.ReqCtx) { +func (g *GenTableApi) GetTableTree(rc *restfulx.ReqCtx) { rc.ResData = g.GenTableApp.FindTree(entity.DevGenTable{}) } @@ -110,7 +110,7 @@ func (g *GenTableApi) GetTableTree(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /develop/code/table [post] // @Security Bearer -func (g *GenTableApi) Insert(rc *ginx.ReqCtx) { +func (g *GenTableApi) Insert(rc *restfulx.ReqCtx) { tablesList := strings.Split(rc.GinCtx.Query("tables"), ",") wg := sync.WaitGroup{} @@ -136,9 +136,9 @@ func (g *GenTableApi) Insert(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /develop/code/table [put] // @Security Bearer -func (g *GenTableApi) Update(rc *ginx.ReqCtx) { +func (g *GenTableApi) Update(rc *restfulx.ReqCtx) { var data entity.DevGenTable - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) g.GenTableApp.Update(data) } @@ -150,7 +150,7 @@ func (g *GenTableApi) Update(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": -1, "message": "删除失败"}" // @Router /develop/code/table/{tableId} [delete] -func (g *GenTableApi) Delete(rc *ginx.ReqCtx) { +func (g *GenTableApi) Delete(rc *restfulx.ReqCtx) { tableIds := rc.GinCtx.Param("tableId") group := utils.IdsStrToIdsIntGroup(tableIds) g.GenTableApp.Delete(group) diff --git a/apps/develop/entity/dev_gen_table.go b/apps/develop/entity/dev_gen_table.go index a2b5765..0d16202 100644 --- a/apps/develop/entity/dev_gen_table.go +++ b/apps/develop/entity/dev_gen_table.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type DevGenTable struct { TableId int64 `gorm:"primaryKey;autoIncrement" json:"tableId"` // 编号 diff --git a/apps/develop/gen/gen.go b/apps/develop/gen/gen.go index bf2548a..38fa585 100644 --- a/apps/develop/gen/gen.go +++ b/apps/develop/gen/gen.go @@ -3,6 +3,8 @@ package gen import ( "bytes" "fmt" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/utils" "github.com/kakuilan/kgo" "log" "os" @@ -10,8 +12,6 @@ import ( "pandax/apps/develop/services" sysEntity "pandax/apps/system/entity" sysServices "pandax/apps/system/services" - "pandax/base/biz" - "pandax/base/utils" "pandax/pkg/global" "strconv" "strings" diff --git a/apps/develop/router/gen.go b/apps/develop/router/gen.go index 1c46dd2..30b41e3 100644 --- a/apps/develop/router/gen.go +++ b/apps/develop/router/gen.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/develop/api" "pandax/apps/develop/services" - "pandax/base/ginx" ) func InitGenRouter(router *gin.RouterGroup) { @@ -15,14 +15,14 @@ func InitGenRouter(router *gin.RouterGroup) { gen := router.Group("gen") gen.GET("preview/:tableId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取生成代码视图").Handle(genApi.Preview) + restfulx.NewReqCtx(c).WithLog("获取生成代码视图").Handle(genApi.Preview) }) gen.GET("code/:tableId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("生成代码").Handle(genApi.GenCode) + restfulx.NewReqCtx(c).WithLog("生成代码").Handle(genApi.GenCode) }) gen.GET("configure/:tableId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("生成配置").Handle(genApi.GenConfigure) + restfulx.NewReqCtx(c).WithLog("生成配置").Handle(genApi.GenConfigure) }) } diff --git a/apps/develop/router/table.go b/apps/develop/router/table.go index 9bb504b..05dad44 100644 --- a/apps/develop/router/table.go +++ b/apps/develop/router/table.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/develop/api" "pandax/apps/develop/services" - "pandax/base/ginx" ) func InitGenTableRouter(router *gin.RouterGroup) { @@ -15,34 +15,34 @@ func InitGenTableRouter(router *gin.RouterGroup) { gen := router.Group("table") gen.GET("/db/list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取数据库列表").Handle(genApi.GetDBTableList) + restfulx.NewReqCtx(c).WithLog("获取数据库列表").Handle(genApi.GetDBTableList) }) gen.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取表列表").Handle(genApi.GetTablePage) + restfulx.NewReqCtx(c).WithLog("获取表列表").Handle(genApi.GetTablePage) }) gen.GET("/info/tableName", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取表信息By tableName").Handle(genApi.GetTableInfoByName) + restfulx.NewReqCtx(c).WithLog("获取表信息By tableName").Handle(genApi.GetTableInfoByName) }) gen.GET("info/:tableId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取表信息").Handle(genApi.GetTableInfo) + restfulx.NewReqCtx(c).WithLog("获取表信息").Handle(genApi.GetTableInfo) }) gen.GET("tableTree", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取表树").Handle(genApi.GetTableTree) + restfulx.NewReqCtx(c).WithLog("获取表树").Handle(genApi.GetTableTree) }) gen.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("新增表").Handle(genApi.Insert) + restfulx.NewReqCtx(c).WithLog("新增表").Handle(genApi.Insert) }) gen.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改表").Handle(genApi.Update) + restfulx.NewReqCtx(c).WithLog("修改表").Handle(genApi.Update) }) gen.DELETE(":tableId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除表").Handle(genApi.Delete) + restfulx.NewReqCtx(c).WithLog("删除表").Handle(genApi.Delete) }) } diff --git a/apps/develop/services/gen_table.go b/apps/develop/services/gen_table.go index e7155e5..3bed062 100644 --- a/apps/develop/services/gen_table.go +++ b/apps/develop/services/gen_table.go @@ -2,9 +2,9 @@ package services import ( "errors" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/develop/entity" - "pandax/base/biz" - "pandax/base/utils" "pandax/pkg/global" ) diff --git a/apps/develop/services/gen_table_column.go b/apps/develop/services/gen_table_column.go index fef61bf..41d69c7 100644 --- a/apps/develop/services/gen_table_column.go +++ b/apps/develop/services/gen_table_column.go @@ -2,8 +2,8 @@ package services import ( "errors" + "github.com/XM-GO/PandaKit/biz" "pandax/apps/develop/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/job/api/job.go b/apps/job/api/job.go index c7b2d02..93d27a6 100644 --- a/apps/job/api/job.go +++ b/apps/job/api/job.go @@ -1,13 +1,13 @@ package api import ( + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/job/api/from" "pandax/apps/job/entity" "pandax/apps/job/jobs" "pandax/apps/job/services" - "pandax/base/biz" - "pandax/base/ginx" - "pandax/base/utils" ) type JobApi struct { @@ -24,9 +24,9 @@ type JobApi struct { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /job/job [post] // @Security X-TOKEN -func (j *JobApi) CreateJob(rc *ginx.ReqCtx) { +func (j *JobApi) CreateJob(rc *restfulx.ReqCtx) { var job entity.SysJob - ginx.BindJsonAndValid(rc.GinCtx, &job) + restfulx.BindJsonAndValid(rc.GinCtx, &job) job.CreateBy = rc.LoginAccount.UserName j.JobApp.Insert(job) @@ -43,9 +43,9 @@ func (j *JobApi) CreateJob(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /job/list [get] // @Security -func (j *JobApi) GetJobList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") @@ -66,8 +66,8 @@ func (j *JobApi) GetJobList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /job/{jobId} [get] // @Security -func (j *JobApi) GetJob(rc *ginx.ReqCtx) { - jobId := ginx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("jobId")) +func (j *JobApi) GetJob(rc *restfulx.ReqCtx) { + jobId := restfulx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("jobId")) rc.ResData = j.JobApp.FindOne(int64(jobId)) } @@ -81,9 +81,9 @@ func (j *JobApi) GetJob(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /job [put] // @Security X-TOKEN -func (l *JobApi) UpdateJob(rc *ginx.ReqCtx) { +func (l *JobApi) UpdateJob(rc *restfulx.ReqCtx) { var job entity.SysJob - ginx.BindJsonAndValid(rc.GinCtx, &job) + restfulx.BindJsonAndValid(rc.GinCtx, &job) l.JobApp.Update(job) } @@ -94,7 +94,7 @@ func (l *JobApi) UpdateJob(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /job/{jobId} [delete] -func (l *JobApi) DeleteJob(rc *ginx.ReqCtx) { +func (l *JobApi) DeleteJob(rc *restfulx.ReqCtx) { jobIds := rc.GinCtx.Param("jobId") group := utils.IdsStrToIdsIntGroup(jobIds) l.JobApp.Delete(group) @@ -107,8 +107,8 @@ func (l *JobApi) DeleteJob(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /job/stop/{jobId} [get] -func (l *JobApi) StopJobForService(rc *ginx.ReqCtx) { - jobId := ginx.PathParamInt(rc.GinCtx, "jobId") +func (l *JobApi) StopJobForService(rc *restfulx.ReqCtx) { + jobId := restfulx.PathParamInt(rc.GinCtx, "jobId") job := l.JobApp.FindOne(int64(jobId)) jobs.Remove(jobs.Crontab, job.EntryId) } @@ -119,8 +119,8 @@ func (l *JobApi) StopJobForService(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /job/stop/{jobId} [get] -func (l *JobApi) StartJobForService(rc *ginx.ReqCtx) { - jobId := ginx.PathParamInt(rc.GinCtx, "jobId") +func (l *JobApi) StartJobForService(rc *restfulx.ReqCtx) { + jobId := restfulx.PathParamInt(rc.GinCtx, "jobId") job := l.JobApp.FindOne(int64(jobId)) biz.IsTrue(job.Status == "0", "以关闭的任务不能开启") @@ -162,9 +162,9 @@ func (l *JobApi) StartJobForService(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /job/changeStatus [put] // @Security X-TOKEN -func (l *JobApi) UpdateStatusJob(rc *ginx.ReqCtx) { +func (l *JobApi) UpdateStatusJob(rc *restfulx.ReqCtx) { var job from.JobStatus - ginx.BindJsonAndValid(rc.GinCtx, &job) + restfulx.BindJsonAndValid(rc.GinCtx, &job) l.JobApp.Update(entity.SysJob{JobId: job.JobId, Status: job.Status}) } diff --git a/apps/job/entity/job.go b/apps/job/entity/job.go index 18a9dac..74e65c2 100644 --- a/apps/job/entity/job.go +++ b/apps/job/entity/job.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type SysJob struct { JobId int64 `json:"jobId" gorm:"primaryKey;autoIncrement"` // 编码 diff --git a/apps/job/jobs/jobbase.go b/apps/job/jobs/jobbase.go index 43d19e2..962c813 100644 --- a/apps/job/jobs/jobbase.go +++ b/apps/job/jobs/jobbase.go @@ -8,7 +8,7 @@ import ( logEntity "pandax/apps/log/entity" logServices "pandax/apps/log/services" - "pandax/base/httpclient" + "github.com/XM-GO/PandaKit/httpclient" "pandax/pkg/global" "sync" "time" diff --git a/apps/job/router/job.go b/apps/job/router/job.go index 4b0f996..4408436 100644 --- a/apps/job/router/job.go +++ b/apps/job/router/job.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/job/api" "pandax/apps/job/services" - "pandax/base/ginx" ) func InitJobRouter(router *gin.RouterGroup) { @@ -15,34 +15,34 @@ func InitJobRouter(router *gin.RouterGroup) { job := router.Group("") job.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取Job列表").Handle(jobApi.GetJobList) + restfulx.NewReqCtx(c).WithLog("获取Job列表").Handle(jobApi.GetJobList) }) job.GET(":jobId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取Job信息").Handle(jobApi.GetJob) + restfulx.NewReqCtx(c).WithLog("获取Job信息").Handle(jobApi.GetJob) }) job.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加Job信息").Handle(jobApi.CreateJob) + restfulx.NewReqCtx(c).WithLog("添加Job信息").Handle(jobApi.CreateJob) }) job.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改Job信息").Handle(jobApi.UpdateJob) + restfulx.NewReqCtx(c).WithLog("修改Job信息").Handle(jobApi.UpdateJob) }) job.DELETE(":jobId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除Job信息").Handle(jobApi.DeleteJob) + restfulx.NewReqCtx(c).WithLog("删除Job信息").Handle(jobApi.DeleteJob) }) job.GET("/stop/:jobId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("停止一个job").Handle(jobApi.StopJobForService) + restfulx.NewReqCtx(c).WithLog("停止一个job").Handle(jobApi.StopJobForService) }) job.GET("/start/:jobId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("开启一个job").Handle(jobApi.StartJobForService) + restfulx.NewReqCtx(c).WithLog("开启一个job").Handle(jobApi.StartJobForService) }) job.PUT("/changeStatus", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改状态").Handle(jobApi.UpdateStatusJob) + restfulx.NewReqCtx(c).WithLog("修改状态").Handle(jobApi.UpdateStatusJob) }) } diff --git a/apps/job/services/job.go b/apps/job/services/job.go index d46adcf..5dc8af1 100644 --- a/apps/job/services/job.go +++ b/apps/job/services/job.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/job/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/log/api/log_job.go b/apps/log/api/log_job.go index 717f614..85d5fd2 100644 --- a/apps/log/api/log_job.go +++ b/apps/log/api/log_job.go @@ -1,10 +1,10 @@ package api import ( + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/log/entity" "pandax/apps/log/services" - "pandax/base/ginx" - "pandax/base/utils" ) type LogJobApi struct { @@ -22,9 +22,9 @@ type LogJobApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /log/logJob/list [get] // @Security -func (l *LogJobApi) GetJobLogList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") @@ -45,7 +45,7 @@ func (l *LogJobApi) GetJobLogList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logJob/{logId} [delete] -func (l *LogJobApi) DeleteJobLog(rc *ginx.ReqCtx) { +func (l *LogJobApi) DeleteJobLog(rc *restfulx.ReqCtx) { logIds := rc.GinCtx.Param("logId") group := utils.IdsStrToIdsIntGroup(logIds) l.LogJobApp.Delete(group) @@ -57,6 +57,6 @@ func (l *LogJobApi) DeleteJobLog(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logJob/all [delete] -func (l *LogJobApi) DeleteAll(rc *ginx.ReqCtx) { +func (l *LogJobApi) DeleteAll(rc *restfulx.ReqCtx) { l.LogJobApp.DeleteAll() } diff --git a/apps/log/api/log_login.go b/apps/log/api/log_login.go index af4fee4..f11d884 100644 --- a/apps/log/api/log_login.go +++ b/apps/log/api/log_login.go @@ -1,10 +1,10 @@ package api import ( + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/log/entity" "pandax/apps/log/services" - "pandax/base/ginx" - "pandax/base/utils" ) type LogLoginApi struct { @@ -21,9 +21,9 @@ type LogLoginApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /log/logLogin/list [get] // @Security -func (l *LogLoginApi) GetLoginLogList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") list, total := l.LogLoginApp.FindListPage(pageNum, pageSize, entity.LogLogin{LoginLocation: loginLocation, Username: username}) @@ -42,8 +42,8 @@ func (l *LogLoginApi) GetLoginLogList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /log/logLogin/{infoId} [get] // @Security -func (l *LogLoginApi) GetLoginLog(rc *ginx.ReqCtx) { - infoId := ginx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("infoId")) +func (l *LogLoginApi) GetLoginLog(rc *restfulx.ReqCtx) { + infoId := restfulx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("infoId")) rc.ResData = l.LogLoginApp.FindOne(int64(infoId)) } @@ -57,9 +57,9 @@ func (l *LogLoginApi) GetLoginLog(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /log/logLogin [put] // @Security X-TOKEN -func (l *LogLoginApi) UpdateLoginLog(rc *ginx.ReqCtx) { +func (l *LogLoginApi) UpdateLoginLog(rc *restfulx.ReqCtx) { var log entity.LogLogin - ginx.BindJsonAndValid(rc.GinCtx, &log) + restfulx.BindJsonAndValid(rc.GinCtx, &log) l.LogLoginApp.Update(log) } @@ -70,7 +70,7 @@ func (l *LogLoginApi) UpdateLoginLog(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logLogin/{infoId} [delete] -func (l *LogLoginApi) DeleteLoginLog(rc *ginx.ReqCtx) { +func (l *LogLoginApi) DeleteLoginLog(rc *restfulx.ReqCtx) { infoIds := rc.GinCtx.Param("infoId") group := utils.IdsStrToIdsIntGroup(infoIds) l.LogLoginApp.Delete(group) @@ -82,6 +82,6 @@ func (l *LogLoginApi) DeleteLoginLog(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logLogin/all [delete] -func (l *LogLoginApi) DeleteAll(rc *ginx.ReqCtx) { +func (l *LogLoginApi) DeleteAll(rc *restfulx.ReqCtx) { l.LogLoginApp.DeleteAll() } diff --git a/apps/log/api/log_oper.go b/apps/log/api/log_oper.go index a2ba251..ce59179 100644 --- a/apps/log/api/log_oper.go +++ b/apps/log/api/log_oper.go @@ -1,11 +1,11 @@ package api import ( + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "log" "pandax/apps/log/entity" "pandax/apps/log/services" - "pandax/base/ginx" - "pandax/base/utils" ) type LogOperApi struct { @@ -22,9 +22,9 @@ type LogOperApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /log/logOper/list [get] // @Security -func (l *LogOperApi) GetOperLogList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") @@ -45,8 +45,8 @@ func (l *LogOperApi) GetOperLogList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /log/logOper/{operId} [get] // @Security -func (l *LogOperApi) GetOperLog(rc *ginx.ReqCtx) { - operId := ginx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("operId")) +func (l *LogOperApi) GetOperLog(rc *restfulx.ReqCtx) { + operId := restfulx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("operId")) rc.ResData = l.LogOperApp.FindOne(int64(operId)) } @@ -57,7 +57,7 @@ func (l *LogOperApi) GetOperLog(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logOper/{operId} [delete] -func (l *LogOperApi) DeleteOperLog(rc *ginx.ReqCtx) { +func (l *LogOperApi) DeleteOperLog(rc *restfulx.ReqCtx) { operIds := rc.GinCtx.Param("operId") group := utils.IdsStrToIdsIntGroup(operIds) log.Println("group", group) @@ -70,6 +70,6 @@ func (l *LogOperApi) DeleteOperLog(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /log/logOper/all [delete] -func (l *LogOperApi) DeleteAll(rc *ginx.ReqCtx) { +func (l *LogOperApi) DeleteAll(rc *restfulx.ReqCtx) { l.LogOperApp.DeleteAll() } diff --git a/apps/log/entity/log_job.go b/apps/log/entity/log_job.go index ec14260..5fa45f3 100644 --- a/apps/log/entity/log_job.go +++ b/apps/log/entity/log_job.go @@ -1,7 +1,7 @@ package entity import ( - "pandax/base/model" + "github.com/XM-GO/PandaKit/model" ) type LogJob struct { diff --git a/apps/log/entity/log_login.go b/apps/log/entity/log_login.go index e4cb062..f297ec5 100644 --- a/apps/log/entity/log_login.go +++ b/apps/log/entity/log_login.go @@ -1,7 +1,7 @@ package entity import ( - "pandax/base/model" + "github.com/XM-GO/PandaKit/model" "time" ) diff --git a/apps/log/entity/log_oper.go b/apps/log/entity/log_oper.go index d240f92..11bd57c 100644 --- a/apps/log/entity/log_oper.go +++ b/apps/log/entity/log_oper.go @@ -1,7 +1,7 @@ package entity import ( - "pandax/base/model" + "github.com/XM-GO/PandaKit/model" ) type LogOper struct { diff --git a/apps/log/router/log.go b/apps/log/router/log.go index 3afc856..2636f48 100644 --- a/apps/log/router/log.go +++ b/apps/log/router/log.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/log/api" "pandax/apps/log/services" - "pandax/base/ginx" ) func InitLogRouter(router *gin.RouterGroup) { @@ -15,23 +15,23 @@ func InitLogRouter(router *gin.RouterGroup) { logLogin := router.Group("logLogin") logLogin.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取登录日志列表").Handle(login.GetLoginLogList) + restfulx.NewReqCtx(c).WithLog("获取登录日志列表").Handle(login.GetLoginLogList) }) logLogin.GET(":infoId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取登录日志信息").Handle(login.GetLoginLog) + restfulx.NewReqCtx(c).WithLog("获取登录日志信息").Handle(login.GetLoginLog) }) logLogin.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改登录日志信息").Handle(login.UpdateLoginLog) + restfulx.NewReqCtx(c).WithLog("修改登录日志信息").Handle(login.UpdateLoginLog) }) logLogin.DELETE("all", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("清空登录日志信息").Handle(login.DeleteAll) + restfulx.NewReqCtx(c).WithLog("清空登录日志信息").Handle(login.DeleteAll) }) logLogin.DELETE(":infoId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除登录日志信息").Handle(login.DeleteLoginLog) + restfulx.NewReqCtx(c).WithLog("删除登录日志信息").Handle(login.DeleteLoginLog) }) // 操作日志 @@ -41,19 +41,19 @@ func InitLogRouter(router *gin.RouterGroup) { logOper := router.Group("logOper") logOper.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取操作日志列表").Handle(oper.GetOperLogList) + restfulx.NewReqCtx(c).WithLog("获取操作日志列表").Handle(oper.GetOperLogList) }) logOper.GET(":operId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取操作日志信息").Handle(oper.GetOperLog) + restfulx.NewReqCtx(c).WithLog("获取操作日志信息").Handle(oper.GetOperLog) }) logOper.DELETE("all", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("清空操作日志信息").Handle(oper.DeleteAll) + restfulx.NewReqCtx(c).WithLog("清空操作日志信息").Handle(oper.DeleteAll) }) logOper.DELETE(":operId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除操作日志信息").Handle(oper.DeleteOperLog) + restfulx.NewReqCtx(c).WithLog("删除操作日志信息").Handle(oper.DeleteOperLog) }) // Job日志 @@ -63,14 +63,14 @@ func InitLogRouter(router *gin.RouterGroup) { logJob := router.Group("logJob") logJob.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取操作日志列表").Handle(job.GetJobLogList) + restfulx.NewReqCtx(c).WithLog("获取操作日志列表").Handle(job.GetJobLogList) }) logJob.DELETE("all", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("清空操作日志信息").Handle(job.DeleteAll) + restfulx.NewReqCtx(c).WithLog("清空操作日志信息").Handle(job.DeleteAll) }) logJob.DELETE(":logId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除操作日志信息").Handle(job.DeleteJobLog) + restfulx.NewReqCtx(c).WithLog("删除操作日志信息").Handle(job.DeleteJobLog) }) } diff --git a/apps/log/services/log_job.go b/apps/log/services/log_job.go index c28ec5c..e3aa6e6 100644 --- a/apps/log/services/log_job.go +++ b/apps/log/services/log_job.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/log/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/log/services/log_login.go b/apps/log/services/log_login.go index 400fb39..898af23 100644 --- a/apps/log/services/log_login.go +++ b/apps/log/services/log_login.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/log/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/log/services/log_oper.go b/apps/log/services/log_oper.go index c0c37c1..d90155e 100644 --- a/apps/log/services/log_oper.go +++ b/apps/log/services/log_oper.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/log/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/resource/api/email.go b/apps/resource/api/email.go index eab460a..91a3c7e 100644 --- a/apps/resource/api/email.go +++ b/apps/resource/api/email.go @@ -1,13 +1,13 @@ package api import ( + "github.com/XM-GO/PandaKit/biz" + email "github.com/XM-GO/PandaKit/mail" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/resource/api/from" "pandax/apps/resource/entity" "pandax/apps/resource/services" - "pandax/base/biz" - "pandax/base/ginx" - email "pandax/base/mail" - "pandax/base/utils" ) /** @@ -29,10 +29,10 @@ type ResEmailsApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /resource/email/list [get] // @Security -func (p *ResEmailsApi) GetResEmailsList(rc *ginx.ReqCtx) { +func (p *ResEmailsApi) GetResEmailsList(rc *restfulx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) + pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) + pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) status := rc.GinCtx.Query("status") category := rc.GinCtx.Query("category") @@ -59,8 +59,8 @@ func (p *ResEmailsApi) GetResEmailsList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /resource/email/{mailId} [get] // @Security -func (p *ResEmailsApi) GetResEmails(rc *ginx.ReqCtx) { - mailId := ginx.PathParamInt(rc.GinCtx, "mailId") +func (p *ResEmailsApi) GetResEmails(rc *restfulx.ReqCtx) { + mailId := restfulx.PathParamInt(rc.GinCtx, "mailId") p.ResEmailsApp.FindOne(int64(mailId)) } @@ -74,9 +74,9 @@ func (p *ResEmailsApi) GetResEmails(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /resource/email [post] // @Security X-TOKEN -func (p *ResEmailsApi) InsertResEmails(rc *ginx.ReqCtx) { +func (p *ResEmailsApi) InsertResEmails(rc *restfulx.ReqCtx) { var data entity.ResEmail - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) p.ResEmailsApp.Insert(data) } @@ -91,9 +91,9 @@ func (p *ResEmailsApi) InsertResEmails(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /resource/email [put] // @Security X-TOKEN -func (p *ResEmailsApi) UpdateResEmails(rc *ginx.ReqCtx) { +func (p *ResEmailsApi) UpdateResEmails(rc *restfulx.ReqCtx) { var data entity.ResEmail - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) if utils.ISDdmMail(data.From) { data.From = "" } @@ -110,7 +110,7 @@ func (p *ResEmailsApi) UpdateResEmails(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /resource/email/{mailId} [delete] -func (p *ResEmailsApi) DeleteResEmails(rc *ginx.ReqCtx) { +func (p *ResEmailsApi) DeleteResEmails(rc *restfulx.ReqCtx) { mailId := rc.GinCtx.Param("mailId") mailIds := utils.IdsStrToIdsIntGroup(mailId) @@ -127,9 +127,9 @@ func (p *ResEmailsApi) DeleteResEmails(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /resource/oss [put] // @Security X-TOKEN -func (p *ResEmailsApi) UpdateMailStatus(rc *ginx.ReqCtx) { +func (p *ResEmailsApi) UpdateMailStatus(rc *restfulx.ReqCtx) { var data entity.ResEmail - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) p.ResEmailsApp.Update(entity.ResEmail{MailId: data.MailId, Status: data.Status}) } @@ -144,9 +144,9 @@ func (p *ResEmailsApi) UpdateMailStatus(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /resource/email/debugMail [post] // @Security X-TOKEN -func (p *ResEmailsApi) DebugMail(rc *ginx.ReqCtx) { +func (p *ResEmailsApi) DebugMail(rc *restfulx.ReqCtx) { var data from.SendMail - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &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 c7f318f..3b8dcf9 100644 --- a/apps/resource/api/oss.go +++ b/apps/resource/api/oss.go @@ -2,12 +2,12 @@ package api import ( "fmt" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/oss" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/resource/entity" "pandax/apps/resource/services" - "pandax/base/biz" - "pandax/base/ginx" - "pandax/base/oss" - "pandax/base/utils" "time" ) @@ -31,10 +31,10 @@ type ResOssesApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /resource/oss/list [get] // @Security -func (p *ResOssesApi) GetResOssesList(rc *ginx.ReqCtx) { +func (p *ResOssesApi) GetResOssesList(rc *restfulx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) + 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") @@ -62,8 +62,8 @@ func (p *ResOssesApi) GetResOssesList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /resource/oss/{ossId} [get] // @Security -func (p *ResOssesApi) GetResOsses(rc *ginx.ReqCtx) { - ossId := ginx.PathParamInt(rc.GinCtx, "ossId") +func (p *ResOssesApi) GetResOsses(rc *restfulx.ReqCtx) { + ossId := restfulx.PathParamInt(rc.GinCtx, "ossId") p.ResOssesApp.FindOne(int64(ossId)) } @@ -77,9 +77,9 @@ func (p *ResOssesApi) GetResOsses(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /resource/oss [post] // @Security X-TOKEN -func (p *ResOssesApi) InsertResOsses(rc *ginx.ReqCtx) { +func (p *ResOssesApi) InsertResOsses(rc *restfulx.ReqCtx) { var data entity.ResOss - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) p.ResOssesApp.Insert(data) } @@ -94,9 +94,9 @@ func (p *ResOssesApi) InsertResOsses(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /resource/oss [put] // @Security X-TOKEN -func (p *ResOssesApi) UpdateResOsses(rc *ginx.ReqCtx) { +func (p *ResOssesApi) UpdateResOsses(rc *restfulx.ReqCtx) { var data entity.ResOss - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) if utils.IsDdmKey(data.AccessKey) { data.AccessKey = "" } @@ -113,7 +113,7 @@ func (p *ResOssesApi) UpdateResOsses(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /resource/oss/{ossId} [delete] -func (p *ResOssesApi) DeleteResOsses(rc *ginx.ReqCtx) { +func (p *ResOssesApi) DeleteResOsses(rc *restfulx.ReqCtx) { ossId := rc.GinCtx.Param("ossId") ossIds := utils.IdsStrToIdsIntGroup(ossId) @@ -126,7 +126,7 @@ func (p *ResOssesApi) DeleteResOsses(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /resource/oss/uploadFile [post] -func (p *ResOssesApi) UplaodResOsses(rc *ginx.ReqCtx) { +func (p *ResOssesApi) UplaodResOsses(rc *restfulx.ReqCtx) { file, _ := rc.GinCtx.FormFile("file") ossCode, _ := rc.GinCtx.GetQuery("ossCode") list := p.ResOssesApp.FindList(entity.ResOss{OssCode: ossCode}) @@ -150,9 +150,9 @@ func (p *ResOssesApi) UplaodResOsses(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /resource/oss [put] // @Security X-TOKEN -func (p *ResOssesApi) UpdateOssStatus(rc *ginx.ReqCtx) { +func (p *ResOssesApi) UpdateOssStatus(rc *restfulx.ReqCtx) { var data entity.ResOss - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) p.ResOssesApp.Update(entity.ResOss{OssId: data.OssId, Status: data.Status}) } diff --git a/apps/resource/entity/mail.go b/apps/resource/entity/mail.go index 9e8387c..36355cf 100644 --- a/apps/resource/entity/mail.go +++ b/apps/resource/entity/mail.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" /** * @Description 添加qq群467890197 交流学习 diff --git a/apps/resource/entity/oss.go b/apps/resource/entity/oss.go index 1223120..1a410fd 100644 --- a/apps/resource/entity/oss.go +++ b/apps/resource/entity/oss.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" /** * @Description 添加qq群467890197 交流学习 diff --git a/apps/resource/router/email.go b/apps/resource/router/email.go index e6493a7..f5c1228 100644 --- a/apps/resource/router/email.go +++ b/apps/resource/router/email.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/resource/api" "pandax/apps/resource/services" - "pandax/base/ginx" ) /** @@ -20,30 +20,30 @@ func InitResEmailsRouter(router *gin.RouterGroup) { routerGroup := router.Group("email") routerGroup.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取ResEmails分页列表").Handle(s.GetResEmailsList) + restfulx.NewReqCtx(c).WithLog("获取ResEmails分页列表").Handle(s.GetResEmailsList) }) routerGroup.GET(":mailId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取ResEmails信息").Handle(s.GetResEmails) + restfulx.NewReqCtx(c).WithLog("获取ResEmails信息").Handle(s.GetResEmails) }) routerGroup.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加ResEmails信息").Handle(s.InsertResEmails) + restfulx.NewReqCtx(c).WithLog("添加ResEmails信息").Handle(s.InsertResEmails) }) routerGroup.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改ResEmails信息").Handle(s.UpdateResEmails) + restfulx.NewReqCtx(c).WithLog("修改ResEmails信息").Handle(s.UpdateResEmails) }) routerGroup.DELETE(":mailId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除ResEmails信息").Handle(s.DeleteResEmails) + restfulx.NewReqCtx(c).WithLog("删除ResEmails信息").Handle(s.DeleteResEmails) }) routerGroup.PUT("changeStatus", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改状态").Handle(s.UpdateMailStatus) + restfulx.NewReqCtx(c).WithLog("修改状态").Handle(s.UpdateMailStatus) }) routerGroup.POST("debugMail", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改状态").Handle(s.DebugMail) + restfulx.NewReqCtx(c).WithLog("修改状态").Handle(s.DebugMail) }) } diff --git a/apps/resource/router/oss.go b/apps/resource/router/oss.go index 4b5567e..eac695b 100644 --- a/apps/resource/router/oss.go +++ b/apps/resource/router/oss.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/resource/api" "pandax/apps/resource/services" - "pandax/base/ginx" ) /** @@ -20,30 +20,30 @@ func InitResOssRouter(router *gin.RouterGroup) { routerGroup := router.Group("oss") routerGroup.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取ResOsses分页列表").Handle(s.GetResOssesList) + restfulx.NewReqCtx(c).WithLog("获取ResOsses分页列表").Handle(s.GetResOssesList) }) routerGroup.GET(":ossId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取ResOsses信息").Handle(s.GetResOsses) + restfulx.NewReqCtx(c).WithLog("获取ResOsses信息").Handle(s.GetResOsses) }) routerGroup.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加ResOsses信息").Handle(s.InsertResOsses) + restfulx.NewReqCtx(c).WithLog("添加ResOsses信息").Handle(s.InsertResOsses) }) routerGroup.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改ResOsses信息").Handle(s.UpdateResOsses) + restfulx.NewReqCtx(c).WithLog("修改ResOsses信息").Handle(s.UpdateResOsses) }) routerGroup.DELETE(":ossId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除ResOsses信息").Handle(s.DeleteResOsses) + restfulx.NewReqCtx(c).WithLog("删除ResOsses信息").Handle(s.DeleteResOsses) }) routerGroup.POST("uploadFile", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("测试文件上传").Handle(s.UplaodResOsses) + restfulx.NewReqCtx(c).WithLog("测试文件上传").Handle(s.UplaodResOsses) }) routerGroup.PUT("/changeStatus", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改状态").Handle(s.UpdateOssStatus) + restfulx.NewReqCtx(c).WithLog("修改状态").Handle(s.UpdateOssStatus) }) } diff --git a/apps/resource/services/email.go b/apps/resource/services/email.go index 260ae15..87018dd 100644 --- a/apps/resource/services/email.go +++ b/apps/resource/services/email.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/resource/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/resource/services/oss.go b/apps/resource/services/oss.go index 3dca64d..ffd4eb9 100644 --- a/apps/resource/services/oss.go +++ b/apps/resource/services/oss.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/resource/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/api/api.go b/apps/system/api/api.go index 390a755..4ebb369 100644 --- a/apps/system/api/api.go +++ b/apps/system/api/api.go @@ -1,12 +1,12 @@ package api import ( + "github.com/XM-GO/PandaKit/casbin" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "log" entity "pandax/apps/system/entity" services "pandax/apps/system/services" - "pandax/base/casbin" - "pandax/base/ginx" - "pandax/base/utils" "strconv" ) @@ -22,9 +22,9 @@ type SystemApiApi struct { // @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 *ginx.ReqCtx) { +func (s *SystemApiApi) CreateApi(rc *restfulx.ReqCtx) { var api entity.SysApi - ginx.BindJsonAndValid(rc.GinCtx, &api) + restfulx.BindJsonAndValid(rc.GinCtx, &api) log.Println(api) s.ApiApp.Insert(api) } @@ -36,7 +36,7 @@ func (s *SystemApiApi) CreateApi(rc *ginx.ReqCtx) { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /system/api/{id} [delete] -func (s *SystemApiApi) DeleteApi(rc *ginx.ReqCtx) { +func (s *SystemApiApi) DeleteApi(rc *restfulx.ReqCtx) { ids := rc.GinCtx.Param("id") s.ApiApp.Delete(utils.IdsStrToIdsIntGroup(ids)) } @@ -54,9 +54,9 @@ func (s *SystemApiApi) DeleteApi(rc *ginx.ReqCtx) { // @Param pageNum query int false "页码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /system/api/list [get] -func (s *SystemApiApi) GetApiList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") @@ -79,8 +79,8 @@ func (s *SystemApiApi) GetApiList(rc *ginx.ReqCtx) { // @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 *ginx.ReqCtx) { - id := ginx.QueryInt(rc.GinCtx, "id", 0) +func (s *SystemApiApi) GetApiById(rc *restfulx.ReqCtx) { + id := restfulx.QueryInt(rc.GinCtx, "id", 0) rc.ResData = s.ApiApp.FindOne(int64(id)) } @@ -93,9 +93,9 @@ func (s *SystemApiApi) GetApiById(rc *ginx.ReqCtx) { // @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 *ginx.ReqCtx) { +func (s *SystemApiApi) UpdateApi(rc *restfulx.ReqCtx) { var api entity.SysApi - ginx.BindJsonAndValid(rc.GinCtx, &api) + restfulx.BindJsonAndValid(rc.GinCtx, &api) s.ApiApp.Update(api) } @@ -106,7 +106,7 @@ func (s *SystemApiApi) UpdateApi(rc *ginx.ReqCtx) { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /system/api/all [get] -func (s *SystemApiApi) GetAllApis(rc *ginx.ReqCtx) { +func (s *SystemApiApi) GetAllApis(rc *restfulx.ReqCtx) { rc.ResData = s.ApiApp.FindList(entity.SysApi{}) } @@ -118,7 +118,7 @@ func (s *SystemApiApi) GetAllApis(rc *ginx.ReqCtx) { // @Param roleKey query string true "权限id, 权限模型列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /casbin/getPolicyPathByRoleId [get] -func (s *SystemApiApi) GetPolicyPathByRoleId(rc *ginx.ReqCtx) { +func (s *SystemApiApi) GetPolicyPathByRoleId(rc *restfulx.ReqCtx) { roleKey := rc.GinCtx.Query("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 b1e7594..0fa826b 100644 --- a/apps/system/api/config.go +++ b/apps/system/api/config.go @@ -1,11 +1,11 @@ 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" - "pandax/base/biz" - "pandax/base/ginx" - "pandax/base/utils" ) type ConfigApi struct { @@ -23,9 +23,9 @@ type ConfigApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/config [get] // @Security -func (p *ConfigApi) GetConfigList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") @@ -47,7 +47,7 @@ func (p *ConfigApi) GetConfigList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/config/configKey [get] // @Security -func (p *ConfigApi) GetConfigListByKey(rc *ginx.ReqCtx) { +func (p *ConfigApi) GetConfigListByKey(rc *restfulx.ReqCtx) { configKey := rc.GinCtx.Query("configKey") biz.IsTrue(configKey != "", "请传入配置Key") rc.ResData = p.ConfigApp.FindList(entity.SysConfig{ConfigKey: configKey}) @@ -60,8 +60,8 @@ func (p *ConfigApi) GetConfigListByKey(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/config/{configId} [get] // @Security -func (p *ConfigApi) GetConfig(rc *ginx.ReqCtx) { - id := ginx.PathParamInt(rc.GinCtx, "configId") +func (p *ConfigApi) GetConfig(rc *restfulx.ReqCtx) { + id := restfulx.PathParamInt(rc.GinCtx, "configId") p.ConfigApp.FindOne(int64(id)) } @@ -75,9 +75,9 @@ func (p *ConfigApi) GetConfig(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/config [post] // @Security X-TOKEN -func (p *ConfigApi) InsertConfig(rc *ginx.ReqCtx) { +func (p *ConfigApi) InsertConfig(rc *restfulx.ReqCtx) { var config entity.SysConfig - ginx.BindJsonAndValid(rc.GinCtx, &config) + restfulx.BindJsonAndValid(rc.GinCtx, &config) p.ConfigApp.Insert(config) } @@ -92,9 +92,9 @@ func (p *ConfigApi) InsertConfig(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/config [put] // @Security X-TOKEN -func (p *ConfigApi) UpdateConfig(rc *ginx.ReqCtx) { +func (p *ConfigApi) UpdateConfig(rc *restfulx.ReqCtx) { var post entity.SysConfig - ginx.BindJsonAndValid(rc.GinCtx, &post) + restfulx.BindJsonAndValid(rc.GinCtx, &post) p.ConfigApp.Update(post) } @@ -105,7 +105,7 @@ func (p *ConfigApi) UpdateConfig(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/config/{configId} [delete] -func (p *ConfigApi) DeleteConfig(rc *ginx.ReqCtx) { +func (p *ConfigApi) DeleteConfig(rc *restfulx.ReqCtx) { configId := rc.GinCtx.Param("configId") p.ConfigApp.Delete(utils.IdsStrToIdsIntGroup(configId)) } diff --git a/apps/system/api/dept.go b/apps/system/api/dept.go index d4ded1c..f6b2b5b 100644 --- a/apps/system/api/dept.go +++ b/apps/system/api/dept.go @@ -3,11 +3,11 @@ package api import ( "errors" "fmt" - entity "pandax/apps/system/entity" - services "pandax/apps/system/services" - "pandax/base/biz" - "pandax/base/ginx" - "pandax/base/utils" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" + "pandax/apps/system/entity" + "pandax/apps/system/services" "pandax/pkg/global" ) @@ -25,8 +25,8 @@ type DeptApi struct { // @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}" // @Router /system/menu/menuTreRoleSelect/{roleId} [get] // @Security X-TOKEN -func (m *DeptApi) GetDeptTreeRoleSelect(rc *ginx.ReqCtx) { - roleId := ginx.PathParamInt(rc.GinCtx, "roleId") +func (m *DeptApi) GetDeptTreeRoleSelect(rc *restfulx.ReqCtx) { + roleId := restfulx.PathParamInt(rc.GinCtx, "roleId") var dept entity.SysDept if !IsTenantAdmin(rc.LoginAccount.TenantId) { dept.TenantId = rc.LoginAccount.TenantId @@ -52,12 +52,12 @@ func (m *DeptApi) GetDeptTreeRoleSelect(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dept/deptList [get] // @Security -func (a *DeptApi) GetDeptList(rc *ginx.ReqCtx) { - //pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - //pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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 := ginx.QueryInt(rc.GinCtx, "deptId", 0) + deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0) dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)} if !IsTenantAdmin(rc.LoginAccount.TenantId) { dept.TenantId = rc.LoginAccount.TenantId @@ -75,7 +75,7 @@ func (a *DeptApi) GetDeptList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dept/ordinaryDeptLis [get] // @Security -func (a *DeptApi) GetOrdinaryDeptList(rc *ginx.ReqCtx) { +func (a *DeptApi) GetOrdinaryDeptList(rc *restfulx.ReqCtx) { var dept entity.SysDept if !IsTenantAdmin(rc.LoginAccount.TenantId) { dept.TenantId = rc.LoginAccount.TenantId @@ -93,10 +93,10 @@ func (a *DeptApi) GetOrdinaryDeptList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dept/deptTree [get] // @Security -func (a *DeptApi) GetDeptTree(rc *ginx.ReqCtx) { +func (a *DeptApi) GetDeptTree(rc *restfulx.ReqCtx) { deptName := rc.GinCtx.Query("deptName") status := rc.GinCtx.Query("status") - deptId := ginx.QueryInt(rc.GinCtx, "deptId", 0) + deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0) dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)} if !IsTenantAdmin(rc.LoginAccount.TenantId) { dept.TenantId = rc.LoginAccount.TenantId @@ -111,8 +111,8 @@ func (a *DeptApi) GetDeptTree(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dept/{deptId} [get] // @Security -func (a *DeptApi) GetDept(rc *ginx.ReqCtx) { - deptId := ginx.PathParamInt(rc.GinCtx, "deptId") +func (a *DeptApi) GetDept(rc *restfulx.ReqCtx) { + deptId := restfulx.PathParamInt(rc.GinCtx, "deptId") rc.ResData = a.DeptApp.FindOne(int64(deptId)) } @@ -126,10 +126,10 @@ func (a *DeptApi) GetDept(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/dept [post] // @Security Bearer -func (a *DeptApi) InsertDept(rc *ginx.ReqCtx) { +func (a *DeptApi) InsertDept(rc *restfulx.ReqCtx) { var dept entity.SysDept g := rc.GinCtx - ginx.BindJsonAndValid(g, &dept) + restfulx.BindJsonAndValid(g, &dept) dept.TenantId = rc.LoginAccount.TenantId dept.CreateBy = rc.LoginAccount.UserName a.DeptApp.Insert(dept) @@ -145,10 +145,10 @@ func (a *DeptApi) InsertDept(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /system/dept [put] // @Security Bearer -func (a *DeptApi) UpdateDept(rc *ginx.ReqCtx) { +func (a *DeptApi) UpdateDept(rc *restfulx.ReqCtx) { var dept entity.SysDept g := rc.GinCtx - ginx.BindJsonAndValid(g, &dept) + restfulx.BindJsonAndValid(g, &dept) dept.UpdateBy = rc.LoginAccount.UserName a.DeptApp.Update(dept) @@ -161,7 +161,7 @@ func (a *DeptApi) UpdateDept(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dept/{deptId} [delete] -func (a *DeptApi) DeleteDept(rc *ginx.ReqCtx) { +func (a *DeptApi) DeleteDept(rc *restfulx.ReqCtx) { deptId := rc.GinCtx.Param("deptId") deptIds := utils.IdsStrToIdsIntGroup(deptId) diff --git a/apps/system/api/dict.go b/apps/system/api/dict.go index 21852bc..74bc0e8 100644 --- a/apps/system/api/dict.go +++ b/apps/system/api/dict.go @@ -2,11 +2,11 @@ package api import ( "fmt" + "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" - "pandax/base/biz" - "pandax/base/ginx" - "pandax/base/utils" "pandax/pkg/global" ) @@ -26,9 +26,9 @@ type DictApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dict/type/list [get] // @Security -func (p *DictApi) GetDictTypeList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") @@ -49,8 +49,8 @@ func (p *DictApi) GetDictTypeList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dict/type/{dictId} [get] // @Security -func (p *DictApi) GetDictType(rc *ginx.ReqCtx) { - dictId := ginx.PathParamInt(rc.GinCtx, "dictId") +func (p *DictApi) GetDictType(rc *restfulx.ReqCtx) { + dictId := restfulx.PathParamInt(rc.GinCtx, "dictId") p.DictType.FindOne(int64(dictId)) } @@ -64,9 +64,9 @@ func (p *DictApi) GetDictType(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/dict/type [post] // @Security X-TOKEN -func (p *DictApi) InsertDictType(rc *ginx.ReqCtx) { +func (p *DictApi) InsertDictType(rc *restfulx.ReqCtx) { var dict entity.SysDictType - ginx.BindJsonAndValid(rc.GinCtx, &dict) + restfulx.BindJsonAndValid(rc.GinCtx, &dict) dict.CreateBy = rc.LoginAccount.UserName p.DictType.Insert(dict) @@ -82,9 +82,9 @@ func (p *DictApi) InsertDictType(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/dict/type [put] // @Security X-TOKEN -func (p *DictApi) UpdateDictType(rc *ginx.ReqCtx) { +func (p *DictApi) UpdateDictType(rc *restfulx.ReqCtx) { var dict entity.SysDictType - ginx.BindJsonAndValid(rc.GinCtx, &dict) + restfulx.BindJsonAndValid(rc.GinCtx, &dict) dict.CreateBy = rc.LoginAccount.UserName p.DictType.Update(dict) @@ -97,7 +97,7 @@ func (p *DictApi) UpdateDictType(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/type/{dictId} [delete] -func (p *DictApi) DeleteDictType(rc *ginx.ReqCtx) { +func (p *DictApi) DeleteDictType(rc *restfulx.ReqCtx) { dictId := rc.GinCtx.Param("dictId") dictIds := utils.IdsStrToIdsIntGroup(dictId) @@ -123,7 +123,7 @@ func (p *DictApi) DeleteDictType(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/type/export [get] -func (p *DictApi) ExportDictType(rc *ginx.ReqCtx) { +func (p *DictApi) ExportDictType(rc *restfulx.ReqCtx) { filename := rc.GinCtx.Query("filename") status := rc.GinCtx.Query("status") dictName := rc.GinCtx.Query("dictName") @@ -144,7 +144,7 @@ func (p *DictApi) ExportDictType(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dict/data/list [get] // @Security -func (p *DictApi) GetDictDataList(rc *ginx.ReqCtx) { +func (p *DictApi) GetDictDataList(rc *restfulx.ReqCtx) { dictLabel := rc.GinCtx.Query("dictLabel") dictType := rc.GinCtx.Query("dictType") status := rc.GinCtx.Query("status") @@ -158,7 +158,7 @@ func (p *DictApi) GetDictDataList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dict/data/type [get] // @Security -func (p *DictApi) GetDictDataListByDictType(rc *ginx.ReqCtx) { +func (p *DictApi) GetDictDataListByDictType(rc *restfulx.ReqCtx) { dictType := rc.GinCtx.Query("dictType") biz.IsTrue(dictType != "", "请传入字典类型") rc.ResData = p.DictData.FindList(entity.SysDictData{DictType: dictType}) @@ -171,8 +171,8 @@ func (p *DictApi) GetDictDataListByDictType(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/dict/data/{dictCode} [get] // @Security -func (p *DictApi) GetDictData(rc *ginx.ReqCtx) { - dictCode := ginx.PathParamInt(rc.GinCtx, "dictCode") +func (p *DictApi) GetDictData(rc *restfulx.ReqCtx) { + dictCode := restfulx.PathParamInt(rc.GinCtx, "dictCode") p.DictData.FindOne(int64(dictCode)) } @@ -186,9 +186,9 @@ func (p *DictApi) GetDictData(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/dict/data [post] // @Security X-TOKEN -func (p *DictApi) InsertDictData(rc *ginx.ReqCtx) { +func (p *DictApi) InsertDictData(rc *restfulx.ReqCtx) { var data entity.SysDictData - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) data.CreateBy = rc.LoginAccount.UserName p.DictData.Insert(data) @@ -204,9 +204,9 @@ func (p *DictApi) InsertDictData(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/dict/data [put] // @Security X-TOKEN -func (p *DictApi) UpdateDictData(rc *ginx.ReqCtx) { +func (p *DictApi) UpdateDictData(rc *restfulx.ReqCtx) { var data entity.SysDictData - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) data.CreateBy = rc.LoginAccount.UserName p.DictData.Update(data) @@ -219,7 +219,7 @@ func (p *DictApi) UpdateDictData(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/data/{dictCode} [delete] -func (p *DictApi) DeleteDictData(rc *ginx.ReqCtx) { +func (p *DictApi) DeleteDictData(rc *restfulx.ReqCtx) { param := rc.GinCtx.Param("dictCode") p.DictData.Delete(utils.IdsStrToIdsIntGroup(param)) } diff --git a/apps/system/api/menu.go b/apps/system/api/menu.go index ffa00e2..bdb43ee 100644 --- a/apps/system/api/menu.go +++ b/apps/system/api/menu.go @@ -1,10 +1,10 @@ package api import ( + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/restfulx" entity "pandax/apps/system/entity" services "pandax/apps/system/services" - "pandax/base/biz" - "pandax/base/ginx" ) type MenuApi struct { @@ -22,7 +22,7 @@ type MenuApi struct { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/menu/menuTreSelect [get] // @Security X-TOKEN -func (m *MenuApi) GetMenuTreeSelect(rc *ginx.ReqCtx) { +func (m *MenuApi) GetMenuTreeSelect(rc *restfulx.ReqCtx) { lable := m.MenuApp.SelectMenuLable(entity.SysMenu{}) rc.ResData = lable } @@ -34,7 +34,7 @@ func (m *MenuApi) GetMenuTreeSelect(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}" // @Router /system/menu/menuRole [get] // @Security X-TOKEN -func (m *MenuApi) GetMenuRole(rc *ginx.ReqCtx) { +func (m *MenuApi) GetMenuRole(rc *restfulx.ReqCtx) { roleKey := rc.GinCtx.Query("roleKey") biz.IsTrue(roleKey != "", "请传入角色Key") rc.ResData = Build(*m.MenuApp.SelectMenuRole(roleKey)) @@ -48,8 +48,8 @@ func (m *MenuApi) GetMenuRole(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}" // @Router /system/menu/menuTreRoleSelect/{roleId} [get] // @Security X-TOKEN -func (m *MenuApi) GetMenuTreeRoleSelect(rc *ginx.ReqCtx) { - roleId := ginx.PathParamInt(rc.GinCtx, "roleId") +func (m *MenuApi) GetMenuTreeRoleSelect(rc *restfulx.ReqCtx) { + roleId := restfulx.PathParamInt(rc.GinCtx, "roleId") result := m.MenuApp.SelectMenuLable(entity.SysMenu{}) menuIds := make([]int64, 0) @@ -70,7 +70,7 @@ func (m *MenuApi) GetMenuTreeRoleSelect(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}" // @Router /system/menu/menuPaths [get] // @Security X-TOKEN -func (m *MenuApi) GetMenuPaths(rc *ginx.ReqCtx) { +func (m *MenuApi) GetMenuPaths(rc *restfulx.ReqCtx) { roleKey := rc.GinCtx.Query("roleKey") biz.IsTrue(roleKey != "", "请传入角色Key") rc.ResData = m.RoleMenuApp.GetMenuPaths(entity.SysRoleMenu{RoleName: roleKey}) @@ -86,7 +86,7 @@ func (m *MenuApi) GetMenuPaths(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}" // @Router /system/menu/menuList [get] // @Security Bearer -func (m *MenuApi) GetMenuList(rc *ginx.ReqCtx) { +func (m *MenuApi) GetMenuList(rc *restfulx.ReqCtx) { menuName := rc.GinCtx.Query("menuName") status := rc.GinCtx.Query("status") @@ -106,8 +106,8 @@ func (m *MenuApi) GetMenuList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}" // @Router /system/menu/{menuId} [get] // @Security Bearer -func (m *MenuApi) GetMenu(rc *ginx.ReqCtx) { - menuId := ginx.PathParamInt(rc.GinCtx, "menuId") +func (m *MenuApi) GetMenu(rc *restfulx.ReqCtx) { + menuId := restfulx.PathParamInt(rc.GinCtx, "menuId") rc.ResData = m.MenuApp.FindOne(int64(menuId)) } @@ -120,9 +120,9 @@ func (m *MenuApi) GetMenu(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /system/menu [post] // @Security X-TOKEN -func (m *MenuApi) InsertMenu(rc *ginx.ReqCtx) { +func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) { var menu entity.SysMenu - ginx.BindJsonAndValid(rc.GinCtx, &menu) + restfulx.BindJsonAndValid(rc.GinCtx, &menu) menu.CreateBy = rc.LoginAccount.UserName m.MenuApp.Insert(menu) permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId) @@ -141,9 +141,9 @@ func (m *MenuApi) InsertMenu(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": -1, "message": "修改失败"}" // @Router /system/menu [put] // @Security X-TOKEN -func (m *MenuApi) UpdateMenu(rc *ginx.ReqCtx) { +func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) { var menu entity.SysMenu - ginx.BindJsonAndValid(rc.GinCtx, &menu) + restfulx.BindJsonAndValid(rc.GinCtx, &menu) menu.UpdateBy = rc.LoginAccount.UserName m.MenuApp.Update(menu) permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId) @@ -161,7 +161,7 @@ func (m *MenuApi) UpdateMenu(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/menu/{menuId} [delete] -func (m *MenuApi) DeleteMenu(rc *ginx.ReqCtx) { - menuId := ginx.PathParamInt(rc.GinCtx, "menuId") +func (m *MenuApi) DeleteMenu(rc *restfulx.ReqCtx) { + menuId := restfulx.PathParamInt(rc.GinCtx, "menuId") m.MenuApp.Delete([]int64{int64(menuId)}) } diff --git a/apps/system/api/notice.go b/apps/system/api/notice.go index 9945494..bcbe200 100644 --- a/apps/system/api/notice.go +++ b/apps/system/api/notice.go @@ -1,10 +1,10 @@ package api import ( + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/system/entity" "pandax/apps/system/services" - "pandax/base/ginx" - "pandax/base/utils" "strings" ) @@ -23,9 +23,9 @@ type NoticeApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/post [get] // @Security -func (p *NoticeApi) GetNoticeList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") @@ -55,9 +55,9 @@ func (p *NoticeApi) GetNoticeList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/notice [post] // @Security X-TOKEN -func (p *NoticeApi) InsertNotice(rc *ginx.ReqCtx) { +func (p *NoticeApi) InsertNotice(rc *restfulx.ReqCtx) { var notice entity.SysNotice - ginx.BindJsonAndValid(rc.GinCtx, ¬ice) + restfulx.BindJsonAndValid(rc.GinCtx, ¬ice) notice.UserName = rc.LoginAccount.UserName p.NoticeApp.Insert(notice) } @@ -72,9 +72,9 @@ func (p *NoticeApi) InsertNotice(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/notice [put] // @Security X-TOKEN -func (p *NoticeApi) UpdateNotice(rc *ginx.ReqCtx) { +func (p *NoticeApi) UpdateNotice(rc *restfulx.ReqCtx) { var notice entity.SysNotice - ginx.BindJsonAndValid(rc.GinCtx, ¬ice) + restfulx.BindJsonAndValid(rc.GinCtx, ¬ice) p.NoticeApp.Update(notice) } @@ -86,7 +86,7 @@ func (p *NoticeApi) UpdateNotice(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/notice/{noticeId} [delete] -func (p *NoticeApi) DeleteNotice(rc *ginx.ReqCtx) { +func (p *NoticeApi) DeleteNotice(rc *restfulx.ReqCtx) { noticeId := rc.GinCtx.Param("noticeId") noticeIds := utils.IdsStrToIdsIntGroup(noticeId) p.NoticeApp.Delete(noticeIds) diff --git a/apps/system/api/post.go b/apps/system/api/post.go index 8242d01..45b6da0 100644 --- a/apps/system/api/post.go +++ b/apps/system/api/post.go @@ -3,11 +3,11 @@ package api import ( "errors" "fmt" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/system/entity" "pandax/apps/system/services" - "pandax/base/biz" - "pandax/base/ginx" - "pandax/base/utils" "pandax/pkg/global" ) @@ -28,10 +28,10 @@ type PostApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/post [get] // @Security -func (p *PostApi) GetPostList(rc *ginx.ReqCtx) { +func (p *PostApi) GetPostList(rc *restfulx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) + 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") @@ -58,8 +58,8 @@ func (p *PostApi) GetPostList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/post/{postId} [get] // @Security -func (p *PostApi) GetPost(rc *ginx.ReqCtx) { - postId := ginx.PathParamInt(rc.GinCtx, "postId") +func (p *PostApi) GetPost(rc *restfulx.ReqCtx) { + postId := restfulx.PathParamInt(rc.GinCtx, "postId") p.PostApp.FindOne(int64(postId)) } @@ -73,9 +73,9 @@ func (p *PostApi) GetPost(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/post [post] // @Security X-TOKEN -func (p *PostApi) InsertPost(rc *ginx.ReqCtx) { +func (p *PostApi) InsertPost(rc *restfulx.ReqCtx) { var post entity.SysPost - ginx.BindJsonAndValid(rc.GinCtx, &post) + restfulx.BindJsonAndValid(rc.GinCtx, &post) post.TenantId = rc.LoginAccount.TenantId post.CreateBy = rc.LoginAccount.UserName p.PostApp.Insert(post) @@ -91,9 +91,9 @@ func (p *PostApi) InsertPost(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/post [put] // @Security X-TOKEN -func (p *PostApi) UpdatePost(rc *ginx.ReqCtx) { +func (p *PostApi) UpdatePost(rc *restfulx.ReqCtx) { var post entity.SysPost - ginx.BindJsonAndValid(rc.GinCtx, &post) + restfulx.BindJsonAndValid(rc.GinCtx, &post) post.CreateBy = rc.LoginAccount.UserName p.PostApp.Update(post) @@ -106,7 +106,7 @@ func (p *PostApi) UpdatePost(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/post/{postId} [delete] -func (p *PostApi) DeletePost(rc *ginx.ReqCtx) { +func (p *PostApi) DeletePost(rc *restfulx.ReqCtx) { postId := rc.GinCtx.Param("postId") postIds := utils.IdsStrToIdsIntGroup(postId) diff --git a/apps/system/api/role.go b/apps/system/api/role.go index e64ebe3..e54e6ff 100644 --- a/apps/system/api/role.go +++ b/apps/system/api/role.go @@ -3,12 +3,12 @@ package api import ( "errors" "fmt" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/casbin" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" entity "pandax/apps/system/entity" services "pandax/apps/system/services" - "pandax/base/biz" - "pandax/base/casbin" - "pandax/base/ginx" - "pandax/base/utils" "pandax/pkg/global" "strconv" ) @@ -31,9 +31,9 @@ type RoleApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/role/rolelist [get] // @Security -func (r *RoleApi) GetRoleList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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") @@ -61,8 +61,8 @@ func (r *RoleApi) GetRoleList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "抱歉未找到相关信息"}" // @Router /system/role [get] // @Security X-TOKEN -func (r *RoleApi) GetRole(rc *ginx.ReqCtx) { - roleId := ginx.PathParamInt(rc.GinCtx, "roleId") +func (r *RoleApi) GetRole(rc *restfulx.ReqCtx) { + roleId := restfulx.PathParamInt(rc.GinCtx, "roleId") role := r.RoleApp.FindOne(int64(roleId)) role.MenuIds = r.RoleApp.GetRoleMeunId(entity.SysRole{RoleId: int64(roleId)}) @@ -78,9 +78,9 @@ func (r *RoleApi) GetRole(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/role [post] -func (r *RoleApi) InsertRole(rc *ginx.ReqCtx) { +func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) { var role entity.SysRole - ginx.BindJsonAndValid(rc.GinCtx, &role) + restfulx.BindJsonAndValid(rc.GinCtx, &role) role.CreateBy = rc.LoginAccount.UserName role.TenantId = rc.LoginAccount.TenantId insert := r.RoleApp.Insert(role) @@ -100,9 +100,9 @@ func (r *RoleApi) InsertRole(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "修改成功"}" // @Success 200 {string} string "{"code": 400, "message": "修改失败"}" // @Router /system/role [put] -func (r *RoleApi) UpdateRole(rc *ginx.ReqCtx) { +func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) { var role entity.SysRole - ginx.BindJsonAndValid(rc.GinCtx, &role) + restfulx.BindJsonAndValid(rc.GinCtx, &role) role.UpdateBy = rc.LoginAccount.UserName // 修改角色 r.RoleApp.Update(role) @@ -124,9 +124,9 @@ func (r *RoleApi) UpdateRole(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "修改成功"}" // @Success 200 {string} string "{"code": 400, "message": "修改失败"}" // @Router /system/role/changeStatus [put] -func (r *RoleApi) UpdateRoleStatus(rc *ginx.ReqCtx) { +func (r *RoleApi) UpdateRoleStatus(rc *restfulx.ReqCtx) { var role entity.SysRole - ginx.BindJsonAndValid(rc.GinCtx, &role) + restfulx.BindJsonAndValid(rc.GinCtx, &role) role.UpdateBy = rc.LoginAccount.UserName // 修改角色 r.RoleApp.Update(role) @@ -141,9 +141,9 @@ func (r *RoleApi) UpdateRoleStatus(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "修改成功"}" // @Success 200 {string} string "{"code": 400, "message": "修改失败"}" // @Router /system/role/dataScope [put] -func (r *RoleApi) UpdateRoleDataScope(rc *ginx.ReqCtx) { +func (r *RoleApi) UpdateRoleDataScope(rc *restfulx.ReqCtx) { var role entity.SysRole - ginx.BindJsonAndValid(rc.GinCtx, &role) + restfulx.BindJsonAndValid(rc.GinCtx, &role) role.UpdateBy = rc.LoginAccount.UserName // 修改角色 update := r.RoleApp.Update(role) @@ -162,7 +162,7 @@ func (r *RoleApi) UpdateRoleDataScope(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/role/{roleId} [delete] -func (r *RoleApi) DeleteRole(rc *ginx.ReqCtx) { +func (r *RoleApi) DeleteRole(rc *restfulx.ReqCtx) { roleId := rc.GinCtx.Param("roleId") roleIds := utils.IdsStrToIdsIntGroup(roleId) @@ -197,7 +197,7 @@ func (r *RoleApi) DeleteRole(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/type/export [get] -func (p *RoleApi) ExportRole(rc *ginx.ReqCtx) { +func (p *RoleApi) ExportRole(rc *restfulx.ReqCtx) { filename := rc.GinCtx.Query("filename") status := rc.GinCtx.Query("status") roleName := rc.GinCtx.Query("roleName") diff --git a/apps/system/api/system.go b/apps/system/api/system.go index 7c04897..e6e8806 100644 --- a/apps/system/api/system.go +++ b/apps/system/api/system.go @@ -2,13 +2,13 @@ package api import ( "fmt" + "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/gorilla/websocket" "github.com/kakuilan/kgo" "net/http" - "pandax/base/biz" - "pandax/base/ginx" - "pandax/base/ws" "runtime" ) @@ -71,8 +71,8 @@ func (s *System) ConnectWs(g *gin.Context) { panic(any(biz.NewBizErr("升级websocket失败"))) } // 权限校验 - rc := ginx.NewReqCtx(g) - if err = ginx.PermissionHandler(rc); err != nil { + rc := restfulx.NewReqCtx(g) + 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 2f688f1..6586f19 100644 --- a/apps/system/api/tenant.go +++ b/apps/system/api/tenant.go @@ -6,10 +6,10 @@ package api * @Date 2022/7/14 17:55 **/ import ( + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/system/entity" "pandax/apps/system/services" - "pandax/base/ginx" - "pandax/base/utils" ) type SysTenantsApi struct { @@ -23,10 +23,10 @@ type SysTenantsApi struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/tenant/list [get] // @Security -func (p *SysTenantsApi) GetSysTenantsList(rc *ginx.ReqCtx) { +func (p *SysTenantsApi) GetSysTenantsList(rc *restfulx.ReqCtx) { data := entity.SysTenants{} - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) + pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) + pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) list, total := p.SysTenantsApp.FindListPage(pageNum, pageSize, data) @@ -43,7 +43,7 @@ func (p *SysTenantsApi) GetSysTenantsList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/tenant/lists [get] // @Security -func (p *SysTenantsApi) GetSysTenantsAll(rc *ginx.ReqCtx) { +func (p *SysTenantsApi) GetSysTenantsAll(rc *restfulx.ReqCtx) { list := make([]entity.SysTenants, 0) if rc.LoginAccount.RoleKey == "admin" { data := entity.SysTenants{} @@ -61,8 +61,8 @@ func (p *SysTenantsApi) GetSysTenantsAll(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/tenant/{tenantId} [get] // @Security -func (p *SysTenantsApi) GetSysTenants(rc *ginx.ReqCtx) { - tenantId := ginx.PathParamInt(rc.GinCtx, "tenantId") +func (p *SysTenantsApi) GetSysTenants(rc *restfulx.ReqCtx) { + tenantId := restfulx.PathParamInt(rc.GinCtx, "tenantId") p.SysTenantsApp.FindOne(int64(tenantId)) } @@ -76,9 +76,9 @@ func (p *SysTenantsApi) GetSysTenants(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/tenant [post] // @Security X-TOKEN -func (p *SysTenantsApi) InsertSysTenants(rc *ginx.ReqCtx) { +func (p *SysTenantsApi) InsertSysTenants(rc *restfulx.ReqCtx) { var data entity.SysTenants - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) p.SysTenantsApp.Insert(data) } @@ -93,9 +93,9 @@ func (p *SysTenantsApi) InsertSysTenants(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/tenant [put] // @Security X-TOKEN -func (p *SysTenantsApi) UpdateSysTenants(rc *ginx.ReqCtx) { +func (p *SysTenantsApi) UpdateSysTenants(rc *restfulx.ReqCtx) { var data entity.SysTenants - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) p.SysTenantsApp.Update(data) } @@ -107,7 +107,7 @@ func (p *SysTenantsApi) UpdateSysTenants(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/tenant/{tenantId} [delete] -func (p *SysTenantsApi) DeleteSysTenants(rc *ginx.ReqCtx) { +func (p *SysTenantsApi) DeleteSysTenants(rc *restfulx.ReqCtx) { tenantId := rc.GinCtx.Param("tenantId") tenantIds := utils.IdsStrToIdsIntGroup(tenantId) p.SysTenantsApp.Delete(tenantIds) diff --git a/apps/system/api/user.go b/apps/system/api/user.go index cef899d..d1d78ac 100644 --- a/apps/system/api/user.go +++ b/apps/system/api/user.go @@ -1,6 +1,7 @@ package api import ( + "github.com/XM-GO/PandaKit/token" "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" "github.com/kakuilan/kgo" @@ -9,16 +10,15 @@ import ( "pandax/apps/system/api/form" "pandax/apps/system/api/vo" "pandax/apps/system/entity" - "pandax/base/token" logEntity "pandax/apps/log/entity" logServices "pandax/apps/log/services" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/captcha" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "pandax/apps/system/services" - "pandax/base/biz" - "pandax/base/captcha" - "pandax/base/ginx" - "pandax/base/utils" "pandax/pkg/global" "strings" "time" @@ -49,7 +49,7 @@ func (u *UserApi) GenerateCaptcha(c *gin.Context) { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}" // @Router /system/user/refreshToken [get] -func (u *UserApi) RefreshToken(rc *ginx.ReqCtx) { +func (u *UserApi) RefreshToken(rc *restfulx.ReqCtx) { tokenStr := rc.GinCtx.Request.Header.Get("X-TOKEN") j := token.NewJWT("", []byte(global.Conf.Jwt.Key), jwt.SigningMethodHS256) token, err := j.RefreshToken(tokenStr) @@ -63,9 +63,9 @@ func (u *UserApi) RefreshToken(rc *ginx.ReqCtx) { // @Param data body form.Login true "用户名, 密码, 验证码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}" // @Router /system/user/login [post] -func (u *UserApi) Login(rc *ginx.ReqCtx) { +func (u *UserApi) Login(rc *restfulx.ReqCtx) { var l form.Login - ginx.BindJsonAndValid(rc.GinCtx, &l) + restfulx.BindJsonAndValid(rc.GinCtx, &l) biz.IsTrue(captcha.Verify(l.CaptchaId, l.Captcha), "验证码认证失败") login := u.UserApp.Login(entity.Login{Username: l.Username, Password: l.Password}) @@ -115,7 +115,7 @@ func (u *UserApi) Login(rc *ginx.ReqCtx) { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"成功"}" // @Router /system/user/auth [get] -func (u *UserApi) Auth(rc *ginx.ReqCtx) { +func (u *UserApi) Auth(rc *restfulx.ReqCtx) { userName := rc.GinCtx.Query("username") biz.NotEmpty(userName, "用户名必传") var user entity.SysUser @@ -139,7 +139,7 @@ func (u *UserApi) Auth(rc *ginx.ReqCtx) { // @Produce application/json // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}" // @Router /system/user/logout [post] -func (u *UserApi) LogOut(rc *ginx.ReqCtx) { +func (u *UserApi) LogOut(rc *restfulx.ReqCtx) { var loginLog logEntity.LogLogin ua := user_agent.New(rc.GinCtx.Request.UserAgent()) loginLog.Ipaddr = rc.GinCtx.ClientIP() @@ -167,13 +167,13 @@ func (u *UserApi) LogOut(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": -1, "message": "抱歉未找到相关信息"}" // @Router /system/user/sysUserList [get] // @Security X-TOKEN -func (u *UserApi) GetSysUserList(rc *ginx.ReqCtx) { - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) +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 := ginx.QueryInt(rc.GinCtx, "deptId", 0) + deptId := restfulx.QueryInt(rc.GinCtx, "deptId", 0) var user entity.SysUser user.Status = status user.Username = userName @@ -199,7 +199,7 @@ func (u *UserApi) GetSysUserList(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/user/profile [get] // @Security -func (u *UserApi) GetSysUserProfile(rc *ginx.ReqCtx) { +func (u *UserApi) GetSysUserProfile(rc *restfulx.ReqCtx) { sysUser := entity.SysUser{} sysUser.UserId = rc.LoginAccount.UserId @@ -235,7 +235,7 @@ func (u *UserApi) GetSysUserProfile(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /system/user/profileAvatar [post] -func (u *UserApi) InsetSysUserAvatar(rc *ginx.ReqCtx) { +func (u *UserApi) InsetSysUserAvatar(rc *restfulx.ReqCtx) { form, err := rc.GinCtx.MultipartForm() biz.ErrIsNil(err, "头像上传失败") @@ -262,9 +262,9 @@ func (u *UserApi) InsetSysUserAvatar(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /system/user/updatePwd [post] -func (u *UserApi) SysUserUpdatePwd(rc *ginx.ReqCtx) { +func (u *UserApi) SysUserUpdatePwd(rc *restfulx.ReqCtx) { var pws entity.SysUserPwd - ginx.BindJsonAndValid(rc.GinCtx, &pws) + restfulx.BindJsonAndValid(rc.GinCtx, &pws) user := entity.SysUser{} user.UserId = rc.LoginAccount.UserId @@ -278,8 +278,8 @@ func (u *UserApi) SysUserUpdatePwd(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/user/sysUser/{userId} [get] // @Security -func (u *UserApi) GetSysUser(rc *ginx.ReqCtx) { - userId := ginx.PathParamInt(rc.GinCtx, "userId") +func (u *UserApi) GetSysUser(rc *restfulx.ReqCtx) { + userId := restfulx.PathParamInt(rc.GinCtx, "userId") user := entity.SysUser{} user.UserId = int64(userId) @@ -312,7 +312,7 @@ func (u *UserApi) GetSysUser(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/user/getInit [get] // @Security -func (u *UserApi) GetSysUserInit(rc *ginx.ReqCtx) { +func (u *UserApi) GetSysUserInit(rc *restfulx.ReqCtx) { var role entity.SysRole if !IsTenantAdmin(rc.LoginAccount.TenantId) { @@ -336,7 +336,7 @@ func (u *UserApi) GetSysUserInit(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /system/user/getInit [get] // @Security -func (u *UserApi) GetUserRolePost(rc *ginx.ReqCtx) { +func (u *UserApi) GetUserRolePost(rc *restfulx.ReqCtx) { var user entity.SysUser user.UserId = rc.LoginAccount.UserId @@ -367,9 +367,9 @@ func (u *UserApi) GetUserRolePost(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/user/sysUser [post] -func (u *UserApi) InsertSysUser(rc *ginx.ReqCtx) { +func (u *UserApi) InsertSysUser(rc *restfulx.ReqCtx) { var sysUser entity.SysUser - ginx.BindJsonAndValid(rc.GinCtx, &sysUser) + restfulx.BindJsonAndValid(rc.GinCtx, &sysUser) sysUser.CreateBy = rc.LoginAccount.UserName u.UserApp.Insert(sysUser) } @@ -383,9 +383,9 @@ func (u *UserApi) InsertSysUser(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/user/sysUser [put] -func (u *UserApi) UpdateSysUser(rc *ginx.ReqCtx) { +func (u *UserApi) UpdateSysUser(rc *restfulx.ReqCtx) { var sysUser entity.SysUser - ginx.BindJsonAndValid(rc.GinCtx, &sysUser) + restfulx.BindJsonAndValid(rc.GinCtx, &sysUser) sysUser.CreateBy = rc.LoginAccount.UserName u.UserApp.Update(sysUser) } @@ -399,9 +399,9 @@ func (u *UserApi) UpdateSysUser(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /system/user/sysUser [put] -func (u *UserApi) UpdateSysUserStu(rc *ginx.ReqCtx) { +func (u *UserApi) UpdateSysUserStu(rc *restfulx.ReqCtx) { var sysUser entity.SysUser - ginx.BindJsonAndValid(rc.GinCtx, &sysUser) + restfulx.BindJsonAndValid(rc.GinCtx, &sysUser) sysUser.CreateBy = rc.LoginAccount.UserName u.UserApp.Update(sysUser) } @@ -413,7 +413,7 @@ func (u *UserApi) UpdateSysUserStu(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/user/sysuser/{userId} [delete] -func (u *UserApi) DeleteSysUser(rc *ginx.ReqCtx) { +func (u *UserApi) DeleteSysUser(rc *restfulx.ReqCtx) { userIds := rc.GinCtx.Param("userId") us := utils.IdsStrToIdsIntGroup(userIds) u.UserApp.Delete(us) @@ -428,7 +428,7 @@ func (u *UserApi) DeleteSysUser(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /system/dict/type/export [get] -func (u *UserApi) ExportUser(rc *ginx.ReqCtx) { +func (u *UserApi) ExportUser(rc *restfulx.ReqCtx) { filename := rc.GinCtx.Query("filename") status := rc.GinCtx.Query("status") userName := rc.GinCtx.Query("username") diff --git a/apps/system/entity/api.go b/apps/system/entity/api.go index 0a383a3..9167c4a 100644 --- a/apps/system/entity/api.go +++ b/apps/system/entity/api.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type SysApi struct { model.BaseAutoModel diff --git a/apps/system/entity/config.go b/apps/system/entity/config.go index 9e0a315..94e2d80 100644 --- a/apps/system/entity/config.go +++ b/apps/system/entity/config.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type SysConfig struct { ConfigId int64 `json:"configId" gorm:"primaryKey;AUTO_INCREMENT;comment:主键编码"` diff --git a/apps/system/entity/dept.go b/apps/system/entity/dept.go index 940976a..a065a7a 100644 --- a/apps/system/entity/dept.go +++ b/apps/system/entity/dept.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type SysDept struct { DeptId int64 `json:"deptId" gorm:"primary_key;AUTO_INCREMENT"` //部门编码 diff --git a/apps/system/entity/dict.go b/apps/system/entity/dict.go index b055e05..99cdab3 100644 --- a/apps/system/entity/dict.go +++ b/apps/system/entity/dict.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type SysDictData struct { DictCode int64 `json:"dictCode" gorm:"primary_key;AUTO_INCREMENT"` diff --git a/apps/system/entity/menu.go b/apps/system/entity/menu.go index cf69806..b84d15d 100644 --- a/apps/system/entity/menu.go +++ b/apps/system/entity/menu.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type SysMenu struct { MenuId int64 `json:"menuId" gorm:"primary_key;AUTO_INCREMENT"` diff --git a/apps/system/entity/notice.go b/apps/system/entity/notice.go index 127907b..224b2e4 100644 --- a/apps/system/entity/notice.go +++ b/apps/system/entity/notice.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type SysNotice struct { NoticeId int64 `json:"noticeId" gorm:"primary_key;AUTO_INCREMENT"` diff --git a/apps/system/entity/post.go b/apps/system/entity/post.go index 8a8fb94..8b9b5f3 100644 --- a/apps/system/entity/post.go +++ b/apps/system/entity/post.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type SysPost struct { PostId int64 `gorm:"primary_key;AUTO_INCREMENT" json:"postId"` diff --git a/apps/system/entity/role.go b/apps/system/entity/role.go index cf1d933..c88b621 100644 --- a/apps/system/entity/role.go +++ b/apps/system/entity/role.go @@ -1,8 +1,8 @@ package entity import ( - "pandax/base/casbin" - "pandax/base/model" + "github.com/XM-GO/PandaKit/casbin" + "github.com/XM-GO/PandaKit/model" ) type SysRole struct { diff --git a/apps/system/entity/tenant.go b/apps/system/entity/tenant.go index 1536437..1029f8e 100644 --- a/apps/system/entity/tenant.go +++ b/apps/system/entity/tenant.go @@ -1,7 +1,7 @@ package entity import ( - "pandax/base/model" + "github.com/XM-GO/PandaKit/model" "time" ) diff --git a/apps/system/entity/user.go b/apps/system/entity/user.go index b0da248..749b6a8 100644 --- a/apps/system/entity/user.go +++ b/apps/system/entity/user.go @@ -1,6 +1,6 @@ package entity -import "pandax/base/model" +import "github.com/XM-GO/PandaKit/model" type LoginM struct { Username string `gorm:"type:varchar(64)" json:"username"` diff --git a/apps/system/router/api.go b/apps/system/router/api.go index eadcdca..571ec71 100644 --- a/apps/system/router/api.go +++ b/apps/system/router/api.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitApiRouter(router *gin.RouterGroup) { @@ -14,30 +14,30 @@ func InitApiRouter(router *gin.RouterGroup) { api := router.Group("api") api.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取api分页列表").Handle(s.GetApiList) + restfulx.NewReqCtx(c).WithLog("获取api分页列表").Handle(s.GetApiList) }) api.GET("all", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取所有api").Handle(s.GetAllApis) + restfulx.NewReqCtx(c).WithLog("获取所有api").Handle(s.GetAllApis) }) api.GET("getPolicyPathByRoleId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取角色拥有的api权限").Handle(s.GetPolicyPathByRoleId) + restfulx.NewReqCtx(c).WithLog("获取角色拥有的api权限").Handle(s.GetPolicyPathByRoleId) }) api.GET(":id", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取api信息").Handle(s.GetApiById) + restfulx.NewReqCtx(c).WithLog("获取api信息").Handle(s.GetApiById) }) api.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加api信息").Handle(s.CreateApi) + restfulx.NewReqCtx(c).WithLog("添加api信息").Handle(s.CreateApi) }) api.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改api信息").Handle(s.UpdateApi) + restfulx.NewReqCtx(c).WithLog("修改api信息").Handle(s.UpdateApi) }) api.DELETE(":id", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除api信息").Handle(s.DeleteApi) + restfulx.NewReqCtx(c).WithLog("删除api信息").Handle(s.DeleteApi) }) } diff --git a/apps/system/router/config.go b/apps/system/router/config.go index 17746c6..88c4b21 100644 --- a/apps/system/router/config.go +++ b/apps/system/router/config.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitConfigRouter(router *gin.RouterGroup) { @@ -14,26 +14,26 @@ func InitConfigRouter(router *gin.RouterGroup) { config := router.Group("config") config.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取配置分页列表").Handle(s.GetConfigList) + restfulx.NewReqCtx(c).WithLog("获取配置分页列表").Handle(s.GetConfigList) }) config.GET("configKey", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取配置列表通过ConfigKey").Handle(s.GetConfigListByKey) + restfulx.NewReqCtx(c).WithLog("获取配置列表通过ConfigKey").Handle(s.GetConfigListByKey) }) config.GET(":configId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取配置信息").Handle(s.GetConfig) + restfulx.NewReqCtx(c).WithLog("获取配置信息").Handle(s.GetConfig) }) config.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加配置信息").Handle(s.InsertConfig) + restfulx.NewReqCtx(c).WithLog("添加配置信息").Handle(s.InsertConfig) }) config.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改配置信息").Handle(s.UpdateConfig) + restfulx.NewReqCtx(c).WithLog("修改配置信息").Handle(s.UpdateConfig) }) config.DELETE(":configId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除配置信息").Handle(s.DeleteConfig) + restfulx.NewReqCtx(c).WithLog("删除配置信息").Handle(s.DeleteConfig) }) } diff --git a/apps/system/router/dept.go b/apps/system/router/dept.go index 4cc3a6f..6438c13 100644 --- a/apps/system/router/dept.go +++ b/apps/system/router/dept.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitDeptRouter(router *gin.RouterGroup) { @@ -16,30 +16,30 @@ func InitDeptRouter(router *gin.RouterGroup) { dept := router.Group("dept") dept.GET("roleDeptTreeSelect/:roleId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取角色部门树").Handle(r.GetDeptTreeRoleSelect) + restfulx.NewReqCtx(c).WithLog("获取角色部门树").Handle(r.GetDeptTreeRoleSelect) }) dept.GET("deptTree", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取所有部门树").Handle(r.GetDeptTree) + restfulx.NewReqCtx(c).WithLog("获取所有部门树").Handle(r.GetDeptTree) }) dept.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取部门列表").Handle(r.GetDeptList) + restfulx.NewReqCtx(c).WithLog("获取部门列表").Handle(r.GetDeptList) }) dept.GET(":deptId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取部门信息").Handle(r.GetDept) + restfulx.NewReqCtx(c).WithLog("获取部门信息").Handle(r.GetDept) }) dept.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加部门信息").Handle(r.InsertDept) + restfulx.NewReqCtx(c).WithLog("添加部门信息").Handle(r.InsertDept) }) dept.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改部门信息").Handle(r.UpdateDept) + restfulx.NewReqCtx(c).WithLog("修改部门信息").Handle(r.UpdateDept) }) dept.DELETE(":deptId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除部门信息").Handle(r.DeleteDept) + restfulx.NewReqCtx(c).WithLog("删除部门信息").Handle(r.DeleteDept) }) } diff --git a/apps/system/router/dict.go b/apps/system/router/dict.go index 5e401e9..e407a08 100644 --- a/apps/system/router/dict.go +++ b/apps/system/router/dict.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitDictRouter(router *gin.RouterGroup) { @@ -15,51 +15,51 @@ func InitDictRouter(router *gin.RouterGroup) { dict := router.Group("dict") dict.GET("type/list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取字典类型分页列表").Handle(s.GetDictTypeList) + restfulx.NewReqCtx(c).WithLog("获取字典类型分页列表").Handle(s.GetDictTypeList) }) dict.GET("type/:dictId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取字典类型信息").Handle(s.GetDictType) + restfulx.NewReqCtx(c).WithLog("获取字典类型信息").Handle(s.GetDictType) }) dict.POST("type", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加字典类型信息").Handle(s.InsertDictType) + restfulx.NewReqCtx(c).WithLog("添加字典类型信息").Handle(s.InsertDictType) }) dict.PUT("type", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改字典类型信息").Handle(s.UpdateDictType) + restfulx.NewReqCtx(c).WithLog("修改字典类型信息").Handle(s.UpdateDictType) }) dict.DELETE("type/:dictId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除字典类型信息").Handle(s.DeleteDictType) + restfulx.NewReqCtx(c).WithLog("删除字典类型信息").Handle(s.DeleteDictType) }) dict.GET("type/export", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("导出字典类型信息").Handle(s.ExportDictType) + restfulx.NewReqCtx(c).WithLog("导出字典类型信息").Handle(s.ExportDictType) }) dict.GET("data/list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取字典数据分页列表").Handle(s.GetDictDataList) + restfulx.NewReqCtx(c).WithLog("获取字典数据分页列表").Handle(s.GetDictDataList) }) dict.GET("data/type", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取字典数据列表通过字典类型").Handle(s.GetDictDataListByDictType) + restfulx.NewReqCtx(c).WithLog("获取字典数据列表通过字典类型").Handle(s.GetDictDataListByDictType) }) dict.GET("data/:dictCode", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取字典数据信息").Handle(s.GetDictData) + restfulx.NewReqCtx(c).WithLog("获取字典数据信息").Handle(s.GetDictData) }) dict.POST("data", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加字典数据信息").Handle(s.InsertDictData) + restfulx.NewReqCtx(c).WithLog("添加字典数据信息").Handle(s.InsertDictData) }) dict.PUT("data", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改字典数据信息").Handle(s.UpdateDictData) + restfulx.NewReqCtx(c).WithLog("修改字典数据信息").Handle(s.UpdateDictData) }) dict.DELETE("data/:dictCode", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除字典数据信息").Handle(s.DeleteDictData) + restfulx.NewReqCtx(c).WithLog("删除字典数据信息").Handle(s.DeleteDictData) }) } diff --git a/apps/system/router/menu.go b/apps/system/router/menu.go index bd22971..cdc7106 100644 --- a/apps/system/router/menu.go +++ b/apps/system/router/menu.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitMenuRouter(router *gin.RouterGroup) { @@ -17,38 +17,38 @@ func InitMenuRouter(router *gin.RouterGroup) { menu := router.Group("menu") menu.GET("menuTreeSelect", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取菜单树").WithNeedToken(false).WithNeedCasbin(false).Handle(s.GetMenuTreeSelect) + restfulx.NewReqCtx(c).WithLog("获取菜单树").WithNeedToken(false).WithNeedCasbin(false).Handle(s.GetMenuTreeSelect) }) menu.GET("menuRole", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取角色菜单").Handle(s.GetMenuRole) + restfulx.NewReqCtx(c).WithLog("获取角色菜单").Handle(s.GetMenuRole) }) menu.GET("roleMenuTreeSelect/:roleId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取角色菜单树").Handle(s.GetMenuTreeRoleSelect) + restfulx.NewReqCtx(c).WithLog("获取角色菜单树").Handle(s.GetMenuTreeRoleSelect) }) menu.GET("menuPaths", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取角色菜单路径列表").Handle(s.GetMenuPaths) + restfulx.NewReqCtx(c).WithLog("获取角色菜单路径列表").Handle(s.GetMenuPaths) }) menu.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取菜单列表").Handle(s.GetMenuList) + restfulx.NewReqCtx(c).WithLog("获取菜单列表").Handle(s.GetMenuList) }) menu.GET(":menuId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取菜单信息").Handle(s.GetMenu) + restfulx.NewReqCtx(c).WithLog("获取菜单信息").Handle(s.GetMenu) }) menu.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加菜单信息").Handle(s.InsertMenu) + restfulx.NewReqCtx(c).WithLog("添加菜单信息").Handle(s.InsertMenu) }) menu.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改菜单信息").Handle(s.UpdateMenu) + restfulx.NewReqCtx(c).WithLog("修改菜单信息").Handle(s.UpdateMenu) }) menu.DELETE(":menuId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除菜单信息").Handle(s.DeleteMenu) + restfulx.NewReqCtx(c).WithLog("删除菜单信息").Handle(s.DeleteMenu) }) } diff --git a/apps/system/router/notice.go b/apps/system/router/notice.go index 1ca5040..f5f448c 100644 --- a/apps/system/router/notice.go +++ b/apps/system/router/notice.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitNoticeRouter(router *gin.RouterGroup) { @@ -15,18 +15,18 @@ func InitNoticeRouter(router *gin.RouterGroup) { notice := router.Group("notice") notice.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取通知分页列表").Handle(s.GetNoticeList) + restfulx.NewReqCtx(c).WithLog("获取通知分页列表").Handle(s.GetNoticeList) }) notice.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加通知信息").Handle(s.InsertNotice) + restfulx.NewReqCtx(c).WithLog("添加通知信息").Handle(s.InsertNotice) }) notice.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改通知信息").Handle(s.UpdateNotice) + restfulx.NewReqCtx(c).WithLog("修改通知信息").Handle(s.UpdateNotice) }) notice.DELETE(":noticeId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除通知信息").Handle(s.DeleteNotice) + restfulx.NewReqCtx(c).WithLog("删除通知信息").Handle(s.DeleteNotice) }) } diff --git a/apps/system/router/post.go b/apps/system/router/post.go index 5215a36..5baf738 100644 --- a/apps/system/router/post.go +++ b/apps/system/router/post.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitPostRouter(router *gin.RouterGroup) { @@ -16,22 +16,22 @@ func InitPostRouter(router *gin.RouterGroup) { post := router.Group("post") post.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取岗位分页列表").Handle(s.GetPostList) + restfulx.NewReqCtx(c).WithLog("获取岗位分页列表").Handle(s.GetPostList) }) post.GET(":postId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取岗位信息").Handle(s.GetPost) + restfulx.NewReqCtx(c).WithLog("获取岗位信息").Handle(s.GetPost) }) post.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加岗位信息").Handle(s.InsertPost) + restfulx.NewReqCtx(c).WithLog("添加岗位信息").Handle(s.InsertPost) }) post.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改岗位信息").Handle(s.UpdatePost) + restfulx.NewReqCtx(c).WithLog("修改岗位信息").Handle(s.UpdatePost) }) post.DELETE(":postId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除岗位信息").Handle(s.DeletePost) + restfulx.NewReqCtx(c).WithLog("删除岗位信息").Handle(s.DeletePost) }) } diff --git a/apps/system/router/role.go b/apps/system/router/role.go index a9dcb85..2e865ee 100644 --- a/apps/system/router/role.go +++ b/apps/system/router/role.go @@ -1,10 +1,10 @@ package router import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitRoleRouter(router *gin.RouterGroup) { @@ -17,34 +17,34 @@ func InitRoleRouter(router *gin.RouterGroup) { role := router.Group("role") role.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取角色分页列表").Handle(s.GetRoleList) + restfulx.NewReqCtx(c).WithLog("获取角色分页列表").Handle(s.GetRoleList) }) role.GET(":roleId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取角色信息").Handle(s.GetRole) + restfulx.NewReqCtx(c).WithLog("获取角色信息").Handle(s.GetRole) }) role.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加角色信息").Handle(s.InsertRole) + restfulx.NewReqCtx(c).WithLog("添加角色信息").Handle(s.InsertRole) }) role.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改角色信息").Handle(s.UpdateRole) + restfulx.NewReqCtx(c).WithLog("修改角色信息").Handle(s.UpdateRole) }) role.PUT("changeStatus", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改角色状态").Handle(s.UpdateRoleStatus) + restfulx.NewReqCtx(c).WithLog("修改角色状态").Handle(s.UpdateRoleStatus) }) role.PUT("dataScope", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改角色部门权限").Handle(s.UpdateRoleDataScope) + restfulx.NewReqCtx(c).WithLog("修改角色部门权限").Handle(s.UpdateRoleDataScope) }) role.DELETE(":roleId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除角色信息").Handle(s.DeleteRole) + restfulx.NewReqCtx(c).WithLog("删除角色信息").Handle(s.DeleteRole) }) role.GET("export", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("导出角色信息").Handle(s.ExportRole) + restfulx.NewReqCtx(c).WithLog("导出角色信息").Handle(s.ExportRole) }) } diff --git a/apps/system/router/tenant.go b/apps/system/router/tenant.go index 9235f15..668b32e 100644 --- a/apps/system/router/tenant.go +++ b/apps/system/router/tenant.go @@ -7,10 +7,10 @@ package router **/ import ( + "github.com/XM-GO/PandaKit/restfulx" "github.com/gin-gonic/gin" "pandax/apps/system/api" "pandax/apps/system/services" - "pandax/base/ginx" ) func InitSysTenantRouter(router *gin.RouterGroup) { @@ -20,26 +20,26 @@ func InitSysTenantRouter(router *gin.RouterGroup) { routerGroup := router.Group("tenant") routerGroup.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取SysTenant分页列表").Handle(s.GetSysTenantsList) + restfulx.NewReqCtx(c).WithLog("获取SysTenant分页列表").Handle(s.GetSysTenantsList) }) routerGroup.GET("lists", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取SysTenant列表").Handle(s.GetSysTenantsAll) + restfulx.NewReqCtx(c).WithLog("获取SysTenant列表").Handle(s.GetSysTenantsAll) }) routerGroup.GET(":tenantId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取SysTenant信息").Handle(s.GetSysTenants) + restfulx.NewReqCtx(c).WithLog("获取SysTenant信息").Handle(s.GetSysTenants) }) routerGroup.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加SysTenant信息").Handle(s.InsertSysTenants) + restfulx.NewReqCtx(c).WithLog("添加SysTenant信息").Handle(s.InsertSysTenants) }) routerGroup.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改SysTenant信息").Handle(s.UpdateSysTenants) + restfulx.NewReqCtx(c).WithLog("修改SysTenant信息").Handle(s.UpdateSysTenants) }) routerGroup.DELETE(":tenantId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除SysTenant信息").Handle(s.DeleteSysTenants) + restfulx.NewReqCtx(c).WithLog("删除SysTenant信息").Handle(s.DeleteSysTenants) }) } diff --git a/apps/system/router/user.go b/apps/system/router/user.go index f55adae..eae97cd 100644 --- a/apps/system/router/user.go +++ b/apps/system/router/user.go @@ -5,8 +5,8 @@ import ( "pandax/apps/system/api" "pandax/apps/system/services" + "github.com/XM-GO/PandaKit/restfulx" logServices "pandax/apps/log/services" - "pandax/base/ginx" ) func InitUserRouter(router *gin.RouterGroup) { @@ -24,56 +24,56 @@ func InitUserRouter(router *gin.RouterGroup) { user.GET("getCaptcha", s.GenerateCaptcha) user.POST("login", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("登录").WithNeedToken(false).WithNeedCasbin(false).Handle(s.Login) + restfulx.NewReqCtx(c).WithLog("登录").WithNeedToken(false).WithNeedCasbin(false).Handle(s.Login) }) user.GET("auth", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("认证信息").WithNeedCasbin(false).Handle(s.Auth) + restfulx.NewReqCtx(c).WithLog("认证信息").WithNeedCasbin(false).Handle(s.Auth) }) user.POST("logout", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("退出登录").WithNeedToken(false).WithNeedCasbin(false).Handle(s.LogOut) + restfulx.NewReqCtx(c).WithLog("退出登录").WithNeedToken(false).WithNeedCasbin(false).Handle(s.LogOut) }) user.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("得到用户分页列表").Handle(s.GetSysUserList) + restfulx.NewReqCtx(c).WithLog("得到用户分页列表").Handle(s.GetSysUserList) }) user.POST("avatar", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改用户头像").Handle(s.InsetSysUserAvatar) + restfulx.NewReqCtx(c).WithLog("修改用户头像").Handle(s.InsetSysUserAvatar) }) user.PUT("pwd", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改用户密码").Handle(s.SysUserUpdatePwd) + restfulx.NewReqCtx(c).WithLog("修改用户密码").Handle(s.SysUserUpdatePwd) }) user.GET("getById/:userId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取用户信息").Handle(s.GetSysUser) + restfulx.NewReqCtx(c).WithLog("获取用户信息").Handle(s.GetSysUser) }) user.GET("getInit", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取初始化角色岗位信息(添加用户初始化)").Handle(s.GetSysUserInit) + restfulx.NewReqCtx(c).WithLog("获取初始化角色岗位信息(添加用户初始化)").Handle(s.GetSysUserInit) }) user.GET("getRoPo", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("获取用户角色岗位信息(添加用户初始化)").Handle(s.GetUserRolePost) + restfulx.NewReqCtx(c).WithLog("获取用户角色岗位信息(添加用户初始化)").Handle(s.GetUserRolePost) }) user.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("添加用户信息").Handle(s.InsertSysUser) + restfulx.NewReqCtx(c).WithLog("添加用户信息").Handle(s.InsertSysUser) }) user.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改用户信息").Handle(s.UpdateSysUser) + restfulx.NewReqCtx(c).WithLog("修改用户信息").Handle(s.UpdateSysUser) }) user.PUT("changeStatus", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("修改用户状态").Handle(s.UpdateSysUserStu) + restfulx.NewReqCtx(c).WithLog("修改用户状态").Handle(s.UpdateSysUserStu) }) user.DELETE(":userId", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("删除用户信息").Handle(s.DeleteSysUser) + restfulx.NewReqCtx(c).WithLog("删除用户信息").Handle(s.DeleteSysUser) }) user.GET("export", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog("导出用户信息").Handle(s.ExportUser) + restfulx.NewReqCtx(c).WithLog("导出用户信息").Handle(s.ExportUser) }) } diff --git a/apps/system/services/api.go b/apps/system/services/api.go index aeadd44..3d57db2 100644 --- a/apps/system/services/api.go +++ b/apps/system/services/api.go @@ -2,10 +2,10 @@ package services import ( "errors" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/casbin" "gorm.io/gorm" "pandax/apps/system/entity" - "pandax/base/biz" - "pandax/base/casbin" "pandax/pkg/global" ) diff --git a/apps/system/services/config.go b/apps/system/services/config.go index 7fd81d2..1e53653 100644 --- a/apps/system/services/config.go +++ b/apps/system/services/config.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/dept.go b/apps/system/services/dept.go index 75f8dec..d3745b6 100644 --- a/apps/system/services/dept.go +++ b/apps/system/services/dept.go @@ -2,9 +2,9 @@ package services import ( "errors" + "github.com/XM-GO/PandaKit/biz" "github.com/kakuilan/kgo" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/dict_data.go b/apps/system/services/dict_data.go index 5de25ec..fd8ae31 100644 --- a/apps/system/services/dict_data.go +++ b/apps/system/services/dict_data.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/dict_type.go b/apps/system/services/dict_type.go index 5cd3c0b..96c16d1 100644 --- a/apps/system/services/dict_type.go +++ b/apps/system/services/dict_type.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/menu.go b/apps/system/services/menu.go index 51bce20..75307e3 100644 --- a/apps/system/services/menu.go +++ b/apps/system/services/menu.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/notice.go b/apps/system/services/notice.go index bc44df0..2ce1422 100644 --- a/apps/system/services/notice.go +++ b/apps/system/services/notice.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/post.go b/apps/system/services/post.go index 80ba4cb..4f58af3 100644 --- a/apps/system/services/post.go +++ b/apps/system/services/post.go @@ -1,8 +1,8 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/role.go b/apps/system/services/role.go index 341defe..f64c312 100644 --- a/apps/system/services/role.go +++ b/apps/system/services/role.go @@ -2,8 +2,8 @@ package services import ( "errors" + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/role_dept.go b/apps/system/services/role_dept.go index a00a92a..7eccf53 100644 --- a/apps/system/services/role_dept.go +++ b/apps/system/services/role_dept.go @@ -2,8 +2,8 @@ package services import ( "fmt" + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/role_menu.go b/apps/system/services/role_menu.go index b19a9a9..1b721bc 100644 --- a/apps/system/services/role_menu.go +++ b/apps/system/services/role_menu.go @@ -2,8 +2,8 @@ package services import ( "fmt" + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/tenant.go b/apps/system/services/tenant.go index 23c88a1..1e540b1 100644 --- a/apps/system/services/tenant.go +++ b/apps/system/services/tenant.go @@ -6,8 +6,8 @@ package services * @Date 2022/7/14 17:49 **/ import ( + "github.com/XM-GO/PandaKit/biz" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/apps/system/services/user.go b/apps/system/services/user.go index 7d6eb61..c016afa 100644 --- a/apps/system/services/user.go +++ b/apps/system/services/user.go @@ -1,10 +1,10 @@ package services import ( + "github.com/XM-GO/PandaKit/biz" "github.com/kakuilan/kgo" "golang.org/x/crypto/bcrypt" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" "time" ) diff --git a/base/biz/assert.go b/base/biz/assert.go deleted file mode 100644 index 044712a..0000000 --- a/base/biz/assert.go +++ /dev/null @@ -1,73 +0,0 @@ -package biz - -import ( - "fmt" - "pandax/base/utils" - "reflect" -) - -func ErrIsNil(err error, msg string, params ...any) { - if err != nil { - if err.Error() == "record not found" { - return - } - panic(any(NewBizErr(fmt.Sprintf(msg, params...)))) - } -} - -func ErrIsNilAppendErr(err error, msg string) { - if err != nil { - panic(any(NewBizErr(fmt.Sprintf(msg, err.Error())))) - } -} - -func IsNil(err error) { - switch t := err.(type) { - case *BizError: - panic(any(t)) - case error: - panic(any(NewBizErr(fmt.Sprintf("非业务异常: %s", err.Error())))) - } -} - -func IsTrue(exp bool, msg string, params ...any) { - if !exp { - panic(any(NewBizErr(fmt.Sprintf(msg, params...)))) - } -} - -func IsTrueBy(exp bool, err BizError) { - if !exp { - panic(any(err)) - } -} - -func NotEmpty(str string, msg string, params ...any) { - if str == "" { - panic(any(NewBizErr(fmt.Sprintf(msg, params...)))) - } -} - -func NotNil(data any, msg string) { - if reflect.ValueOf(data).IsNil() { - panic(any(NewBizErr(msg))) - } -} - -func NotBlank(data any, msg string) { - if utils.IsBlank(reflect.ValueOf(data)) { - panic(any(NewBizErr(msg))) - } -} - -func IsEquals(data any, data1 any, msg string) { - if data != data1 { - panic(any(NewBizErr(msg))) - } -} - -func Nil(data any, msg string) { - if !reflect.ValueOf(data).IsNil() { - panic(any(NewBizErr(msg))) - } -} diff --git a/base/biz/bizerror.go b/base/biz/bizerror.go deleted file mode 100644 index d846c7b..0000000 --- a/base/biz/bizerror.go +++ /dev/null @@ -1,35 +0,0 @@ -package biz - -// 业务错误 -type BizError struct { - code int16 - err string -} - -var ( - Success *BizError = NewBizErrCode(200, "success") - BizErr *BizError = NewBizErrCode(400, "biz error") - ServerError *BizError = NewBizErrCode(500, "服务器异常,请联系管理员") - PermissionErr *BizError = NewBizErrCode(4001, "没有权限操作,可能是TOKEN过期了,请先登录") - CasbinErr *BizError = NewBizErrCode(403, "没有API接口访问权限,请联系管理员") -) - -// 错误消息 -func (e *BizError) Error() string { - return e.err -} - -// 错误码 -func (e *BizError) Code() int16 { - return e.code -} - -// 创建业务逻辑错误结构体,默认为业务逻辑错误 -func NewBizErr(msg string) *BizError { - return &BizError{code: BizErr.code, err: msg} -} - -// 创建业务逻辑错误结构体,可设置指定错误code -func NewBizErrCode(code int16, msg string) *BizError { - return &BizError{code: code, err: msg} -} diff --git a/base/cache/cache.go b/base/cache/cache.go deleted file mode 100644 index 7da1431..0000000 --- a/base/cache/cache.go +++ /dev/null @@ -1,25 +0,0 @@ -package cache - -type Cache interface { - // 添加缓存,如果缓存则返回错误 - Add(k string, v any) error - - // 如果不存在则添加缓存值,否则直接返回 - AddIfAbsent(k string, v any) - - // 如果存在则直接返回,否则调用getValue回调函数获取值并添加该缓存值 - // @return 缓存值 - ComputeIfAbsent(k string, getValueFunc func(string) (any, error)) (any, error) - - // 获取缓存值,参数1为值,参数2->是否存在该缓存 - Get(k string) (any, bool) - - // 缓存数量 - Count() int - - // 删除缓存 - Delete(k string) - - // 清空所有缓存 - Clear() -} diff --git a/base/cache/timed_cache.go b/base/cache/timed_cache.go deleted file mode 100644 index 0291658..0000000 --- a/base/cache/timed_cache.go +++ /dev/null @@ -1,432 +0,0 @@ -package cache - -import ( - "encoding/gob" - "fmt" - "io" - "os" - "sync" - "time" -) - -type Item struct { - Value any // 对象 - Expiration int64 // 缓存有效时间 - UseCount int64 // 使用次数 - AccessTime int64 // 访问时间 -} - -// 是否过期 -func (item Item) Expired() bool { - if item.Expiration == 0 { - return false - } - return time.Now().UnixNano() > item.AccessTime+item.Expiration -} - -// 是否过期 -// @return 值 and 是否过期 -func (item *Item) GetValue(updateAccessTime bool) (any, bool) { - isExpired := item.Expired() - // 更新最后访问时间,用于增加值的有效期 - if !isExpired && updateAccessTime { - item.AccessTime = time.Now().UnixNano() - } - item.UseCount = item.UseCount + 1 - return item.Value, isExpired -} - -const ( - // 无过期时间 - NoExpiration time.Duration = -1 - // 默认过期时间 - DefaultExpiration time.Duration = 0 - // 默认清理缓存时间差 - DefaultCleanupInterval = 10 -) - -type TimedCache struct { - *timedcache -} - -type timedcache struct { - defaultExpiration time.Duration - updateAccessTime bool // 是否更新最后访问时间 - items map[any]*Item - mu sync.RWMutex - onEvicted func(any, any) // 移除时回调函数 - janitor *janitor -} - -// Add an item to the cache only if an item doesn't already exist for the given -// key, or if the existing item has expired. Returns an error otherwise. -func (c *timedcache) Add(k any, x any, d time.Duration) error { - c.mu.Lock() - defer c.mu.Unlock() - _, found := c.get(k) - if found { - return fmt.Errorf("Item %s already exists", k) - } - c.set(k, x, d) - return nil -} - -func (c *timedcache) Put(k any, x any) { - c.mu.Lock() - defer c.mu.Unlock() - c.set(k, x, c.defaultExpiration) -} - -func (c *timedcache) AddIfAbsent(k any, x any) { - c.mu.Lock() - defer c.mu.Unlock() - _, found := c.get(k) - if found { - return - } - c.set(k, x, c.defaultExpiration) -} - -func (c *timedcache) ComputeIfAbsent(k any, getValueFunc func(any) (any, error)) (any, error) { - c.mu.Lock() - defer c.mu.Unlock() - value, found := c.get(k) - if found { - return value, nil - } - value, err := getValueFunc(k) - if err != nil { - return nil, err - } - - c.set(k, value, c.defaultExpiration) - return value, nil -} - -func (c *timedcache) set(k any, x any, d time.Duration) { - var e int64 - if d == DefaultExpiration { - d = c.defaultExpiration - } - if d > 0 { - e = d.Nanoseconds() - } - c.items[k] = &Item{ - Value: x, - Expiration: e, - AccessTime: time.Now().UnixNano(), - } -} - -// Get an item from the cache. Returns the item or nil, and a bool indicating -// whether the key was found. -func (c *timedcache) Get(k any) (any, bool) { - c.mu.RLock() - defer c.mu.RUnlock() - return c.get(k) -} - -func (c *timedcache) get(k any) (any, bool) { - item, found := c.items[k] - if !found { - return nil, false - } - - value, expired := item.GetValue(c.updateAccessTime) - if expired { - // c.Delete(k) - return nil, false - } - return value, true -} - -// Increment an item of type int, int8, int16, int32, int64, uintptr, uint, -// uint8, uint32, or uint64, float32 or float64 by n. Returns an error if the -// item's value is not an integer, if it was not found, or if it is not -// possible to increment it by n. To retrieve the incremented value, use one -// of the specialized methods, e.g. IncrementInt64. -func (c *timedcache) Increment(k any, n int64) error { - c.mu.Lock() - v, found := c.items[k] - if !found || v.Expired() { - c.mu.Unlock() - return fmt.Errorf("Item %s not found", k) - } - switch v.Value.(type) { - case int: - v.Value = v.Value.(int) + int(n) - case int8: - v.Value = v.Value.(int8) + int8(n) - case int16: - v.Value = v.Value.(int16) + int16(n) - case int32: - v.Value = v.Value.(int32) + int32(n) - case int64: - v.Value = v.Value.(int64) + n - case uint: - v.Value = v.Value.(uint) + uint(n) - case uintptr: - v.Value = v.Value.(uintptr) + uintptr(n) - case uint8: - v.Value = v.Value.(uint8) + uint8(n) - case uint16: - v.Value = v.Value.(uint16) + uint16(n) - case uint32: - v.Value = v.Value.(uint32) + uint32(n) - case uint64: - v.Value = v.Value.(uint64) + uint64(n) - case float32: - v.Value = v.Value.(float32) + float32(n) - case float64: - v.Value = v.Value.(float64) + float64(n) - default: - c.mu.Unlock() - return fmt.Errorf("The value for %s is not an integer", k) - } - c.items[k] = v - c.mu.Unlock() - return nil -} - -// Returns the number of items in the cache. This may include items that have -// expired, but have not yet been cleaned up. -func (c *timedcache) Count() int { - c.mu.RLock() - n := len(c.items) - c.mu.RUnlock() - return n -} - -// Copies all unexpired items in the cache into a new map and returns it. -func (c *timedcache) Items() map[any]*Item { - c.mu.RLock() - defer c.mu.RUnlock() - m := make(map[any]*Item, len(c.items)) - now := time.Now().UnixNano() - for k, v := range c.items { - // "Inlining" of Expired - if v.Expiration > 0 { - if now > (v.Expiration + v.AccessTime) { - continue - } - } - m[k] = v - } - return m -} - -// 删除指定key的数据 -func (c *timedcache) Delete(k any) { - c.mu.Lock() - v, evicted := c.delete(k) - c.mu.Unlock() - if evicted { - c.onEvicted(k, v) - } -} - -func (c *timedcache) delete(k any) (any, bool) { - // 如果有移除回调函数,则返回值及是否有删除回调函数用于进行回调处理 - if c.onEvicted != nil { - if v, found := c.items[k]; found { - delete(c.items, k) - return v.Value, true - } - } - delete(c.items, k) - return nil, false -} - -type keyAndValue struct { - key any - value any -} - -// Delete all expired items from the cache. -func (c *timedcache) DeleteExpired() { - var evictedItems []keyAndValue - now := time.Now().UnixNano() - c.mu.Lock() - for k, v := range c.items { - // "Inlining" of expired - if v.Expiration > 0 && now > (v.Expiration+v.AccessTime) { - ov, evicted := c.delete(k) - if evicted { - evictedItems = append(evictedItems, keyAndValue{k, ov}) - } - } - } - c.mu.Unlock() - for _, v := range evictedItems { - c.onEvicted(v.key, v.value) - } -} - -// 清空所有缓存 -func (c *timedcache) Clear() { - c.mu.Lock() - c.items = map[any]*Item{} - c.mu.Unlock() -} - -// Write the cache's items (using Gob) to an io.Writer. -// -// NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the -// documentation for NewFrom().) -func (c *timedcache) Save(w io.Writer) (err error) { - enc := gob.NewEncoder(w) - defer func() { - if x := recover(); x != nil { - err = fmt.Errorf("Error registering item types with Gob library") - } - }() - c.mu.RLock() - defer c.mu.RUnlock() - for _, v := range c.items { - gob.Register(v.Value) - } - err = enc.Encode(&c.items) - return -} - -// Save the cache's items to the given filename, creating the file if it -// doesn't exist, and overwriting it if it does. -// -// NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the -// documentation for NewFrom().) -func (c *timedcache) SaveFile(fname string) error { - fp, err := os.Create(fname) - if err != nil { - return err - } - err = c.Save(fp) - if err != nil { - fp.Close() - return err - } - return fp.Close() -} - -// Add (Gob-serialized) cache items from an io.Reader, excluding any items with -// keys that already exist (and haven't expired) in the current cache. -// -// NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the -// documentation for NewFrom().) -func (c *timedcache) Load(r io.Reader) error { - dec := gob.NewDecoder(r) - items := map[string]*Item{} - err := dec.Decode(&items) - if err == nil { - c.mu.Lock() - defer c.mu.Unlock() - for k, v := range items { - ov, found := c.items[k] - if !found || ov.Expired() { - c.items[k] = v - } - } - } - return err -} - -// Load and add cache items from the given filename, excluding any items with -// keys that already exist in the current cache. -// -// NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the -// documentation for NewFrom().) -func (c *timedcache) LoadFile(fname string) error { - fp, err := os.Open(fname) - if err != nil { - return err - } - err = c.Load(fp) - if err != nil { - fp.Close() - return err - } - return fp.Close() -} - -type janitor struct { - Interval time.Duration - stop chan bool -} - -func (j *janitor) Run(c *timedcache) { - ticker := time.NewTicker(j.Interval) - for { - select { - case <-ticker.C: - c.DeleteExpired() - case <-j.stop: - ticker.Stop() - return - } - } -} - -func stopJanitor(c *TimedCache) { - c.janitor.stop <- true -} - -func runJanitor(c *timedcache, ci time.Duration) { - j := &janitor{ - Interval: ci, - stop: make(chan bool), - } - c.janitor = j - go j.Run(c) -} - -func newCache(de time.Duration, m map[any]*Item) *timedcache { - if de == 0 { - de = -1 - } - c := &timedcache{ - defaultExpiration: de, - items: m, - } - return c -} - -func newCacheWithJanitor(de time.Duration, ci time.Duration, m map[any]*Item) *TimedCache { - c := newCache(de, m) - // This trick ensures that the janitor goroutine (which--granted it - // was enabled--is running DeleteExpired on c forever) does not keep - // the returned C object from being garbage collected. When it is - // garbage collected, the finalizer stops the janitor goroutine, after - // which c can be collected. - C := &TimedCache{c} - if ci > 0 { - runJanitor(c, ci) - // runtime.SetFinalizer(C, stopJanitor) - } - return C -} - -// Return a new cache with a given default expiration duration and cleanup -// interval. If the expiration duration is less than one (or NoExpiration), -// the items in the cache never expire (by default), and must be deleted -// manually. If the cleanup interval is less than one, expired items are not -// deleted from the cache before calling c.DeleteExpired(). -func NewTimedCache(defaultExpiration, cleanupInterval time.Duration) *TimedCache { - items := make(map[any]*Item) - return newCacheWithJanitor(defaultExpiration, cleanupInterval, items) -} - -// 调用删除函数时,会回调该剔除函数 -func (c *TimedCache) OnEvicted(f func(any, any)) *TimedCache { - c.mu.Lock() - c.onEvicted = f - c.mu.Unlock() - return c -} - -// 是否更新最后访问时间,是则会更新最后访问时间 -// 即只要在指定缓存时间内都没有访问该缓存,则会失效,反之失效开始时间点为最后访问时间 -func (c *TimedCache) WithUpdateAccessTime(update bool) *TimedCache { - c.mu.Lock() - c.updateAccessTime = update - c.mu.Unlock() - return c -} diff --git a/base/captcha/captcha.go b/base/captcha/captcha.go deleted file mode 100644 index 3cb21ba..0000000 --- a/base/captcha/captcha.go +++ /dev/null @@ -1,28 +0,0 @@ -package captcha - -import ( - "pandax/base/biz" - - "github.com/mojocn/base64Captcha" -) - -var store = base64Captcha.DefaultMemStore -var driver base64Captcha.Driver = base64Captcha.NewDriverDigit(80, 240, 4, 0.7, 80) - -// 生成验证码 -func Generate() (string, string) { - c := base64Captcha.NewCaptcha(driver, store) - // 获取 - id, b64s, err := c.Generate() - biz.ErrIsNilAppendErr(err, "获取验证码错误: %s") - return id, b64s -} - -// 验证验证码 -func Verify(id string, val string) bool { - if id == "" || val == "" { - return false - } - // 同时清理掉这个图片 - return store.Verify(id, val, true) -} diff --git a/base/casbin/casbin.go b/base/casbin/casbin.go deleted file mode 100644 index 34443e6..0000000 --- a/base/casbin/casbin.go +++ /dev/null @@ -1,64 +0,0 @@ -package casbin - -import ( - "github.com/casbin/casbin/v2" - gormadapter "github.com/casbin/gorm-adapter/v3" - "pandax/base/biz" - "pandax/pkg/global" - "sync" -) - -func UpdateCasbin(tenantId string, roleKey string, casbinInfos []CasbinRule) error { - ClearCasbin(0, tenantId, roleKey) - rules := [][]string{} - for _, v := range casbinInfos { - rules = append(rules, []string{tenantId, roleKey, v.Path, v.Method}) - } - e := Casbin() - success, _ := e.AddPolicies(rules) - biz.IsTrue(success, "存在相同api,添加失败,请联系管理员") - return nil -} - -func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) { - err := global.Db.Table("casbin_rule").Model(&CasbinRule{}).Where("v2 = ? AND v3 = ?", oldPath, oldMethod).Updates(map[string]any{ - "v2": newPath, - "v3": newMethod, - }).Error - biz.ErrIsNil(err, "修改api失败") -} - -func GetPolicyPathByRoleId(tenantId, roleKey string) (pathMaps []CasbinRule) { - e := Casbin() - list := e.GetFilteredPolicy(0, tenantId, roleKey) - for _, v := range list { - pathMaps = append(pathMaps, CasbinRule{ - Path: v[2], - Method: v[3], - }) - } - return pathMaps -} - -func ClearCasbin(v int, p ...string) bool { - e := Casbin() - success, _ := e.RemoveFilteredPolicy(v, p...) - return success - -} - -var ( - syncedEnforcer *casbin.SyncedEnforcer - once sync.Once -) - -func Casbin() *casbin.SyncedEnforcer { - once.Do(func() { - a, err := gormadapter.NewAdapterByDB(global.Db) - biz.ErrIsNil(err, "新建权限适配器失败") - syncedEnforcer, err = casbin.NewSyncedEnforcer(global.Conf.Casbin.ModelPath, a) - biz.ErrIsNil(err, "新建权限适配器失败") - }) - _ = syncedEnforcer.LoadPolicy() - return syncedEnforcer -} diff --git a/base/casbin/casbin_model.go b/base/casbin/casbin_model.go deleted file mode 100644 index 6bdf48f..0000000 --- a/base/casbin/casbin_model.go +++ /dev/null @@ -1,16 +0,0 @@ -package casbin - -type CasbinRule struct { - Ptype string `json:"ptype" gorm:"column:ptype"` - RoleKey string `json:"roleKey" gorm:"column:v0"` - Path string `json:"path" gorm:"column:v1"` - Method string `json:"method" gorm:"column:v2"` - V3 string `json:"v3" gorm:"column:v3"` - V4 string `json:"v4" gorm:"column:v4"` - V5 string `json:"v5" gorm:"column:v5"` - Id int `json:"id" gorm:"primary_key;AUTO_INCREMENT;column:id"` -} - -func (CasbinRule) TableName() string { - return "casbin_rule" -} diff --git a/base/config/app.go b/base/config/app.go deleted file mode 100644 index bef8b38..0000000 --- a/base/config/app.go +++ /dev/null @@ -1,12 +0,0 @@ -package config - -import "fmt" - -type App struct { - Name string `yaml:"name"` - Version string `yaml:"version"` -} - -func (a *App) GetAppInfo() string { - return fmt.Sprintf("[%s:%s]", a.Name, a.Version) -} diff --git a/base/config/casbin.go b/base/config/casbin.go deleted file mode 100644 index 4b5b196..0000000 --- a/base/config/casbin.go +++ /dev/null @@ -1,5 +0,0 @@ -package config - -type Casbin struct { - ModelPath string `mapstructure:"model-path" json:"model-path" yaml:"model-path"` -} diff --git a/base/config/config.go b/base/config/config.go deleted file mode 100644 index 82e36fc..0000000 --- a/base/config/config.go +++ /dev/null @@ -1,64 +0,0 @@ -package config - -import ( - "flag" - "fmt" - "pandax/base/biz" - "pandax/base/utils" - "path/filepath" -) - -var GConfig *Config - -func InitConfig(configFilePath string) *Config { - // 获取启动参数中,配置文件的绝对路径 - path, _ := filepath.Abs(configFilePath) - startConfigParam = &CmdConfigParam{ConfigFilePath: path} - // 读取配置文件信息 - yc := &Config{} - if err := utils.LoadYml(startConfigParam.ConfigFilePath, yc); err != nil { - panic(any(fmt.Sprintf("读取配置文件[%s]失败: %s", startConfigParam.ConfigFilePath, err.Error()))) - } - // 校验配置文件内容信息 - yc.Valid() - GConfig = yc - return yc - -} - -// 启动配置参数 -type CmdConfigParam struct { - ConfigFilePath string // -e 配置文件路径 -} - -// 启动可执行文件时的参数 -var startConfigParam *CmdConfigParam - -// yaml配置文件映射对象 -type Config struct { - App *App `yaml:"app"` - Server *Server `yaml:"server"` - Jwt *Jwt `yaml:"jwt"` - Redis *Redis `yaml:"redis"` - Mysql *Mysql `yaml:"mysql"` - Postgresql *Postgresql `yaml:"postgresql"` - Casbin *Casbin `yaml:"casbin"` - Gen *Gen `yaml:"gen"` - Log *Log `yaml:"log"` -} - -// 配置文件内容校验 -func (c *Config) Valid() { - biz.IsTrue(c.Jwt != nil, "配置文件的[jwt]信息不能为空") - c.Jwt.Valid() -} - -// 获取执行可执行文件时,指定的启动参数 -func getStartConfig() *CmdConfigParam { - configFilePath := flag.String("e", "./config.yml", "配置文件路径,默认为可执行文件目录") - flag.Parse() - // 获取配置文件绝对路径 - path, _ := filepath.Abs(*configFilePath) - sc := &CmdConfigParam{ConfigFilePath: path} - return sc -} diff --git a/base/config/db.go b/base/config/db.go deleted file mode 100644 index c2a2a26..0000000 --- a/base/config/db.go +++ /dev/null @@ -1,33 +0,0 @@ -package config - -import "fmt" - -type Mysql struct { - Host string `mapstructure:"host" json:"host" yaml:"host"` - Config string `mapstructure:"config" json:"config" yaml:"config"` - Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"` - Username string `mapstructure:"username" json:"username" yaml:"username"` - Password string `mapstructure:"password" json:"password" yaml:"password"` - MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` - MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` - LogMode bool `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"` - LogZap string `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"` -} - -func (m *Mysql) Dsn() string { - return m.Username + ":" + m.Password + "@tcp(" + m.Host + ")/" + m.Dbname + "?" + m.Config -} - -type Postgresql struct { - Host string `mapstructure:"host" json:"host" yaml:"host"` - Port int `mapstructure:"port" json:"port" yaml:"port"` - Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"` - Username string `mapstructure:"username" json:"username" yaml:"username"` - Password string `mapstructure:"password" json:"password" yaml:"password"` - MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` - MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` -} - -func (m *Postgresql) PgDsn() string { - return fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", m.Host, m.Port, m.Username, m.Password, m.Dbname) -} diff --git a/base/config/gen.go b/base/config/gen.go deleted file mode 100644 index fc6468c..0000000 --- a/base/config/gen.go +++ /dev/null @@ -1,11 +0,0 @@ -package config - -/** - * @Description - * @Author Panda - * @Date 2021/12/31 15:13 - **/ -type Gen struct { - Dbname string `mapstructure:"dbname" json:"dbname" yaml:"dbname"` - Frontpath string `mapstructure:"frontpath" json:"frontpath" yaml:"frontpath"` -} diff --git a/base/config/jwt.go b/base/config/jwt.go deleted file mode 100644 index 6d991c8..0000000 --- a/base/config/jwt.go +++ /dev/null @@ -1,15 +0,0 @@ -package config - -import ( - "pandax/base/biz" -) - -type Jwt struct { - Key string `yaml:"key"` - ExpireTime int64 `yaml:"expire-time"` // 过期时间,单位分钟 -} - -func (j *Jwt) Valid() { - biz.IsTrue(j.Key != "", "config.yml之 [jwt.key] 不能为空") - biz.IsTrue(j.ExpireTime != 0, "config.yml之 [jwt.expire-time] 不能为空") -} diff --git a/base/config/log.go b/base/config/log.go deleted file mode 100644 index ac9815b..0000000 --- a/base/config/log.go +++ /dev/null @@ -1,30 +0,0 @@ -package config - -import "path" - -type Log struct { - Level string `yaml:"level"` - File *LogFile `yaml:"file"` -} - -type LogFile struct { - Name string `yaml:"name"` - Path string `yaml:"path"` -} - -// 获取完整路径文件名 -func (l *LogFile) GetFilename() string { - var filepath, filename string - if fp := l.Path; fp == "" { - filepath = "./" - } else { - filepath = fp - } - if fn := l.Name; fn == "" { - filename = "default.log" - } else { - filename = fn - } - - return path.Join(filepath, filename) -} diff --git a/base/config/redis.go b/base/config/redis.go deleted file mode 100644 index 10316a4..0000000 --- a/base/config/redis.go +++ /dev/null @@ -1,8 +0,0 @@ -package config - -type Redis struct { - Host string `yaml:"host"` - Port int `yaml:"port"` - Password string `yaml:"password"` - Db int `yaml:"db"` -} diff --git a/base/config/server.go b/base/config/server.go deleted file mode 100644 index 2424a61..0000000 --- a/base/config/server.go +++ /dev/null @@ -1,41 +0,0 @@ -package config - -import "fmt" - -type Server struct { - Port int `yaml:"port"` - Model string `yaml:"model"` - Cors bool `yaml:"cors"` - Rate *Rate `yaml:"rate"` - IsInitTable bool `yaml:"isInitTable"` - DbType string `yaml:"db-type"` - ExcelDir string `yaml:"excel-dir"` - Tls *Tls `yaml:"tls"` - Static *[]*Static `yaml:"static"` - StaticFile *[]*StaticFile `yaml:"static-file"` -} - -func (s *Server) GetPort() string { - return fmt.Sprintf(":%d", s.Port) -} - -type Static struct { - RelativePath string `yaml:"relative-path"` - Root string `yaml:"root"` -} - -type StaticFile struct { - RelativePath string `yaml:"relative-path"` - Filepath string `yaml:"filepath"` -} - -type Tls struct { - Enable bool `yaml:"enable"` // 是否启用tls - KeyFile string `yaml:"key-file"` // 私钥文件路径 - CertFile string `yaml:"cert-file"` // 证书文件路径 -} - -type Rate struct { - Enable bool `yaml:"enable"` // 是否限流 - RateNum float64 `yaml:"rate-num"` // 限流数量 -} diff --git a/base/file/file.go b/base/file/file.go deleted file mode 100644 index d008fea..0000000 --- a/base/file/file.go +++ /dev/null @@ -1,33 +0,0 @@ -package utilFile - -import ( - "io" - "net/http" - "os" -) - -/** - * @Description 添加qq群467890197 交流学习 - * @Author 熊猫 - * @Date 2022/1/14 11:13 - **/ - -// DownloadFile 会将url下载到本地文件,它会在下载时写入,而不是将整个文件加载到内存中。 -func DownloadFile(url, filepath string) error { - // Get the data - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - // Create the file - out, err := os.Create(filepath) - if err != nil { - return err - } - defer out.Close() - // Write the body to file - _, err = io.Copy(out, resp.Body) - return err -} diff --git a/base/file/zipfiles.go b/base/file/zipfiles.go deleted file mode 100644 index b0ba911..0000000 --- a/base/file/zipfiles.go +++ /dev/null @@ -1,66 +0,0 @@ -package utilFile - -import ( - "archive/zip" - "io" - "os" - "strings" -) - -func ZipFiles(filename string, files []string, oldForm, newForm string) error { - - newZipFile, err := os.Create(filename) - if err != nil { - return err - } - defer func() { - _ = newZipFile.Close() - }() - - zipWriter := zip.NewWriter(newZipFile) - defer func() { - _ = zipWriter.Close() - }() - - // 把files添加到zip中 - for _, file := range files { - - err = func(file string) error { - zipFile, err := os.Open(file) - if err != nil { - return err - } - defer zipFile.Close() - // 获取file的基础信息 - info, err := zipFile.Stat() - if err != nil { - return err - } - - header, err := zip.FileInfoHeader(info) - if err != nil { - return err - } - - // 使用上面的FileInforHeader() 就可以把文件保存的路径替换成我们自己想要的了,如下面 - header.Name = strings.Replace(file, oldForm, newForm, -1) - - // 优化压缩 - // 更多参考see http://golang.org/pkg/archive/zip/#pkg-constants - header.Method = zip.Deflate - - writer, err := zipWriter.CreateHeader(header) - if err != nil { - return err - } - if _, err = io.Copy(writer, zipFile); err != nil { - return err - } - return nil - }(file) - if err != nil { - return err - } - } - return nil -} diff --git a/base/ginx/ginx.go b/base/ginx/ginx.go deleted file mode 100644 index cfcf021..0000000 --- a/base/ginx/ginx.go +++ /dev/null @@ -1,96 +0,0 @@ -package ginx - -import ( - "encoding/json" - "net/http" - "pandax/base/biz" - "pandax/base/model" - "pandax/pkg/global" - "strconv" - - "github.com/gin-gonic/gin" -) - -// 绑定并校验请求结构体参数 结构体添加 例如: binding:"required" 或binding:"required,gt=10" -func BindJsonAndValid(g *gin.Context, data any) { - if err := g.ShouldBindJSON(data); err != nil { - panic(any(biz.NewBizErr("传参格式错误:" + err.Error()))) - } -} - -// 绑定查询字符串到 -func BindQuery(g *gin.Context, data any) { - if err := g.ShouldBindQuery(data); err != nil { - panic(any(biz.NewBizErr(err.Error()))) - } -} - -func ParamsToAny(g *gin.Context, in any) { - vars := make(map[string]any) - for _, v := range g.Params { - vars[v.Key] = v.Value - } - marshal, _ := json.Marshal(vars) - err := json.Unmarshal(marshal, in) - biz.ErrIsNil(err, "error get path value encoding unmarshal") - return -} - -// 获取分页参数 -func GetPageParam(g *gin.Context) *model.PageParam { - return &model.PageParam{PageNum: QueryInt(g, "pageNum", 1), PageSize: QueryInt(g, "pageSize", 10)} -} - -// 获取查询参数中指定参数值,并转为int -func QueryInt(g *gin.Context, qm string, defaultInt int) int { - qv := g.Query(qm) - if qv == "" { - return defaultInt - } - qvi, err := strconv.Atoi(qv) - biz.ErrIsNil(err, "query param not int") - return qvi -} - -// 获取路径参数 -func PathParamInt(g *gin.Context, pm string) int { - value, _ := strconv.Atoi(g.Param(pm)) - return value -} - -// 文件下载 -func Download(g *gin.Context, filename string) { - g.Writer.Header().Add("success", "true") - g.Writer.Header().Set("Content-Length", "-1") - g.Writer.Header().Set("Content-Disposition", "attachment; filename="+filename) - g.File(filename) -} - -// 返回统一成功结果 -func SuccessRes(g *gin.Context, data any) { - g.JSON(http.StatusOK, model.Success(data)) -} - -// 返回失败结果集 -func ErrorRes(g *gin.Context, err any) { - if err != nil { - - } - switch t := err.(type) { - case *biz.BizError: - g.JSON(http.StatusOK, model.Error(t)) - break - case error: - g.JSON(http.StatusOK, model.ServerError()) - global.Log.Error(t) - // panic(err) - break - case string: - g.JSON(http.StatusOK, model.ServerError()) - global.Log.Error(t) - // panic(err) - break - default: - global.Log.Error(t) - } -} diff --git a/base/ginx/log_handler.go b/base/ginx/log_handler.go deleted file mode 100644 index aa5f8a6..0000000 --- a/base/ginx/log_handler.go +++ /dev/null @@ -1,84 +0,0 @@ -package ginx - -import ( - "encoding/json" - "fmt" - "pandax/base/biz" - "pandax/base/utils" - "pandax/pkg/global" - "reflect" - "runtime/debug" - - "github.com/sirupsen/logrus" -) - -type LogInfo struct { - LogResp bool // 是否记录返回结果 - Description string // 请求描述 -} - -func NewLogInfo(description string) *LogInfo { - return &LogInfo{Description: description, LogResp: false} -} - -func (i *LogInfo) WithLogResp(logResp bool) *LogInfo { - i.LogResp = logResp - return i -} - -func LogHandler(rc *ReqCtx) error { - li := rc.LogInfo - if li == nil { - return nil - } - - lfs := logrus.Fields{} - if la := rc.LoginAccount; la != nil { - lfs["uid"] = la.UserId - lfs["uname"] = la.UserName - } - - req := rc.GinCtx.Request - lfs[req.Method] = req.URL.Path - - if err := rc.Err; err != nil { - global.Log.WithFields(lfs).Error(getErrMsg(rc, err)) - return nil - } - global.Log.WithFields(lfs).Info(getLogMsg(rc)) - return nil -} - -func getLogMsg(rc *ReqCtx) string { - msg := rc.LogInfo.Description + fmt.Sprintf(" ->%dms", rc.timed) - if !utils.IsBlank(reflect.ValueOf(rc.ReqParam)) { - rb, _ := json.Marshal(rc.ReqParam) - msg = msg + fmt.Sprintf("\n--> %s", string(rb)) - } - - // 返回结果不为空,则记录返回结果 - if rc.LogInfo.LogResp && !utils.IsBlank(reflect.ValueOf(rc.ResData)) { - respB, _ := json.Marshal(rc.ResData) - msg = msg + fmt.Sprintf("\n<-- %s", string(respB)) - } - return msg -} - -func getErrMsg(rc *ReqCtx, err any) string { - msg := rc.LogInfo.Description - if !utils.IsBlank(reflect.ValueOf(rc.ReqParam)) { - rb, _ := json.Marshal(rc.ReqParam) - msg = msg + fmt.Sprintf("\n--> %s", string(rb)) - } - - var errMsg string - switch t := err.(type) { - case *biz.BizError: - errMsg = fmt.Sprintf("\n<-e errCode: %d, errMsg: %s", t.Code(), t.Error()) - case error: - errMsg = fmt.Sprintf("\n<-e errMsg: %s\n%s", t.Error(), string(debug.Stack())) - case string: - errMsg = fmt.Sprintf("\n<-e errMsg: %s\n%s", t, string(debug.Stack())) - } - return (msg + errMsg) -} diff --git a/base/ginx/permission_handler.go b/base/ginx/permission_handler.go deleted file mode 100644 index 297c6fd..0000000 --- a/base/ginx/permission_handler.go +++ /dev/null @@ -1,60 +0,0 @@ -package ginx - -import ( - "github.com/dgrijalva/jwt-go" - "pandax/base/biz" - "pandax/base/casbin" - "pandax/base/token" - "pandax/pkg/global" - "strconv" -) - -type Permission struct { - NeedToken bool // 是否需要token - NeedCasbin bool // 是否进行权限 api路径权限验证 -} - -func (p *Permission) WithNeedToken(needToken bool) *Permission { - p.NeedToken = needToken - return p -} - -func (p *Permission) WithNeedCasBin(needCasBin bool) *Permission { - p.NeedCasbin = needCasBin - return p -} - -func PermissionHandler(rc *ReqCtx) error { - permission := rc.RequiredPermission - // 如果需要的权限信息不为空,并且不需要token,则不返回错误,继续后续逻辑 - if permission != nil && !permission.NeedToken { - return nil - } - tokenStr := rc.GinCtx.Request.Header.Get("X-TOKEN") - // header不存在则从查询参数token中获取 - if tokenStr == "" { - tokenStr = rc.GinCtx.Query("token") - } - if tokenStr == "" { - return biz.PermissionErr - } - j := token.NewJWT("", []byte(global.Conf.Jwt.Key), jwt.SigningMethodHS256) - loginAccount, err := j.ParseToken(tokenStr) - if err != nil || loginAccount == nil { - return biz.PermissionErr - } - rc.LoginAccount = loginAccount - - if !permission.NeedCasbin { - return nil - } - e := casbin.Casbin() - // 判断策略中是否存在 - tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId)) - success, err := e.Enforce(tenantId, loginAccount.RoleKey, rc.GinCtx.Request.URL.Path, rc.GinCtx.Request.Method) - if !success { - return biz.CasbinErr - } - - return nil -} diff --git a/base/ginx/req_ctx.go b/base/ginx/req_ctx.go deleted file mode 100644 index 89e9452..0000000 --- a/base/ginx/req_ctx.go +++ /dev/null @@ -1,124 +0,0 @@ -package ginx - -import ( - "pandax/base/biz" - "pandax/base/token" - "time" - - "github.com/gin-gonic/gin" -) - -// 处理函数 -type HandlerFunc func(*ReqCtx) - -type ReqCtx struct { - GinCtx *gin.Context // gin context - - // NeedToken bool // 是否需要token - RequiredPermission *Permission // 需要的权限信息,默认为nil,需要校验token - LoginAccount *token.Claims // 登录账号信息,只有校验token后才会有值 - - LogInfo *LogInfo // 日志相关信息 - ReqParam any // 请求参数,主要用于记录日志 - ResData any // 响应结果 - Err any // 请求错误 - - timed int64 // 执行时间 - noRes bool // 无需返回结果,即文件下载等 -} - -func (rc *ReqCtx) Handle(handler HandlerFunc) { - ginCtx := rc.GinCtx - defer func() { - var err any - err = recover() - if err != nil { - rc.Err = err - ErrorRes(ginCtx, err) - } - // 应用所有请求后置处理器 - ApplyHandlerInterceptor(afterHandlers, rc) - }() - biz.IsTrue(ginCtx != nil, "ginContext == nil") - - // 默认为不记录请求参数,可在handler回调函数中覆盖赋值 - rc.ReqParam = 0 - // 默认响应结果为nil,可在handler中赋值 - rc.ResData = nil - - // 调用请求前所有处理器 - err := ApplyHandlerInterceptor(beforeHandlers, rc) - if err != nil { - panic(err) - } - - begin := time.Now() - handler(rc) - rc.timed = time.Now().Sub(begin).Milliseconds() - if !rc.noRes { - SuccessRes(ginCtx, rc.ResData) - } -} - -func (rc *ReqCtx) Download(filename string) { - rc.noRes = true - Download(rc.GinCtx, filename) -} - -// 新建请求上下文,默认需要校验token -func NewReqCtx(g *gin.Context) *ReqCtx { - return &ReqCtx{GinCtx: g, LogInfo: NewLogInfo("默认日志信息"), RequiredPermission: &Permission{NeedToken: true, NeedCasbin: true}} -} - -// 调用该方法设置请求描述,则默认记录日志,并不记录响应结果 -func (r *ReqCtx) WithLog(model string) *ReqCtx { - r.LogInfo.Description = model - return r -} - -// 设置请求上下文需要的权限信息 -func (r *ReqCtx) WithRequiredPermission(permission *Permission) *ReqCtx { - r.RequiredPermission = permission - return r -} - -// 是否需要token -func (r *ReqCtx) WithNeedToken(needToken bool) *ReqCtx { - r.RequiredPermission.NeedToken = needToken - return r -} - -// 是否需要Casbin -func (r *ReqCtx) WithNeedCasbin(needCasbin bool) *ReqCtx { - r.RequiredPermission.NeedCasbin = needCasbin - return r -} - -// 处理器拦截器函数 -type HandlerInterceptorFunc func(*ReqCtx) error -type HandlerInterceptors []HandlerInterceptorFunc - -var ( - beforeHandlers HandlerInterceptors - afterHandlers HandlerInterceptors -) - -// 使用前置处理器函数 -func UseBeforeHandlerInterceptor(b HandlerInterceptorFunc) { - beforeHandlers = append(beforeHandlers, b) -} - -// 使用后置处理器函数 -func UseAfterHandlerInterceptor(b HandlerInterceptorFunc) { - afterHandlers = append(afterHandlers, b) -} - -// 应用指定处理器拦截器,如果有一个错误则直接返回错误 -func ApplyHandlerInterceptor(his HandlerInterceptors, rc *ReqCtx) any { - for _, handler := range his { - if err := handler(rc); err != nil { - return err - } - } - return nil -} diff --git a/base/httpclient/httpclient.go b/base/httpclient/httpclient.go deleted file mode 100644 index f11c1bf..0000000 --- a/base/httpclient/httpclient.go +++ /dev/null @@ -1,228 +0,0 @@ -package httpclient - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "mime/multipart" - "net/http" - "os" - "time" -) - -var client = &http.Client{} - -// 默认超时 -const DefTimeout = 60 - -type RequestWrapper struct { - url string - method string - timeout int - body io.Reader - header map[string]string -} - -type MultipartFile struct { - FieldName string // 字段名 - FileName string // 文件名 - FilePath string // 文件路径,文件路径不为空,则优先读取文件路径的内容 - Bytes []byte // 文件内容 -} - -// 创建一个请求 -func NewRequest(url string) *RequestWrapper { - return &RequestWrapper{url: url} -} - -func (r *RequestWrapper) Url(url string) *RequestWrapper { - r.url = url - return r -} - -func (r *RequestWrapper) Header(name, value string) *RequestWrapper { - if r.header == nil { - r.header = make(map[string]string) - } - r.header[name] = value - return r -} - -func (r *RequestWrapper) Timeout(timeout int) *RequestWrapper { - r.timeout = timeout - return r -} - -func (r *RequestWrapper) GetByParam(paramMap map[string]string) *ResponseWrapper { - var params string - for k, v := range paramMap { - if params != "" { - params += "&" - } else { - params += "?" - } - params += k + "=" + v - } - r.url += "?" + params - return r.Get() -} - -func (r *RequestWrapper) Get() *ResponseWrapper { - r.method = "GET" - r.body = nil - return request(r) -} - -func (r *RequestWrapper) PostJson(body string) *ResponseWrapper { - buf := bytes.NewBufferString(body) - r.method = "POST" - r.body = buf - if r.header == nil { - r.header = make(map[string]string) - } - r.header["Content-type"] = "application/json" - return request(r) -} - -func (r *RequestWrapper) PostObj(body any) *ResponseWrapper { - marshal, err := json.Marshal(body) - if err != nil { - return createRequestError(errors.New("解析json obj错误")) - } - return r.PostJson(string(marshal)) -} - -func (r *RequestWrapper) PostParams(params string) *ResponseWrapper { - buf := bytes.NewBufferString(params) - r.method = "POST" - r.body = buf - if r.header == nil { - r.header = make(map[string]string) - } - r.header["Content-type"] = "application/x-www-form-urlencoded" - return request(r) -} - -func (r *RequestWrapper) PostMulipart(files []MultipartFile, reqParams map[string]string) *ResponseWrapper { - buf := &bytes.Buffer{} - // 文件写入 buf - writer := multipart.NewWriter(buf) - for _, uploadFile := range files { - var reader io.Reader - // 如果文件路径不为空,则读取该路径文件,否则使用bytes - if uploadFile.FilePath != "" { - file, err := os.Open(uploadFile.FilePath) - if err != nil { - return createRequestError(err) - } - defer file.Close() - reader = file - } else { - reader = bytes.NewBuffer(uploadFile.Bytes) - } - - part, err := writer.CreateFormFile(uploadFile.FieldName, uploadFile.FileName) - if err != nil { - return createRequestError(err) - } - _, err = io.Copy(part, reader) - } - // 如果有其他参数,则写入body - for k, v := range reqParams { - if err := writer.WriteField(k, v); err != nil { - return createRequestError(err) - } - } - if err := writer.Close(); err != nil { - return createRequestError(err) - } - - r.method = "POST" - r.body = buf - if r.header == nil { - r.header = make(map[string]string) - } - r.header["Content-type"] = writer.FormDataContentType() - return request(r) -} - -type ResponseWrapper struct { - StatusCode int - Body []byte - Header http.Header -} - -func (r *ResponseWrapper) IsSuccess() bool { - return r.StatusCode == 200 -} - -func (r *ResponseWrapper) BodyToObj(objPtr any) error { - _ = json.Unmarshal(r.Body, &objPtr) - return r.getError() -} - -func (r *ResponseWrapper) BodyToString() (string, error) { - return string(r.Body), r.getError() -} - -func (r *ResponseWrapper) BodyToMap() (map[string]any, error) { - var res map[string]any - err := json.Unmarshal(r.Body, &res) - if err != nil { - return nil, err - } - return res, r.getError() -} - -func (r *ResponseWrapper) getError() error { - if !r.IsSuccess() { - return errors.New(string(r.Body)) - } - return nil -} - -func request(rw *RequestWrapper) *ResponseWrapper { - wrapper := &ResponseWrapper{StatusCode: 0, Header: make(http.Header)} - timeout := rw.timeout - if timeout > 0 { - client.Timeout = time.Duration(timeout) * time.Second - } else { - timeout = DefTimeout - } - - req, err := http.NewRequest(rw.method, rw.url, rw.body) - if err != nil { - return createRequestError(err) - } - setRequestHeader(req, rw.header) - resp, err := client.Do(req) - if err != nil { - wrapper.Body = []byte(fmt.Sprintf("执行HTTP请求错误-%s", err.Error())) - return wrapper - } - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - wrapper.Body = []byte(fmt.Sprintf("读取HTTP请求返回值失败-%s", err.Error())) - return wrapper - } - wrapper.StatusCode = resp.StatusCode - wrapper.Body = body - wrapper.Header = resp.Header - - return wrapper -} - -func setRequestHeader(req *http.Request, header map[string]string) { - req.Header.Set("User-Agent", "golang/mayfly") - for k, v := range header { - req.Header.Set(k, v) - } -} - -func createRequestError(err error) *ResponseWrapper { - return &ResponseWrapper{0, []byte(fmt.Sprintf("创建HTTP请求错误-%s", err.Error())), make(http.Header)} -} diff --git a/base/logger/logger.go b/base/logger/logger.go deleted file mode 100644 index 268d343..0000000 --- a/base/logger/logger.go +++ /dev/null @@ -1,73 +0,0 @@ -package logger - -import ( - "fmt" - "os" - "pandax/base/config" - "strings" - "time" - - "github.com/sirupsen/logrus" -) - -var Log *logrus.Logger - -func InitLog(logConf *config.Log) *logrus.Logger { - Log = logrus.New() - Log.SetFormatter(new(LogFormatter)) - Log.SetReportCaller(true) - - // 如果不存在日志配置信息,则默认debug级别 - if logConf == nil { - Log.SetLevel(logrus.DebugLevel) - return nil - } - - // 根据配置文件设置日志级别 - if level := logConf.Level; level != "" { - l, err := logrus.ParseLevel(level) - if err != nil { - panic(any(fmt.Sprintf("日志级别不存在: %s", level))) - } - Log.SetLevel(l) - } else { - Log.SetLevel(logrus.DebugLevel) - } - - if logFile := logConf.File; logFile != nil { - //写入文件 - file, err := os.OpenFile(logFile.GetFilename(), os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModeAppend|0666) - if err != nil { - panic(any(fmt.Sprintf("创建日志文件失败: %s", err.Error()))) - } - - Log.Out = file - } - return Log -} - -type LogFormatter struct{} - -func (l *LogFormatter) Format(entry *logrus.Entry) ([]byte, error) { - timestamp := time.Now().Local().Format("2006-01-02 15:04:05.000") - level := entry.Level - logMsg := fmt.Sprintf("%s [%s]", timestamp, strings.ToUpper(level.String())) - // 如果存在调用信息,且为error级别以上记录文件及行号 - if caller := entry.Caller; caller != nil { - var fp string - // 全路径切割,只获取项目相关路径, - // 即/Users/hml/Desktop/project/go/pandax/test.go只获取/test.go - ps := strings.Split(caller.File, "pandax/") - if len(ps) >= 2 { - fp = ps[1] - } else { - fp = ps[0] - } - logMsg = logMsg + fmt.Sprintf(" [%s:%d]", fp, caller.Line) - } - for k, v := range entry.Data { - logMsg = logMsg + fmt.Sprintf(" [%s=%v]", k, v) - } - logMsg = logMsg + fmt.Sprintf(" : %s\n", entry.Message) - return []byte(logMsg), nil -} diff --git a/base/mail/email.go b/base/mail/email.go deleted file mode 100644 index fab4e4a..0000000 --- a/base/mail/email.go +++ /dev/null @@ -1,64 +0,0 @@ -package email - -import ( - "crypto/tls" - "fmt" - "net/smtp" - "strings" - - "github.com/jordan-wright/email" -) - -type Mail struct { - Host string `json:"host"` // 服务器地址 - Port int `json:"port"` // 服务器端口 - From string `json:"from"` // 邮箱账号 - Nickname string `json:"nickname"` // 发件人 - Secret string `json:"secret"` // 邮箱密码 - IsSSL bool `json:"isSsl"` // 是否开启ssl -} - -func (m Mail) Email(to, subject string, body string) error { - tos := strings.Split(to, ",") - return m.send(tos, subject, body) -} - -//@function: ErrorToEmail -//@description: 给email中间件错误发送邮件到指定邮箱 -//@param: subject string, body string -//@return: error - -func (m Mail) ErrorToEmail(to, subject string, body string) error { - tos := strings.Split(to, ",") - if tos[len(to)-1] == "" { // 判断切片的最后一个元素是否为空,为空则移除 - tos = tos[:len(tos)-1] - } - return m.send(tos, subject, body) -} - -//@function: send -//@description: Email发送方法 -//@param: subject string, body string -//@return: error - -func (m Mail) send(to []string, subject string, body string) error { - - auth := smtp.PlainAuth("", m.From, m.Secret, m.Host) - e := email.NewEmail() - if m.Nickname != "" { - e.From = fmt.Sprintf("%s <%s>", m.Nickname, m.From) - } else { - e.From = m.From - } - e.To = to - e.Subject = subject - e.HTML = []byte(body) - var err error - hostAddr := fmt.Sprintf("%s:%d", m.Host, m.Port) - if m.IsSSL { - err = e.SendWithTLS(hostAddr, auth, &tls.Config{ServerName: m.Host}) - } else { - err = e.Send(hostAddr, auth) - } - return err -} diff --git a/base/mail/mail_test.go b/base/mail/mail_test.go deleted file mode 100644 index b15ff0d..0000000 --- a/base/mail/mail_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package email - -import "testing" - -/** - * @Description 添加qq群467890197 交流学习 - * @Author 熊猫 - * @Date 2022/1/17 10:35 - **/ - -func TestMail_Email(t *testing.T) { - ma := Mail{ - Host: "smtp.163.com", - Port: 25, - From: "18610165312@163.com", - Nickname: "panda", - Secret: "DCXZCAGTCMSEGPZL", - IsSSL: false, - } - - email := ma.Email("18353366911@163.com", "ceshi", "ceshibody") - t.Log(email) -} diff --git a/base/model/base_model.go b/base/model/base_model.go deleted file mode 100644 index faaa5c0..0000000 --- a/base/model/base_model.go +++ /dev/null @@ -1,33 +0,0 @@ -package model - -import ( - "gorm.io/gorm" - "time" -) - -// BaseAutoModel 使用代码生成需要此,不能自由命名id -type BaseAutoModel struct { - Id int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id" form:"id"` - CreatedAt time.Time `gorm:"column:create_time" json:"createTime" form:"createTime"` - UpdatedAt time.Time `gorm:"column:update_time" json:"updateTime" form:"updateTime"` - DeletedAt gorm.DeletedAt `gorm:"column:delete_time" sql:"index" json:"-"` -} - -// BaseAutoModelD 表想要硬删除使用他 -type BaseAutoModelD struct { - Id int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id" form:"id"` - CreatedAt time.Time `gorm:"column:create_time" json:"createTime" form:"createTime"` - UpdatedAt time.Time `gorm:"column:update_time" json:"updateTime" form:"updateTime"` -} - -type BaseModel struct { - CreatedAt time.Time `gorm:"column:create_time" json:"createTime" form:"createTime"` - UpdatedAt time.Time `gorm:"column:update_time" json:"updateTime" form:"updateTime"` - DeletedAt gorm.DeletedAt `gorm:"column:delete_time" sql:"index" json:"-"` -} - -// BaseModelD 硬删除 -type BaseModelD struct { - CreatedAt time.Time `gorm:"column:create_time" json:"createTime" form:"create_time"` - UpdatedAt time.Time `gorm:"column:update_time" json:"updateTime" form:"update_time"` -} diff --git a/base/model/login_account.go b/base/model/login_account.go deleted file mode 100644 index 74e70f9..0000000 --- a/base/model/login_account.go +++ /dev/null @@ -1,14 +0,0 @@ -package model - -type AppContext struct { -} - -type LoginAccount struct { - UserId int64 - TenantId int64 - RoleId int64 - DeptId int64 - PostId int64 - Username string - RoleKey string -} diff --git a/base/model/model.go b/base/model/model.go deleted file mode 100644 index 16d183c..0000000 --- a/base/model/model.go +++ /dev/null @@ -1,201 +0,0 @@ -package model - -import ( - "fmt" - "pandax/base/biz" - "pandax/pkg/global" - "strconv" - - "strings" - "time" - - "gorm.io/gorm" -) - -type Model struct { - Id int64 `json:"id"` - CreateTime *time.Time `json:"createTime"` - CreatorId int64 `json:"creatorId"` - Creator string `json:"creator"` - UpdateTime *time.Time `json:"updateTime"` - ModifierId int64 `json:"modifierId"` - Modifier string `json:"modifier"` -} - -// 设置基础信息. 如创建时间,修改时间,创建者,修改者信息 -func (m *Model) SetBaseInfo(account *LoginAccount) { - nowTime := time.Now() - isCreate := m.Id == 0 - if isCreate { - m.CreateTime = &nowTime - } - m.UpdateTime = &nowTime - - if account == nil { - return - } - id := account.UserId - name := account.Username - if isCreate { - m.CreatorId = id - m.Creator = name - } - m.Modifier = name - m.ModifierId = id -} - -// 事务 -func Tx(funcs ...func(db *gorm.DB) error) (err error) { - tx := global.Db.Begin() - defer func() { - var err any - err = recover() - if err != nil { - tx.Rollback() - err = fmt.Errorf("%v", err) - } - }() - for _, f := range funcs { - err = f(tx) - if err != nil { - tx.Rollback() - return - } - } - err = tx.Commit().Error - return -} - -// 根据id获取实体对象。model需为指针类型(需要将查询出来的值赋值给model) -// -// 若error不为nil则为不存在该记录 -func GetById(model any, id uint64, cols ...string) error { - return global.Db.Select(cols).Where("id = ?", id).First(model).Error -} - -// 根据id列表查询 -func GetByIdIn(model any, list any, ids []uint64, orderBy ...string) { - var orderByStr string - if orderBy == nil { - orderByStr = "id desc" - } else { - orderByStr = strings.Join(orderBy, ",") - } - global.Db.Model(model).Where("id in (?)", ids).Order(orderByStr).Find(list) -} - -// 根据id列表查询 model可以是对象,也可以是map[string]interface{} -func CountBy(model any) int64 { - var count int64 - global.Db.Model(model).Where(model).Count(&count) - return count -} - -// 根据id更新model,更新字段为model中不为空的值,即int类型不为0,ptr类型不为nil这类字段值 -func UpdateById(model any) error { - return global.Db.Model(model).Updates(model).Error -} -func UpdateByWhere(model any, where any) error { - return global.Db.Model(model).Where(where).Updates(model).Error -} - -// 根据id删除model -func DeleteById(model any, id uint64) error { - return global.Db.Delete(model, "id = ?", id).Error -} - -// 根据条件删除 -func DeleteByCondition(model any) error { - return global.Db.Where(model).Delete(model).Error -} - -// 插入model -func Insert(model any) error { - return global.Db.Create(model).Error -} - -// 获取满足model中不为空的字段值条件的所有数据. -// -// list为数组类型 如 var users *[]User,可指定为非model结构体,即只包含需要返回的字段结构体 -func ListBy(model any, list any, cols ...string) { - global.Db.Model(model).Select(cols).Where(model).Find(list) -} - -// 获取满足model中不为空的字段值条件的所有数据. -// -// list为数组类型 如 var users *[]User,可指定为非model结构体 -func ListByOrder(model any, list any, order ...string) { - var orderByStr string - if order == nil { - orderByStr = "id desc" - } else { - orderByStr = strings.Join(order, ",") - } - global.Db.Model(model).Where(model).Order(orderByStr).Find(list) -} - -// 获取满足model中不为空的字段值条件的单个对象。model需为指针类型(需要将查询出来的值赋值给model) -// -// 若 error不为nil,则为不存在该记录 -func GetBy(model any, cols ...string) error { - return global.Db.Select(cols).Where(model).First(model).Error -} - -// 获取满足conditionModel中不为空的字段值条件的单个对象。model需为指针类型(需要将查询出来的值赋值给model) -// toModel 需要查询的字段 -// 若 error不为nil,则为不存在该记录 -func GetByConditionTo(conditionModel any, toModel any) error { - return global.Db.Model(conditionModel).Where(conditionModel).First(toModel).Error -} - -// 获取分页结果 -func GetPage(pageParam *PageParam, conditionModel any, toModels any, orderBy ...string) *PageResult { - var count int64 - err := global.Db.Model(conditionModel).Where(conditionModel).Count(&count).Error - biz.ErrIsNilAppendErr(err, " 查询错误:%s") - if count == 0 { - return &PageResult{Total: 0, List: []string{}} - } - - page := pageParam.PageNum - pageSize := pageParam.PageSize - var orderByStr string - if orderBy == nil { - orderByStr = "id desc" - } else { - orderByStr = strings.Join(orderBy, ",") - } - err = global.Db.Model(conditionModel).Where(conditionModel).Order(orderByStr).Limit(pageSize).Offset((page - 1) * pageSize).Find(toModels).Error - biz.ErrIsNil(err, "查询失败") - return &PageResult{Total: count, List: toModels} -} - -// 根据sql获取分页对象 -func GetPageBySql(sql string, param *PageParam, toModel any, args ...any) *PageResult { - db := global.Db - selectIndex := strings.Index(sql, "SELECT ") + 7 - fromIndex := strings.Index(sql, " FROM") - selectCol := sql[selectIndex:fromIndex] - countSql := strings.Replace(sql, selectCol, "COUNT(*) AS total ", 1) - // 查询count - var count int - db.Raw(countSql, args...).Scan(&count) - if count == 0 { - return &PageResult{Total: 0, List: []string{}} - } - // 分页查询 - limitSql := sql + " LIMIT " + strconv.Itoa(param.PageNum-1) + ", " + strconv.Itoa(param.PageSize) - err := db.Raw(limitSql).Scan(toModel).Error - biz.ErrIsNil(err, "查询失败") - return &PageResult{Total: int64(count), List: toModel} -} - -func GetListBySql(sql string, params ...any) []map[string]any { - var maps []map[string]any - global.Db.Raw(sql, params).Scan(&maps) - return maps -} - -func GetListBySql2Model(sql string, toEntity any, params ...any) error { - return global.Db.Raw(sql, params).Find(toEntity).Error -} diff --git a/base/model/page.go b/base/model/page.go deleted file mode 100644 index 67a093c..0000000 --- a/base/model/page.go +++ /dev/null @@ -1,14 +0,0 @@ -package model - -// 分页参数 -type PageParam struct { - PageNum int `json:"pageNum"` - PageSize int `json:"pageSize"` - Params string `json:"params"` -} - -// 分页结果 -type PageResult struct { - Total int64 `json:"total"` - List any `json:"list"` -} diff --git a/base/model/result.go b/base/model/result.go deleted file mode 100644 index 3de6698..0000000 --- a/base/model/result.go +++ /dev/null @@ -1,62 +0,0 @@ -package model - -import ( - "encoding/json" - "fmt" - "pandax/base/biz" -) - -const ( - SuccessCode = 200 - SuccessMsg = "success" -) - -// 统一返回结果结构体 -type Result struct { - Code int16 `json:"code"` - Msg string `json:"msg"` - Data any `json:"data"` -} - -// 将Result转为json字符串 -func (r *Result) ToJson() string { - jsonData, err := json.Marshal(r) - if err != nil { - fmt.Println("data转json错误") - } - return string(jsonData) -} - -// 判断该Result是否为成功状态 -func (r *Result) IsSuccess() bool { - return r.Code == SuccessCode -} - -// 返回成功状态的Result -// data 成功附带的数据消息 -func Success(data any) *Result { - return &Result{Code: SuccessCode, Msg: SuccessMsg, Data: data} -} - -// 返回成功状态的Result -// data 成功不附带数据 -func SuccessNoData() *Result { - return &Result{Code: SuccessCode, Msg: SuccessMsg} -} - -func Error(bizerr *biz.BizError) *Result { - return &Result{Code: bizerr.Code(), Msg: bizerr.Error()} -} - -// 返回服务器错误Result -func ServerError() *Result { - return Error(biz.ServerError) -} - -func TokenError() *Result { - return Error(biz.PermissionErr) -} - -func ErrorBy(code int16, msg string) *Result { - return &Result{Code: code, Msg: msg} -} diff --git a/base/oss/README.md b/base/oss/README.md deleted file mode 100644 index 1b6ba71..0000000 --- a/base/oss/README.md +++ /dev/null @@ -1 +0,0 @@ -## \ No newline at end of file diff --git a/base/oss/aliyun.go b/base/oss/aliyun.go deleted file mode 100644 index 33f3956..0000000 --- a/base/oss/aliyun.go +++ /dev/null @@ -1,88 +0,0 @@ -package oss - -import ( - "github.com/pkg/errors" - "io" - - aliOssSdk "github.com/aliyun/aliyun-oss-go-sdk/oss" -) - -//oss 上传配置 -type AliConfig struct { - AccessKey string `json:"access_key"` - SecretKey string `json:"secret_key"` - Bucket string `json:"bucket"` - Endpoint string `json:"endpoint"` -} - -//oss 根据参数来创建 Bucket -func (c *AliConfig) CreateBucket() (bucket *aliOssSdk.Bucket, err error) { - // Endpoint以杭州为例,其它Region请按实际情况填写。 - endpoint := c.Endpoint - // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。 - accessKeyId := c.AccessKey - accessKeySecret := c.SecretKey - bucketName := c.Bucket - // 创建OSSClient实例。 - ossClient, err := aliOssSdk.New(endpoint, accessKeyId, accessKeySecret) - if err != nil { - return nil, errors.Wrapf(err, "创建 aliyun OSSClient实例失败") - } - // 获取存储空间。 - bucket, err = ossClient.Bucket(bucketName) - if err != nil { - return nil, errors.Wrapf(err, "获取 aliyun OSS 存储空间失败") - } - return -} - -//oss 上传客户端 -type aliOss struct { - bucket *aliOssSdk.Bucket -} - -func NewAliOss(c AliConfig) Driver { - bucket, err := c.CreateBucket() - if err != nil { - panic(any(err)) - } - return &aliOss{ - bucket: bucket, - } -} - -// Put 上传 -func (c *aliOss) Put(objectName string, localFileName string) error { - err := c.bucket.PutObjectFromFile(objectName, localFileName) - if err != nil { - return errors.Wrapf(err, "put oss file fail") - } - return nil -} - -func (c *aliOss) PutObj(objectName string, file io.Reader) error { - err := c.bucket.PutObject(objectName, file) - if err != nil { - return errors.Wrapf(err, "put oss file fail") - } - return nil -} - -// Get 下载 -func (c *aliOss) Get(objectName, downloadedFileName string) error { - err := c.bucket.GetObjectToFile(objectName, downloadedFileName) - if err != nil { - return errors.Wrapf(err, "get oss file fail") - } - return nil -} - -// Del 删除 -func (c *aliOss) Del(objectName string) error { - // 删除文件。 - err := c.bucket.DeleteObject(objectName) - if err != nil { - return errors.Wrapf(err, "del oss file fail") - } - return nil -} diff --git a/base/oss/build.go b/base/oss/build.go deleted file mode 100644 index b96abca..0000000 --- a/base/oss/build.go +++ /dev/null @@ -1,15 +0,0 @@ -package oss - -import ( - "path" - "time" - - "github.com/google/uuid" -) - -func BuildName(fileName, fileType string) (string, error) { - t := time.Now().Format("20060102") - newUUID, _ := uuid.NewUUID() - ext := path.Ext(fileName) - return t + "/" + fileType + "/" + newUUID.String() + ext, nil -} diff --git a/base/oss/oss.go b/base/oss/oss.go deleted file mode 100644 index bb59057..0000000 --- a/base/oss/oss.go +++ /dev/null @@ -1,15 +0,0 @@ -package oss - -import "io" - -// Driver oss驱动接口定义 -type Driver interface { - //上传 - Put(objectName, localFileName string) error - - PutObj(objectName string, file io.Reader) error - //下载 - Get(objectName, downloadedFileName string) error - //删除 - Del(objectName string) error -} diff --git a/base/oss/qiniu.go b/base/oss/qiniu.go deleted file mode 100644 index f91c1e7..0000000 --- a/base/oss/qiniu.go +++ /dev/null @@ -1,130 +0,0 @@ -package oss - -import ( - "context" - "io" - utilFile "pandax/base/file" - - "github.com/pkg/errors" - "github.com/qiniu/go-sdk/v7/auth/qbox" - "github.com/qiniu/go-sdk/v7/storage" -) - -type QiniuConfig struct { - AccessKey string - SecretKey string - Bucket string - PolicyExpires uint64 // 上传凭证的有效时间,单位秒 - Zone *storage.Zone // 空间所在的机房 - UseHTTPS bool // 是否使用https域名 - UseCdnDomains bool // 是否使用cdn加速域名 - CentralRsHost string // 中心机房的RsHost,用于list bucket - Domain string // 外链域名 -} - -type qiniuOss struct { - config QiniuConfig -} - -func NewQnOss(config QiniuConfig) *qiniuOss { - return &qiniuOss{ - config: config, - } -} - -func NewDefaultQnOss() *qiniuOss { - config := QiniuConfig{ - AccessKey: "", - SecretKey: "", - Bucket: "", - PolicyExpires: 0, - Zone: nil, - UseHTTPS: false, - UseCdnDomains: false, - CentralRsHost: "", - Domain: "", - } - return NewQnOss(config) -} - -func (q *qiniuOss) Put(objectName, localFileName string) error { - // 鉴权 - mac := qbox.NewMac(q.config.AccessKey, q.config.SecretKey) - // 上传策略 - putPolicy := storage.PutPolicy{ - Scope: q.config.Bucket, - Expires: q.config.PolicyExpires, - } - // 获取上传token - upToken := putPolicy.UploadToken(mac) - - // 上传Config对象 - cfg := storage.Config{ - Zone: q.config.Zone, //指定上传的区域 - UseHTTPS: q.config.UseHTTPS, // 是否使用https域名 - UseCdnDomains: q.config.UseCdnDomains, //是否使用CDN上传加速 - } - // 构建表单上传的对象 - formUploader := storage.NewFormUploader(&cfg) - ret := storage.PutRet{} - // 上传文件 - err := formUploader.PutFile(context.Background(), &ret, upToken, objectName, localFileName, nil) - if err != nil { - return errors.Wrapf(err, "qiniu oss put file fail") - } - return nil -} - -func (q *qiniuOss) PutObj(objectName string, file io.Reader) error { - // 鉴权 - mac := qbox.NewMac(q.config.AccessKey, q.config.SecretKey) - // 上传策略 - putPolicy := storage.PutPolicy{ - Scope: q.config.Bucket, - Expires: q.config.PolicyExpires, - } - // 获取上传token - upToken := putPolicy.UploadToken(mac) - - // 上传Config对象 - cfg := storage.Config{ - Zone: q.config.Zone, //指定上传的区域 - UseHTTPS: q.config.UseHTTPS, // 是否使用https域名 - UseCdnDomains: q.config.UseCdnDomains, //是否使用CDN上传加速 - } - // 构建表单上传的对象 - formUploader := storage.NewFormUploader(&cfg) - ret := storage.PutRet{} - - // 上传文件 - err := formUploader.Put(context.Background(), &ret, upToken, objectName, file, 0, nil) - if err != nil { - return errors.Wrapf(err, "qiniu oss put file fail") - } - return nil -} - -func (q *qiniuOss) Get(objectName, downloadedFileName string) error { - publicAccessURL := storage.MakePublicURL(q.config.Domain, objectName) - err := utilFile.DownloadFile(publicAccessURL, downloadedFileName) - if err != nil { - return errors.Wrapf(err, "qiniu oss get file fail") - } - return nil -} - -func (q *qiniuOss) Del(objectName string) error { - mac := qbox.NewMac(q.config.AccessKey, q.config.SecretKey) - cfg := storage.Config{ - Zone: q.config.Zone, //指定上传的区域 - UseHTTPS: q.config.UseHTTPS, // 是否使用https域名 - UseCdnDomains: q.config.UseCdnDomains, //是否使用CDN上传加速 - } - bucketManager := storage.NewBucketManager(mac, &cfg) - - err := bucketManager.Delete(q.config.Bucket, objectName) - if err != nil { - return errors.Wrapf(err, "qiniu oss del file fail") - } - return nil -} diff --git a/base/oss/tencentyun.go b/base/oss/tencentyun.go deleted file mode 100644 index 5e2c853..0000000 --- a/base/oss/tencentyun.go +++ /dev/null @@ -1,67 +0,0 @@ -package oss - -import ( - "context" - "net/http" - "net/url" - - "github.com/pkg/errors" - "github.com/tencentyun/cos-go-sdk-v5" -) - -//oss 上传配置 -type TencentConfig struct { - SecretID string - SecretKey string - bucket string -} - -func (t *TencentConfig) CreateClient() *cos.Client { - // 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息 - u, _ := url.Parse(t.bucket) - b := &cos.BaseURL{BucketURL: u} - c := cos.NewClient(b, &http.Client{ - Transport: &cos.AuthorizationTransport{ - SecretID: t.SecretID, - SecretKey: t.SecretKey, - }, - }) - return c -} - -type tencentOss struct { - client *cos.Client -} - -func NewTencentOss(c TencentConfig) *tencentOss { - client := c.CreateClient() - return &tencentOss{ - client: client, - } -} - -func (t *tencentOss) Put(objectName, localFileName string) error { - // 通过本地文件上传对象 - _, err := t.client.Object.PutFromFile(context.Background(), objectName, localFileName, nil) - if err != nil { - return errors.Wrapf(err, "tencentOss put fail") - } - return nil -} - -func (t *tencentOss) Get(objectName, downloadedFileName string) error { - // 获取对象到本地文件 - _, err := t.client.Object.GetToFile(context.Background(), objectName, downloadedFileName, nil) - if err != nil { - return errors.Wrapf(err, "tencentOss get fail") - } - return nil -} - -func (t *tencentOss) Del(objectName string) error { - _, err := t.client.Object.Delete(context.Background(), objectName) - if err != nil { - return errors.Wrapf(err, "tencentOss del fail") - } - return nil -} diff --git a/base/rediscli/rediscli.go b/base/rediscli/rediscli.go deleted file mode 100644 index 3127993..0000000 --- a/base/rediscli/rediscli.go +++ /dev/null @@ -1,64 +0,0 @@ -package rediscli - -import ( - "fmt" - "time" - - "github.com/go-redis/redis" -) - -var cli *redis.Client - -func SetCli(client *redis.Client) { - cli = client -} - -func GetCli() *redis.Client { - return cli -} - -// get key value -func Get(key string) string { - val, err := cli.Get(key).Result() - switch { - case err == redis.Nil: - fmt.Println("key does not exist") - case err != nil: - fmt.Println("Get failed", err) - case val == "": - fmt.Println("value is empty") - } - return val -} - -// set key value -func Set(key string, val string, expiration time.Duration) { - cli.Set(key, val, expiration) -} - -func HSet(key string, field string, val any) { - cli.HSet(key, field, val) -} - -// hget -func HGet(key string, field string) string { - val, _ := cli.HGet(key, field).Result() - return val -} - -// hget -func HExist(key string, field string) bool { - val, _ := cli.HExists(key, field).Result() - return val -} - -// hgetall -func HGetAll(key string) map[string]string { - vals, _ := cli.HGetAll(key).Result() - return vals -} - -// hdel -func HDel(key string, fields ...string) int { - return int(cli.HDel(key, fields...).Val()) -} diff --git a/base/restfulx/log_handler.go b/base/restfulx/log_handler.go deleted file mode 100644 index 84d7132..0000000 --- a/base/restfulx/log_handler.go +++ /dev/null @@ -1,84 +0,0 @@ -package restfulx - -import ( - "encoding/json" - "fmt" - "pandax/base/biz" - "pandax/base/utils" - "pandax/pkg/global" - "reflect" - "runtime/debug" - - "github.com/sirupsen/logrus" -) - -type LogInfo struct { - LogResp bool // 是否记录返回结果 - Description string // 请求描述 -} - -func NewLogInfo(description string) *LogInfo { - return &LogInfo{Description: description, LogResp: false} -} - -func (i *LogInfo) WithLogResp(logResp bool) *LogInfo { - i.LogResp = logResp - return i -} - -func LogHandler(rc *ReqCtx) error { - li := rc.LogInfo - if li == nil { - return nil - } - - lfs := logrus.Fields{} - if la := rc.LoginAccount; la != nil { - lfs["uid"] = la.UserId - lfs["uname"] = la.UserName - } - - req := rc.GinCtx.Request - lfs[req.Method] = req.URL.Path - - if err := rc.Err; err != nil { - global.Log.WithFields(lfs).Error(getErrMsg(rc, err)) - return nil - } - global.Log.WithFields(lfs).Info(getLogMsg(rc)) - return nil -} - -func getLogMsg(rc *ReqCtx) string { - msg := rc.LogInfo.Description + fmt.Sprintf(" ->%dms", rc.timed) - if !utils.IsBlank(reflect.ValueOf(rc.ReqParam)) { - rb, _ := json.Marshal(rc.ReqParam) - msg = msg + fmt.Sprintf("\n--> %s", string(rb)) - } - - // 返回结果不为空,则记录返回结果 - if rc.LogInfo.LogResp && !utils.IsBlank(reflect.ValueOf(rc.ResData)) { - respB, _ := json.Marshal(rc.ResData) - msg = msg + fmt.Sprintf("\n<-- %s", string(respB)) - } - return msg -} - -func getErrMsg(rc *ReqCtx, err any) string { - msg := rc.LogInfo.Description - if !utils.IsBlank(reflect.ValueOf(rc.ReqParam)) { - rb, _ := json.Marshal(rc.ReqParam) - msg = msg + fmt.Sprintf("\n--> %s", string(rb)) - } - - var errMsg string - switch t := err.(type) { - case *biz.BizError: - errMsg = fmt.Sprintf("\n<-e errCode: %d, errMsg: %s", t.Code(), t.Error()) - case error: - errMsg = fmt.Sprintf("\n<-e errMsg: %s\n%s", t.Error(), string(debug.Stack())) - case string: - errMsg = fmt.Sprintf("\n<-e errMsg: %s\n%s", t, string(debug.Stack())) - } - return (msg + errMsg) -} diff --git a/base/restfulx/permission_handler.go b/base/restfulx/permission_handler.go deleted file mode 100644 index e06054b..0000000 --- a/base/restfulx/permission_handler.go +++ /dev/null @@ -1,60 +0,0 @@ -package restfulx - -import ( - "github.com/dgrijalva/jwt-go" - "pandax/base/biz" - "pandax/base/casbin" - "pandax/base/token" - "pandax/pkg/global" - "strconv" -) - -type Permission struct { - NeedToken bool // 是否需要token - NeedCasbin bool // 是否进行权限 api路径权限验证 -} - -func (p *Permission) WithNeedToken(needToken bool) *Permission { - p.NeedToken = needToken - return p -} - -func (p *Permission) WithNeedCasBin(needCasBin bool) *Permission { - p.NeedCasbin = needCasBin - return p -} - -func PermissionHandler(rc *ReqCtx) error { - permission := rc.RequiredPermission - // 如果需要的权限信息不为空,并且不需要token,则不返回错误,继续后续逻辑 - if permission != nil && !permission.NeedToken { - return nil - } - tokenStr := rc.GinCtx.Request.Header.Get("X-TOKEN") - // header不存在则从查询参数token中获取 - if tokenStr == "" { - tokenStr = rc.GinCtx.Query("token") - } - if tokenStr == "" { - return biz.PermissionErr - } - j := token.NewJWT("", []byte(global.Conf.Jwt.Key), jwt.SigningMethodHS256) - loginAccount, err := j.ParseToken(tokenStr) - if err != nil || loginAccount == nil { - return biz.PermissionErr - } - rc.LoginAccount = loginAccount - - if !permission.NeedCasbin { - return nil - } - e := casbin.Casbin() - // 判断策略中是否存在 - tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId)) - success, err := e.Enforce(tenantId, loginAccount.RoleKey, rc.GinCtx.Request.URL.Path, rc.GinCtx.Request.Method) - if !success { - return biz.CasbinErr - } - - return nil -} diff --git a/base/restfulx/req_ctx.go b/base/restfulx/req_ctx.go deleted file mode 100644 index 30a6bb2..0000000 --- a/base/restfulx/req_ctx.go +++ /dev/null @@ -1,124 +0,0 @@ -package restfulx - -import ( - "pandax/base/biz" - "pandax/base/ginx" - "pandax/base/token" - "time" - - "github.com/gin-gonic/gin" -) - -// 处理函数 -type HandlerFunc func(*ReqCtx) - -type ReqCtx struct { - GinCtx *gin.Context // gin context - - // NeedToken bool // 是否需要token - RequiredPermission *Permission // 需要的权限信息,默认为nil,需要校验token - LoginAccount *token.Claims // 登录账号信息,只有校验token后才会有值 - - LogInfo *LogInfo // 日志相关信息 - ReqParam any // 请求参数,主要用于记录日志 - ResData any // 响应结果 - Err any // 请求错误 - - timed int64 // 执行时间 - noRes bool // 无需返回结果,即文件下载等 -} - -func (rc *ReqCtx) Handle(handler HandlerFunc) { - ginCtx := rc.GinCtx - defer func() { - var err any - err = recover() - if err != nil { - rc.Err = err - ginx.ErrorRes(ginCtx, err) - } - // 应用所有请求后置处理器 - ApplyHandlerInterceptor(afterHandlers, rc) - }() - biz.IsTrue(ginCtx != nil, "ginContext == nil") - - // 默认为不记录请求参数,可在handler回调函数中覆盖赋值 - rc.ReqParam = 0 - // 默认响应结果为nil,可在handler中赋值 - rc.ResData = nil - - // 调用请求前所有处理器 - err := ApplyHandlerInterceptor(beforeHandlers, rc) - if err != nil { - panic(err) - } - - begin := time.Now() - handler(rc) - rc.timed = time.Now().Sub(begin).Milliseconds() - if !rc.noRes { - ginx.SuccessRes(ginCtx, rc.ResData) - } -} - -func (rc *ReqCtx) Download(filename string) { - rc.noRes = true - ginx.Download(rc.GinCtx, filename) -} - -func NewReqCtx(g *gin.Context) *ReqCtx { - return &ReqCtx{GinCtx: g, RequiredPermission: &Permission{NeedToken: true, NeedCasbin: true}} -} - -// 调用该方法设置请求描述,则默认记录日志,并不记录响应结果 -func (r *ReqCtx) WithLog(li *LogInfo) *ReqCtx { - r.LogInfo = li - return r -} - -// 设置请求上下文需要的权限信息 -func (r *ReqCtx) WithRequiredPermission(permission *Permission) *ReqCtx { - r.RequiredPermission = permission - return r -} - -// 是否需要token -func (r *ReqCtx) WithNeedToken(needToken bool) *ReqCtx { - r.RequiredPermission.NeedToken = needToken - return r -} - -// 是否需要Casbin -func (r *ReqCtx) WithNeedCasbin(needCasbin bool) *ReqCtx { - r.RequiredPermission.NeedCasbin = needCasbin - return r -} - -// 处理器拦截器函数 -type HandlerInterceptorFunc func(*ReqCtx) error -type HandlerInterceptors []HandlerInterceptorFunc - -var ( - beforeHandlers HandlerInterceptors - afterHandlers HandlerInterceptors -) - -// 使用前置处理器函数 -func UseBeforeHandlerInterceptor(b HandlerInterceptorFunc) { - beforeHandlers = append(beforeHandlers, b) -} - -// 使用后置处理器函数 -func UseAfterHandlerInterceptor(b HandlerInterceptorFunc) { - afterHandlers = append(afterHandlers, b) -} - -// 应用指定处理器拦截器,如果有一个错误则直接返回错误 -func ApplyHandlerInterceptor(his HandlerInterceptors, rc *ReqCtx) any { - for _, handler := range his { - if err := handler(rc); err != nil { - return err - } - } - return nil -} diff --git a/base/restfulx/restfulx.go b/base/restfulx/restfulx.go deleted file mode 100644 index 56a270b..0000000 --- a/base/restfulx/restfulx.go +++ /dev/null @@ -1,95 +0,0 @@ -package restfulx - -import ( - "encoding/json" - "net/http" - "pandax/base/biz" - "pandax/base/model" - "pandax/pkg/global" - "strconv" - - "github.com/gin-gonic/gin" -) - -// 绑定并校验请求结构体参数 结构体添加 例如: binding:"required" 或binding:"required,gt=10" -func BindJsonAndValid(g *gin.Context, data any) { - if err := g.ShouldBindJSON(data); err != nil { - panic(any(biz.NewBizErr("传参格式错误:" + err.Error()))) - } -} - -// 绑定查询字符串到 -func BindQuery(g *gin.Context, data any) { - if err := g.ShouldBindQuery(data); err != nil { - panic(any(biz.NewBizErr(err.Error()))) - } -} -func ParamsToAny(g *gin.Context, in any) { - vars := make(map[string]any) - for _, v := range g.Params { - vars[v.Key] = v.Value - } - marshal, _ := json.Marshal(vars) - err := json.Unmarshal(marshal, in) - biz.ErrIsNil(err, "error get path value encoding unmarshal") - return -} - -// 获取分页参数 -func GetPageParam(g *gin.Context) *model.PageParam { - return &model.PageParam{PageNum: QueryInt(g, "pageNum", 1), PageSize: QueryInt(g, "pageSize", 10)} -} - -// 获取查询参数中指定参数值,并转为int -func QueryInt(g *gin.Context, qm string, defaultInt int) int { - qv := g.Query(qm) - if qv == "" { - return defaultInt - } - qvi, err := strconv.Atoi(qv) - biz.ErrIsNil(err, "query param not int") - return qvi -} - -// 获取路径参数 -func PathParamInt(g *gin.Context, pm string) int { - value, _ := strconv.Atoi(g.Param(pm)) - return value -} - -// 文件下载 -func Download(g *gin.Context, filename string) { - g.Writer.Header().Add("success", "true") - g.Writer.Header().Set("Content-Length", "-1") - g.Writer.Header().Set("Content-Disposition", "attachment; filename="+filename) - g.File(filename) -} - -// 返回统一成功结果 -func SuccessRes(g *gin.Context, data any) { - g.JSON(http.StatusOK, model.Success(data)) -} - -// 返回失败结果集 -func ErrorRes(g *gin.Context, err any) { - if err != nil { - - } - switch t := err.(type) { - case *biz.BizError: - g.JSON(http.StatusOK, model.Error(t)) - break - case error: - g.JSON(http.StatusOK, model.ServerError()) - global.Log.Error(t) - // panic(err) - break - case string: - g.JSON(http.StatusOK, model.ServerError()) - global.Log.Error(t) - // panic(err) - break - default: - global.Log.Error(t) - } -} diff --git a/base/sms/README.md b/base/sms/README.md deleted file mode 100644 index 1b6ba71..0000000 --- a/base/sms/README.md +++ /dev/null @@ -1 +0,0 @@ -## \ No newline at end of file diff --git a/base/sms/aliyun.go b/base/sms/aliyun.go deleted file mode 100644 index ce1d84f..0000000 --- a/base/sms/aliyun.go +++ /dev/null @@ -1,44 +0,0 @@ -package sms - -import ( - "github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi" - "github.com/pkg/errors" -) - -type AliConfig struct { - accessKeyId string - accessSecret string - RegionId string -} - -type AliSms struct { - config AliConfig -} - -func NewAliSms(AliConfig AliConfig) *AliSms { - return &AliSms{ - config: AliConfig, - } -} - -func (a *AliSms) Send(PhoneNumbers, SignName, TemplateCode, TemplateParam string) error { - //客户端 - client, err := dysmsapi.NewClientWithAccessKey(a.config.RegionId, a.config.accessKeyId, a.config.accessSecret) - if err != nil { - return errors.Wrapf(err, "ali sms client init fail") - } - //参数处理 - request := dysmsapi.CreateSendSmsRequest() - request.Scheme = "https" - request.PhoneNumbers = PhoneNumbers - request.SignName = SignName - request.TemplateCode = TemplateCode - //json格式 - request.TemplateParam = TemplateParam - //发送 - _, err = client.SendSms(request) - if err != nil { - return errors.Wrapf(err, "ali sms send fail") - } - return nil -} diff --git a/base/sms/sms.go b/base/sms/sms.go deleted file mode 100644 index a3bf74e..0000000 --- a/base/sms/sms.go +++ /dev/null @@ -1,14 +0,0 @@ -package sms - -type Sms interface { - Send(PhoneNumbers, SignName, TemplateCode, TemplateParam string) error -} - -func NewDefaultSms(use string) Sms { - switch use { - case "AliYun": - return NewAliSms(AliConfig{}) - default: - panic("sms driver err") - } -} diff --git a/base/starter/gorm.go b/base/starter/gorm.go deleted file mode 100644 index da5d5cf..0000000 --- a/base/starter/gorm.go +++ /dev/null @@ -1,77 +0,0 @@ -package starter - -import ( - "database/sql" - "gorm.io/driver/mysql" - "gorm.io/driver/postgres" - "gorm.io/gorm" - "gorm.io/gorm/logger" - "pandax/pkg/global" - "time" - - _ "github.com/lib/pq" -) - -func GormInit(ty string) *gorm.DB { - switch ty { - case "mysql": - return GormMysql() - case "postgresql": - return GormPostgresql() - } - return nil -} -func GormMysql() *gorm.DB { - m := global.Conf.Mysql - if m == nil || m.Dbname == "" { - global.Log.Panic("未找到数据库配置信息") - return nil - } - global.Log.Infof("连接mysql [%s]", m.Host) - mysqlConfig := mysql.Config{ - DSN: m.Dsn(), // DSN data source name - DefaultStringSize: 191, // string 类型字段的默认长度 - DisableDatetimePrecision: true, // 禁用 datetime 精度,MySQL 5.6 之前的数据库不支持 - DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引 - DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列 - SkipInitializeWithVersion: false, // 根据版本自动配置 - } - ormConfig := &gorm.Config{Logger: logger.Default.LogMode(logger.Silent)} - db, err := gorm.Open(mysql.New(mysqlConfig), ormConfig) - if err != nil { - global.Log.Panicf("连接mysql失败! [%s]", err.Error()) - return nil - } - sqlDB, _ := db.DB() - sqlDB.SetMaxIdleConns(m.MaxIdleConns) - sqlDB.SetMaxOpenConns(m.MaxOpenConns) - return db -} - -func GormPostgresql() *gorm.DB { - m := global.Conf.Postgresql - if m == nil || m.Dbname == "" { - global.Log.Panic("未找到数据库配置信息") - return nil - } - global.Log.Infof("连接postgres [%s]", m.PgDsn()) - db, err := sql.Open("postgres", m.PgDsn()) - if err != nil { - global.Log.Panicf("连接postgresql失败! [%s]", err.Error()) - } - gormDb, err := gorm.Open(postgres.New(postgres.Config{ - Conn: db, - }), &gorm.Config{}) - if err != nil { - global.Log.Panicf("连接postgresql失败! [%s]", err.Error()) - } - sqlDB, err := gormDb.DB() - // SetMaxIdleConns 设置空闲连接池中连接的最大数量 - sqlDB.SetMaxIdleConns(m.MaxIdleConns) - // SetMaxOpenConns 设置打开数据库连接的最大数量。 - sqlDB.SetMaxOpenConns(m.MaxOpenConns) - // SetConnMaxLifetime 设置了连接可复用的最大时间。 - sqlDB.SetConnMaxLifetime(time.Hour) - - return gormDb -} diff --git a/base/starter/redis.go b/base/starter/redis.go deleted file mode 100644 index 4ed2fb4..0000000 --- a/base/starter/redis.go +++ /dev/null @@ -1,28 +0,0 @@ -package starter - -import ( - "fmt" - "pandax/pkg/global" - - "github.com/go-redis/redis" -) - -func ConnRedis() *redis.Client { - // 设置redis客户端 - redisConf := global.Conf.Redis - if redisConf == nil { - global.Log.Panic("未找到redis配置信息") - } - global.Log.Infof("连接redis [%s:%d]", redisConf.Host, redisConf.Port) - rdb := redis.NewClient(&redis.Options{ - Addr: fmt.Sprintf("%s:%d", redisConf.Host, redisConf.Port), - Password: redisConf.Password, // no password set - DB: redisConf.Db, // use default DB - }) - // 测试连接 - _, e := rdb.Ping().Result() - if e != nil { - global.Log.Panic(fmt.Sprintf("连接redis失败! [%s:%d]", redisConf.Host, redisConf.Port)) - } - return rdb -} diff --git a/base/starter/web-server.go b/base/starter/web-server.go deleted file mode 100644 index 18b0e12..0000000 --- a/base/starter/web-server.go +++ /dev/null @@ -1,23 +0,0 @@ -package starter - -import ( - "pandax/pkg/global" - - "github.com/gin-gonic/gin" -) - -func RunWebServer(web *gin.Engine) { - server := global.Conf.Server - port := server.GetPort() - if app := global.Conf.App; app != nil { - global.Log.Infof("%s- Listening and serving HTTP on %s", app.GetAppInfo(), port) - } else { - global.Log.Infof("Listening and serving HTTP on %s", port) - } - - if server.Tls != nil && server.Tls.Enable { - web.RunTLS(port, server.Tls.CertFile, server.Tls.KeyFile) - } else { - web.Run(port) - } -} diff --git a/base/token/token.go b/base/token/token.go deleted file mode 100644 index 6e2d023..0000000 --- a/base/token/token.go +++ /dev/null @@ -1,134 +0,0 @@ -package token - -import ( - "errors" - "fmt" - "github.com/dgrijalva/jwt-go" - "strings" - "time" -) - -type Claims struct { - UserId int64 - TenantId int64 - UserName string - RoleId int64 - RoleKey string - DeptId int64 - PostId int64 - jwt.StandardClaims -} - -type JWT struct { - SignedKeyID string - SignedKey []byte - SignedMethod jwt.SigningMethod -} - -var ( - TokenExpired = errors.New("token is expired") - TokenNotValidYet = errors.New("token not active yet") - TokenMalformed = errors.New("that's not even a token") - TokenInvalid = errors.New("couldn't handle this token") -) - -func NewJWT(kid string, key []byte, method jwt.SigningMethod) *JWT { - return &JWT{ - SignedKeyID: kid, - SignedKey: key, - SignedMethod: method, - } -} - -// CreateToken 创建一个token -func (j *JWT) CreateToken(claims Claims) (string, error) { - token := jwt.NewWithClaims(jwt.SigningMethodHS256, &claims) - var key interface{} - if j.isEs() { - v, err := jwt.ParseECPrivateKeyFromPEM(j.SignedKey) - if err != nil { - return "", err - } - key = v - } else if j.isRsOrPS() { - v, err := jwt.ParseRSAPrivateKeyFromPEM(j.SignedKey) - if err != nil { - return "", err - } - key = v - } else if j.isHs() { - key = j.SignedKey - } else { - return "", errors.New("unsupported sign method") - } - return token.SignedString(key) -} - -// ParseToken 解析 token -func (j *JWT) ParseToken(tokenString string) (*Claims, error) { - token, err := jwt.ParseWithClaims(tokenString, &Claims{}, func(token *jwt.Token) (i interface{}, e error) { - if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { - return nil, fmt.Errorf("parse error") - } - return j.SignedKey, nil - }) - if err != nil { - if ve, ok := err.(*jwt.ValidationError); ok { - if ve.Errors&jwt.ValidationErrorMalformed != 0 { - return nil, TokenMalformed - } else if ve.Errors&jwt.ValidationErrorExpired != 0 { - // Token is expired - return nil, TokenExpired - } else if ve.Errors&jwt.ValidationErrorNotValidYet != 0 { - return nil, TokenNotValidYet - } else { - return nil, TokenInvalid - } - } - } - if token != nil { - if claims, ok := token.Claims.(*Claims); ok && token.Valid { - return claims, nil - } - return nil, TokenInvalid - - } else { - return nil, TokenInvalid - - } - -} - -// 更新token -func (j *JWT) RefreshToken(tokenString string) (string, error) { - jwt.TimeFunc = func() time.Time { - return time.Unix(0, 0) - } - token, err := jwt.ParseWithClaims(tokenString, &Claims{}, func(token *jwt.Token) (interface{}, error) { - return j.SignedKey, nil - }) - if err != nil { - return "", err - } - - if claims, ok := token.Claims.(*Claims); ok && token.Valid { - jwt.TimeFunc = time.Now - claims.StandardClaims.ExpiresAt = time.Now().Unix() + 60*60*24*7 - return j.CreateToken(*claims) - } - return "", TokenInvalid -} - -func (a *JWT) isEs() bool { - return strings.HasPrefix(a.SignedMethod.Alg(), "ES") -} - -func (a *JWT) isRsOrPS() bool { - isRs := strings.HasPrefix(a.SignedMethod.Alg(), "RS") - isPs := strings.HasPrefix(a.SignedMethod.Alg(), "PS") - return isRs || isPs -} - -func (a *JWT) isHs() bool { - return strings.HasPrefix(a.SignedMethod.Alg(), "HS") -} diff --git a/base/utils/ddm.go b/base/utils/ddm.go deleted file mode 100644 index 04af9bf..0000000 --- a/base/utils/ddm.go +++ /dev/null @@ -1,43 +0,0 @@ -package utils - -/** - * @Description 添加qq群467890197 交流学习 - * @Author 熊猫 - * @Date 2022/1/13 17:16 - **/ - -func DdmKey(data string) string { - if len(data) < 6 { - return data - } - return data[:3] + "****" + data[len(data)-3:] -} - -func IsDdmKey(data string) bool { - if len(data) > 6 && data[3:len(data)-3] == "****" { - return true - } - return false -} - -func DdmMail(data string) string { - return data[:3] + "****" + data[len(data)-8:] -} - -func ISDdmMail(data string) bool { - if len(data) > 11 && data[3:len(data)-8] == "****" { - return true - } - return false -} - -func DdmPassword(data string) string { - return "******" -} - -func IsDdmPassword(data string) bool { - if data == "******" { - return true - } - return false -} diff --git a/base/utils/ddm_test.go b/base/utils/ddm_test.go deleted file mode 100644 index 3f1cd99..0000000 --- a/base/utils/ddm_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package utils - -import ( - "testing" -) - -/** - * @Description 添加qq群467890197 交流学习 - * @Author 熊猫 - * @Date 2022/1/17 10:01 - **/ - -func TestDdmKey(t *testing.T) { - aa := "fsdfsf535343sdfsdf3" - bb := "23423423@qq.com" - - key := DdmKey(aa) - t.Log(key) - ddmKey := IsDdmKey(key) - t.Log(ddmKey) - - mail := DdmMail(bb) - t.Log(mail) - ismail := ISDdmMail(mail) - t.Log(ismail) -} diff --git a/base/utils/excel.go b/base/utils/excel.go deleted file mode 100644 index 239d6f8..0000000 --- a/base/utils/excel.go +++ /dev/null @@ -1,46 +0,0 @@ -package utils - -import ( - "fmt" - "github.com/xuri/excelize/v2" - "reflect" -) - -func ExportExcel(head []string, datas [][]any, filePath string) error { - excel := excelize.NewFile() - excel.SetSheetRow("Sheet1", "A1", &head) - for i, data := range datas { - axis := fmt.Sprintf("A%d", i+2) - excel.SetSheetRow("Sheet1", axis, &data) - } - excel.SaveAs(filePath) - return nil -} - -func GetFileName(path, filename string) string { - return path + filename -} - -func InterfaceToExcel(data any, fileName string) { - heads := make([]string, 0) - datas := make([][]any, 0) - v := reflect.ValueOf(data) - max := int64(v.Len()) - for i := 0; i < int(max); i++ { - u := v.Index(i).Interface() - var key = reflect.TypeOf(u) - var val = reflect.ValueOf(u) - num := key.NumField() - if i == 0 { - for i := 0; i < num; i++ { - heads = append(heads, key.Field(i).Name) - } - } - field := make([]any, 0) - for i := 0; i < num; i++ { - field = append(field, val.Field(i).Interface()) - } - datas = append(datas, field) - } - ExportExcel(heads, datas, fileName) -} diff --git a/base/utils/excel_test.go b/base/utils/excel_test.go deleted file mode 100644 index dd643f0..0000000 --- a/base/utils/excel_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package utils - -import ( - "testing" -) - -type User struct { - Name string `json:"name"` - Age int64 `json:"age"` -} - -func TestExportExcel(t *testing.T) { - us := make([]User, 0) - us = append(us, User{Name: "张三", Age: 12}) - us = append(us, User{Name: "李四", Age: 23}) - name := GetFileName("./", "字典") - t.Log(name) - InterfaceToExcel(us, name) -} diff --git a/base/utils/float_to_f.go.go b/base/utils/float_to_f.go.go deleted file mode 100644 index 3a8b911..0000000 --- a/base/utils/float_to_f.go.go +++ /dev/null @@ -1,26 +0,0 @@ -package utils - -import ( - "fmt" - "strconv" -) - -func ParseFloat2F(value float64) float64 { - newValue, err := strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64) - if err != nil { - fmt.Println("保留2位小数, 转换float出错") - return value - } - return newValue - -} - -func ParseStringToInt64(value string) int64 { - - newValue, err := strconv.ParseInt(value, 10, 64) - if err != nil { - fmt.Println("string转换int64出错") - return 0 - } - return newValue -} diff --git a/base/utils/ip.go b/base/utils/ip.go deleted file mode 100644 index 3a56d77..0000000 --- a/base/utils/ip.go +++ /dev/null @@ -1,54 +0,0 @@ -package utils - -import ( - "fmt" - "net" - "pandax/base/httpclient" -) - -const ipurl = "http://whois.pconline.com.cn/ipJson.jsp" - -const UNKNOWN = "XX XX" - -//GetRealAddressByIP 获取真实地址 -func GetRealAddressByIP(ip string) string { - if ip == "127.0.0.1" || ip == "localhost" { - return "内部IP" - } - url := fmt.Sprintf("%s?ip=%s&json=true", ipurl, ip) - - res := httpclient.NewRequest(url).Get() - if res == nil || res.StatusCode != 200 { - return UNKNOWN - } - toMap, err := res.BodyToMap() - if err != nil { - return UNKNOWN - } - //log.Println(fmt.Sprintf("%s %s",toMap["pro"].(string),toMap["city"].(string))) - return toMap["addr"].(string) -} - -// 获取局域网ip地址 -func GetLocaHonst() string { - netInterfaces, err := net.Interfaces() - if err != nil { - fmt.Println("net.Interfaces failed, err:", err.Error()) - } - - for i := 0; i < len(netInterfaces); i++ { - if (netInterfaces[i].Flags & net.FlagUp) != 0 { - addrs, _ := netInterfaces[i].Addrs() - - for _, address := range addrs { - if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { - if ipnet.IP.To4() != nil { - return ipnet.IP.String() - } - } - } - } - - } - return "" -} diff --git a/base/utils/json_utils.go b/base/utils/json_utils.go deleted file mode 100644 index 10822f5..0000000 --- a/base/utils/json_utils.go +++ /dev/null @@ -1,14 +0,0 @@ -package utils - -import ( - "encoding/json" -) - -func Json2Map(jsonStr string) map[string]any { - var res map[string]any - if jsonStr == "" { - return res - } - _ = json.Unmarshal([]byte(jsonStr), &res) - return res -} diff --git a/base/utils/regexp.go b/base/utils/regexp.go deleted file mode 100644 index 78b0d7b..0000000 --- a/base/utils/regexp.go +++ /dev/null @@ -1,42 +0,0 @@ -package utils - -import ( - "regexp" - "sync" -) - -var ( - regexMu = sync.RWMutex{} - // Cache for regex object. - // Note that: - // 1. It uses sync.RWMutex ensuring the concurrent safety. - // 2. There's no expiring logic for this map. - regexMap = make(map[string]*regexp.Regexp) -) - -// getRegexp returns *regexp.Regexp object with given `pattern`. -// It uses cache to enhance the performance for compiling regular expression pattern, -// which means, it will return the same *regexp.Regexp object with the same regular -// expression pattern. -// -// It is concurrent-safe for multiple goroutines. -func GetRegexp(pattern string) (regex *regexp.Regexp, err error) { - // Retrieve the regular expression object using reading lock. - regexMu.RLock() - regex = regexMap[pattern] - regexMu.RUnlock() - if regex != nil { - return - } - // If it does not exist in the cache, - // it compiles the pattern and creates one. - regex, err = regexp.Compile(pattern) - if err != nil { - return - } - // Cache the result object using writing lock. - regexMu.Lock() - regexMap[pattern] = regex - regexMu.Unlock() - return -} diff --git a/base/utils/str_utils.go b/base/utils/str_utils.go deleted file mode 100644 index 3eecf91..0000000 --- a/base/utils/str_utils.go +++ /dev/null @@ -1,131 +0,0 @@ -package utils - -import ( - "bytes" - "github.com/kakuilan/kgo" - "strings" - "text/template" -) - -func UnicodeIndex(str, substr string) int { - // 子串在字符串的字节位置 - result := strings.Index(str, substr) - if result >= 0 { - // 获得子串之前的字符串并转换成[]byte - prefix := []byte(str)[0:result] - // 将子串之前的字符串转换成[]rune - rs := []rune(string(prefix)) - // 获得子串之前的字符串的长度,便是子串在字符串的字符位置 - result = len(rs) - } - - return result -} - -func ReplaceString(pattern, replace, src string) (string, error) { - if r, err := GetRegexp(pattern); err == nil { - return r.ReplaceAllString(src, replace), nil - } else { - return "", err - } -} - -func Contains(haystack, needle string, startOffset ...int) int { - length := len(haystack) - offset := 0 - if len(startOffset) > 0 { - offset = startOffset[0] - } - if length == 0 || offset > length || -offset > length { - return -1 - } - - if offset < 0 { - offset += length - } - pos := strings.Index(strings.ToLower(haystack[offset:]), strings.ToLower(needle)) - if pos == -1 { - return -1 - } - return pos + offset -} - -// 字符串模板解析 -func TemplateResolve(temp string, data any) string { - t, _ := template.New("string-temp").Parse(temp) - var tmplBytes bytes.Buffer - - err := t.Execute(&tmplBytes, data) - if err != nil { - panic(err) - } - return tmplBytes.String() -} - -func ReverStrTemplate(temp, str string, res map[string]any) { - index := UnicodeIndex(temp, "{") - ei := UnicodeIndex(temp, "}") + 1 - next := kgo.KStr.Trim(temp[ei:], " ") - nextContain := UnicodeIndex(next, "{") - nextIndexValue := next - if nextContain != -1 { - nextIndexValue = kgo.KStr.Substr(next, 0, nextContain) - } - key := temp[index+1 : ei-1] - // 如果后面没有内容了,则取字符串的长度即可 - var valueLastIndex int - if nextIndexValue == "" { - valueLastIndex = kgo.KStr.MbStrlen(str) - } else { - valueLastIndex = UnicodeIndex(str, nextIndexValue) - } - value := kgo.KStr.Trim(kgo.KStr.Substr(str, index, valueLastIndex), " ") - res[key] = value - // 如果后面的还有需要解析的,则递归调用解析 - if nextContain != -1 { - ReverStrTemplate(next, kgo.KStr.Trim(kgo.KStr.Substr(str, UnicodeIndex(str, value)+kgo.KStr.MbStrlen(value), kgo.KStr.MbStrlen(str))), res) - } -} - -func B2S(bs []uint8) string { - ba := []byte{} - for _, b := range bs { - ba = append(ba, byte(b)) - } - return string(ba) -} - -func IdsStrToIdsIntGroup(keys string) []int64 { - IDS := make([]int64, 0) - ids := strings.Split(keys, ",") - for i := 0; i < len(ids); i++ { - ID := kgo.KConv.Str2Int(ids[i]) - IDS = append(IDS, int64(ID)) - } - return IDS -} - -// 获取部门 -// isP 是父ID 否则子ID -func DeptPCIds(deptIds []string, id int64, isP bool) []int64 { - pRes := make([]int64, 0) - cRes := make([]int64, 0) - is := true - for _, deptId := range deptIds { - did := kgo.KConv.Str2Int64(deptId) - if is { - pRes = append(pRes, did) - } - if kgo.KConv.Str2Int64(deptId) == id { - is = false - } - if !is { - cRes = append(cRes, did) - } - } - if isP { - return pRes - } else { - return cRes - } -} diff --git a/base/utils/str_utils_test.go b/base/utils/str_utils_test.go deleted file mode 100644 index 9f42174..0000000 --- a/base/utils/str_utils_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package utils - -import ( - "log" - "strings" - "testing" -) - -func TestIdsStrToIdsIntGroup(t *testing.T) { - group := IdsStrToIdsIntGroup("aaa") - t.Log(len(group)) -} - -func TestGetRealAddressByIP(t *testing.T) { - ip := GetRealAddressByIP("10.42.0.1") - t.Log(ip) -} - -func TestDeptPCIds(t *testing.T) { - split := strings.Split(strings.Trim("/0/2", "/"), "/") - log.Println("split", split) - ids := DeptPCIds(split, 2, true) - t.Log(ids) -} diff --git a/base/utils/struct_utils.go b/base/utils/struct_utils.go deleted file mode 100644 index dc51d60..0000000 --- a/base/utils/struct_utils.go +++ /dev/null @@ -1,654 +0,0 @@ -package utils - -import ( - "database/sql" - "encoding/json" - "errors" - "fmt" - "reflect" - "strconv" - "strings" -) - -// Copy copy things,引用至copier -func Copy(toValue any, fromValue any) (err error) { - var ( - isSlice bool - amount = 1 - from = Indirect(reflect.ValueOf(fromValue)) - to = Indirect(reflect.ValueOf(toValue)) - ) - - if !to.CanAddr() { - return errors.New("copy to value is unaddressable") - } - - // Return is from value is invalid - if !from.IsValid() { - return - } - - fromType := IndirectType(from.Type()) - toType := IndirectType(to.Type()) - - // Just set it if possible to assign - // And need to do copy anyway if the type is struct - if fromType.Kind() != reflect.Struct && from.Type().AssignableTo(to.Type()) { - to.Set(from) - return - } - - if fromType.Kind() != reflect.Struct || toType.Kind() != reflect.Struct { - return - } - - if to.Kind() == reflect.Slice { - isSlice = true - if from.Kind() == reflect.Slice { - amount = from.Len() - } - } - - for i := 0; i < amount; i++ { - var dest, source reflect.Value - - if isSlice { - // source - if from.Kind() == reflect.Slice { - source = Indirect(from.Index(i)) - } else { - source = Indirect(from) - } - // dest - dest = Indirect(reflect.New(toType).Elem()) - } else { - source = Indirect(from) - dest = Indirect(to) - } - - // check source - if source.IsValid() { - fromTypeFields := deepFields(fromType) - //fmt.Printf("%#v", fromTypeFields) - // Copy from field to field or method - for _, field := range fromTypeFields { - name := field.Name - - if fromField := source.FieldByName(name); fromField.IsValid() { - // has field - if toField := dest.FieldByName(name); toField.IsValid() { - if toField.CanSet() { - if !set(toField, fromField) { - if err := Copy(toField.Addr().Interface(), fromField.Interface()); err != nil { - return err - } - } - } - } else { - // try to set to method - var toMethod reflect.Value - if dest.CanAddr() { - toMethod = dest.Addr().MethodByName(name) - } else { - toMethod = dest.MethodByName(name) - } - - if toMethod.IsValid() && toMethod.Type().NumIn() == 1 && fromField.Type().AssignableTo(toMethod.Type().In(0)) { - toMethod.Call([]reflect.Value{fromField}) - } - } - } - } - - // Copy from method to field - for _, field := range deepFields(toType) { - name := field.Name - - var fromMethod reflect.Value - if source.CanAddr() { - fromMethod = source.Addr().MethodByName(name) - } else { - fromMethod = source.MethodByName(name) - } - - if fromMethod.IsValid() && fromMethod.Type().NumIn() == 0 && fromMethod.Type().NumOut() == 1 { - if toField := dest.FieldByName(name); toField.IsValid() && toField.CanSet() { - values := fromMethod.Call([]reflect.Value{}) - if len(values) >= 1 { - set(toField, values[0]) - } - } - } - } - } - if isSlice { - if dest.Addr().Type().AssignableTo(to.Type().Elem()) { - to.Set(reflect.Append(to, dest.Addr())) - } else if dest.Type().AssignableTo(to.Type().Elem()) { - to.Set(reflect.Append(to, dest)) - } - } - } - return -} - -// 对结构体的每个字段以及字段值执行doWith回调函数, 包括匿名属性的字段 -func DoWithFields(str any, doWith func(fType reflect.StructField, fValue reflect.Value) error) error { - t := IndirectType(reflect.TypeOf(str)) - if t.Kind() != reflect.Struct { - return errors.New("非结构体") - } - - fieldNum := t.NumField() - v := Indirect(reflect.ValueOf(str)) - for i := 0; i < fieldNum; i++ { - ft := t.Field(i) - fv := v.Field(i) - // 如果是匿名属性,则递归调用该方法 - if ft.Anonymous { - DoWithFields(fv.Interface(), doWith) - continue - } - err := doWith(ft, fv) - if err != nil { - return err - } - } - return nil -} - -func deepFields(reflectType reflect.Type) []reflect.StructField { - var fields []reflect.StructField - - if reflectType = IndirectType(reflectType); reflectType.Kind() == reflect.Struct { - for i := 0; i < reflectType.NumField(); i++ { - v := reflectType.Field(i) - if v.Anonymous { - fields = append(fields, deepFields(v.Type)...) - } else { - fields = append(fields, v) - } - } - } - - return fields -} - -func Indirect(reflectValue reflect.Value) reflect.Value { - for reflectValue.Kind() == reflect.Ptr { - reflectValue = reflectValue.Elem() - } - return reflectValue -} - -func IndirectType(reflectType reflect.Type) reflect.Type { - for reflectType.Kind() == reflect.Ptr || reflectType.Kind() == reflect.Slice { - reflectType = reflectType.Elem() - } - return reflectType -} - -func set(to, from reflect.Value) bool { - if from.IsValid() { - if to.Kind() == reflect.Ptr { - //set `to` to nil if from is nil - if from.Kind() == reflect.Ptr && from.IsNil() { - to.Set(reflect.Zero(to.Type())) - return true - } else if to.IsNil() { - to.Set(reflect.New(to.Type().Elem())) - } - to = to.Elem() - } - - if from.Type().ConvertibleTo(to.Type()) { - to.Set(from.Convert(to.Type())) - } else if scanner, ok := to.Addr().Interface().(sql.Scanner); ok { - err := scanner.Scan(from.Interface()) - if err != nil { - return false - } - } else if from.Kind() == reflect.Ptr { - return set(to, from.Elem()) - } else { - return false - } - } - return true -} - -func Map2Struct(m map[string]any, s any) error { - toValue := Indirect(reflect.ValueOf(s)) - if !toValue.CanAddr() { - return errors.New("to value is unaddressable") - } - - innerStructMaps := getInnerStructMaps(m) - if len(innerStructMaps) != 0 { - for k, v := range innerStructMaps { - var fieldV reflect.Value - if strings.Contains(k, ".") { - fieldV = getFiledValueByPath(k, toValue) - } else { - fieldV = toValue.FieldByName(k) - } - - if !fieldV.CanSet() || !fieldV.CanAddr() { - continue - } - fieldT := fieldV.Type().Elem() - if fieldT.Kind() != reflect.Struct { - return errors.New(k + "不是结构体") - } - // 如果值为nil,则默认创建一个并赋值 - if fieldV.IsNil() { - fieldV.Set(reflect.New(fieldT)) - } - err := Map2Struct(v, fieldV.Addr().Interface()) - if err != nil { - return err - } - } - } - var err error - for k, v := range m { - if v == nil { - continue - } - k = strings.Title(k) - // 如果key含有下划线,则将其转为驼峰 - if strings.Contains(k, "_") { - k = Case2Camel(k) - } - - fieldV := toValue.FieldByName(k) - if !fieldV.CanSet() { - continue - } - - err = decode(k, v, fieldV) - if err != nil { - return err - } - } - - return nil -} - -func Maps2Structs(maps []map[string]any, structs any) error { - structsV := reflect.Indirect(reflect.ValueOf(structs)) - valType := structsV.Type() - valElemType := valType.Elem() - sliceType := reflect.SliceOf(valElemType) - - length := len(maps) - - valSlice := structsV - if valSlice.IsNil() { - // Make a new slice to hold our result, same size as the original data. - valSlice = reflect.MakeSlice(sliceType, length, length) - } - - for i := 0; i < length; i++ { - err := Map2Struct(maps[i], valSlice.Index(i).Addr().Interface()) - if err != nil { - return err - } - } - structsV.Set(valSlice) - return nil -} - -func getFiledValueByPath(path string, value reflect.Value) reflect.Value { - split := strings.Split(path, ".") - for _, v := range split { - if value.Type().Kind() == reflect.Ptr { - // 如果值为nil,则创建并赋值 - if value.IsNil() { - value.Set(reflect.New(IndirectType(value.Type()))) - } - value = value.Elem() - } - value = value.FieldByName(v) - } - return value -} - -func getInnerStructMaps(m map[string]any) map[string]map[string]any { - key2map := make(map[string]map[string]any) - for k, v := range m { - if !strings.Contains(k, ".") { - continue - } - lastIndex := strings.LastIndex(k, ".") - prefix := k[0:lastIndex] - m2 := key2map[prefix] - if m2 == nil { - key2map[prefix] = map[string]any{k[lastIndex+1:]: v} - } else { - m2[k[lastIndex+1:]] = v - } - delete(m, k) - } - return key2map -} - -// decode等方法摘抄自mapstructure库 - -func decode(name string, input any, outVal reflect.Value) error { - var inputVal reflect.Value - if input != nil { - inputVal = reflect.ValueOf(input) - - // We need to check here if input is a typed nil. Typed nils won't - // match the "input == nil" below so we check that here. - if inputVal.Kind() == reflect.Ptr && inputVal.IsNil() { - input = nil - } - } - - if !inputVal.IsValid() { - // If the input value is invalid, then we just set the value - // to be the zero value. - outVal.Set(reflect.Zero(outVal.Type())) - return nil - } - - var err error - outputKind := getKind(outVal) - switch outputKind { - case reflect.Int: - err = decodeInt(name, input, outVal) - case reflect.Uint: - err = decodeUint(name, input, outVal) - case reflect.Float32: - err = decodeFloat(name, input, outVal) - case reflect.String: - err = decodeString(name, input, outVal) - case reflect.Ptr: - _, err = decodePtr(name, input, outVal) - default: - // If we reached this point then we weren't able to decode it - return fmt.Errorf("%s: unsupported type: %s", name, outputKind) - } - return err -} - -func decodeInt(name string, data any, val reflect.Value) error { - dataVal := reflect.Indirect(reflect.ValueOf(data)) - dataKind := getKind(dataVal) - dataType := dataVal.Type() - - switch { - case dataKind == reflect.Int: - val.SetInt(dataVal.Int()) - case dataKind == reflect.Uint: - val.SetInt(int64(dataVal.Uint())) - case dataKind == reflect.Float32: - val.SetInt(int64(dataVal.Float())) - case dataKind == reflect.Bool: - if dataVal.Bool() { - val.SetInt(1) - } else { - val.SetInt(0) - } - case dataKind == reflect.String: - i, err := strconv.ParseInt(dataVal.String(), 0, val.Type().Bits()) - if err == nil { - val.SetInt(i) - } else { - return fmt.Errorf("cannot parse '%s' as int: %s", name, err) - } - case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": - jn := data.(json.Number) - i, err := jn.Int64() - if err != nil { - return fmt.Errorf( - "error decoding json.Number into %s: %s", name, err) - } - val.SetInt(i) - default: - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s'", - name, val.Type(), dataVal.Type()) - } - - return nil -} - -func decodeUint(name string, data any, val reflect.Value) error { - dataVal := reflect.Indirect(reflect.ValueOf(data)) - dataKind := getKind(dataVal) - dataType := dataVal.Type() - - switch { - case dataKind == reflect.Int: - i := dataVal.Int() - if i < 0 { - return fmt.Errorf("cannot parse '%s', %d overflows uint", - name, i) - } - val.SetUint(uint64(i)) - case dataKind == reflect.Uint: - val.SetUint(dataVal.Uint()) - case dataKind == reflect.Float32: - f := dataVal.Float() - if f < 0 { - return fmt.Errorf("cannot parse '%s', %f overflows uint", - name, f) - } - val.SetUint(uint64(f)) - case dataKind == reflect.Bool: - if dataVal.Bool() { - val.SetUint(1) - } else { - val.SetUint(0) - } - case dataKind == reflect.String: - i, err := strconv.ParseUint(dataVal.String(), 0, val.Type().Bits()) - if err == nil { - val.SetUint(i) - } else { - return fmt.Errorf("cannot parse '%s' as uint: %s", name, err) - } - case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": - jn := data.(json.Number) - i, err := jn.Int64() - if err != nil { - return fmt.Errorf( - "error decoding json.Number into %s: %s", name, err) - } - if i < 0 { - return fmt.Errorf("cannot parse '%s', %d overflows uint", - name, i) - } - val.SetUint(uint64(i)) - default: - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s'", - name, val.Type(), dataVal.Type()) - } - - return nil -} - -func decodeFloat(name string, data any, val reflect.Value) error { - dataVal := reflect.Indirect(reflect.ValueOf(data)) - dataKind := getKind(dataVal) - dataType := dataVal.Type() - - switch { - case dataKind == reflect.Int: - val.SetFloat(float64(dataVal.Int())) - case dataKind == reflect.Uint: - val.SetFloat(float64(dataVal.Uint())) - case dataKind == reflect.Float32: - val.SetFloat(dataVal.Float()) - case dataKind == reflect.Bool: - if dataVal.Bool() { - val.SetFloat(1) - } else { - val.SetFloat(0) - } - case dataKind == reflect.String: - f, err := strconv.ParseFloat(dataVal.String(), val.Type().Bits()) - if err == nil { - val.SetFloat(f) - } else { - return fmt.Errorf("cannot parse '%s' as float: %s", name, err) - } - case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": - jn := data.(json.Number) - i, err := jn.Float64() - if err != nil { - return fmt.Errorf( - "error decoding json.Number into %s: %s", name, err) - } - val.SetFloat(i) - default: - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s'", - name, val.Type(), dataVal.Type()) - } - - return nil -} - -func decodeString(name string, data any, val reflect.Value) error { - dataVal := reflect.Indirect(reflect.ValueOf(data)) - dataKind := getKind(dataVal) - - converted := true - switch { - case dataKind == reflect.String: - val.SetString(dataVal.String()) - case dataKind == reflect.Bool: - if dataVal.Bool() { - val.SetString("1") - } else { - val.SetString("0") - } - case dataKind == reflect.Int: - val.SetString(strconv.FormatInt(dataVal.Int(), 10)) - case dataKind == reflect.Uint: - val.SetString(strconv.FormatUint(dataVal.Uint(), 10)) - case dataKind == reflect.Float32: - val.SetString(strconv.FormatFloat(dataVal.Float(), 'f', -1, 64)) - case dataKind == reflect.Slice, - dataKind == reflect.Array: - dataType := dataVal.Type() - elemKind := dataType.Elem().Kind() - switch elemKind { - case reflect.Uint8: - var uints []uint8 - if dataKind == reflect.Array { - uints = make([]uint8, dataVal.Len(), dataVal.Len()) - for i := range uints { - uints[i] = dataVal.Index(i).Interface().(uint8) - } - } else { - uints = dataVal.Interface().([]uint8) - } - val.SetString(string(uints)) - default: - converted = false - } - default: - converted = false - } - - if !converted { - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s'", - name, val.Type(), dataVal.Type()) - } - - return nil -} - -func decodePtr(name string, data any, val reflect.Value) (bool, error) { - // If the input data is nil, then we want to just set the output - // pointer to be nil as well. - isNil := data == nil - if !isNil { - switch v := reflect.Indirect(reflect.ValueOf(data)); v.Kind() { - case reflect.Chan, - reflect.Func, - reflect.Interface, - reflect.Map, - reflect.Ptr, - reflect.Slice: - isNil = v.IsNil() - } - } - if isNil { - if !val.IsNil() && val.CanSet() { - nilValue := reflect.New(val.Type()).Elem() - val.Set(nilValue) - } - - return true, nil - } - - // Create an element of the concrete (non pointer) type and decode - // into that. Then set the value of the pointer to this type. - valType := val.Type() - valElemType := valType.Elem() - if val.CanSet() { - realVal := val - if realVal.IsNil() { - realVal = reflect.New(valElemType) - } - - if err := decode(name, data, reflect.Indirect(realVal)); err != nil { - return false, err - } - - val.Set(realVal) - } else { - if err := decode(name, data, reflect.Indirect(val)); err != nil { - return false, err - } - } - return false, nil -} - -func getKind(val reflect.Value) reflect.Kind { - kind := val.Kind() - - switch { - case kind >= reflect.Int && kind <= reflect.Int64: - return reflect.Int - case kind >= reflect.Uint && kind <= reflect.Uint64: - return reflect.Uint - case kind >= reflect.Float32 && kind <= reflect.Float64: - return reflect.Float32 - default: - return kind - } -} - -// 下划线写法转为驼峰写法 -func Case2Camel(name string) string { - name = strings.Replace(name, "_", " ", -1) - name = strings.Title(name) - return strings.Replace(name, " ", "", -1) -} - -func IsBlank(value reflect.Value) bool { - switch value.Kind() { - case reflect.String: - return value.Len() == 0 - case reflect.Bool: - return !value.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return value.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return value.Uint() == 0 - case reflect.Float32, reflect.Float64: - return value.Float() == 0 - case reflect.Interface, reflect.Ptr: - return value.IsNil() - } - return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface()) -} diff --git a/base/utils/struct_utils_test.go b/base/utils/struct_utils_test.go deleted file mode 100644 index 21e84df..0000000 --- a/base/utils/struct_utils_test.go +++ /dev/null @@ -1,194 +0,0 @@ -package utils - -import ( - "fmt" - "reflect" - "strings" - "testing" - "time" -) - -type Src struct { - Id *int64 `json:"id"` - Username string `json:"username"` - CreateTime time.Time `json:"time"` - UpdateTime time.Time - Inner *SrcInner -} - -type SrcInner struct { - Name string - Desc string - Id int64 - Dest *Dest -} - -type Dest struct { - Username string - Id int64 - CreateTime time.Time - Inner *DestInner -} - -type DestInner struct { - Desc string -} - -func TestDeepFields(t *testing.T) { - ////src := Src{Username: "test", Id: 1000, CreateTime: time.Now()} - //si := SrcInner{Desc: "desc"} - //src.Inner = &si - ////src.Id = 1222 - //dest := new(Dest) - //err := structutils.Copy(dest, src) - //if err != nil { - // fmt.Println(err.Error()) - //} else { - // fmt.Println(dest) - //} - -} - -func TestGetFieldNames(t *testing.T) { - //names := structutils.GetFieldNames(new(Src)) - //fmt.Println(names) -} - -func TestMaps2Structs(t *testing.T) { - mapInstance := make(map[string]any) - mapInstance["Username"] = "liang637210" - mapInstance["Id"] = 28 - mapInstance["CreateTime"] = time.Now() - mapInstance["Creator"] = "createor" - mapInstance["Inner.Id"] = 10 - mapInstance["Inner.Name"] = "hahah" - mapInstance["Inner.Desc"] = "inner desc" - mapInstance["Inner.Dest.Username"] = "inner dest uername" - mapInstance["Inner.Dest.Inner.Desc"] = "inner dest inner desc" - - mapInstance2 := make(map[string]any) - mapInstance2["Username"] = "liang6372102" - mapInstance2["Id"] = 282 - mapInstance2["CreateTime"] = time.Now() - mapInstance2["Creator"] = "createor2" - mapInstance2["Inner.Id"] = 102 - mapInstance2["Inner.Name"] = "hahah2" - mapInstance2["Inner.Desc"] = "inner desc2" - mapInstance2["Inner.Dest.Username"] = "inner dest uername2" - mapInstance2["Inner.Dest.Inner.Desc"] = "inner dest inner desc2" - - maps := make([]map[string]any, 2) - maps[0] = mapInstance - maps[1] = mapInstance2 - res := new([]Src) - err := Maps2Structs(maps, res) - if err != nil { - fmt.Println(err) - } -} - -func TestMap2Struct(t *testing.T) { - mapInstance := make(map[string]any) - mapInstance["Username"] = "liang637210" - mapInstance["Id"] = 12 - mapInstance["CreateTime"] = time.Now() - mapInstance["Creator"] = "createor" - mapInstance["Inner.Id"] = nil - mapInstance["Inner.Name"] = "hahah" - mapInstance["Inner.Desc"] = "inner desc" - mapInstance["Inner.Dest.Username"] = "inner dest uername" - mapInstance["Inner.Dest.Inner.Desc"] = "inner dest inner desc" - - //innerMap := make(map[string]interface{}) - //innerMap["Name"] = "Innername" - - //a := new(Src) - ////a.Inner = new(SrcInner) - // - //stime := time.Now().UnixNano() - //for i := 0; i < 1000000; i++ { - // err := structutils.Map2Struct(mapInstance, a) - // if err != nil { - // fmt.Println(err) - // } - //} - //etime := time.Now().UnixNano() - //fmt.Println(etime - stime) - //if err != nil { - // fmt.Println(err) - //} else { - // fmt.Println(a) - //} - - s := new(Src) - //name, b := structutils.IndirectType(reflect.TypeOf(s)).FieldByName("Inner") - //if structutils.IndirectType(name.Type).Kind() != reflect.Struct { - // fmt.Println(name.Name + "不是结构体") - //} else { - // //innerType := name.Type - // innerValue := structutils.Indirect(reflect.ValueOf(s)).FieldByName("Inner") - // //if innerValue.IsValid() && innerValue.IsNil() { - // // innerValue.Set(reflect.New(innerValue.Type().Elem())) - // //} - // if !innerValue.IsValid() { - // fmt.Println("is valid") - // } else { - // //innerValue.Set(reflect.New(innerValue.Type())) - // fmt.Println(innerValue.CanSet()) - // fmt.Println(innerValue.CanAddr()) - // //mapstructure.Decode(innerMap, innerValue.Addr().Interface()) - // } - // - //} - // - //fmt.Println(name, b) - //将 map 转换为指定的结构体 - // if err := decode(mapInstance, &s); err != nil { - // fmt.Println(err) - // } - fmt.Printf("map2struct后得到的 struct 内容为:%v", s) -} - -func getPrefixKeyMap(m map[string]any) map[string]map[string]any { - key2map := make(map[string]map[string]any) - for k, v := range m { - if !strings.Contains(k, ".") { - continue - } - lastIndex := strings.LastIndex(k, ".") - prefix := k[0:lastIndex] - m2 := key2map[prefix] - if m2 == nil { - key2map[prefix] = map[string]any{k[lastIndex+1:]: v} - } else { - m2[k[lastIndex+1:]] = v - } - delete(m, k) - } - return key2map -} - -func TestReflect(t *testing.T) { - type dog struct { - LegCount int - } - // 获取dog实例的反射值对象 - valueOfDog := reflect.ValueOf(&dog{}).Elem() - - // 获取legCount字段的值 - vLegCount := valueOfDog.FieldByName("LegCount") - - fmt.Println(vLegCount.CanSet()) - fmt.Println(vLegCount.CanAddr()) - // 尝试设置legCount的值(这里会发生崩溃) - vLegCount.SetInt(4) -} - -func TestTemplateResolve(t *testing.T) { - d := make(map[string]string) - d["Name"] = "黄先生" - d["Age"] = "23jlfdsjf" - resolve := TemplateResolve("{{.Name}} is name, and {{.Age}} is age", d) - fmt.Println(resolve) - -} diff --git a/base/utils/template.go b/base/utils/template.go deleted file mode 100644 index 285527d..0000000 --- a/base/utils/template.go +++ /dev/null @@ -1,28 +0,0 @@ -package utils - -import ( - "bytes" - "text/template" -) - -func parse(t *template.Template, vars any) string { - var tmplBytes bytes.Buffer - - err := t.Execute(&tmplBytes, vars) - if err != nil { - panic(err) - } - return tmplBytes.String() -} - -// 模板字符串解析 -// str 模板字符串 -// vars 参数变量 -func TemplateParse(str string, vars any) string { - tmpl, err := template.New("tmpl").Parse(str) - - if err != nil { - panic(err) - } - return parse(tmpl, vars) -} diff --git a/base/utils/tree_utils.go b/base/utils/tree_utils.go deleted file mode 100644 index f14ae36..0000000 --- a/base/utils/tree_utils.go +++ /dev/null @@ -1,74 +0,0 @@ -package utils - -// ConvertToINodeArray 其他的结构体想要生成菜单树,直接实现这个接口 -type INode interface { - // GetId获取id - GetId() int - // GetPid 获取父id - GetPid() int - // IsRoot 判断当前节点是否是顶层根节点 - IsRoot() bool - - SetChildren(childern any) -} - -type INodes []INode - -func (nodes INodes) Len() int { - return len(nodes) -} -func (nodes INodes) Swap(i, j int) { - nodes[i], nodes[j] = nodes[j], nodes[i] -} -func (nodes INodes) Less(i, j int) bool { - return nodes[i].GetId() < nodes[j].GetId() -} - -// GenerateTree 自定义的结构体实现 INode 接口后调用此方法生成树结构 -// nodes 需要生成树的节点 -// selectedNode 生成树后选中的节点 -// menuTrees 生成成功后的树结构对象 -func GenerateTree(nodes []INode) (trees []INode) { - trees = []INode{} - // 定义顶层根和子节点 - var roots, childs []INode - for _, v := range nodes { - if v.IsRoot() { - // 判断顶层根节点 - roots = append(roots, v) - } - childs = append(childs, v) - } - - for _, v := range roots { - // 递归 - setChildren(v, childs) - trees = append(trees, v) - } - return -} - -// recursiveTree 递归生成树结构 -// tree 递归的树对象 -// nodes 递归的节点 -// selectedNodes 选中的节点 -func setChildren(parent INode, nodes []INode) { - children := []INode{} - for _, v := range nodes { - if v.IsRoot() { - // 如果当前节点是顶层根节点就跳过 - continue - } - if parent.GetId() == v.GetPid() { - children = append(children, v) - } - } - if len(children) == 0 { - return - } - - parent.SetChildren(children) - for _, c := range children { - setChildren(c, nodes) - } -} diff --git a/base/utils/yml.go b/base/utils/yml.go deleted file mode 100644 index 60e75ea..0000000 --- a/base/utils/yml.go +++ /dev/null @@ -1,27 +0,0 @@ -package utils - -import ( - "errors" - "io/ioutil" - - "gopkg.in/yaml.v3" -) - -// 从指定路径加载yaml文件 -func LoadYml(path string, out any) error { - yamlFileBytes, readErr := ioutil.ReadFile(path) - if readErr != nil { - return readErr - } - // yaml解析 - err := yaml.Unmarshal(yamlFileBytes, out) - if err != nil { - return errors.New("无法解析 [" + path + "] -- " + err.Error()) - } - return nil -} - -func LoadYmlByString(yamlStr string, out any) error { - // yaml解析 - return yaml.Unmarshal([]byte(yamlStr), out) -} diff --git a/base/ws/msg.go b/base/ws/msg.go deleted file mode 100644 index 3e3a20a..0000000 --- a/base/ws/msg.go +++ /dev/null @@ -1,27 +0,0 @@ -package ws - -const SuccessMsgType = 1 -const ErrorMsgType = 0 -const InfoMsgType = 2 - -// websocket消息 -type Msg struct { - Type int `json:"type"` // 消息类型 - Title string `json:"title"` // 消息标题 - Msg string `json:"msg"` // 消息内容 -} - -// 普通消息 -func NewMsg(title, msg string) *Msg { - return &Msg{Type: InfoMsgType, Title: title, Msg: msg} -} - -// 成功消息 -func SuccessMsg(title, msg string) *Msg { - return &Msg{Type: SuccessMsgType, Title: title, Msg: msg} -} - -// 错误消息 -func ErrMsg(title, msg string) *Msg { - return &Msg{Type: ErrorMsgType, Title: title, Msg: msg} -} diff --git a/base/ws/ws.go b/base/ws/ws.go deleted file mode 100644 index 48888e5..0000000 --- a/base/ws/ws.go +++ /dev/null @@ -1,66 +0,0 @@ -package ws - -import ( - "encoding/json" - "net/http" - "pandax/pkg/global" - "time" - - "github.com/gorilla/websocket" -) - -var Upgrader = websocket.Upgrader{ - ReadBufferSize: 1024, - WriteBufferSize: 1024 * 1024 * 10, - CheckOrigin: func(r *http.Request) bool { - return true - }, -} - -var conns = make(map[uint64]*websocket.Conn, 100) - -func init() { - checkConn() -} - -// 放置ws连接 -func Put(userId uint64, conn *websocket.Conn) { - Delete(userId) - conns[userId] = conn -} - -func checkConn() { - heartbeat := time.Duration(20) * time.Second - tick := time.NewTicker(heartbeat) - go func() { - for range tick.C { - // 遍历所有连接,ping失败的则删除掉 - for uid, conn := range conns { - err := conn.WriteControl(websocket.PingMessage, []byte("ping"), time.Now().Add(heartbeat/2)) - if err != nil { - global.Log.Info("删除ping失败的websocket连接:uid = ", uid) - Delete(uid) - return - } - } - } - }() -} - -// 删除ws连接 -func Delete(userid uint64) { - conn := conns[userid] - if conn != nil { - conn.Close() - delete(conns, userid) - } -} - -// 对指定用户发送消息 -func SendMsg(userId uint64, msg *Msg) { - conn := conns[userId] - if conn != nil { - bytes, _ := json.Marshal(msg) - conn.WriteMessage(websocket.TextMessage, bytes) - } -} diff --git a/go.mod b/go.mod index b137d5a..141bd77 100644 --- a/go.mod +++ b/go.mod @@ -3,60 +3,33 @@ module pandax go 1.18 require ( - github.com/gin-gonic/gin v1.7.4 - github.com/go-redis/redis v6.15.9+incompatible - github.com/gorilla/websocket v1.4.2 - // ssh - golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 - gopkg.in/yaml.v3 v3.0.0 - gorm.io/gorm v1.22.3 -) - -require ( - github.com/aliyun/alibaba-cloud-sdk-go v1.61.1443 - github.com/aliyun/aliyun-oss-go-sdk v2.2.0+incompatible - github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect - github.com/casbin/casbin/v2 v2.37.4 - github.com/casbin/gorm-adapter/v3 v3.4.6 + 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/golang/protobuf v1.5.2 // indirect - github.com/google/uuid v1.3.0 - github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible - github.com/json-iterator/go v1.1.12 // indirect + github.com/gin-gonic/gin v1.7.4 + github.com/gorilla/websocket v1.4.2 github.com/kakuilan/kgo v0.1.8 - github.com/lib/pq v1.10.4 - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/mojocn/base64Captcha v1.3.5 github.com/mssola/user_agent v0.5.3 - github.com/onsi/ginkgo v1.16.4 // indirect - github.com/patrickmn/go-cache v2.1.0+incompatible // indirect - github.com/pkg/errors v0.9.1 - github.com/qiniu/go-sdk/v7 v7.11.0 github.com/robfig/cron/v3 v3.0.1 - github.com/sirupsen/logrus v1.8.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.6 - github.com/tencentyun/cos-go-sdk-v5 v0.7.33 - github.com/xuri/excelize/v2 v2.4.1 - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect - golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect - google.golang.org/protobuf v1.28.0 // indirect - gorm.io/driver/mysql v1.2.0 - gorm.io/driver/postgres v1.2.3 + github.com/swaggo/swag v1.7.4 + golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 + gorm.io/gorm v1.22.3 ) -require github.com/spf13/cobra v1.5.0 - 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/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/fsnotify/fsnotify v1.5.4 // 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 @@ -66,11 +39,13 @@ require ( 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 + github.com/go-redis/redis v6.15.9+incompatible // indirect github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/google/go-cmp v0.5.8 // indirect + github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-querystring v1.0.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect github.com/jackc/pgconn v1.10.1 // indirect @@ -82,30 +57,41 @@ require ( github.com/jackc/pgx/v4 v4.14.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.2 // indirect - github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect + github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible // indirect github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/leodido/go-urn v1.2.1 // indirect + github.com/lib/pq v1.10.4 // indirect github.com/mailru/easyjson v0.7.6 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/mojocn/base64Captcha v1.3.5 // indirect github.com/mozillazg/go-httpheader v0.2.1 // indirect - github.com/onsi/gomega v1.10.1 // indirect + github.com/nxadm/tail v1.4.8 // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/qiniu/go-sdk/v7 v7.11.0 // indirect github.com/richardlehane/mscfb v1.0.3 // indirect github.com/richardlehane/msoleps v1.0.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/testify v1.7.1 // indirect + github.com/tencentyun/cos-go-sdk-v5 v0.7.33 // indirect github.com/ugorji/go/codec v1.1.7 // indirect github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 // indirect + github.com/xuri/excelize/v2 v2.4.1 // indirect golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb // indirect - golang.org/x/mod v0.4.1 // indirect golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect - golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect 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 - golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect - gopkg.in/ini.v1 v1.66.4 // 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 + gorm.io/driver/mysql v1.2.0 // indirect + gorm.io/driver/postgres v1.2.3 // indirect gorm.io/driver/sqlserver v1.2.1 // indirect gorm.io/plugin/dbresolver v1.1.0 // indirect ) diff --git a/go.sum b/go.sum index b9795d0..1de9e9d 100644 --- a/go.sum +++ b/go.sum @@ -12,14 +12,11 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko 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/agiledragon/gomonkey/v2 v2.3.1 h1:k+UnUY0EMNYUFUAQVETGY9uUTxjMdnUkP0ARyJS1zzs= -github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.1443 h1:rCVskInhkRcnsRgrvsZjmHRsjXxfQNdrHaU8CgV2vrg= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.1443/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU= +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/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/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= -github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= 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= github.com/casbin/casbin/v2 v2.37.4 h1:RWSKPjaZ8JlOBlcW1bI/FTII8OPxvQ9jVy9JwyNL6DQ= @@ -43,10 +40,8 @@ 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/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= 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= @@ -87,33 +82,20 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= 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/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.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.2/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.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.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 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= @@ -121,10 +103,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/uuid v1.1.1/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/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 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/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 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= @@ -182,18 +162,14 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI= github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA= github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kakuilan/kgo v0.1.8 h1:b9UfGYNbUpWjPheOEgu/MsWUVDNWbcSit6BbNsBAPl0= github.com/kakuilan/kgo v0.1.8/go.mod h1:S9driqss6OluzqiOfUx7xN8nw0H6bFu5v7c19P09RRc= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -232,7 +208,6 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= @@ -244,22 +219,10 @@ github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISe github.com/mssola/user_agent v0.5.3 h1:lBRPML9mdFuIZgI2cmlQ+atbpJdLdeVl2IDodjBR578= github.com/mssola/user_agent v0.5.3/go.mod h1:TTPno8LPY3wAIEKRpAtkdMT0f8SE24pLRGPahjCH4uw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= -github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= -github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= -github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= -github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -295,10 +258,8 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -313,13 +274,11 @@ 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/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 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/swaggo/swag v1.7.6 h1:UbAqHyXkW2J+cDjs5S43MkuYR7a6stB7Am7SK8NBmRg= -github.com/swaggo/swag v1.7.6/go.mod h1:7vLqNYEtYoIsD14wXgy9oDS65MNiDANrPtbk9rnLuj0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.194/go.mod h1:yrBKWhChnDqNz1xuXdSbWXG56XawEq0G5j1lg4VwBD4= github.com/tencentyun/cos-go-sdk-v5 v0.7.33 h1:5jmJU7U/1nf/7ZPDkrUL8KlF1oDUzTHsdtLNY6x0hq4= @@ -365,55 +324,46 @@ golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+o 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/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/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-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 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-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/sync v0.0.0-20180314180146-1d60e4601c6f/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 h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= 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-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/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= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/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-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/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= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -428,7 +378,6 @@ golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 h1:GZokNIeuVkl3aZHJchRrr13W 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-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/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-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -437,7 +386,6 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -447,13 +395,6 @@ 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= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -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.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 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.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= @@ -464,18 +405,12 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= -gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= -gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 4d310c4..64fb13a 100644 --- a/main.go +++ b/main.go @@ -1,13 +1,13 @@ package main import ( + "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" "os" "pandax/apps/job/jobs" - "pandax/base/config" - "pandax/base/ginx" - "pandax/base/logger" - "pandax/base/starter" "pandax/pkg/global" "pandax/pkg/initialize" "pandax/pkg/middleware" @@ -31,11 +31,11 @@ var rootCmd = &cobra.Command{ } }, Run: func(cmd *cobra.Command, args []string) { - ginx.UseAfterHandlerInterceptor(middleware.OperationHandler) + restfulx.UseAfterHandlerInterceptor(middleware.OperationHandler) // gin前置 函数 - ginx.UseBeforeHandlerInterceptor(ginx.PermissionHandler) + restfulx.UseBeforeHandlerInterceptor(restfulx.PermissionHandler) // gin后置 函数 - ginx.UseAfterHandlerInterceptor(ginx.LogHandler) + restfulx.UseAfterHandlerInterceptor(restfulx.LogHandler) go func() { // 启动系统调度任务 jobs.InitJob() diff --git a/pkg/global/global.go b/pkg/global/global.go index 8fdfaf2..4cb1ff5 100644 --- a/pkg/global/global.go +++ b/pkg/global/global.go @@ -1,9 +1,9 @@ package global import ( + "github.com/XM-GO/PandaKit/config" "github.com/sirupsen/logrus" "gorm.io/gorm" - "pandax/base/config" ) var ( diff --git a/pkg/initialize/table.go b/pkg/initialize/table.go index cc58723..8f509c6 100644 --- a/pkg/initialize/table.go +++ b/pkg/initialize/table.go @@ -1,12 +1,12 @@ package initialize import ( + "github.com/XM-GO/PandaKit/biz" devEntity "pandax/apps/develop/entity" jobEntity "pandax/apps/job/entity" logEntity "pandax/apps/log/entity" resSourceEntity "pandax/apps/resource/entity" "pandax/apps/system/entity" - "pandax/base/biz" "pandax/pkg/global" ) diff --git a/pkg/middleware/oper.go b/pkg/middleware/oper.go index fc09ea2..08d33ba 100644 --- a/pkg/middleware/oper.go +++ b/pkg/middleware/oper.go @@ -1,14 +1,14 @@ package middleware import ( + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" "net/http" "pandax/apps/log/entity" "pandax/apps/log/services" - "pandax/base/ginx" - "pandax/base/utils" ) -func OperationHandler(rc *ginx.ReqCtx) error { +func OperationHandler(rc *restfulx.ReqCtx) error { c := rc.GinCtx // 请求操作不做记录 if c.Request.Method == http.MethodGet || rc.LoginAccount == nil { diff --git a/resource/template/go/api.template b/resource/template/go/api.template index f75d682..3154a27 100644 --- a/resource/template/go/api.template +++ b/resource/template/go/api.template @@ -7,9 +7,9 @@ package api import ( "pandax/apps/{{.PackageName}}/entity" "pandax/apps/{{.PackageName}}/services" - "pandax/base/ginx" - "pandax/base/ginx" - "pandax/base/utils" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/restfulx" + "github.com/XM-GO/PandaKit/utils" ) type {{.ClassName}}Api struct { @@ -23,16 +23,16 @@ type {{.ClassName}}Api struct { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /{{.PackageName}}/{{.BusinessName}}/list [get] // @Security -func (p *{{.ClassName}}Api) Get{{.ClassName}}List(rc *ginx.ReqCtx) { +func (p *{{.ClassName}}Api) Get{{.ClassName}}List(rc *restfulx.ReqCtx) { data := entity.{{.ClassName}}{} - pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1) - pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10) + pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1) + pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10) {{- range $index, $column := .Columns -}} {{- if eq $column.IsRequired "1" -}} {{- if eq $column.GoType "string" }} data.{{$column.GoField}} = rc.GinCtx.Query("{{$column.JsonField}}") {{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") -}} - data.{{$column.GoField}} = ginx.QueryInt(rc.GinCtx, "{{$column.JsonField}}", 0) + data.{{$column.GoField}} = restfulx.QueryInt(rc.GinCtx, "{{$column.JsonField}}", 0) {{- end -}} {{- end -}} {{- end }} @@ -54,8 +54,8 @@ func (p *{{.ClassName}}Api) Get{{.ClassName}}List(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /{{.PackageName}}/{{.BusinessName}}/{{"{"}}{{.PkJsonField}}{{"}"}} [get] // @Security -func (p *{{.ClassName}}Api) Get{{.ClassName}}(rc *ginx.ReqCtx) { - {{.PkJsonField}} := ginx.PathParamInt(rc.GinCtx, "{{.PkJsonField}}") +func (p *{{.ClassName}}Api) Get{{.ClassName}}(rc *restfulx.ReqCtx) { + {{.PkJsonField}} := restfulx.PathParamInt(rc.GinCtx, "{{.PkJsonField}}") p.{{.ClassName}}App.FindOne(int64({{.PkJsonField}})) } @@ -69,9 +69,9 @@ func (p *{{.ClassName}}Api) Get{{.ClassName}}(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /{{.PackageName}}/{{.BusinessName}} [post] // @Security X-TOKEN -func (p *{{.ClassName}}Api) Insert{{.ClassName}}(rc *ginx.ReqCtx) { +func (p *{{.ClassName}}Api) Insert{{.ClassName}}(rc *restfulx.ReqCtx) { var data entity.{{.ClassName}} - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) p.{{.ClassName}}App.Insert(data) } @@ -86,9 +86,9 @@ func (p *{{.ClassName}}Api) Insert{{.ClassName}}(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 400, "message": "添加失败"}" // @Router /{{.PackageName}}/{{.BusinessName}} [put] // @Security X-TOKEN -func (p *{{.ClassName}}Api) Update{{.ClassName}}(rc *ginx.ReqCtx) { +func (p *{{.ClassName}}Api) Update{{.ClassName}}(rc *restfulx.ReqCtx) { var data entity.{{.ClassName}} - ginx.BindJsonAndValid(rc.GinCtx, &data) + restfulx.BindJsonAndValid(rc.GinCtx, &data) p.{{.ClassName}}App.Update(data) } @@ -100,7 +100,7 @@ func (p *{{.ClassName}}Api) Update{{.ClassName}}(rc *ginx.ReqCtx) { // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 400, "message": "删除失败"}" // @Router /{{.PackageName}}/{{.BusinessName}}/{{"{"}}{{.PkJsonField}}{{"}"}} [delete] -func (p *{{.ClassName}}Api) Delete{{.ClassName}}(rc *ginx.ReqCtx) { +func (p *{{.ClassName}}Api) Delete{{.ClassName}}(rc *restfulx.ReqCtx) { {{.PkJsonField}} := rc.GinCtx.Param("{{.PkJsonField}}") {{.PkJsonField}}s := utils.IdsStrToIdsIntGroup({{.PkJsonField}}) diff --git a/resource/template/go/router.template b/resource/template/go/router.template index d492f23..fdb9a90 100644 --- a/resource/template/go/router.template +++ b/resource/template/go/router.template @@ -9,7 +9,7 @@ import ( "github.com/gin-gonic/gin" "pandax/apps/{{.PackageName}}/api" "pandax/apps/{{.PackageName}}/services" - "pandax/base/ginx" + "github.com/XM-GO/PandaKit/restfulx" ) func Init{{.ClassName}}Router(router *gin.RouterGroup) { @@ -18,29 +18,29 @@ func Init{{.ClassName}}Router(router *gin.RouterGroup) { } routerGroup := router.Group("{{.BusinessName}}") - {{.ClassName}}ListLog := ginx.NewLogInfo("获取{{.FunctionName}}分页列表") + {{.ClassName}}ListLog := restfulx.NewLogInfo("获取{{.FunctionName}}分页列表") routerGroup.GET("list", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog({{.ClassName}}ListLog).Handle(s.Get{{.ClassName}}List) + restfulx.NewReqCtx(c).WithLog({{.ClassName}}ListLog).Handle(s.Get{{.ClassName}}List) }) - {{.ClassName}}Log := ginx.NewLogInfo("获取{{.FunctionName}}信息") + {{.ClassName}}Log := restfulx.NewLogInfo("获取{{.FunctionName}}信息") routerGroup.GET(":{{.PkJsonField}}", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog({{.ClassName}}Log).Handle(s.Get{{.ClassName}}) + restfulx.NewReqCtx(c).WithLog({{.ClassName}}Log).Handle(s.Get{{.ClassName}}) }) - insert{{.ClassName}}Log := ginx.NewLogInfo("添加{{.FunctionName}}信息") + insert{{.ClassName}}Log := restfulx.NewLogInfo("添加{{.FunctionName}}信息") routerGroup.POST("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog(insert{{.ClassName}}Log).Handle(s.Insert{{.ClassName}}) + restfulx.NewReqCtx(c).WithLog(insert{{.ClassName}}Log).Handle(s.Insert{{.ClassName}}) }) - update{{.ClassName}}Log := ginx.NewLogInfo("修改{{.FunctionName}}信息") + update{{.ClassName}}Log := restfulx.NewLogInfo("修改{{.FunctionName}}信息") routerGroup.PUT("", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog(update{{.ClassName}}Log).Handle(s.Update{{.ClassName}}) + restfulx.NewReqCtx(c).WithLog(update{{.ClassName}}Log).Handle(s.Update{{.ClassName}}) }) - delete{{.ClassName}}Log := ginx.NewLogInfo("删除{{.FunctionName}}信息") + delete{{.ClassName}}Log := restfulx.NewLogInfo("删除{{.FunctionName}}信息") routerGroup.DELETE(":{{.PkJsonField}}", func(c *gin.Context) { - ginx.NewReqCtx(c).WithLog(delete{{.ClassName}}Log).Handle(s.Delete{{.ClassName}}) + restfulx.NewReqCtx(c).WithLog(delete{{.ClassName}}Log).Handle(s.Delete{{.ClassName}}) }) } diff --git a/resource/template/go/service.template b/resource/template/go/service.template index 42d3b36..bd4789a 100644 --- a/resource/template/go/service.template +++ b/resource/template/go/service.template @@ -8,8 +8,8 @@ package services import ( "pandax/apps/{{.PackageName}}/entity" - "pandax/base/biz" - "pandax/base/global" + "github.com/XM-GO/PandaKit/biz" + "github.com/XM-GO/PandaKit/global" ) type (