diff --git a/app/admin/apis/sys_config.go b/app/admin/apis/sys_config.go index 8aa9d2ba..e4886bce 100644 --- a/app/admin/apis/sys_config.go +++ b/app/admin/apis/sys_config.go @@ -30,7 +30,7 @@ type SysConfig struct { // @Security Bearer func (e SysConfig) GetPage(c *gin.Context) { s := service.SysConfig{} - req := dto.SysConfigSearch{} + req := dto.SysConfigGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Form). @@ -60,7 +60,7 @@ func (e SysConfig) GetPage(c *gin.Context) { // @Router /api/v1/sys-config/{id} [get] // @Security Bearer func (e SysConfig) Get(c *gin.Context) { - req := dto.SysConfigById{} + req := dto.SysConfigGetReq{} s := service.SysConfig{} err := e.MakeContext(c). MakeOrm(). @@ -158,7 +158,7 @@ func (e SysConfig) Update(c *gin.Context) { // @Security Bearer func (e SysConfig) Delete(c *gin.Context) { s := service.SysConfig{} - req := dto.SysConfigById{} + req := dto.SysConfigDeleteReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). @@ -179,14 +179,14 @@ func (e SysConfig) Delete(c *gin.Context) { e.OK(req.GetId(), "删除成功") } -// GetSysConfigBySysApp 获取系统配置信息 +// Get2SysApp 获取系统配置信息 // @Summary 获取系统前台配置信息,主要注意这里不在验证权限 // @Description 获取系统配置信息,主要注意这里不在验证权限 // @Tags 配置管理 // @Success 200 {object} response.Response{data=map[string]string} "{"code": 200, "data": [...]}" // @Router /api/v1/app-config [get] -func (e SysConfig) GetSysConfigBySysApp(c *gin.Context) { - req := dto.SysConfigSearch{} +func (e SysConfig) Get2SysApp(c *gin.Context) { + req := dto.SysConfigGetToSysAppReq{} s := service.SysConfig{} err := e.MakeContext(c). MakeOrm(). diff --git a/app/admin/apis/sys_dept.go b/app/admin/apis/sys_dept.go index c3d15220..306e1292 100644 --- a/app/admin/apis/sys_dept.go +++ b/app/admin/apis/sys_dept.go @@ -29,7 +29,7 @@ type SysDept struct { // @Security Bearer func (e SysDept) GetPage(c *gin.Context) { s := service.SysDept{} - req := dto.SysDeptSearch{} + req := dto.SysDeptGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req). @@ -50,17 +50,16 @@ func (e SysDept) GetPage(c *gin.Context) { } // Get -// @Summary 部门列表数据 +// @Summary 获取部门数据 // @Description 获取JSON // @Tags 部门 // @Param deptId path string false "deptId" -// @Param position query string false "position" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/dept/{deptId} [get] // @Security Bearer func (e SysDept) Get(c *gin.Context) { s := service.SysDept{} - req := dto.SysDeptById{} + req := dto.SysDeptGetReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). @@ -95,7 +94,7 @@ func (e SysDept) Get(c *gin.Context) { // @Security Bearer func (e SysDept) Insert(c *gin.Context) { s := service.SysDept{} - req := dto.SysDeptControl{} + req := dto.SysDeptInsertReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON). @@ -131,7 +130,7 @@ func (e SysDept) Insert(c *gin.Context) { // @Security Bearer func (e SysDept) Update(c *gin.Context) { s := service.SysDept{} - req := dto.SysDeptControl{} + req := dto.SysDeptUpdateReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req). @@ -162,7 +161,7 @@ func (e SysDept) Update(c *gin.Context) { // @Security Bearer func (e SysDept) Delete(c *gin.Context) { s := service.SysDept{} - req := dto.SysDeptById{} + req := dto.SysDeptDeleteReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). @@ -185,7 +184,7 @@ func (e SysDept) Delete(c *gin.Context) { // Get2Tree 用户管理 左侧部门树 func (e SysDept) Get2Tree(c *gin.Context) { s := service.SysDept{} - req := dto.SysDeptSearch{} + req := dto.SysDeptGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req,binding.Form). diff --git a/app/admin/apis/sys_dict_data.go b/app/admin/apis/sys_dict_data.go index 3cf5486d..049fe997 100644 --- a/app/admin/apis/sys_dict_data.go +++ b/app/admin/apis/sys_dict_data.go @@ -30,7 +30,7 @@ type SysDictData struct { // @Security Bearer func (e SysDictData) GetPage(c *gin.Context) { s := service.SysDictData{} - req := dto.SysDictDataSearch{} + req := dto.SysDictDataGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Form). @@ -63,7 +63,7 @@ func (e SysDictData) GetPage(c *gin.Context) { // @Security Bearer func (e SysDictData) Get(c *gin.Context) { s := service.SysDictData{} - req := dto.SysDictDataById{} + req := dto.SysDictDataGetReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, nil). @@ -93,14 +93,13 @@ func (e SysDictData) Get(c *gin.Context) { // @Tags 字典数据 // @Accept application/json // @Product application/json -// @Param data body dto.SysDictDataControl true "data" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" +// @Param data body dto.SysDictDataInsertReq true "data" +// @Success 200 {object} response.Response "{"code": 200, "message": "添加成功"}" // @Router /api/v1/dict/data [post] // @Security Bearer func (e SysDictData) Insert(c *gin.Context) { s := service.SysDictData{} - req := dto.SysDictDataControl{} + req := dto.SysDictDataInsertReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON). @@ -127,14 +126,13 @@ func (e SysDictData) Insert(c *gin.Context) { // @Tags 字典数据 // @Accept application/json // @Product application/json -// @Param data body dto.SysDictDataControl true "body" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" +// @Param data body dto.SysDictDataUpdateReq true "body" +// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}" // @Router /api/v1/dict/data/{dictCode} [put] // @Security Bearer func (e SysDictData) Update(c *gin.Context) { s := service.SysDictData{} - req := dto.SysDictDataControl{} + req := dto.SysDictDataUpdateReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). @@ -158,14 +156,13 @@ func (e SysDictData) Update(c *gin.Context) { // @Summary 删除字典数据 // @Description 删除数据 // @Tags 字典数据 -// @Param dictCode body dto.SysDictDataById true "body" -// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" -// @Success 200 {string} string "{"code": -1, "message": "删除失败"}" +// @Param dictCode body dto.SysDictDataDeleteReq true "body" +// @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}" // @Router /api/v1/dict/data [delete] // @Security Bearer func (e SysDictData) Delete(c *gin.Context) { s := service.SysDictData{} - req := dto.SysDictDataById{} + req := dto.SysDictDataDeleteReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). @@ -185,21 +182,20 @@ func (e SysDictData) Delete(c *gin.Context) { e.OK(req.GetId(), "删除成功") } -// GetSysDictDataAll 数据字典根据key获取 业务页面使用 +// GetAll 数据字典根据key获取 业务页面使用 // @Summary 数据字典根据key获取 // @Description 数据字典根据key获取 // @Tags 字典数据 // @Param dictType query int true "dictType" -// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" -// @Success 200 {string} string "{"code": -1, "message": "删除失败"}" +// @Success 200 {object} response.Response{data=[]dto.SysDictDataGetAllResp} "{"code": 200, "data": [...]}" // @Router /api/v1/dict-data/option-select [get] // @Security Bearer -func (e SysDictData) GetSysDictDataAll(c *gin.Context) { +func (e SysDictData) GetAll(c *gin.Context) { s := service.SysDictData{} - req := dto.SysDictDataSearch{} + req := dto.SysDictDataGetPageReq{} err := e.MakeContext(c). MakeOrm(). - Bind(&req, binding.Form). + Bind(&req). MakeService(&s.Service). Errors if err != nil { @@ -213,5 +209,12 @@ func (e SysDictData) GetSysDictDataAll(c *gin.Context) { e.Error(500, err, "查询失败") return } - e.OK(list, "查询成功") -} \ No newline at end of file + l := make([]dto.SysDictDataGetAllResp, 0) + for _, i := range list { + d := dto.SysDictDataGetAllResp{} + e.Translate(i, &d) + l = append(l, d) + } + + e.OK(l,"查询成功") +} diff --git a/app/admin/apis/sys_dict_type.go b/app/admin/apis/sys_dict_type.go index 4dedc9de..b93035e0 100644 --- a/app/admin/apis/sys_dict_type.go +++ b/app/admin/apis/sys_dict_type.go @@ -31,7 +31,7 @@ type SysDictType struct { // @Security Bearer func (e SysDictType) GetPage(c *gin.Context) { s := service.SysDictType{} - req :=dto.SysDictTypeSearch{} + req :=dto.SysDictTypeGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Form). @@ -62,7 +62,7 @@ func (e SysDictType) GetPage(c *gin.Context) { // @Security Bearer func (e SysDictType) Get(c *gin.Context) { s := service.SysDictType{} - req :=dto.SysDictTypeById{} + req :=dto.SysDictTypeGetReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, nil). @@ -88,14 +88,13 @@ func (e SysDictType) Get(c *gin.Context) { // @Tags 字典类型 // @Accept application/json // @Product application/json -// @Param data body dto.SysDictTypeControl true "data" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" +// @Param data body dto.SysDictTypeInsertReq true "data" +// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/dict/type [post] // @Security Bearer func (e SysDictType) Insert(c *gin.Context) { s := service.SysDictType{} - req :=dto.SysDictTypeControl{} + req :=dto.SysDictTypeInsertReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON). @@ -122,14 +121,13 @@ func (e SysDictType) Insert(c *gin.Context) { // @Tags 字典类型 // @Accept application/json // @Product application/json -// @Param data body dto.SysDictTypeControl true "body" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" +// @Param data body dto.SysDictTypeUpdateReq true "body" +// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/dict/type/{dictId} [put] // @Security Bearer func (e SysDictType) Update(c *gin.Context) { s := service.SysDictType{} - req :=dto.SysDictTypeControl{} + req :=dto.SysDictTypeUpdateReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). @@ -153,14 +151,13 @@ func (e SysDictType) Update(c *gin.Context) { // @Summary 删除字典类型 // @Description 删除数据 // @Tags 字典类型 -// @Param dictId path int true "dictId" -// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" -// @Success 200 {string} string "{"code": -1, "message": "删除失败"}" +// @Param dictCode body dto.SysDictTypeDeleteReq true "body" +// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/dict/type [delete] // @Security Bearer func (e SysDictType) Delete(c *gin.Context) { s := service.SysDictType{} - req :=dto.SysDictTypeById{} + req :=dto.SysDictTypeDeleteReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). @@ -192,7 +189,7 @@ func (e SysDictType) Delete(c *gin.Context) { // @Security Bearer func (e SysDictType) GetAll(c *gin.Context) { s := service.SysDictType{} - req :=dto.SysDictTypeSearch{} + req :=dto.SysDictTypeGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Form). diff --git a/app/admin/apis/sys_login_log.go b/app/admin/apis/sys_login_log.go index 15508220..6b6b4af8 100644 --- a/app/admin/apis/sys_login_log.go +++ b/app/admin/apis/sys_login_log.go @@ -29,7 +29,7 @@ type SysLoginLog struct { // @Security Bearer func (e SysLoginLog) GetPage(c *gin.Context) { s := service.SysLoginLog{} - req :=dto.SysLoginLogSearch {} + req :=dto.SysLoginLogGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Form). @@ -84,7 +84,7 @@ func (e SysLoginLog) Get(c *gin.Context) { // @Summary 登录日志删除 // @Description 登录日志删除 // @Tags 登录日志 -// @Param data body dto.SysLoginLogById true "body" +// @Param data body dto.SysLoginLogDeleteReq true "body" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/sys-login-log [delete] // @Security Bearer diff --git a/app/admin/apis/sys_menu.go b/app/admin/apis/sys_menu.go index 1ff50b42..d6eab24d 100644 --- a/app/admin/apis/sys_menu.go +++ b/app/admin/apis/sys_menu.go @@ -20,13 +20,12 @@ type SysMenu struct { // @Description 获取JSON // @Tags 菜单 // @Param menuName query string false "menuName" -// @Param menuName query string false "menuName" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/menu [get] // @Security Bearer func (e SysMenu) GetPage(c *gin.Context) { s := service.SysMenu{} - req := dto.SysMenuSearch{} + req := dto.SysMenuGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Form). @@ -55,7 +54,7 @@ func (e SysMenu) GetPage(c *gin.Context) { // @Router /api/v1/menu/{id} [get] // @Security Bearer func (e SysMenu) Get(c *gin.Context) { - req := dto.SysMenuById{} + req := dto.SysMenuGetReq{} s := new(service.SysMenu) err := e.MakeContext(c). MakeOrm(). @@ -83,12 +82,12 @@ func (e SysMenu) Get(c *gin.Context) { // @Tags 菜单 // @Accept application/json // @Product application/json -// @Param data body dto.SysMenuControl true "data" +// @Param data body dto.SysMenuInsertReq true "data" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/menu [post] // @Security Bearer func (e SysMenu) Insert(c *gin.Context) { - req := dto.SysMenuControl{} + req := dto.SysMenuInsertReq{} s := new(service.SysMenu) err := e.MakeContext(c). MakeOrm(). @@ -117,12 +116,12 @@ func (e SysMenu) Insert(c *gin.Context) { // @Accept application/json // @Product application/json // @Param id path int true "id" -// @Param data body dto.SysMenuControl true "body" +// @Param data body dto.SysMenuUpdateReq true "body" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/menu/{id} [put] // @Security Bearer func (e SysMenu) Update(c *gin.Context) { - req := dto.SysMenuControl{} + req := dto.SysMenuUpdateReq{} s := new(service.SysMenu) err := e.MakeContext(c). MakeOrm(). @@ -148,12 +147,12 @@ func (e SysMenu) Update(c *gin.Context) { // @Summary 删除菜单 // @Description 删除数据 // @Tags 菜单 -// @Param data body dto.SysMenuById true "body" +// @Param data body dto.SysMenuDeleteReq true "body" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Router /api/v1/menu [delete] // @Security Bearer func (e SysMenu) Delete(c *gin.Context) { - control := new(dto.SysMenuById) + control := new(dto.SysMenuDeleteReq) s := new(service.SysMenu) err := e.MakeContext(c). MakeOrm(). diff --git a/app/admin/apis/sys_role.go b/app/admin/apis/sys_role.go index 04aa5ece..5c9f8af8 100644 --- a/app/admin/apis/sys_role.go +++ b/app/admin/apis/sys_role.go @@ -35,7 +35,7 @@ type SysRole struct { // @Security Bearer func (e SysRole) GetPage(c *gin.Context) { s := service.SysRole{} - req := dto.SysRoleSearch{} + req := dto.SysRoleGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Form). @@ -69,7 +69,7 @@ func (e SysRole) GetPage(c *gin.Context) { // @Security Bearer func (e SysRole) Get(c *gin.Context) { s := service.SysRole{} - req := dto.SysRoleById{} + req := dto.SysRoleGetReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, nil). @@ -104,7 +104,7 @@ func (e SysRole) Get(c *gin.Context) { // @Security Bearer func (e SysRole) Insert(c *gin.Context) { s := service.SysRole{} - req := dto.SysRoleControl{} + req := dto.SysRoleInsertReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON). @@ -148,7 +148,7 @@ func (e SysRole) Insert(c *gin.Context) { // @Security Bearer func (e SysRole) Update(c *gin.Context) { s := service.SysRole{} - req := dto.SysRoleControl{} + req := dto.SysRoleUpdateReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, nil, binding.JSON). @@ -186,7 +186,7 @@ func (e SysRole) Update(c *gin.Context) { // @Security Bearer func (e SysRole) Delete(c *gin.Context) { s := new(service.SysRole) - req := dto.SysRoleById{} + req := dto.SysRoleDeleteReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON). @@ -206,7 +206,7 @@ func (e SysRole) Delete(c *gin.Context) { } _, err = global.LoadPolicy(c) if err != nil { - e.Error(500, err, fmt.Sprintf("删除角色 %v 失败,失败信息 %s", req.Id, err.Error())) + e.Error(500, err, fmt.Sprintf("删除角色 %v 失败,失败信息 %s", req.GetId(), err.Error())) return } e.OK(req.GetId(), fmt.Sprintf("删除角色角色 %v 状态成功!", req.GetId())) diff --git a/app/admin/apis/sys_user.go b/app/admin/apis/sys_user.go index efc44140..a8636ee4 100644 --- a/app/admin/apis/sys_user.go +++ b/app/admin/apis/sys_user.go @@ -448,5 +448,6 @@ func (e SysUser) GetInfo(c *gin.Context) { mp["userId"] = sysUser.UserId mp["deptId"] = sysUser.DeptId mp["name"] = sysUser.NickName + mp["code"] = 200 e.OK(mp, "") } \ No newline at end of file diff --git a/app/admin/router/sys_config.go b/app/admin/router/sys_config.go index 532e7c43..2dabd088 100644 --- a/app/admin/router/sys_config.go +++ b/app/admin/router/sys_config.go @@ -31,7 +31,7 @@ func registerSysConfigRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMidd r2 := v1.Group("/app-config") { - r2.GET("", api.GetSysConfigBySysApp) + r2.GET("", api.Get2SysApp) } r3 := v1.Group("/set-config").Use(authMiddleware.MiddlewareFunc()) diff --git a/app/admin/router/sys_dict.go b/app/admin/router/sys_dict.go index 729ab64f..ae9e0c4f 100644 --- a/app/admin/router/sys_dict.go +++ b/app/admin/router/sys_dict.go @@ -32,6 +32,6 @@ func registerDictRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlewar } opSelect := v1.Group("/dict-data").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) { - opSelect.GET("/option-select", dataApi.GetSysDictDataAll) + opSelect.GET("/option-select", dataApi.GetAll) } } diff --git a/app/admin/service/dto/sys_config.go b/app/admin/service/dto/sys_config.go index e0356bdb..cbc03656 100644 --- a/app/admin/service/dto/sys_config.go +++ b/app/admin/service/dto/sys_config.go @@ -6,8 +6,8 @@ import ( common "go-admin/common/models" ) -// SysConfigSearch 列表或者搜索使用结构体 -type SysConfigSearch struct { +// SysConfigGetPageReq 列表或者搜索使用结构体 +type SysConfigGetPageReq struct { dto.Pagination `search:"-"` ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config"` ConfigKey string `form:"configKey" search:"type:contains;column:config_key;table:sys_config"` @@ -24,7 +24,15 @@ type SysConfigOrder struct { CreatedAtOrder string `search:"type:order;column:created_at;table:sys_config" form:"createdAtOrder"` } -func (m *SysConfigSearch) GetNeedSearch() interface{} { +func (m *SysConfigGetPageReq) GetNeedSearch() interface{} { + return *m +} + +type SysConfigGetToSysAppReq struct { + IsFrontend int `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"` +} + +func (m *SysConfigGetToSysAppReq) GetNeedSearch() interface{} { return *m } @@ -86,22 +94,19 @@ type GetSysConfigByKEYForServiceResp struct { ConfigValue string `json:"configValue" comment:""` } -// SysConfigById 获取单个或者删除的结构体 -type SysConfigById struct { - Id int `uri:"id"` +type SysConfigGetReq struct { + Id int `uri:"id"` +} + +func (s *SysConfigGetReq) GetId() interface{} { + return s.Id +} + +type SysConfigDeleteReq struct { Ids []int `json:"ids"` common.ControlBy } -func (s *SysConfigById) Generate() *SysConfigById { - cp := *s - return &cp -} - -func (s *SysConfigById) GetId() interface{} { - if len(s.Ids) > 0 { - s.Ids = append(s.Ids, s.Id) - return s.Ids - } - return s.Id +func (s *SysConfigDeleteReq) GetId() interface{} { + return s.Ids } diff --git a/app/admin/service/dto/sys_dept.go b/app/admin/service/dto/sys_dept.go index b0427ea8..345a5501 100644 --- a/app/admin/service/dto/sys_dept.go +++ b/app/admin/service/dto/sys_dept.go @@ -3,13 +3,10 @@ package dto import ( "go-admin/app/admin/models" common "go-admin/common/models" - - "go-admin/common/dto" ) -// SysDeptSearch 列表或者搜索使用结构体 -type SysDeptSearch struct { - dto.Pagination `search:"-"` +// SysDeptGetPageReq 列表或者搜索使用结构体 +type SysDeptGetPageReq struct { DeptId int `form:"deptId" search:"type:exact;column:dept_id;table:sys_dept" comment:"id"` //id ParentId int `form:"parentId" search:"type:exact;column:parent_id;table:sys_dept" comment:"上级部门"` //上级部门 DeptPath string `form:"deptPath" search:"type:exact;column:dept_path;table:sys_dept" comment:""` //路径 @@ -21,26 +18,24 @@ type SysDeptSearch struct { Status string `form:"status" search:"type:exact;column:status;table:sys_dept" comment:"状态"` //状态 } -func (m *SysDeptSearch) GetNeedSearch() interface{} { +func (m *SysDeptGetPageReq) GetNeedSearch() interface{} { return *m } -// SysDeptControl 增、改使用的结构体 -type SysDeptControl struct { - DeptId int `uri:"id" comment:"编码"` // 编码 - ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门 - DeptPath string `json:"deptPath" comment:""` //路径 - DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称 - Sort int `json:"sort" comment:"排序" vd:"?"` //排序 - Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人 - Phone string `json:"phone" comment:"手机" vd:"?"` //手机 - Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱 - Status int `json:"status" comment:"状态" vd:"$>0"` //状态 +type SysDeptInsertReq struct { + DeptId int `uri:"id" comment:"编码"` // 编码 + ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门 + DeptPath string `json:"deptPath" comment:""` //路径 + DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称 + Sort int `json:"sort" comment:"排序" vd:"?"` //排序 + Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人 + Phone string `json:"phone" comment:"手机" vd:"?"` //手机 + Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱 + Status int `json:"status" comment:"状态" vd:"$>0"` //状态 common.ControlBy } -// Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型 -func (s *SysDeptControl) Generate(model *models.SysDept) { +func (s *SysDeptInsertReq) Generate(model *models.SysDept) { if s.DeptId != 0 { model.DeptId = s.DeptId } @@ -55,31 +50,57 @@ func (s *SysDeptControl) Generate(model *models.SysDept) { } // GetId 获取数据对应的ID -func (s *SysDeptControl) GetId() interface{} { +func (s *SysDeptInsertReq) GetId() interface{} { return s.DeptId } -// SysDeptById 获取单个或者删除的结构体 -type SysDeptById struct { - Id int `uri:"id"` - Ids []int `json:"ids"` +type SysDeptUpdateReq struct { + DeptId int `uri:"id" comment:"编码"` // 编码 + ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门 + DeptPath string `json:"deptPath" comment:""` //路径 + DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称 + Sort int `json:"sort" comment:"排序" vd:"?"` //排序 + Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人 + Phone string `json:"phone" comment:"手机" vd:"?"` //手机 + Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱 + Status int `json:"status" comment:"状态" vd:"$>0"` //状态 + common.ControlBy } -func (s *SysDeptById) Generate() *SysDeptById { - cp := *s - return &cp -} - -func (s *SysDeptById) GetId() interface{} { - if len(s.Ids) > 0 { - s.Ids = append(s.Ids, s.Id) - return s.Ids +// Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型 +func (s *SysDeptUpdateReq) Generate(model *models.SysDept) { + if s.DeptId != 0 { + model.DeptId = s.DeptId } + model.DeptName = s.DeptName + model.ParentId = s.ParentId + model.DeptPath = s.DeptPath + model.Sort = s.Sort + model.Leader = s.Leader + model.Phone = s.Phone + model.Email = s.Email + model.Status = s.Status +} + +// GetId 获取数据对应的ID +func (s *SysDeptUpdateReq) GetId() interface{} { + return s.DeptId +} + +type SysDeptGetReq struct { + Id int `uri:"id"` +} + +func (s *SysDeptGetReq) GetId() interface{} { return s.Id } -func (s *SysDeptById) GenerateM() (*models.SysDept, error) { - return &models.SysDept{}, nil +type SysDeptDeleteReq struct { + Ids []int `json:"ids"` +} + +func (s *SysDeptDeleteReq) GetId() interface{} { + return s.Ids } type DeptLabel struct { diff --git a/app/admin/service/dto/sys_dict_data.go b/app/admin/service/dto/sys_dict_data.go index 4a953f56..842f4183 100644 --- a/app/admin/service/dto/sys_dict_data.go +++ b/app/admin/service/dto/sys_dict_data.go @@ -6,7 +6,7 @@ import ( common "go-admin/common/models" ) -type SysDictDataSearch struct { +type SysDictDataGetPageReq struct { dto.Pagination `search:"-"` Id int `form:"id" search:"type:exact;column:dict_code;table:sys_dict_data" comment:""` DictLabel string `form:"dictLabel" search:"type:contains;column:dict_label;table:sys_dict_data" comment:""` @@ -15,12 +15,17 @@ type SysDictDataSearch struct { Status string `form:"status" search:"type:exact;column:status;table:sys_dict_data" comment:""` } -func (m *SysDictDataSearch) GetNeedSearch() interface{} { +func (m *SysDictDataGetPageReq) GetNeedSearch() interface{} { return *m } -type SysDictDataControl struct { - Id int `uri:"dictCode" comment:""` +type SysDictDataGetAllResp struct { + DictLabel string `json:"label"` + DictValue string `json:"value"` +} + +type SysDictDataInsertReq struct { + Id int `json:"-" comment:""` DictSort int `json:"dictSort" comment:""` DictLabel string `json:"dictLabel" comment:""` DictValue string `json:"dictValue" comment:""` @@ -28,14 +33,13 @@ type SysDictDataControl struct { CssClass string `json:"cssClass" comment:""` ListClass string `json:"listClass" comment:""` IsDefault string `json:"isDefault" comment:""` - Status int `json:"status" comment:""` + Status int `json:"status" comment:""` Default string `json:"default" comment:""` Remark string `json:"remark" comment:""` common.ControlBy } -func (s *SysDictDataControl) Generate(model *models.SysDictData) { - +func (s *SysDictDataInsertReq) Generate(model *models.SysDictData) { model.DictCode = s.Id model.DictSort = s.DictSort model.DictLabel = s.DictLabel @@ -49,24 +53,56 @@ func (s *SysDictDataControl) Generate(model *models.SysDictData) { model.Remark = s.Remark } -func (s *SysDictDataControl) GetId() interface{} { +func (s *SysDictDataInsertReq) GetId() interface{} { return s.Id } -type SysDictDataById struct { - Id int `uri:"dictCode"` - Ids []int `json:"ids"` +type SysDictDataUpdateReq struct { + Id int `uri:"dictCode" comment:""` + DictSort int `json:"dictSort" comment:""` + DictLabel string `json:"dictLabel" comment:""` + DictValue string `json:"dictValue" comment:""` + DictType string `json:"dictType" comment:""` + CssClass string `json:"cssClass" comment:""` + ListClass string `json:"listClass" comment:""` + IsDefault string `json:"isDefault" comment:""` + Status int `json:"status" comment:""` + Default string `json:"default" comment:""` + Remark string `json:"remark" comment:""` + common.ControlBy +} + +func (s *SysDictDataUpdateReq) Generate(model *models.SysDictData) { + model.DictCode = s.Id + model.DictSort = s.DictSort + model.DictLabel = s.DictLabel + model.DictValue = s.DictValue + model.DictType = s.DictType + model.CssClass = s.CssClass + model.ListClass = s.ListClass + model.IsDefault = s.IsDefault + model.Status = s.Status + model.Default = s.Default + model.Remark = s.Remark +} + +func (s *SysDictDataUpdateReq) GetId() interface{} { + return s.Id +} + +type SysDictDataGetReq struct { + Id int `uri:"dictCode"` +} + +func (s *SysDictDataGetReq) GetId() interface{} { + return s.Id +} + +type SysDictDataDeleteReq struct { + Ids []int `json:"ids"` common.ControlBy `json:"-"` } -func (s *SysDictDataById) GetId() interface{} { - if len(s.Ids) > 0 { - s.Ids = append(s.Ids, s.Id) - return s.Ids - } - return s.Id -} - -func (s *SysDictDataById) GenerateM() (common.ActiveRecord, error) { - return &models.SysDictData{}, nil +func (s *SysDictDataDeleteReq) GetId() interface{} { + return s.Ids } diff --git a/app/admin/service/dto/sys_dict_type.go b/app/admin/service/dto/sys_dict_type.go index 76df729c..db664323 100644 --- a/app/admin/service/dto/sys_dict_type.go +++ b/app/admin/service/dto/sys_dict_type.go @@ -7,7 +7,7 @@ import ( common "go-admin/common/models" ) -type SysDictTypeSearch struct { +type SysDictTypeGetPageReq struct { dto.Pagination `search:"-"` DictId []int `form:"dictId" search:"type:in;column:dict_id;table:sys_dict_type"` DictName string `form:"dictName" search:"type:icontains;column:dict_name;table:sys_dict_type"` @@ -19,11 +19,11 @@ type SysDictTypeOrder struct { DictIdOrder string `search:"type:order;column:dict_id;table:sys_dict_type" form:"dictIdOrder"` } -func (m *SysDictTypeSearch) GetNeedSearch() interface{} { +func (m *SysDictTypeGetPageReq) GetNeedSearch() interface{} { return *m } -type SysDictTypeControl struct { +type SysDictTypeInsertReq struct { Id int `uri:"id"` DictName string `json:"dictName"` DictType string `json:"dictType"` @@ -32,7 +32,7 @@ type SysDictTypeControl struct { common.ControlBy } -func (s *SysDictTypeControl) Generate(model *models.SysDictType) { +func (s *SysDictTypeInsertReq) Generate(model *models.SysDictType) { if s.Id != 0 { model.ID = s.Id } @@ -43,28 +43,47 @@ func (s *SysDictTypeControl) Generate(model *models.SysDictType) { } -func (s *SysDictTypeControl) GetId() interface{} { +func (s *SysDictTypeInsertReq) GetId() interface{} { return s.Id } -type SysDictTypeById struct { - dto.ObjectById +type SysDictTypeUpdateReq struct { + Id int `uri:"id"` + DictName string `json:"dictName"` + DictType string `json:"dictType"` + Status int `json:"status"` + Remark string `json:"remark"` common.ControlBy } -func (s *SysDictTypeById) Generate() dto.Control { - cp := *s - return &cp +func (s *SysDictTypeUpdateReq) Generate(model *models.SysDictType) { + if s.Id != 0 { + model.ID = s.Id + } + model.DictName = s.DictName + model.DictType = s.DictType + model.Status = s.Status + model.Remark = s.Remark + } -func (s *SysDictTypeById) GetId() interface{} { - if len(s.Ids) > 0 { - s.Ids = append(s.Ids, s.Id) - return s.Ids - } +func (s *SysDictTypeUpdateReq) GetId() interface{} { return s.Id } -func (s *SysDictTypeById) GenerateM() (common.ActiveRecord, error) { - return &models.SysDictType{}, nil +type SysDictTypeGetReq struct { + Id int `uri:"id"` +} + +func (s *SysDictTypeGetReq) GetId() interface{} { + return s.Id +} + +type SysDictTypeDeleteReq struct { + Ids []int `json:"ids"` + common.ControlBy +} + +func (s *SysDictTypeDeleteReq) GetId() interface{} { + return s.Ids } diff --git a/app/admin/service/dto/sys_login_log.go b/app/admin/service/dto/sys_login_log.go index 79c98a7b..42a6e45c 100644 --- a/app/admin/service/dto/sys_login_log.go +++ b/app/admin/service/dto/sys_login_log.go @@ -1,14 +1,12 @@ package dto import ( - "go-admin/app/admin/models" "time" "go-admin/common/dto" - common "go-admin/common/models" ) -type SysLoginLogSearch struct { +type SysLoginLogGetPageReq struct { dto.Pagination `search:"-"` Username string `form:"username" search:"type:exact;column:username;table:sys_login_log" comment:"用户名"` Status string `form:"status" search:"type:exact;column:status;table:sys_login_log" comment:"状态"` @@ -23,7 +21,7 @@ type SysLoginLogOrder struct { CreatedAtOrder string `search:"type:order;column:created_at;table:sys_login_log" form:"createdAtOrder"` } -func (m *SysLoginLogSearch) GetNeedSearch() interface{} { +func (m *SysLoginLogGetPageReq) GetNeedSearch() interface{} { return *m } @@ -41,26 +39,6 @@ type SysLoginLogControl struct { Msg string `json:"msg" comment:"信息"` } -func (s *SysLoginLogControl) Generate() (*models.SysLoginLog, error) { - return &models.SysLoginLog{ - Model: common.Model{Id: s.ID}, - Username: s.Username, - Status: s.Status, - Ipaddr: s.Ipaddr, - LoginLocation: s.LoginLocation, - Browser: s.Browser, - Os: s.Os, - Platform: s.Platform, - LoginTime: s.LoginTime, - Remark: s.Remark, - Msg: s.Msg, - }, nil -} - -func (s *SysLoginLogControl) GetId() interface{} { - return s.ID -} - type SysLoginLogGetReq struct { Id int `uri:"id"` } diff --git a/app/admin/service/dto/sys_menu.go b/app/admin/service/dto/sys_menu.go index 7447d747..67f46746 100644 --- a/app/admin/service/dto/sys_menu.go +++ b/app/admin/service/dto/sys_menu.go @@ -7,19 +7,18 @@ import ( "go-admin/common/dto" ) -// SysMenuSearch 列表或者搜索使用结构体 -type SysMenuSearch struct { +// SysMenuGetPageReq 列表或者搜索使用结构体 +type SysMenuGetPageReq struct { dto.Pagination `search:"-"` Title string `form:"title" search:"type:contains;column:title;table:sys_menu" comment:"菜单名称"` // 菜单名称 Visible int `form:"visible" search:"type:exact;column:visible;table:sys_menu" comment:"显示状态"` // 显示状态 } -func (m *SysMenuSearch) GetNeedSearch() interface{} { +func (m *SysMenuGetPageReq) GetNeedSearch() interface{} { return *m } -// SysMenuControl 增、改使用的结构体 -type SysMenuControl struct { +type SysMenuInsertReq struct { MenuId int `uri:"id" comment:"编码"` // 编码 MenuName string `form:"menuName" comment:"菜单name"` //菜单name Title string `form:"title" comment:"显示名称"` //显示名称 @@ -41,16 +40,7 @@ type SysMenuControl struct { common.ControlBy } -func (s *SysMenuControl) SetCreateBy(id int) { - s.CreateBy = id -} - -func (s *SysMenuControl) SetUpdateBy(id int) { - s.UpdateBy = id -} - -// Generate 结构体数据转化 从 Control 至 model 对应的模型 -func (s *SysMenuControl) Generate(model *models.SysMenu) { +func (s *SysMenuInsertReq) Generate(model *models.SysMenu) { if s.MenuId != 0 { model.MenuId = s.MenuId } @@ -78,33 +68,79 @@ func (s *SysMenuControl) Generate(model *models.SysMenu) { } } -// GetId 获取数据对应的ID -func (s *SysMenuControl) GetId() interface{} { +func (s *SysMenuInsertReq) GetId() interface{} { return s.MenuId } -// SysMenuById 获取单个或者删除的结构体 -type SysMenuById struct { - Id int `uri:"id"` +type SysMenuUpdateReq struct { + MenuId int `uri:"id" comment:"编码"` // 编码 + MenuName string `form:"menuName" comment:"菜单name"` //菜单name + Title string `form:"title" comment:"显示名称"` //显示名称 + Icon string `form:"icon" comment:"图标"` //图标 + Path string `form:"path" comment:"路径"` //路径 + Paths string `form:"paths" comment:"id路径"` //id路径 + MenuType string `form:"menuType" comment:"菜单类型"` //菜单类型 + SysApi []models.SysApi `form:"sysApi"` + Apis []int `form:"apis"` + Action string `form:"action" comment:"请求方式"` //请求方式 + Permission string `form:"permission" comment:"权限编码"` //权限编码 + ParentId int `form:"parentId" comment:"上级菜单"` //上级菜单 + NoCache bool `form:"noCache" comment:"是否缓存"` //是否缓存 + Breadcrumb string `form:"breadcrumb" comment:"是否面包屑"` //是否面包屑 + Component string `form:"component" comment:"组件"` //组件 + Sort int `form:"sort" comment:"排序"` //排序 + Visible string `form:"visible" comment:"是否显示"` //是否显示 + IsFrame string `form:"isFrame" comment:"是否frame"` //是否frame + common.ControlBy +} + +func (s *SysMenuUpdateReq) Generate(model *models.SysMenu) { + if s.MenuId != 0 { + model.MenuId = s.MenuId + } + model.MenuName = s.MenuName + model.Title = s.Title + model.Icon = s.Icon + model.Path = s.Path + model.Paths = s.Paths + model.MenuType = s.MenuType + model.Action = s.Action + model.SysApi = s.SysApi + model.Permission = s.Permission + model.ParentId = s.ParentId + model.NoCache = s.NoCache + model.Breadcrumb = s.Breadcrumb + model.Component = s.Component + model.Sort = s.Sort + model.Visible = s.Visible + model.IsFrame = s.IsFrame + if s.CreateBy != 0 { + model.CreateBy = s.CreateBy + } + if s.UpdateBy != 0 { + model.UpdateBy = s.UpdateBy + } +} + +func (s *SysMenuUpdateReq) GetId() interface{} { + return s.MenuId +} + +type SysMenuGetReq struct { + Id int `uri:"id"` +} + +func (s *SysMenuGetReq) GetId() interface{} { + return s.Id +} + +type SysMenuDeleteReq struct { Ids []int `json:"ids"` common.ControlBy } -func (s *SysMenuById) Generate() *SysMenuById { - cp := *s - return &cp -} - -func (s *SysMenuById) GetId() interface{} { - if len(s.Ids) > 0 { - s.Ids = append(s.Ids, s.Id) - return s.Ids - } - return s.Id -} - -func (s *SysMenuById) GenerateM() (*models.SysMenu, error) { - return &models.SysMenu{}, nil +func (s *SysMenuDeleteReq) GetId() interface{} { + return s.Ids } type MenuLabel struct { @@ -120,4 +156,4 @@ type MenuRole struct { type SelectRole struct { RoleId int `uri:"roleId"` -} \ No newline at end of file +} diff --git a/app/admin/service/dto/sys_role.go b/app/admin/service/dto/sys_role.go index 640128d2..0fb31f5d 100644 --- a/app/admin/service/dto/sys_role.go +++ b/app/admin/service/dto/sys_role.go @@ -7,8 +7,7 @@ import ( "go-admin/common/dto" ) -// SysRoleSearch 列表或者搜索使用结构体 -type SysRoleSearch struct { +type SysRoleGetPageReq struct { dto.Pagination `search:"-"` RoleId int `form:"roleId" search:"type:exact;column:role_id;table:sys_role" comment:"角色编码"` // 角色编码 @@ -30,11 +29,11 @@ type SysRoleOrder struct { CreatedAtOrder string `search:"type:order;column:created_at;table:sys_role" form:"createdAtOrder"` } -func (m *SysRoleSearch) GetNeedSearch() interface{} { +func (m *SysRoleGetPageReq) GetNeedSearch() interface{} { return *m } -type SysRoleControl struct { +type SysRoleInsertReq struct { RoleId int `uri:"id" comment:"角色编码"` // 角色编码 RoleName string `form:"roleName" comment:"角色名称"` // 角色名称 Status string `form:"status" comment:"状态"` // 状态 @@ -51,16 +50,7 @@ type SysRoleControl struct { common.ControlBy } -func (s *SysRoleControl) SetCreateBy(id int) { - s.CreateBy = id -} - -func (s *SysRoleControl) SetUpdateBy(id int) { - s.UpdateBy = id -} - -// Generate 结构体数据转化 -func (s *SysRoleControl) Generate(model *models.SysRole) { +func (s *SysRoleInsertReq) Generate(model *models.SysRole) { if s.RoleId != 0 { model.RoleId = s.RoleId } @@ -74,11 +64,46 @@ func (s *SysRoleControl) Generate(model *models.SysRole) { model.DataScope = s.DataScope model.SysMenu = &s.SysMenu model.SysDept = s.SysDept - } -// GetId 获取数据对应的ID -func (s *SysRoleControl) GetId() interface{} { +func (s *SysRoleInsertReq) GetId() interface{} { + return s.RoleId +} + +type SysRoleUpdateReq struct { + RoleId int `uri:"id" comment:"角色编码"` // 角色编码 + RoleName string `form:"roleName" comment:"角色名称"` // 角色名称 + Status string `form:"status" comment:"状态"` // 状态 + RoleKey string `form:"roleKey" comment:"角色代码"` // 角色代码 + RoleSort int `form:"roleSort" comment:"角色排序"` // 角色排序 + Flag string `form:"flag" comment:"标记"` // 标记 + Remark string `form:"remark" comment:"备注"` // 备注 + Admin bool `form:"admin" comment:"是否管理员"` + DataScope string `form:"dataScope"` + SysMenu []models.SysMenu `form:"sysMenu"` + MenuIds []int `form:"menuIds"` + SysDept []models.SysDept `form:"sysDept"` + DeptIds []int `form:"deptIds"` + common.ControlBy +} + +func (s *SysRoleUpdateReq) Generate(model *models.SysRole) { + if s.RoleId != 0 { + model.RoleId = s.RoleId + } + model.RoleName = s.RoleName + model.Status = s.Status + model.RoleKey = s.RoleKey + model.RoleSort = s.RoleSort + model.Flag = s.Flag + model.Remark = s.Remark + model.Admin = s.Admin + model.DataScope = s.DataScope + model.SysMenu = &s.SysMenu + model.SysDept = s.SysDept +} + +func (s *SysRoleUpdateReq) GetId() interface{} { return s.RoleId } @@ -103,26 +128,20 @@ type SysRoleByName struct { RoleName string `form:"role"` // 角色编码 } -// SysRoleById 获取单个或者删除的结构体 -type SysRoleById struct { - dto.ObjectById +type SysRoleGetReq struct { + Id int `uri:"id"` } -func (s *SysRoleById) Generate() *SysRoleById { - cp := *s - return &cp -} - -func (s *SysRoleById) GetId() interface{} { - if len(s.Ids) > 0 { - s.Ids = append(s.Ids, s.Id) - return s.Ids - } +func (s *SysRoleGetReq) GetId() interface{} { return s.Id } -func (s *SysRoleById) GenerateM() (*models.SysRole, error) { - return &models.SysRole{}, nil +type SysRoleDeleteReq struct { + Ids []int `json:"ids"` +} + +func (s *SysRoleDeleteReq) GetId() interface{} { + return s.Ids } // RoleDataScopeReq 角色数据权限修改 @@ -142,4 +161,4 @@ func (s *RoleDataScopeReq) Generate(model *models.SysRole) { type DeptIdList struct { DeptId int `json:"DeptId"` -} \ No newline at end of file +} diff --git a/app/admin/service/sys_config.go b/app/admin/service/sys_config.go index 7d9c5e9f..a7a99f62 100644 --- a/app/admin/service/sys_config.go +++ b/app/admin/service/sys_config.go @@ -16,7 +16,7 @@ type SysConfig struct { } // GetPage 获取SysConfig列表 -func (e *SysConfig) GetPage(c *dto.SysConfigSearch, list *[]models.SysConfig, count *int64) error { +func (e *SysConfig) GetPage(c *dto.SysConfigGetPageReq, list *[]models.SysConfig, count *int64) error { err := e.Orm. Scopes( cDto.MakeCondition(c.GetNeedSearch()), @@ -32,7 +32,7 @@ func (e *SysConfig) GetPage(c *dto.SysConfigSearch, list *[]models.SysConfig, co } // Get 获取SysConfig对象 -func (e *SysConfig) Get(d *dto.SysConfigById, model *models.SysConfig) error { +func (e *SysConfig) Get(d *dto.SysConfigGetReq, model *models.SysConfig) error { err := e.Orm.First(model, d.GetId()).Error if err != nil && errors.Is(err, gorm.ErrRecordNotFound) { err = errors.New("查看对象不存在或无权查看") @@ -137,7 +137,7 @@ func (e *SysConfig) UpdateForSet(c *[]dto.GetSetSysConfigReq) error { } // Remove 删除SysConfig -func (e *SysConfig) Remove(d *dto.SysConfigById) error { +func (e *SysConfig) Remove(d *dto.SysConfigDeleteReq) error { var err error var data models.SysConfig @@ -167,7 +167,7 @@ func (e *SysConfig) GetWithKey(c *dto.SysConfigByKeyReq, resp *dto.GetSysConfigB return nil } -func (e *SysConfig) GetWithKeyList(c *dto.SysConfigSearch, list *[]models.SysConfig) error { +func (e *SysConfig) GetWithKeyList(c *dto.SysConfigGetToSysAppReq, list *[]models.SysConfig) error { var err error err = e.Orm. Scopes( diff --git a/app/admin/service/sys_dept.go b/app/admin/service/sys_dept.go index d5d13e59..80fe0a77 100644 --- a/app/admin/service/sys_dept.go +++ b/app/admin/service/sys_dept.go @@ -20,24 +20,24 @@ type SysDept struct { } // GetPage 获取SysDept列表 -func (e *SysDept) GetPage(c *dto.SysDeptSearch, list *[]models.SysDept) error { - var err error - var data models.SysDept - - err = e.Orm.Model(&data). - Scopes( - cDto.MakeCondition(c.GetNeedSearch()), - ). - Find(list).Error - if err != nil { - e.Log.Errorf("db error:%s", err) - return err - } - return nil -} +//func (e *SysDept) GetPage(c *dto.SysDeptGetPageReq, list *[]models.SysDept) error { +// var err error +// var data models.SysDept +// +// err = e.Orm.Model(&data). +// Scopes( +// cDto.MakeCondition(c.GetNeedSearch()), +// ). +// Find(list).Error +// if err != nil { +// e.Log.Errorf("db error:%s", err) +// return err +// } +// return nil +//} // Get 获取SysDept对象 -func (e *SysDept) Get(d *dto.SysDeptById, model *models.SysDept) error { +func (e *SysDept) Get(d *dto.SysDeptGetReq, model *models.SysDept) error { var err error var data models.SysDept @@ -57,7 +57,7 @@ func (e *SysDept) Get(d *dto.SysDeptById, model *models.SysDept) error { } // Insert 创建SysDept对象 -func (e *SysDept) Insert(c *dto.SysDeptControl) error { +func (e *SysDept) Insert(c *dto.SysDeptInsertReq) error { var err error var data models.SysDept c.Generate(&data) @@ -92,7 +92,7 @@ func (e *SysDept) Insert(c *dto.SysDeptControl) error { } // Update 修改SysDept对象 -func (e *SysDept) Update(c *dto.SysDeptControl) error { +func (e *SysDept) Update(c *dto.SysDeptUpdateReq) error { var err error var model = models.SysDept{} tx := e.Orm.Debug().Begin() @@ -127,7 +127,7 @@ func (e *SysDept) Update(c *dto.SysDeptControl) error { } // Remove 删除SysDept -func (e *SysDept) Remove(d *dto.SysDeptById) error { +func (e *SysDept) Remove(d *dto.SysDeptDeleteReq) error { var err error var data models.SysDept @@ -145,7 +145,7 @@ func (e *SysDept) Remove(d *dto.SysDeptById) error { } // GetSysDeptList 获取组织数据 -func (e *SysDept) getList(c *dto.SysDeptSearch, list *[]models.SysDept) error { +func (e *SysDept) getList(c *dto.SysDeptGetPageReq, list *[]models.SysDept) error { var err error var data models.SysDept @@ -162,7 +162,7 @@ func (e *SysDept) getList(c *dto.SysDeptSearch, list *[]models.SysDept) error { } // SetDeptTree 设置组织数据 -func (e *SysDept) SetDeptTree(c *dto.SysDeptSearch) (m []dto.DeptLabel, err error) { +func (e *SysDept) SetDeptTree(c *dto.SysDeptGetPageReq) (m []dto.DeptLabel, err error) { var list []models.SysDept err = e.getList(c, &list) @@ -198,7 +198,7 @@ func deptTreeCall(deptList *[]models.SysDept, dept dto.DeptLabel) dto.DeptLabel } // SetDeptPage 设置dept页面数据 -func (e *SysDept) SetDeptPage(c *dto.SysDeptSearch) (m []models.SysDept, err error) { +func (e *SysDept) SetDeptPage(c *dto.SysDeptGetPageReq) (m []models.SysDept, err error) { var list []models.SysDept err = e.getList(c, &list) for i := 0; i < len(list); i++ { diff --git a/app/admin/service/sys_dict_data.go b/app/admin/service/sys_dict_data.go index 31c22df7..28eedbad 100644 --- a/app/admin/service/sys_dict_data.go +++ b/app/admin/service/sys_dict_data.go @@ -16,7 +16,7 @@ type SysDictData struct { } // GetPage 获取列表 -func (e *SysDictData) GetPage(c *dto.SysDictDataSearch, list *[]models.SysDictData, count *int64) error { +func (e *SysDictData) GetPage(c *dto.SysDictDataGetPageReq, list *[]models.SysDictData, count *int64) error { var err error var data models.SysDictData @@ -35,7 +35,7 @@ func (e *SysDictData) GetPage(c *dto.SysDictDataSearch, list *[]models.SysDictDa } // Get 获取对象 -func (e *SysDictData) Get(d *dto.SysDictDataById, model *models.SysDictData) error { +func (e *SysDictData) Get(d *dto.SysDictDataGetReq, model *models.SysDictData) error { var err error var data models.SysDictData @@ -55,7 +55,7 @@ func (e *SysDictData) Get(d *dto.SysDictDataById, model *models.SysDictData) err } // Insert 创建对象 -func (e *SysDictData) Insert(c *dto.SysDictDataControl) error { +func (e *SysDictData) Insert(c *dto.SysDictDataInsertReq) error { var err error var data = new(models.SysDictData) c.Generate(data) @@ -68,7 +68,7 @@ func (e *SysDictData) Insert(c *dto.SysDictDataControl) error { } // Update 修改对象 -func (e *SysDictData) Update(c *dto.SysDictDataControl) error { +func (e *SysDictData) Update(c *dto.SysDictDataUpdateReq) error { var err error var model = models.SysDictData{} e.Orm.First(&model, c.GetId()) @@ -86,7 +86,7 @@ func (e *SysDictData) Update(c *dto.SysDictDataControl) error { } // Remove 删除 -func (e *SysDictData) Remove(c *dto.SysDictDataById) error { +func (e *SysDictData) Remove(c *dto.SysDictDataDeleteReq) error { var err error var data models.SysDictData @@ -104,7 +104,7 @@ func (e *SysDictData) Remove(c *dto.SysDictDataById) error { } // GetAll 获取所有 -func (e *SysDictData) GetAll(c *dto.SysDictDataSearch, list *[]models.SysDictData) error { +func (e *SysDictData) GetAll(c *dto.SysDictDataGetPageReq, list *[]models.SysDictData) error { var err error var data models.SysDictData diff --git a/app/admin/service/sys_dict_type.go b/app/admin/service/sys_dict_type.go index b652433a..888bccb7 100644 --- a/app/admin/service/sys_dict_type.go +++ b/app/admin/service/sys_dict_type.go @@ -16,7 +16,7 @@ type SysDictType struct { } // GetPage 获取列表 -func (e *SysDictType) GetPage(c *dto.SysDictTypeSearch, list *[]models.SysDictType, count *int64) error { +func (e *SysDictType) GetPage(c *dto.SysDictTypeGetPageReq, list *[]models.SysDictType, count *int64) error { var err error var data models.SysDictType @@ -35,7 +35,7 @@ func (e *SysDictType) GetPage(c *dto.SysDictTypeSearch, list *[]models.SysDictTy } // Get 获取对象 -func (e *SysDictType) Get(d *dto.SysDictTypeById, model *models.SysDictType) error { +func (e *SysDictType) Get(d *dto.SysDictTypeGetReq, model *models.SysDictType) error { var err error db := e.Orm.First(model, d.GetId()) @@ -53,7 +53,7 @@ func (e *SysDictType) Get(d *dto.SysDictTypeById, model *models.SysDictType) err } // Insert 创建对象 -func (e *SysDictType) Insert(c *dto.SysDictTypeControl) error { +func (e *SysDictType) Insert(c *dto.SysDictTypeInsertReq) error { var err error var data models.SysDictType c.Generate(&data) @@ -71,7 +71,7 @@ func (e *SysDictType) Insert(c *dto.SysDictTypeControl) error { } // Update 修改对象 -func (e *SysDictType) Update(c *dto.SysDictTypeControl) error { +func (e *SysDictType) Update(c *dto.SysDictTypeUpdateReq) error { var err error var model = models.SysDictType{} e.Orm.First(&model, c.GetId()) @@ -89,7 +89,7 @@ func (e *SysDictType) Update(c *dto.SysDictTypeControl) error { } // Remove 删除 -func (e *SysDictType) Remove(d *dto.SysDictTypeById) error { +func (e *SysDictType) Remove(d *dto.SysDictTypeDeleteReq) error { var err error var data models.SysDictType @@ -107,7 +107,7 @@ func (e *SysDictType) Remove(d *dto.SysDictTypeById) error { } // GetAll 获取所有 -func (e *SysDictType) GetAll(c *dto.SysDictTypeSearch, list *[]models.SysDictType) error { +func (e *SysDictType) GetAll(c *dto.SysDictTypeGetPageReq, list *[]models.SysDictType) error { var err error var data models.SysDictType diff --git a/app/admin/service/sys_login_log.go b/app/admin/service/sys_login_log.go index 8bc51236..04db57d7 100644 --- a/app/admin/service/sys_login_log.go +++ b/app/admin/service/sys_login_log.go @@ -15,8 +15,8 @@ type SysLoginLog struct { service.Service } -// GetSysLoginLogPage 获取SysLoginLog列表 -func (e *SysLoginLog) GetPage(c *dto.SysLoginLogSearch, list *[]models.SysLoginLog, count *int64) error { +// GetPage 获取SysLoginLog列表 +func (e *SysLoginLog) GetPage(c *dto.SysLoginLogGetPageReq, list *[]models.SysLoginLog, count *int64) error { var err error var data models.SysLoginLog diff --git a/app/admin/service/sys_menu.go b/app/admin/service/sys_menu.go index 5fb48ed9..9c779c77 100644 --- a/app/admin/service/sys_menu.go +++ b/app/admin/service/sys_menu.go @@ -19,7 +19,7 @@ type SysMenu struct { } // GetPage 获取SysMenu列表 -func (e *SysMenu) GetPage(c *dto.SysMenuSearch, menus *[]models.SysMenu) *SysMenu { +func (e *SysMenu) GetPage(c *dto.SysMenuGetPageReq, menus *[]models.SysMenu) *SysMenu { var menu = make([]models.SysMenu, 0) err := e.getPage(c, &menu).Error if err != nil { @@ -37,7 +37,7 @@ func (e *SysMenu) GetPage(c *dto.SysMenuSearch, menus *[]models.SysMenu) *SysMen } // getPage 菜单分页列表 -func (e *SysMenu) getPage(c *dto.SysMenuSearch, list *[]models.SysMenu) *SysMenu { +func (e *SysMenu) getPage(c *dto.SysMenuGetPageReq, list *[]models.SysMenu) *SysMenu { var err error var data models.SysMenu @@ -56,7 +56,7 @@ func (e *SysMenu) getPage(c *dto.SysMenuSearch, list *[]models.SysMenu) *SysMenu } // Get 获取SysMenu对象 -func (e *SysMenu) Get(d *dto.SysMenuById, model *models.SysMenu) *SysMenu { +func (e *SysMenu) Get(d *dto.SysMenuGetReq, model *models.SysMenu) *SysMenu { var err error var data models.SysMenu @@ -83,7 +83,7 @@ func (e *SysMenu) Get(d *dto.SysMenuById, model *models.SysMenu) *SysMenu { } // Insert 创建SysMenu对象 -func (e *SysMenu) Insert(c *dto.SysMenuControl) *SysMenu { +func (e *SysMenu) Insert(c *dto.SysMenuInsertReq) *SysMenu { var err error var data models.SysMenu c.Generate(&data) @@ -115,7 +115,7 @@ func (e *SysMenu) initPaths(menu *models.SysMenu) error { } // Update 修改SysMenu对象 -func (e *SysMenu) Update(c *dto.SysMenuControl) *SysMenu { +func (e *SysMenu) Update(c *dto.SysMenuUpdateReq) *SysMenu { var err error tx := e.Orm.Debug().Begin() defer func() { @@ -151,7 +151,7 @@ func (e *SysMenu) Update(c *dto.SysMenuControl) *SysMenu { } // Remove 删除SysMenu -func (e *SysMenu) Remove(d *dto.SysMenuById) *SysMenu { +func (e *SysMenu) Remove(d *dto.SysMenuDeleteReq) *SysMenu { var err error var data models.SysMenu @@ -169,7 +169,7 @@ func (e *SysMenu) Remove(d *dto.SysMenuById) *SysMenu { } // GetList 获取菜单数据 -func (e *SysMenu) GetList(c *dto.SysMenuSearch, list *[]models.SysMenu) error { +func (e *SysMenu) GetList(c *dto.SysMenuGetPageReq, list *[]models.SysMenu) error { var err error var data models.SysMenu @@ -188,7 +188,7 @@ func (e *SysMenu) GetList(c *dto.SysMenuSearch, list *[]models.SysMenu) error { // SetLabel 修改角色中 设置菜单基础数据 func (e *SysMenu) SetLabel() (m []dto.MenuLabel, err error) { var list []models.SysMenu - err = e.GetList(&dto.SysMenuSearch{}, &list) + err = e.GetList(&dto.SysMenuGetPageReq{}, &list) m = make([]dto.MenuLabel, 0) for i := 0; i < len(list); i++ { diff --git a/app/admin/service/sys_role.go b/app/admin/service/sys_role.go index 2dd3053c..7f9d71b5 100644 --- a/app/admin/service/sys_role.go +++ b/app/admin/service/sys_role.go @@ -19,7 +19,7 @@ type SysRole struct { } // GetPage 获取SysRole列表 -func (e *SysRole) GetPage(c *dto.SysRoleSearch, list *[]models.SysRole, count *int64) error { +func (e *SysRole) GetPage(c *dto.SysRoleGetPageReq, list *[]models.SysRole, count *int64) error { var err error var data models.SysRole @@ -38,7 +38,7 @@ func (e *SysRole) GetPage(c *dto.SysRoleSearch, list *[]models.SysRole, count *i } // Get 获取SysRole对象 -func (e *SysRole) Get(d *dto.SysRoleById, model *models.SysRole) error { +func (e *SysRole) Get(d *dto.SysRoleGetReq, model *models.SysRole) error { var err error db := e.Orm.First(model, d.GetId()) err = db.Error @@ -60,7 +60,7 @@ func (e *SysRole) Get(d *dto.SysRoleById, model *models.SysRole) error { } // Insert 创建SysRole对象 -func (e *SysRole) Insert(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error { +func (e *SysRole) Insert(c *dto.SysRoleInsertReq, cb *casbin.SyncedEnforcer) error { var err error var data models.SysRole var dataMenu []models.SysMenu @@ -106,7 +106,7 @@ func (e *SysRole) Insert(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error } // Update 修改SysRole对象 -func (e *SysRole) Update(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error { +func (e *SysRole) Update(c *dto.SysRoleUpdateReq, cb *casbin.SyncedEnforcer) error { var err error tx := e.Orm.Debug().Begin() defer func() { @@ -153,7 +153,7 @@ func (e *SysRole) Update(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error } // Remove 删除SysRole -func (e *SysRole) Remove(c *dto.SysRoleById) error { +func (e *SysRole) Remove(c *dto.SysRoleDeleteReq) error { var err error tx := e.Orm.Begin() defer func() { diff --git a/app/other/apis/tools/gen.go b/app/other/apis/tools/gen.go index 6d0afcc6..e9baafca9 100644 --- a/app/other/apis/tools/gen.go +++ b/app/other/apis/tools/gen.go @@ -305,7 +305,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) { tab, _ := table.Get(e.Orm,true) tab.MLTBName = strings.Replace(tab.TBName, "_", "-", -1) - Mmenu := dto.SysMenuControl{} + Mmenu := dto.SysMenuInsertReq{} Mmenu.Title = tab.TableComment Mmenu.Icon = "pass" Mmenu.Path = "/" + tab.MLTBName @@ -320,7 +320,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) { Mmenu.CreateBy = 1 s.Insert(&Mmenu) - Cmenu := dto.SysMenuControl{} + Cmenu := dto.SysMenuInsertReq{} Cmenu.MenuName = tab.ClassName + "Manage" Cmenu.Title = tab.TableComment Cmenu.Icon = "pass" @@ -338,7 +338,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) { Cmenu.UpdateBy = 1 s.Insert(&Cmenu) - MList := dto.SysMenuControl{} + MList := dto.SysMenuInsertReq{} MList.MenuName = "" MList.Title = "分页获取" + tab.TableComment MList.Icon = "" @@ -355,7 +355,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) { MList.UpdateBy = 1 s.Insert(&MList) - MCreate := dto.SysMenuControl{} + MCreate := dto.SysMenuInsertReq{} MCreate.MenuName = "" MCreate.Title = "创建" + tab.TableComment MCreate.Icon = "" @@ -372,7 +372,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) { MCreate.UpdateBy = 1 s.Insert(&MCreate) - MUpdate := dto.SysMenuControl{} + MUpdate := dto.SysMenuInsertReq{} MUpdate.MenuName = "" MUpdate.Title = "修改" + tab.TableComment MUpdate.Icon = "" @@ -389,7 +389,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) { MUpdate.UpdateBy = 1 s.Insert(&MUpdate) - MDelete := dto.SysMenuControl{} + MDelete := dto.SysMenuInsertReq{} MDelete.MenuName = "" MDelete.Title = "删除" + tab.TableComment MDelete.Icon = "" diff --git a/go.mod b/go.mod index c99a16fe..5847e45c 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ require ( github.com/bytedance/go-tagexpr/v2 v2.7.12 github.com/casbin/casbin/v2 v2.25.1 github.com/gin-gonic/gin v1.7.2 - github.com/go-admin-team/go-admin-core v1.3.6 - github.com/go-admin-team/go-admin-core/sdk v1.3.6 + github.com/go-admin-team/go-admin-core v1.3.7 + github.com/go-admin-team/go-admin-core/sdk v1.3.7 github.com/google/uuid v1.2.0 github.com/mssola/user_agent v0.5.2 github.com/opentracing/opentracing-go v1.1.0 @@ -31,7 +31,7 @@ require ( gorm.io/gorm v1.21.11 ) -//replace ( -// github.com/go-admin-team/go-admin-core => ../go-admin-core -// github.com/go-admin-team/go-admin-core/sdk => ../go-admin-core/sdk -//) +replace ( + github.com/go-admin-team/go-admin-core => ../go-admin-core + github.com/go-admin-team/go-admin-core/sdk => ../go-admin-core/sdk +)