refactor🎨: update request mode name

This commit is contained in:
zhangwenjian
2021-07-15 00:43:06 +08:00
parent 4a2659573b
commit a45113258c
26 changed files with 431 additions and 318 deletions
+6 -6
View File
@@ -30,7 +30,7 @@ type SysConfig struct {
// @Security Bearer // @Security Bearer
func (e SysConfig) GetPage(c *gin.Context) { func (e SysConfig) GetPage(c *gin.Context) {
s := service.SysConfig{} s := service.SysConfig{}
req := dto.SysConfigSearch{} req := dto.SysConfigGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.Form). Bind(&req, binding.Form).
@@ -60,7 +60,7 @@ func (e SysConfig) GetPage(c *gin.Context) {
// @Router /api/v1/sys-config/{id} [get] // @Router /api/v1/sys-config/{id} [get]
// @Security Bearer // @Security Bearer
func (e SysConfig) Get(c *gin.Context) { func (e SysConfig) Get(c *gin.Context) {
req := dto.SysConfigById{} req := dto.SysConfigGetReq{}
s := service.SysConfig{} s := service.SysConfig{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
@@ -158,7 +158,7 @@ func (e SysConfig) Update(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysConfig) Delete(c *gin.Context) { func (e SysConfig) Delete(c *gin.Context) {
s := service.SysConfig{} s := service.SysConfig{}
req := dto.SysConfigById{} req := dto.SysConfigDeleteReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON, nil). Bind(&req, binding.JSON, nil).
@@ -179,14 +179,14 @@ func (e SysConfig) Delete(c *gin.Context) {
e.OK(req.GetId(), "删除成功") e.OK(req.GetId(), "删除成功")
} }
// GetSysConfigBySysApp 获取系统配置信息 // Get2SysApp 获取系统配置信息
// @Summary 获取系统前台配置信息,主要注意这里不在验证权限 // @Summary 获取系统前台配置信息,主要注意这里不在验证权限
// @Description 获取系统配置信息,主要注意这里不在验证权限 // @Description 获取系统配置信息,主要注意这里不在验证权限
// @Tags 配置管理 // @Tags 配置管理
// @Success 200 {object} response.Response{data=map[string]string} "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response{data=map[string]string} "{"code": 200, "data": [...]}"
// @Router /api/v1/app-config [get] // @Router /api/v1/app-config [get]
func (e SysConfig) GetSysConfigBySysApp(c *gin.Context) { func (e SysConfig) Get2SysApp(c *gin.Context) {
req := dto.SysConfigSearch{} req := dto.SysConfigGetToSysAppReq{}
s := service.SysConfig{} s := service.SysConfig{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
+7 -8
View File
@@ -29,7 +29,7 @@ type SysDept struct {
// @Security Bearer // @Security Bearer
func (e SysDept) GetPage(c *gin.Context) { func (e SysDept) GetPage(c *gin.Context) {
s := service.SysDept{} s := service.SysDept{}
req := dto.SysDeptSearch{} req := dto.SysDeptGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req). Bind(&req).
@@ -50,17 +50,16 @@ func (e SysDept) GetPage(c *gin.Context) {
} }
// Get // Get
// @Summary 部门列表数据 // @Summary 获取部门数据
// @Description 获取JSON // @Description 获取JSON
// @Tags 部门 // @Tags 部门
// @Param deptId path string false "deptId" // @Param deptId path string false "deptId"
// @Param position query string false "position"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dept/{deptId} [get] // @Router /api/v1/dept/{deptId} [get]
// @Security Bearer // @Security Bearer
func (e SysDept) Get(c *gin.Context) { func (e SysDept) Get(c *gin.Context) {
s := service.SysDept{} s := service.SysDept{}
req := dto.SysDeptById{} req := dto.SysDeptGetReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON, nil). Bind(&req, binding.JSON, nil).
@@ -95,7 +94,7 @@ func (e SysDept) Get(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysDept) Insert(c *gin.Context) { func (e SysDept) Insert(c *gin.Context) {
s := service.SysDept{} s := service.SysDept{}
req := dto.SysDeptControl{} req := dto.SysDeptInsertReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON). Bind(&req, binding.JSON).
@@ -131,7 +130,7 @@ func (e SysDept) Insert(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysDept) Update(c *gin.Context) { func (e SysDept) Update(c *gin.Context) {
s := service.SysDept{} s := service.SysDept{}
req := dto.SysDeptControl{} req := dto.SysDeptUpdateReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req). Bind(&req).
@@ -162,7 +161,7 @@ func (e SysDept) Update(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysDept) Delete(c *gin.Context) { func (e SysDept) Delete(c *gin.Context) {
s := service.SysDept{} s := service.SysDept{}
req := dto.SysDeptById{} req := dto.SysDeptDeleteReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON, nil). Bind(&req, binding.JSON, nil).
@@ -185,7 +184,7 @@ func (e SysDept) Delete(c *gin.Context) {
// Get2Tree 用户管理 左侧部门树 // Get2Tree 用户管理 左侧部门树
func (e SysDept) Get2Tree(c *gin.Context) { func (e SysDept) Get2Tree(c *gin.Context) {
s := service.SysDept{} s := service.SysDept{}
req := dto.SysDeptSearch{} req := dto.SysDeptGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req,binding.Form). Bind(&req,binding.Form).
+25 -22
View File
@@ -30,7 +30,7 @@ type SysDictData struct {
// @Security Bearer // @Security Bearer
func (e SysDictData) GetPage(c *gin.Context) { func (e SysDictData) GetPage(c *gin.Context) {
s := service.SysDictData{} s := service.SysDictData{}
req := dto.SysDictDataSearch{} req := dto.SysDictDataGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.Form). Bind(&req, binding.Form).
@@ -63,7 +63,7 @@ func (e SysDictData) GetPage(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysDictData) Get(c *gin.Context) { func (e SysDictData) Get(c *gin.Context) {
s := service.SysDictData{} s := service.SysDictData{}
req := dto.SysDictDataById{} req := dto.SysDictDataGetReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, nil). Bind(&req, nil).
@@ -93,14 +93,13 @@ func (e SysDictData) Get(c *gin.Context) {
// @Tags 字典数据 // @Tags 字典数据
// @Accept application/json // @Accept application/json
// @Product application/json // @Product application/json
// @Param data body dto.SysDictDataControl true "data" // @Param data body dto.SysDictDataInsertReq true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {object} response.Response "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/dict/data [post] // @Router /api/v1/dict/data [post]
// @Security Bearer // @Security Bearer
func (e SysDictData) Insert(c *gin.Context) { func (e SysDictData) Insert(c *gin.Context) {
s := service.SysDictData{} s := service.SysDictData{}
req := dto.SysDictDataControl{} req := dto.SysDictDataInsertReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON). Bind(&req, binding.JSON).
@@ -127,14 +126,13 @@ func (e SysDictData) Insert(c *gin.Context) {
// @Tags 字典数据 // @Tags 字典数据
// @Accept application/json // @Accept application/json
// @Product application/json // @Product application/json
// @Param data body dto.SysDictDataControl true "body" // @Param data body dto.SysDictDataUpdateReq true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/dict/data/{dictCode} [put] // @Router /api/v1/dict/data/{dictCode} [put]
// @Security Bearer // @Security Bearer
func (e SysDictData) Update(c *gin.Context) { func (e SysDictData) Update(c *gin.Context) {
s := service.SysDictData{} s := service.SysDictData{}
req := dto.SysDictDataControl{} req := dto.SysDictDataUpdateReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON, nil). Bind(&req, binding.JSON, nil).
@@ -158,14 +156,13 @@ func (e SysDictData) Update(c *gin.Context) {
// @Summary 删除字典数据 // @Summary 删除字典数据
// @Description 删除数据 // @Description 删除数据
// @Tags 字典数据 // @Tags 字典数据
// @Param dictCode body dto.SysDictDataById true "body" // @Param dictCode body dto.SysDictDataDeleteReq true "body"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
// @Router /api/v1/dict/data [delete] // @Router /api/v1/dict/data [delete]
// @Security Bearer // @Security Bearer
func (e SysDictData) Delete(c *gin.Context) { func (e SysDictData) Delete(c *gin.Context) {
s := service.SysDictData{} s := service.SysDictData{}
req := dto.SysDictDataById{} req := dto.SysDictDataDeleteReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON, nil). Bind(&req, binding.JSON, nil).
@@ -185,21 +182,20 @@ func (e SysDictData) Delete(c *gin.Context) {
e.OK(req.GetId(), "删除成功") e.OK(req.GetId(), "删除成功")
} }
// GetSysDictDataAll 数据字典根据key获取 业务页面使用 // GetAll 数据字典根据key获取 业务页面使用
// @Summary 数据字典根据key获取 // @Summary 数据字典根据key获取
// @Description 数据字典根据key获取 // @Description 数据字典根据key获取
// @Tags 字典数据 // @Tags 字典数据
// @Param dictType query int true "dictType" // @Param dictType query int true "dictType"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {object} response.Response{data=[]dto.SysDictDataGetAllResp} "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
// @Router /api/v1/dict-data/option-select [get] // @Router /api/v1/dict-data/option-select [get]
// @Security Bearer // @Security Bearer
func (e SysDictData) GetSysDictDataAll(c *gin.Context) { func (e SysDictData) GetAll(c *gin.Context) {
s := service.SysDictData{} s := service.SysDictData{}
req := dto.SysDictDataSearch{} req := dto.SysDictDataGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.Form). Bind(&req).
MakeService(&s.Service). MakeService(&s.Service).
Errors Errors
if err != nil { if err != nil {
@@ -213,5 +209,12 @@ func (e SysDictData) GetSysDictDataAll(c *gin.Context) {
e.Error(500, err, "查询失败") e.Error(500, err, "查询失败")
return return
} }
e.OK(list, "查询成功") l := make([]dto.SysDictDataGetAllResp, 0)
} for _, i := range list {
d := dto.SysDictDataGetAllResp{}
e.Translate(i, &d)
l = append(l, d)
}
e.OK(l,"查询成功")
}
+12 -15
View File
@@ -31,7 +31,7 @@ type SysDictType struct {
// @Security Bearer // @Security Bearer
func (e SysDictType) GetPage(c *gin.Context) { func (e SysDictType) GetPage(c *gin.Context) {
s := service.SysDictType{} s := service.SysDictType{}
req :=dto.SysDictTypeSearch{} req :=dto.SysDictTypeGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.Form). Bind(&req, binding.Form).
@@ -62,7 +62,7 @@ func (e SysDictType) GetPage(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysDictType) Get(c *gin.Context) { func (e SysDictType) Get(c *gin.Context) {
s := service.SysDictType{} s := service.SysDictType{}
req :=dto.SysDictTypeById{} req :=dto.SysDictTypeGetReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, nil). Bind(&req, nil).
@@ -88,14 +88,13 @@ func (e SysDictType) Get(c *gin.Context) {
// @Tags 字典类型 // @Tags 字典类型
// @Accept application/json // @Accept application/json
// @Product application/json // @Product application/json
// @Param data body dto.SysDictTypeControl true "data" // @Param data body dto.SysDictTypeInsertReq true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/dict/type [post] // @Router /api/v1/dict/type [post]
// @Security Bearer // @Security Bearer
func (e SysDictType) Insert(c *gin.Context) { func (e SysDictType) Insert(c *gin.Context) {
s := service.SysDictType{} s := service.SysDictType{}
req :=dto.SysDictTypeControl{} req :=dto.SysDictTypeInsertReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON). Bind(&req, binding.JSON).
@@ -122,14 +121,13 @@ func (e SysDictType) Insert(c *gin.Context) {
// @Tags 字典类型 // @Tags 字典类型
// @Accept application/json // @Accept application/json
// @Product application/json // @Product application/json
// @Param data body dto.SysDictTypeControl true "body" // @Param data body dto.SysDictTypeUpdateReq true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/dict/type/{dictId} [put] // @Router /api/v1/dict/type/{dictId} [put]
// @Security Bearer // @Security Bearer
func (e SysDictType) Update(c *gin.Context) { func (e SysDictType) Update(c *gin.Context) {
s := service.SysDictType{} s := service.SysDictType{}
req :=dto.SysDictTypeControl{} req :=dto.SysDictTypeUpdateReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON, nil). Bind(&req, binding.JSON, nil).
@@ -153,14 +151,13 @@ func (e SysDictType) Update(c *gin.Context) {
// @Summary 删除字典类型 // @Summary 删除字典类型
// @Description 删除数据 // @Description 删除数据
// @Tags 字典类型 // @Tags 字典类型
// @Param dictId path int true "dictId" // @Param dictCode body dto.SysDictTypeDeleteReq true "body"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
// @Router /api/v1/dict/type [delete] // @Router /api/v1/dict/type [delete]
// @Security Bearer // @Security Bearer
func (e SysDictType) Delete(c *gin.Context) { func (e SysDictType) Delete(c *gin.Context) {
s := service.SysDictType{} s := service.SysDictType{}
req :=dto.SysDictTypeById{} req :=dto.SysDictTypeDeleteReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON, nil). Bind(&req, binding.JSON, nil).
@@ -192,7 +189,7 @@ func (e SysDictType) Delete(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysDictType) GetAll(c *gin.Context) { func (e SysDictType) GetAll(c *gin.Context) {
s := service.SysDictType{} s := service.SysDictType{}
req :=dto.SysDictTypeSearch{} req :=dto.SysDictTypeGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.Form). Bind(&req, binding.Form).
+2 -2
View File
@@ -29,7 +29,7 @@ type SysLoginLog struct {
// @Security Bearer // @Security Bearer
func (e SysLoginLog) GetPage(c *gin.Context) { func (e SysLoginLog) GetPage(c *gin.Context) {
s := service.SysLoginLog{} s := service.SysLoginLog{}
req :=dto.SysLoginLogSearch {} req :=dto.SysLoginLogGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.Form). Bind(&req, binding.Form).
@@ -84,7 +84,7 @@ func (e SysLoginLog) Get(c *gin.Context) {
// @Summary 登录日志删除 // @Summary 登录日志删除
// @Description 登录日志删除 // @Description 登录日志删除
// @Tags 登录日志 // @Tags 登录日志
// @Param data body dto.SysLoginLogById true "body" // @Param data body dto.SysLoginLogDeleteReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-login-log [delete] // @Router /api/v1/sys-login-log [delete]
// @Security Bearer // @Security Bearer
+8 -9
View File
@@ -20,13 +20,12 @@ type SysMenu struct {
// @Description 获取JSON // @Description 获取JSON
// @Tags 菜单 // @Tags 菜单
// @Param menuName query string false "menuName" // @Param menuName query string false "menuName"
// @Param menuName query string false "menuName"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/menu [get] // @Router /api/v1/menu [get]
// @Security Bearer // @Security Bearer
func (e SysMenu) GetPage(c *gin.Context) { func (e SysMenu) GetPage(c *gin.Context) {
s := service.SysMenu{} s := service.SysMenu{}
req := dto.SysMenuSearch{} req := dto.SysMenuGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.Form). Bind(&req, binding.Form).
@@ -55,7 +54,7 @@ func (e SysMenu) GetPage(c *gin.Context) {
// @Router /api/v1/menu/{id} [get] // @Router /api/v1/menu/{id} [get]
// @Security Bearer // @Security Bearer
func (e SysMenu) Get(c *gin.Context) { func (e SysMenu) Get(c *gin.Context) {
req := dto.SysMenuById{} req := dto.SysMenuGetReq{}
s := new(service.SysMenu) s := new(service.SysMenu)
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
@@ -83,12 +82,12 @@ func (e SysMenu) Get(c *gin.Context) {
// @Tags 菜单 // @Tags 菜单
// @Accept application/json // @Accept application/json
// @Product 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": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/menu [post] // @Router /api/v1/menu [post]
// @Security Bearer // @Security Bearer
func (e SysMenu) Insert(c *gin.Context) { func (e SysMenu) Insert(c *gin.Context) {
req := dto.SysMenuControl{} req := dto.SysMenuInsertReq{}
s := new(service.SysMenu) s := new(service.SysMenu)
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
@@ -117,12 +116,12 @@ func (e SysMenu) Insert(c *gin.Context) {
// @Accept application/json // @Accept application/json
// @Product application/json // @Product application/json
// @Param id path int true "id" // @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": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/menu/{id} [put] // @Router /api/v1/menu/{id} [put]
// @Security Bearer // @Security Bearer
func (e SysMenu) Update(c *gin.Context) { func (e SysMenu) Update(c *gin.Context) {
req := dto.SysMenuControl{} req := dto.SysMenuUpdateReq{}
s := new(service.SysMenu) s := new(service.SysMenu)
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
@@ -148,12 +147,12 @@ func (e SysMenu) Update(c *gin.Context) {
// @Summary 删除菜单 // @Summary 删除菜单
// @Description 删除数据 // @Description 删除数据
// @Tags 菜单 // @Tags 菜单
// @Param data body dto.SysMenuById true "body" // @Param data body dto.SysMenuDeleteReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/menu [delete] // @Router /api/v1/menu [delete]
// @Security Bearer // @Security Bearer
func (e SysMenu) Delete(c *gin.Context) { func (e SysMenu) Delete(c *gin.Context) {
control := new(dto.SysMenuById) control := new(dto.SysMenuDeleteReq)
s := new(service.SysMenu) s := new(service.SysMenu)
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
+6 -6
View File
@@ -35,7 +35,7 @@ type SysRole struct {
// @Security Bearer // @Security Bearer
func (e SysRole) GetPage(c *gin.Context) { func (e SysRole) GetPage(c *gin.Context) {
s := service.SysRole{} s := service.SysRole{}
req := dto.SysRoleSearch{} req := dto.SysRoleGetPageReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.Form). Bind(&req, binding.Form).
@@ -69,7 +69,7 @@ func (e SysRole) GetPage(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysRole) Get(c *gin.Context) { func (e SysRole) Get(c *gin.Context) {
s := service.SysRole{} s := service.SysRole{}
req := dto.SysRoleById{} req := dto.SysRoleGetReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, nil). Bind(&req, nil).
@@ -104,7 +104,7 @@ func (e SysRole) Get(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysRole) Insert(c *gin.Context) { func (e SysRole) Insert(c *gin.Context) {
s := service.SysRole{} s := service.SysRole{}
req := dto.SysRoleControl{} req := dto.SysRoleInsertReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON). Bind(&req, binding.JSON).
@@ -148,7 +148,7 @@ func (e SysRole) Insert(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysRole) Update(c *gin.Context) { func (e SysRole) Update(c *gin.Context) {
s := service.SysRole{} s := service.SysRole{}
req := dto.SysRoleControl{} req := dto.SysRoleUpdateReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, nil, binding.JSON). Bind(&req, nil, binding.JSON).
@@ -186,7 +186,7 @@ func (e SysRole) Update(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysRole) Delete(c *gin.Context) { func (e SysRole) Delete(c *gin.Context) {
s := new(service.SysRole) s := new(service.SysRole)
req := dto.SysRoleById{} req := dto.SysRoleDeleteReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON). Bind(&req, binding.JSON).
@@ -206,7 +206,7 @@ func (e SysRole) Delete(c *gin.Context) {
} }
_, err = global.LoadPolicy(c) _, err = global.LoadPolicy(c)
if err != nil { 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 return
} }
e.OK(req.GetId(), fmt.Sprintf("删除角色角色 %v 状态成功!", req.GetId())) e.OK(req.GetId(), fmt.Sprintf("删除角色角色 %v 状态成功!", req.GetId()))
+1
View File
@@ -448,5 +448,6 @@ func (e SysUser) GetInfo(c *gin.Context) {
mp["userId"] = sysUser.UserId mp["userId"] = sysUser.UserId
mp["deptId"] = sysUser.DeptId mp["deptId"] = sysUser.DeptId
mp["name"] = sysUser.NickName mp["name"] = sysUser.NickName
mp["code"] = 200
e.OK(mp, "") e.OK(mp, "")
} }
+1 -1
View File
@@ -31,7 +31,7 @@ func registerSysConfigRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMidd
r2 := v1.Group("/app-config") r2 := v1.Group("/app-config")
{ {
r2.GET("", api.GetSysConfigBySysApp) r2.GET("", api.Get2SysApp)
} }
r3 := v1.Group("/set-config").Use(authMiddleware.MiddlewareFunc()) r3 := v1.Group("/set-config").Use(authMiddleware.MiddlewareFunc())
+1 -1
View File
@@ -32,6 +32,6 @@ func registerDictRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlewar
} }
opSelect := v1.Group("/dict-data").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) opSelect := v1.Group("/dict-data").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{ {
opSelect.GET("/option-select", dataApi.GetSysDictDataAll) opSelect.GET("/option-select", dataApi.GetAll)
} }
} }
+22 -17
View File
@@ -6,8 +6,8 @@ import (
common "go-admin/common/models" common "go-admin/common/models"
) )
// SysConfigSearch 列表或者搜索使用结构体 // SysConfigGetPageReq 列表或者搜索使用结构体
type SysConfigSearch struct { type SysConfigGetPageReq struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config"` 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"` 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"` 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 return *m
} }
@@ -86,22 +94,19 @@ type GetSysConfigByKEYForServiceResp struct {
ConfigValue string `json:"configValue" comment:""` ConfigValue string `json:"configValue" comment:""`
} }
// SysConfigById 获取单个或者删除的结构体 type SysConfigGetReq struct {
type SysConfigById struct { Id int `uri:"id"`
Id int `uri:"id"` }
func (s *SysConfigGetReq) GetId() interface{} {
return s.Id
}
type SysConfigDeleteReq struct {
Ids []int `json:"ids"` Ids []int `json:"ids"`
common.ControlBy common.ControlBy
} }
func (s *SysConfigById) Generate() *SysConfigById { func (s *SysConfigDeleteReq) GetId() interface{} {
cp := *s return s.Ids
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
} }
+56 -35
View File
@@ -3,13 +3,10 @@ package dto
import ( import (
"go-admin/app/admin/models" "go-admin/app/admin/models"
common "go-admin/common/models" common "go-admin/common/models"
"go-admin/common/dto"
) )
// SysDeptSearch 列表或者搜索使用结构体 // SysDeptGetPageReq 列表或者搜索使用结构体
type SysDeptSearch struct { type SysDeptGetPageReq struct {
dto.Pagination `search:"-"`
DeptId int `form:"deptId" search:"type:exact;column:dept_id;table:sys_dept" comment:"id"` //id 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:"上级部门"` //上级部门 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:""` //路径 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:"状态"` //状态 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 return *m
} }
// SysDeptControl 增、改使用的结构体 type SysDeptInsertReq struct {
type SysDeptControl struct { DeptId int `uri:"id" comment:"编码"` // 编码
DeptId int `uri:"id" comment:"编码"` // 编码 ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门
ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门 DeptPath string `json:"deptPath" comment:""` //路径
DeptPath string `json:"deptPath" comment:""` //路径 DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称
DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称 Sort int `json:"sort" comment:"排序" vd:"?"` //排序
Sort int `json:"sort" comment:"排序" vd:"?"` //排序 Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人
Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人 Phone string `json:"phone" comment:"手机" vd:"?"` //手机
Phone string `json:"phone" comment:"手机" vd:"?"` //手机 Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱
Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱 Status int `json:"status" comment:"状态" vd:"$>0"` //状态
Status int `json:"status" comment:"状态" vd:"$>0"` //状态
common.ControlBy common.ControlBy
} }
// Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型 func (s *SysDeptInsertReq) Generate(model *models.SysDept) {
func (s *SysDeptControl) Generate(model *models.SysDept) {
if s.DeptId != 0 { if s.DeptId != 0 {
model.DeptId = s.DeptId model.DeptId = s.DeptId
} }
@@ -55,31 +50,57 @@ func (s *SysDeptControl) Generate(model *models.SysDept) {
} }
// GetId 获取数据对应的ID // GetId 获取数据对应的ID
func (s *SysDeptControl) GetId() interface{} { func (s *SysDeptInsertReq) GetId() interface{} {
return s.DeptId return s.DeptId
} }
// SysDeptById 获取单个或者删除的结构体 type SysDeptUpdateReq struct {
type SysDeptById struct { DeptId int `uri:"id" comment:"编码"` // 编码
Id int `uri:"id"` ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门
Ids []int `json:"ids"` 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 { // Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型
cp := *s func (s *SysDeptUpdateReq) Generate(model *models.SysDept) {
return &cp if s.DeptId != 0 {
} model.DeptId = s.DeptId
func (s *SysDeptById) GetId() interface{} {
if len(s.Ids) > 0 {
s.Ids = append(s.Ids, s.Id)
return s.Ids
} }
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 return s.Id
} }
func (s *SysDeptById) GenerateM() (*models.SysDept, error) { type SysDeptDeleteReq struct {
return &models.SysDept{}, nil Ids []int `json:"ids"`
}
func (s *SysDeptDeleteReq) GetId() interface{} {
return s.Ids
} }
type DeptLabel struct { type DeptLabel struct {
+57 -21
View File
@@ -6,7 +6,7 @@ import (
common "go-admin/common/models" common "go-admin/common/models"
) )
type SysDictDataSearch struct { type SysDictDataGetPageReq struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
Id int `form:"id" search:"type:exact;column:dict_code;table:sys_dict_data" comment:""` 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:""` 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:""` 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 return *m
} }
type SysDictDataControl struct { type SysDictDataGetAllResp struct {
Id int `uri:"dictCode" comment:""` DictLabel string `json:"label"`
DictValue string `json:"value"`
}
type SysDictDataInsertReq struct {
Id int `json:"-" comment:""`
DictSort int `json:"dictSort" comment:""` DictSort int `json:"dictSort" comment:""`
DictLabel string `json:"dictLabel" comment:""` DictLabel string `json:"dictLabel" comment:""`
DictValue string `json:"dictValue" comment:""` DictValue string `json:"dictValue" comment:""`
@@ -28,14 +33,13 @@ type SysDictDataControl struct {
CssClass string `json:"cssClass" comment:""` CssClass string `json:"cssClass" comment:""`
ListClass string `json:"listClass" comment:""` ListClass string `json:"listClass" comment:""`
IsDefault string `json:"isDefault" comment:""` IsDefault string `json:"isDefault" comment:""`
Status int `json:"status" comment:""` Status int `json:"status" comment:""`
Default string `json:"default" comment:""` Default string `json:"default" comment:""`
Remark string `json:"remark" comment:""` Remark string `json:"remark" comment:""`
common.ControlBy common.ControlBy
} }
func (s *SysDictDataControl) Generate(model *models.SysDictData) { func (s *SysDictDataInsertReq) Generate(model *models.SysDictData) {
model.DictCode = s.Id model.DictCode = s.Id
model.DictSort = s.DictSort model.DictSort = s.DictSort
model.DictLabel = s.DictLabel model.DictLabel = s.DictLabel
@@ -49,24 +53,56 @@ func (s *SysDictDataControl) Generate(model *models.SysDictData) {
model.Remark = s.Remark model.Remark = s.Remark
} }
func (s *SysDictDataControl) GetId() interface{} { func (s *SysDictDataInsertReq) GetId() interface{} {
return s.Id return s.Id
} }
type SysDictDataById struct { type SysDictDataUpdateReq struct {
Id int `uri:"dictCode"` Id int `uri:"dictCode" comment:""`
Ids []int `json:"ids"` 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:"-"` common.ControlBy `json:"-"`
} }
func (s *SysDictDataById) GetId() interface{} { func (s *SysDictDataDeleteReq) GetId() interface{} {
if len(s.Ids) > 0 { return s.Ids
s.Ids = append(s.Ids, s.Id)
return s.Ids
}
return s.Id
}
func (s *SysDictDataById) GenerateM() (common.ActiveRecord, error) {
return &models.SysDictData{}, nil
} }
+36 -17
View File
@@ -7,7 +7,7 @@ import (
common "go-admin/common/models" common "go-admin/common/models"
) )
type SysDictTypeSearch struct { type SysDictTypeGetPageReq struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
DictId []int `form:"dictId" search:"type:in;column:dict_id;table:sys_dict_type"` 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"` 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"` 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 return *m
} }
type SysDictTypeControl struct { type SysDictTypeInsertReq struct {
Id int `uri:"id"` Id int `uri:"id"`
DictName string `json:"dictName"` DictName string `json:"dictName"`
DictType string `json:"dictType"` DictType string `json:"dictType"`
@@ -32,7 +32,7 @@ type SysDictTypeControl struct {
common.ControlBy common.ControlBy
} }
func (s *SysDictTypeControl) Generate(model *models.SysDictType) { func (s *SysDictTypeInsertReq) Generate(model *models.SysDictType) {
if s.Id != 0 { if s.Id != 0 {
model.ID = s.Id 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 return s.Id
} }
type SysDictTypeById struct { type SysDictTypeUpdateReq struct {
dto.ObjectById Id int `uri:"id"`
DictName string `json:"dictName"`
DictType string `json:"dictType"`
Status int `json:"status"`
Remark string `json:"remark"`
common.ControlBy common.ControlBy
} }
func (s *SysDictTypeById) Generate() dto.Control { func (s *SysDictTypeUpdateReq) Generate(model *models.SysDictType) {
cp := *s if s.Id != 0 {
return &cp 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{} { func (s *SysDictTypeUpdateReq) GetId() interface{} {
if len(s.Ids) > 0 {
s.Ids = append(s.Ids, s.Id)
return s.Ids
}
return s.Id return s.Id
} }
func (s *SysDictTypeById) GenerateM() (common.ActiveRecord, error) { type SysDictTypeGetReq struct {
return &models.SysDictType{}, nil 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
} }
+2 -24
View File
@@ -1,14 +1,12 @@
package dto package dto
import ( import (
"go-admin/app/admin/models"
"time" "time"
"go-admin/common/dto" "go-admin/common/dto"
common "go-admin/common/models"
) )
type SysLoginLogSearch struct { type SysLoginLogGetPageReq struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
Username string `form:"username" search:"type:exact;column:username;table:sys_login_log" comment:"用户名"` 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:"状态"` 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"` 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 return *m
} }
@@ -41,26 +39,6 @@ type SysLoginLogControl struct {
Msg string `json:"msg" comment:"信息"` 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 { type SysLoginLogGetReq struct {
Id int `uri:"id"` Id int `uri:"id"`
} }
+72 -36
View File
@@ -7,19 +7,18 @@ import (
"go-admin/common/dto" "go-admin/common/dto"
) )
// SysMenuSearch 列表或者搜索使用结构体 // SysMenuGetPageReq 列表或者搜索使用结构体
type SysMenuSearch struct { type SysMenuGetPageReq struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
Title string `form:"title" search:"type:contains;column:title;table:sys_menu" comment:"菜单名称"` // 菜单名称 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:"显示状态"` // 显示状态 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 return *m
} }
// SysMenuControl 增、改使用的结构体 type SysMenuInsertReq struct {
type SysMenuControl struct {
MenuId int `uri:"id" comment:"编码"` // 编码 MenuId int `uri:"id" comment:"编码"` // 编码
MenuName string `form:"menuName" comment:"菜单name"` //菜单name MenuName string `form:"menuName" comment:"菜单name"` //菜单name
Title string `form:"title" comment:"显示名称"` //显示名称 Title string `form:"title" comment:"显示名称"` //显示名称
@@ -41,16 +40,7 @@ type SysMenuControl struct {
common.ControlBy common.ControlBy
} }
func (s *SysMenuControl) SetCreateBy(id int) { func (s *SysMenuInsertReq) Generate(model *models.SysMenu) {
s.CreateBy = id
}
func (s *SysMenuControl) SetUpdateBy(id int) {
s.UpdateBy = id
}
// Generate 结构体数据转化 从 Control 至 model 对应的模型
func (s *SysMenuControl) Generate(model *models.SysMenu) {
if s.MenuId != 0 { if s.MenuId != 0 {
model.MenuId = s.MenuId model.MenuId = s.MenuId
} }
@@ -78,33 +68,79 @@ func (s *SysMenuControl) Generate(model *models.SysMenu) {
} }
} }
// GetId 获取数据对应的ID func (s *SysMenuInsertReq) GetId() interface{} {
func (s *SysMenuControl) GetId() interface{} {
return s.MenuId return s.MenuId
} }
// SysMenuById 获取单个或者删除的结构体 type SysMenuUpdateReq struct {
type SysMenuById struct { MenuId int `uri:"id" comment:"编码"` // 编码
Id int `uri:"id"` 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"` Ids []int `json:"ids"`
common.ControlBy common.ControlBy
} }
func (s *SysMenuById) Generate() *SysMenuById { func (s *SysMenuDeleteReq) GetId() interface{} {
cp := *s return s.Ids
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
} }
type MenuLabel struct { type MenuLabel struct {
@@ -120,4 +156,4 @@ type MenuRole struct {
type SelectRole struct { type SelectRole struct {
RoleId int `uri:"roleId"` RoleId int `uri:"roleId"`
} }
+52 -33
View File
@@ -7,8 +7,7 @@ import (
"go-admin/common/dto" "go-admin/common/dto"
) )
// SysRoleSearch 列表或者搜索使用结构体 type SysRoleGetPageReq struct {
type SysRoleSearch struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
RoleId int `form:"roleId" search:"type:exact;column:role_id;table:sys_role" comment:"角色编码"` // 角色编码 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"` 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 return *m
} }
type SysRoleControl struct { type SysRoleInsertReq struct {
RoleId int `uri:"id" comment:"角色编码"` // 角色编码 RoleId int `uri:"id" comment:"角色编码"` // 角色编码
RoleName string `form:"roleName" comment:"角色名称"` // 角色名称 RoleName string `form:"roleName" comment:"角色名称"` // 角色名称
Status string `form:"status" comment:"状态"` // 状态 Status string `form:"status" comment:"状态"` // 状态
@@ -51,16 +50,7 @@ type SysRoleControl struct {
common.ControlBy common.ControlBy
} }
func (s *SysRoleControl) SetCreateBy(id int) { func (s *SysRoleInsertReq) Generate(model *models.SysRole) {
s.CreateBy = id
}
func (s *SysRoleControl) SetUpdateBy(id int) {
s.UpdateBy = id
}
// Generate 结构体数据转化
func (s *SysRoleControl) Generate(model *models.SysRole) {
if s.RoleId != 0 { if s.RoleId != 0 {
model.RoleId = s.RoleId model.RoleId = s.RoleId
} }
@@ -74,11 +64,46 @@ func (s *SysRoleControl) Generate(model *models.SysRole) {
model.DataScope = s.DataScope model.DataScope = s.DataScope
model.SysMenu = &s.SysMenu model.SysMenu = &s.SysMenu
model.SysDept = s.SysDept model.SysDept = s.SysDept
} }
// GetId 获取数据对应的ID func (s *SysRoleInsertReq) GetId() interface{} {
func (s *SysRoleControl) 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 return s.RoleId
} }
@@ -103,26 +128,20 @@ type SysRoleByName struct {
RoleName string `form:"role"` // 角色编码 RoleName string `form:"role"` // 角色编码
} }
// SysRoleById 获取单个或者删除的结构体 type SysRoleGetReq struct {
type SysRoleById struct { Id int `uri:"id"`
dto.ObjectById
} }
func (s *SysRoleById) Generate() *SysRoleById { func (s *SysRoleGetReq) GetId() interface{} {
cp := *s
return &cp
}
func (s *SysRoleById) GetId() interface{} {
if len(s.Ids) > 0 {
s.Ids = append(s.Ids, s.Id)
return s.Ids
}
return s.Id return s.Id
} }
func (s *SysRoleById) GenerateM() (*models.SysRole, error) { type SysRoleDeleteReq struct {
return &models.SysRole{}, nil Ids []int `json:"ids"`
}
func (s *SysRoleDeleteReq) GetId() interface{} {
return s.Ids
} }
// RoleDataScopeReq 角色数据权限修改 // RoleDataScopeReq 角色数据权限修改
@@ -142,4 +161,4 @@ func (s *RoleDataScopeReq) Generate(model *models.SysRole) {
type DeptIdList struct { type DeptIdList struct {
DeptId int `json:"DeptId"` DeptId int `json:"DeptId"`
} }
+4 -4
View File
@@ -16,7 +16,7 @@ type SysConfig struct {
} }
// GetPage 获取SysConfig列表 // 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. err := e.Orm.
Scopes( Scopes(
cDto.MakeCondition(c.GetNeedSearch()), cDto.MakeCondition(c.GetNeedSearch()),
@@ -32,7 +32,7 @@ func (e *SysConfig) GetPage(c *dto.SysConfigSearch, list *[]models.SysConfig, co
} }
// Get 获取SysConfig对象 // 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 err := e.Orm.First(model, d.GetId()).Error
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) { if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
err = errors.New("查看对象不存在或无权查看") err = errors.New("查看对象不存在或无权查看")
@@ -137,7 +137,7 @@ func (e *SysConfig) UpdateForSet(c *[]dto.GetSetSysConfigReq) error {
} }
// Remove 删除SysConfig // Remove 删除SysConfig
func (e *SysConfig) Remove(d *dto.SysConfigById) error { func (e *SysConfig) Remove(d *dto.SysConfigDeleteReq) error {
var err error var err error
var data models.SysConfig var data models.SysConfig
@@ -167,7 +167,7 @@ func (e *SysConfig) GetWithKey(c *dto.SysConfigByKeyReq, resp *dto.GetSysConfigB
return nil 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 var err error
err = e.Orm. err = e.Orm.
Scopes( Scopes(
+22 -22
View File
@@ -20,24 +20,24 @@ type SysDept struct {
} }
// GetPage 获取SysDept列表 // GetPage 获取SysDept列表
func (e *SysDept) GetPage(c *dto.SysDeptSearch, list *[]models.SysDept) error { //func (e *SysDept) GetPage(c *dto.SysDeptGetPageReq, list *[]models.SysDept) error {
var err error // var err error
var data models.SysDept // var data models.SysDept
//
err = e.Orm.Model(&data). // err = e.Orm.Model(&data).
Scopes( // Scopes(
cDto.MakeCondition(c.GetNeedSearch()), // cDto.MakeCondition(c.GetNeedSearch()),
). // ).
Find(list).Error // Find(list).Error
if err != nil { // if err != nil {
e.Log.Errorf("db error:%s", err) // e.Log.Errorf("db error:%s", err)
return err // return err
} // }
return nil // return nil
} //}
// Get 获取SysDept对象 // 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 err error
var data models.SysDept var data models.SysDept
@@ -57,7 +57,7 @@ func (e *SysDept) Get(d *dto.SysDeptById, model *models.SysDept) error {
} }
// Insert 创建SysDept对象 // Insert 创建SysDept对象
func (e *SysDept) Insert(c *dto.SysDeptControl) error { func (e *SysDept) Insert(c *dto.SysDeptInsertReq) error {
var err error var err error
var data models.SysDept var data models.SysDept
c.Generate(&data) c.Generate(&data)
@@ -92,7 +92,7 @@ func (e *SysDept) Insert(c *dto.SysDeptControl) error {
} }
// Update 修改SysDept对象 // Update 修改SysDept对象
func (e *SysDept) Update(c *dto.SysDeptControl) error { func (e *SysDept) Update(c *dto.SysDeptUpdateReq) error {
var err error var err error
var model = models.SysDept{} var model = models.SysDept{}
tx := e.Orm.Debug().Begin() tx := e.Orm.Debug().Begin()
@@ -127,7 +127,7 @@ func (e *SysDept) Update(c *dto.SysDeptControl) error {
} }
// Remove 删除SysDept // Remove 删除SysDept
func (e *SysDept) Remove(d *dto.SysDeptById) error { func (e *SysDept) Remove(d *dto.SysDeptDeleteReq) error {
var err error var err error
var data models.SysDept var data models.SysDept
@@ -145,7 +145,7 @@ func (e *SysDept) Remove(d *dto.SysDeptById) error {
} }
// GetSysDeptList 获取组织数据 // 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 err error
var data models.SysDept var data models.SysDept
@@ -162,7 +162,7 @@ func (e *SysDept) getList(c *dto.SysDeptSearch, list *[]models.SysDept) error {
} }
// SetDeptTree 设置组织数据 // 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 var list []models.SysDept
err = e.getList(c, &list) err = e.getList(c, &list)
@@ -198,7 +198,7 @@ func deptTreeCall(deptList *[]models.SysDept, dept dto.DeptLabel) dto.DeptLabel
} }
// SetDeptPage 设置dept页面数据 // 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 var list []models.SysDept
err = e.getList(c, &list) err = e.getList(c, &list)
for i := 0; i < len(list); i++ { for i := 0; i < len(list); i++ {
+6 -6
View File
@@ -16,7 +16,7 @@ type SysDictData struct {
} }
// GetPage 获取列表 // 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 err error
var data models.SysDictData var data models.SysDictData
@@ -35,7 +35,7 @@ func (e *SysDictData) GetPage(c *dto.SysDictDataSearch, list *[]models.SysDictDa
} }
// Get 获取对象 // 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 err error
var data models.SysDictData var data models.SysDictData
@@ -55,7 +55,7 @@ func (e *SysDictData) Get(d *dto.SysDictDataById, model *models.SysDictData) err
} }
// Insert 创建对象 // Insert 创建对象
func (e *SysDictData) Insert(c *dto.SysDictDataControl) error { func (e *SysDictData) Insert(c *dto.SysDictDataInsertReq) error {
var err error var err error
var data = new(models.SysDictData) var data = new(models.SysDictData)
c.Generate(data) c.Generate(data)
@@ -68,7 +68,7 @@ func (e *SysDictData) Insert(c *dto.SysDictDataControl) error {
} }
// Update 修改对象 // Update 修改对象
func (e *SysDictData) Update(c *dto.SysDictDataControl) error { func (e *SysDictData) Update(c *dto.SysDictDataUpdateReq) error {
var err error var err error
var model = models.SysDictData{} var model = models.SysDictData{}
e.Orm.First(&model, c.GetId()) e.Orm.First(&model, c.GetId())
@@ -86,7 +86,7 @@ func (e *SysDictData) Update(c *dto.SysDictDataControl) error {
} }
// Remove 删除 // Remove 删除
func (e *SysDictData) Remove(c *dto.SysDictDataById) error { func (e *SysDictData) Remove(c *dto.SysDictDataDeleteReq) error {
var err error var err error
var data models.SysDictData var data models.SysDictData
@@ -104,7 +104,7 @@ func (e *SysDictData) Remove(c *dto.SysDictDataById) error {
} }
// GetAll 获取所有 // 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 err error
var data models.SysDictData var data models.SysDictData
+6 -6
View File
@@ -16,7 +16,7 @@ type SysDictType struct {
} }
// GetPage 获取列表 // 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 err error
var data models.SysDictType var data models.SysDictType
@@ -35,7 +35,7 @@ func (e *SysDictType) GetPage(c *dto.SysDictTypeSearch, list *[]models.SysDictTy
} }
// Get 获取对象 // 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 var err error
db := e.Orm.First(model, d.GetId()) db := e.Orm.First(model, d.GetId())
@@ -53,7 +53,7 @@ func (e *SysDictType) Get(d *dto.SysDictTypeById, model *models.SysDictType) err
} }
// Insert 创建对象 // Insert 创建对象
func (e *SysDictType) Insert(c *dto.SysDictTypeControl) error { func (e *SysDictType) Insert(c *dto.SysDictTypeInsertReq) error {
var err error var err error
var data models.SysDictType var data models.SysDictType
c.Generate(&data) c.Generate(&data)
@@ -71,7 +71,7 @@ func (e *SysDictType) Insert(c *dto.SysDictTypeControl) error {
} }
// Update 修改对象 // Update 修改对象
func (e *SysDictType) Update(c *dto.SysDictTypeControl) error { func (e *SysDictType) Update(c *dto.SysDictTypeUpdateReq) error {
var err error var err error
var model = models.SysDictType{} var model = models.SysDictType{}
e.Orm.First(&model, c.GetId()) e.Orm.First(&model, c.GetId())
@@ -89,7 +89,7 @@ func (e *SysDictType) Update(c *dto.SysDictTypeControl) error {
} }
// Remove 删除 // Remove 删除
func (e *SysDictType) Remove(d *dto.SysDictTypeById) error { func (e *SysDictType) Remove(d *dto.SysDictTypeDeleteReq) error {
var err error var err error
var data models.SysDictType var data models.SysDictType
@@ -107,7 +107,7 @@ func (e *SysDictType) Remove(d *dto.SysDictTypeById) error {
} }
// GetAll 获取所有 // 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 err error
var data models.SysDictType var data models.SysDictType
+2 -2
View File
@@ -15,8 +15,8 @@ type SysLoginLog struct {
service.Service service.Service
} }
// GetSysLoginLogPage 获取SysLoginLog列表 // GetPage 获取SysLoginLog列表
func (e *SysLoginLog) GetPage(c *dto.SysLoginLogSearch, list *[]models.SysLoginLog, count *int64) error { func (e *SysLoginLog) GetPage(c *dto.SysLoginLogGetPageReq, list *[]models.SysLoginLog, count *int64) error {
var err error var err error
var data models.SysLoginLog var data models.SysLoginLog
+8 -8
View File
@@ -19,7 +19,7 @@ type SysMenu struct {
} }
// GetPage 获取SysMenu列表 // 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) var menu = make([]models.SysMenu, 0)
err := e.getPage(c, &menu).Error err := e.getPage(c, &menu).Error
if err != nil { if err != nil {
@@ -37,7 +37,7 @@ func (e *SysMenu) GetPage(c *dto.SysMenuSearch, menus *[]models.SysMenu) *SysMen
} }
// getPage 菜单分页列表 // 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 err error
var data models.SysMenu var data models.SysMenu
@@ -56,7 +56,7 @@ func (e *SysMenu) getPage(c *dto.SysMenuSearch, list *[]models.SysMenu) *SysMenu
} }
// Get 获取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 err error
var data models.SysMenu var data models.SysMenu
@@ -83,7 +83,7 @@ func (e *SysMenu) Get(d *dto.SysMenuById, model *models.SysMenu) *SysMenu {
} }
// Insert 创建SysMenu对象 // Insert 创建SysMenu对象
func (e *SysMenu) Insert(c *dto.SysMenuControl) *SysMenu { func (e *SysMenu) Insert(c *dto.SysMenuInsertReq) *SysMenu {
var err error var err error
var data models.SysMenu var data models.SysMenu
c.Generate(&data) c.Generate(&data)
@@ -115,7 +115,7 @@ func (e *SysMenu) initPaths(menu *models.SysMenu) error {
} }
// Update 修改SysMenu对象 // Update 修改SysMenu对象
func (e *SysMenu) Update(c *dto.SysMenuControl) *SysMenu { func (e *SysMenu) Update(c *dto.SysMenuUpdateReq) *SysMenu {
var err error var err error
tx := e.Orm.Debug().Begin() tx := e.Orm.Debug().Begin()
defer func() { defer func() {
@@ -151,7 +151,7 @@ func (e *SysMenu) Update(c *dto.SysMenuControl) *SysMenu {
} }
// Remove 删除SysMenu // Remove 删除SysMenu
func (e *SysMenu) Remove(d *dto.SysMenuById) *SysMenu { func (e *SysMenu) Remove(d *dto.SysMenuDeleteReq) *SysMenu {
var err error var err error
var data models.SysMenu var data models.SysMenu
@@ -169,7 +169,7 @@ func (e *SysMenu) Remove(d *dto.SysMenuById) *SysMenu {
} }
// GetList 获取菜单数据 // 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 err error
var data models.SysMenu var data models.SysMenu
@@ -188,7 +188,7 @@ func (e *SysMenu) GetList(c *dto.SysMenuSearch, list *[]models.SysMenu) error {
// SetLabel 修改角色中 设置菜单基础数据 // SetLabel 修改角色中 设置菜单基础数据
func (e *SysMenu) SetLabel() (m []dto.MenuLabel, err error) { func (e *SysMenu) SetLabel() (m []dto.MenuLabel, err error) {
var list []models.SysMenu var list []models.SysMenu
err = e.GetList(&dto.SysMenuSearch{}, &list) err = e.GetList(&dto.SysMenuGetPageReq{}, &list)
m = make([]dto.MenuLabel, 0) m = make([]dto.MenuLabel, 0)
for i := 0; i < len(list); i++ { for i := 0; i < len(list); i++ {
+5 -5
View File
@@ -19,7 +19,7 @@ type SysRole struct {
} }
// GetPage 获取SysRole列表 // 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 err error
var data models.SysRole var data models.SysRole
@@ -38,7 +38,7 @@ func (e *SysRole) GetPage(c *dto.SysRoleSearch, list *[]models.SysRole, count *i
} }
// Get 获取SysRole对象 // 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 var err error
db := e.Orm.First(model, d.GetId()) db := e.Orm.First(model, d.GetId())
err = db.Error err = db.Error
@@ -60,7 +60,7 @@ func (e *SysRole) Get(d *dto.SysRoleById, model *models.SysRole) error {
} }
// Insert 创建SysRole对象 // 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 err error
var data models.SysRole var data models.SysRole
var dataMenu []models.SysMenu var dataMenu []models.SysMenu
@@ -106,7 +106,7 @@ func (e *SysRole) Insert(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error
} }
// Update 修改SysRole对象 // 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 var err error
tx := e.Orm.Debug().Begin() tx := e.Orm.Debug().Begin()
defer func() { defer func() {
@@ -153,7 +153,7 @@ func (e *SysRole) Update(c *dto.SysRoleControl, cb *casbin.SyncedEnforcer) error
} }
// Remove 删除SysRole // Remove 删除SysRole
func (e *SysRole) Remove(c *dto.SysRoleById) error { func (e *SysRole) Remove(c *dto.SysRoleDeleteReq) error {
var err error var err error
tx := e.Orm.Begin() tx := e.Orm.Begin()
defer func() { defer func() {
+6 -6
View File
@@ -305,7 +305,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
tab, _ := table.Get(e.Orm,true) tab, _ := table.Get(e.Orm,true)
tab.MLTBName = strings.Replace(tab.TBName, "_", "-", -1) tab.MLTBName = strings.Replace(tab.TBName, "_", "-", -1)
Mmenu := dto.SysMenuControl{} Mmenu := dto.SysMenuInsertReq{}
Mmenu.Title = tab.TableComment Mmenu.Title = tab.TableComment
Mmenu.Icon = "pass" Mmenu.Icon = "pass"
Mmenu.Path = "/" + tab.MLTBName Mmenu.Path = "/" + tab.MLTBName
@@ -320,7 +320,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
Mmenu.CreateBy = 1 Mmenu.CreateBy = 1
s.Insert(&Mmenu) s.Insert(&Mmenu)
Cmenu := dto.SysMenuControl{} Cmenu := dto.SysMenuInsertReq{}
Cmenu.MenuName = tab.ClassName + "Manage" Cmenu.MenuName = tab.ClassName + "Manage"
Cmenu.Title = tab.TableComment Cmenu.Title = tab.TableComment
Cmenu.Icon = "pass" Cmenu.Icon = "pass"
@@ -338,7 +338,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
Cmenu.UpdateBy = 1 Cmenu.UpdateBy = 1
s.Insert(&Cmenu) s.Insert(&Cmenu)
MList := dto.SysMenuControl{} MList := dto.SysMenuInsertReq{}
MList.MenuName = "" MList.MenuName = ""
MList.Title = "分页获取" + tab.TableComment MList.Title = "分页获取" + tab.TableComment
MList.Icon = "" MList.Icon = ""
@@ -355,7 +355,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
MList.UpdateBy = 1 MList.UpdateBy = 1
s.Insert(&MList) s.Insert(&MList)
MCreate := dto.SysMenuControl{} MCreate := dto.SysMenuInsertReq{}
MCreate.MenuName = "" MCreate.MenuName = ""
MCreate.Title = "创建" + tab.TableComment MCreate.Title = "创建" + tab.TableComment
MCreate.Icon = "" MCreate.Icon = ""
@@ -372,7 +372,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
MCreate.UpdateBy = 1 MCreate.UpdateBy = 1
s.Insert(&MCreate) s.Insert(&MCreate)
MUpdate := dto.SysMenuControl{} MUpdate := dto.SysMenuInsertReq{}
MUpdate.MenuName = "" MUpdate.MenuName = ""
MUpdate.Title = "修改" + tab.TableComment MUpdate.Title = "修改" + tab.TableComment
MUpdate.Icon = "" MUpdate.Icon = ""
@@ -389,7 +389,7 @@ func (e Gen) GenMenuAndApi(c *gin.Context) {
MUpdate.UpdateBy = 1 MUpdate.UpdateBy = 1
s.Insert(&MUpdate) s.Insert(&MUpdate)
MDelete := dto.SysMenuControl{} MDelete := dto.SysMenuInsertReq{}
MDelete.MenuName = "" MDelete.MenuName = ""
MDelete.Title = "删除" + tab.TableComment MDelete.Title = "删除" + tab.TableComment
MDelete.Icon = "" MDelete.Icon = ""
+6 -6
View File
@@ -9,8 +9,8 @@ require (
github.com/bytedance/go-tagexpr/v2 v2.7.12 github.com/bytedance/go-tagexpr/v2 v2.7.12
github.com/casbin/casbin/v2 v2.25.1 github.com/casbin/casbin/v2 v2.25.1
github.com/gin-gonic/gin v1.7.2 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 v1.3.7
github.com/go-admin-team/go-admin-core/sdk v1.3.6 github.com/go-admin-team/go-admin-core/sdk v1.3.7
github.com/google/uuid v1.2.0 github.com/google/uuid v1.2.0
github.com/mssola/user_agent v0.5.2 github.com/mssola/user_agent v0.5.2
github.com/opentracing/opentracing-go v1.1.0 github.com/opentracing/opentracing-go v1.1.0
@@ -31,7 +31,7 @@ require (
gorm.io/gorm v1.21.11 gorm.io/gorm v1.21.11
) )
//replace ( replace (
// github.com/go-admin-team/go-admin-core => ../go-admin-core github.com/go-admin-team/go-admin-core => ../go-admin-core
// github.com/go-admin-team/go-admin-core/sdk => ../go-admin-core/sdk github.com/go-admin-team/go-admin-core/sdk => ../go-admin-core/sdk
//) )