refactor🎨: 修改请求参数命名
This commit is contained in:
1 parent
3fd34db3c1
commit
f80e64688e
14 files changed
+192
-99
No files matched your search
@@ -32,7 +32,7 @@ type SysApi struct {
|
|||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysApi) GetPage(c *gin.Context) {
|
func (e SysApi) GetPage(c *gin.Context) {
|
||||||
s := service.SysApi{}
|
s := service.SysApi{}
|
||||||
req := dto.SysApiSearch{}
|
req := dto.SysApiGetPageReq{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, binding.Form).
|
Bind(&req, binding.Form).
|
||||||
@@ -64,7 +64,7 @@ func (e SysApi) GetPage(c *gin.Context) {
|
|||||||
// @Router /api/v1/sys-api/{id} [get]
|
// @Router /api/v1/sys-api/{id} [get]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysApi) Get(c *gin.Context) {
|
func (e SysApi) Get(c *gin.Context) {
|
||||||
req := dto.SysApiById{}
|
req := dto.SysApiGetReq{}
|
||||||
s := service.SysApi{}
|
s := service.SysApi{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
@@ -97,7 +97,7 @@ func (e SysApi) Get(c *gin.Context) {
|
|||||||
// @Router /api/v1/sys-api/{id} [put]
|
// @Router /api/v1/sys-api/{id} [put]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysApi) Update(c *gin.Context) {
|
func (e SysApi) Update(c *gin.Context) {
|
||||||
req := dto.SysApiControl{}
|
req := dto.SysApiUpdateReq{}
|
||||||
s := service.SysApi{}
|
s := service.SysApi{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
@@ -127,18 +127,17 @@ func (e SysApi) Update(c *gin.Context) {
|
|||||||
// @Router /api/v1/sys-api [delete]
|
// @Router /api/v1/sys-api [delete]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysApi) DeleteSysApi(c *gin.Context) {
|
func (e SysApi) DeleteSysApi(c *gin.Context) {
|
||||||
req := dto.SysApiById{}
|
req := dto.SysApiDeleteReq{}
|
||||||
s := service.SysApi{}
|
s := service.SysApi{}
|
||||||
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 {
|
||||||
e.Logger.Error(err)
|
e.Logger.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.SetUpdateBy(user.GetUserId(c))
|
|
||||||
p := actions.GetPermissionFromContext(c)
|
p := actions.GetPermissionFromContext(c)
|
||||||
err = s.Remove(&req, p)
|
err = s.Remove(&req, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func (e SysDept) GetPage(c *gin.Context) {
|
|||||||
req := dto.SysDeptSearch{}
|
req := dto.SysDeptSearch{}
|
||||||
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 {
|
||||||
@@ -134,7 +134,7 @@ func (e SysDept) Update(c *gin.Context) {
|
|||||||
req := dto.SysDeptControl{}
|
req := dto.SysDeptControl{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, binding.JSON, nil).
|
Bind(&req).
|
||||||
MakeService(&s.Service).
|
MakeService(&s.Service).
|
||||||
Errors
|
Errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -159,6 +159,7 @@ func (e SysDept) Update(c *gin.Context) {
|
|||||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||||
// @Router /api/v1/dept [delete]
|
// @Router /api/v1/dept [delete]
|
||||||
|
// @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.SysDeptById{}
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package apis
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin/binding"
|
|
||||||
"go-admin/app/admin/models"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||||
|
"go-admin/app/admin/models"
|
||||||
"go-admin/app/admin/service"
|
"go-admin/app/admin/service"
|
||||||
"go-admin/app/admin/service/dto"
|
"go-admin/app/admin/service/dto"
|
||||||
)
|
)
|
||||||
@@ -33,7 +31,7 @@ type SysOperaLog struct {
|
|||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysOperaLog) GetPage(c *gin.Context) {
|
func (e SysOperaLog) GetPage(c *gin.Context) {
|
||||||
s := service.SysOperaLog{}
|
s := service.SysOperaLog{}
|
||||||
req := new(dto.SysOperaLogSearch)
|
req := new(dto.SysOperaLogGetPageReq)
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(req, binding.Form).
|
Bind(req, binding.Form).
|
||||||
@@ -50,7 +48,7 @@ func (e SysOperaLog) GetPage(c *gin.Context) {
|
|||||||
|
|
||||||
err = s.GetPage(req, &list, &count)
|
err = s.GetPage(req, &list, &count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
e.Error(500, err, "查询失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +93,7 @@ func (e SysOperaLog) Get(c *gin.Context) {
|
|||||||
// @Param data body dto.SysOperaLogById true "body"
|
// @Param data body dto.SysOperaLogById true "body"
|
||||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||||
// @Router /api/v1/sys-opera-log [delete]
|
// @Router /api/v1/sys-opera-log [delete]
|
||||||
|
// @Security Bearer
|
||||||
func (e SysOperaLog) Delete(c *gin.Context) {
|
func (e SysOperaLog) Delete(c *gin.Context) {
|
||||||
s := new(service.SysOperaLog)
|
s := new(service.SysOperaLog)
|
||||||
req := dto.SysOperaLogById{}
|
req := dto.SysOperaLogById{}
|
||||||
|
|||||||
+17
-15
@@ -1,6 +1,7 @@
|
|||||||
package apis
|
package apis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gin-gonic/gin/binding"
|
"github.com/gin-gonic/gin/binding"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||||
@@ -29,7 +30,7 @@ type SysPost struct {
|
|||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysPost) GetPage(c *gin.Context) {
|
func (e SysPost) GetPage(c *gin.Context) {
|
||||||
s := service.SysPost{}
|
s := service.SysPost{}
|
||||||
req := dto.SysPostSearch{}
|
req := dto.SysPostPageReq{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, binding.Form).
|
Bind(&req, binding.Form).
|
||||||
@@ -57,13 +58,13 @@ func (e SysPost) GetPage(c *gin.Context) {
|
|||||||
// @Summary 获取岗位信息
|
// @Summary 获取岗位信息
|
||||||
// @Description 获取JSON
|
// @Description 获取JSON
|
||||||
// @Tags 岗位
|
// @Tags 岗位
|
||||||
// @Param postId path int true "postId"
|
// @Param id path int true "编码"
|
||||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||||
// @Router /api/v1/post/{postId} [get]
|
// @Router /api/v1/post/{postId} [get]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysPost) Get(c *gin.Context) {
|
func (e SysPost) Get(c *gin.Context) {
|
||||||
s := service.SysPost{}
|
s := service.SysPost{}
|
||||||
req := dto.SysPostById{}
|
req := dto.SysPostGetReq{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, nil).
|
Bind(&req, nil).
|
||||||
@@ -78,7 +79,7 @@ func (e SysPost) Get(c *gin.Context) {
|
|||||||
|
|
||||||
err = s.Get(&req, &object)
|
err = s.Get(&req, &object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, "查询失败")
|
e.Error(500, err, fmt.Sprintf("岗位信息获取失败!错误详情:%s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,14 +92,14 @@ func (e SysPost) Get(c *gin.Context) {
|
|||||||
// @Tags 岗位
|
// @Tags 岗位
|
||||||
// @Accept application/json
|
// @Accept application/json
|
||||||
// @Product application/json
|
// @Product application/json
|
||||||
// @Param data body dto.SysPostControl true "data"
|
// @Param data body dto.SysPostInsertReq true "data"
|
||||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||||
// @Router /api/v1/post [post]
|
// @Router /api/v1/post [post]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysPost) Insert(c *gin.Context) {
|
func (e SysPost) Insert(c *gin.Context) {
|
||||||
s := service.SysPost{}
|
s := service.SysPost{}
|
||||||
req := dto.SysPostControl{}
|
req := dto.SysPostInsertReq{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, binding.JSON).
|
Bind(&req, binding.JSON).
|
||||||
@@ -112,7 +113,7 @@ func (e SysPost) Insert(c *gin.Context) {
|
|||||||
req.SetCreateBy(user.GetUserId(c))
|
req.SetCreateBy(user.GetUserId(c))
|
||||||
err = s.Insert(&req)
|
err = s.Insert(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Error(500, err, "创建失败")
|
e.Error(500, err, fmt.Sprintf("新建岗位失败!错误详情:%s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK(req.GetId(), "创建成功")
|
e.OK(req.GetId(), "创建成功")
|
||||||
@@ -124,14 +125,14 @@ func (e SysPost) Insert(c *gin.Context) {
|
|||||||
// @Tags 岗位
|
// @Tags 岗位
|
||||||
// @Accept application/json
|
// @Accept application/json
|
||||||
// @Product application/json
|
// @Product application/json
|
||||||
// @Param data body dto.SysPostControl true "body"
|
// @Param data body dto.SysPostUpdateReq true "body"
|
||||||
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
|
||||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||||
// @Router /api/v1/post/ [put]
|
// @Router /api/v1/post/{id} [put]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (e SysPost) Update(c *gin.Context) {
|
func (e SysPost) Update(c *gin.Context) {
|
||||||
s := service.SysPost{}
|
s := service.SysPost{}
|
||||||
req := dto.SysPostControl{}
|
req := dto.SysPostUpdateReq{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, binding.JSON, nil).
|
Bind(&req, binding.JSON, nil).
|
||||||
@@ -147,7 +148,7 @@ func (e SysPost) Update(c *gin.Context) {
|
|||||||
|
|
||||||
err = s.Update(&req)
|
err = s.Update(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Error(500, err, fmt.Sprintf("岗位更新失败!错误详情:%s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK(req.GetId(), "更新成功")
|
e.OK(req.GetId(), "更新成功")
|
||||||
@@ -157,13 +158,14 @@ func (e SysPost) Update(c *gin.Context) {
|
|||||||
// @Summary 删除岗位
|
// @Summary 删除岗位
|
||||||
// @Description 删除数据
|
// @Description 删除数据
|
||||||
// @Tags 岗位
|
// @Tags 岗位
|
||||||
// @Param id path int true "id"
|
// @Param id body dto.SysPostDeleteReq true "请求参数"
|
||||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||||
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
|
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
|
||||||
// @Router /api/v1/post [delete]
|
// @Router /api/v1/post [delete]
|
||||||
|
// @Security Bearer
|
||||||
func (e SysPost) Delete(c *gin.Context) {
|
func (e SysPost) Delete(c *gin.Context) {
|
||||||
s := service.SysPost{}
|
s := service.SysPost{}
|
||||||
req := dto.SysPostById{}
|
req := dto.SysPostDeleteReq{}
|
||||||
err := e.MakeContext(c).
|
err := e.MakeContext(c).
|
||||||
MakeOrm().
|
MakeOrm().
|
||||||
Bind(&req, binding.JSON).
|
Bind(&req, binding.JSON).
|
||||||
@@ -177,8 +179,8 @@ func (e SysPost) Delete(c *gin.Context) {
|
|||||||
req.SetUpdateBy(user.GetUserId(c))
|
req.SetUpdateBy(user.GetUserId(c))
|
||||||
err = s.Remove(&req)
|
err = s.Remove(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Logger.Error(err)
|
e.Error(500, err, fmt.Sprintf("岗位删除失败!错误详情:%s", err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.OK(req.GetId(), "删除成功")
|
e.OK(req.GetId(), "删除成功")
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,8 @@ import (
|
|||||||
common "go-admin/common/models"
|
common "go-admin/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SysApiSearch struct {
|
// SysApiGetPageReq 功能列表请求参数
|
||||||
|
type SysApiGetPageReq struct {
|
||||||
dto.Pagination `search:"-"`
|
dto.Pagination `search:"-"`
|
||||||
Title string `form:"title" search:"type:contains;column:title;table:sys_api" comment:"标题"`
|
Title string `form:"title" search:"type:contains;column:title;table:sys_api" comment:"标题"`
|
||||||
Path string `form:"path" search:"type:contains;column:path;table:sys_api" comment:"地址"`
|
Path string `form:"path" search:"type:contains;column:path;table:sys_api" comment:"地址"`
|
||||||
@@ -21,11 +22,35 @@ type SysApiOrder struct {
|
|||||||
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_api" form:"createdAtOrder"`
|
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_api" form:"createdAtOrder"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysApiSearch) GetNeedSearch() interface{} {
|
func (m *SysApiGetPageReq) GetNeedSearch() interface{} {
|
||||||
return *m
|
return *m
|
||||||
}
|
}
|
||||||
|
|
||||||
type SysApiControl struct {
|
// SysApiInsertReq 功能创建请求参数
|
||||||
|
type SysApiInsertReq struct {
|
||||||
|
Id int `json:"-" comment:"编码"` // 编码
|
||||||
|
Handle string `json:"handle" comment:"handle"`
|
||||||
|
Title string `json:"title" comment:"标题"`
|
||||||
|
Path string `json:"path" comment:"地址"`
|
||||||
|
Type string `json:"type" comment:""`
|
||||||
|
Action string `json:"action" comment:"类型"`
|
||||||
|
common.ControlBy
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SysApiInsertReq) Generate(model *models.SysApi) {
|
||||||
|
model.Handle = s.Handle
|
||||||
|
model.Title = s.Title
|
||||||
|
model.Path = s.Path
|
||||||
|
model.Type = s.Type
|
||||||
|
model.Action = s.Action
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SysApiInsertReq) GetId() interface{} {
|
||||||
|
return s.Id
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysApiUpdateReq 功能更新请求参数
|
||||||
|
type SysApiUpdateReq struct {
|
||||||
Id int `uri:"id" comment:"编码"` // 编码
|
Id int `uri:"id" comment:"编码"` // 编码
|
||||||
Handle string `json:"handle" comment:"handle"`
|
Handle string `json:"handle" comment:"handle"`
|
||||||
Title string `json:"title" comment:"标题"`
|
Title string `json:"title" comment:"标题"`
|
||||||
@@ -35,7 +60,7 @@ type SysApiControl struct {
|
|||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysApiControl) Generate(model *models.SysApi) {
|
func (s *SysApiUpdateReq) Generate(model *models.SysApi) {
|
||||||
if s.Id != 0 {
|
if s.Id != 0 {
|
||||||
model.Id = s.Id
|
model.Id = s.Id
|
||||||
}
|
}
|
||||||
@@ -46,28 +71,16 @@ func (s *SysApiControl) Generate(model *models.SysApi) {
|
|||||||
model.Action = s.Action
|
model.Action = s.Action
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysApiControl) GetId() interface{} {
|
func (s *SysApiUpdateReq) GetId() interface{} {
|
||||||
return s.Id
|
return s.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
type SysApiById struct {
|
// SysApiGetReq 功能获取请求参数
|
||||||
dto.ObjectById
|
type SysApiGetReq struct {
|
||||||
common.ControlBy
|
dto.ObjectGetReq
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysApiById) GetId() interface{} {
|
// SysApiDeleteReq 功能删除请求参数
|
||||||
if len(s.Ids) > 0 {
|
type SysApiDeleteReq struct {
|
||||||
s.Ids = append(s.Ids, s.Id)
|
dto.ObjectDeleteReq
|
||||||
return s.Ids
|
|
||||||
}
|
|
||||||
return s.Id
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SysApiById) Generate() dto.Control {
|
|
||||||
o := *s
|
|
||||||
return &o
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SysApiById) GenerateM() (common.ActiveRecord, error) {
|
|
||||||
return &models.SysApi{}, nil
|
|
||||||
}
|
}
|
||||||
@@ -27,15 +27,15 @@ func (m *SysDeptSearch) GetNeedSearch() interface{} {
|
|||||||
|
|
||||||
// SysDeptControl 增、改使用的结构体
|
// SysDeptControl 增、改使用的结构体
|
||||||
type SysDeptControl struct {
|
type SysDeptControl struct {
|
||||||
DeptId int `uri:"id" comment:"编码"` // 编码
|
DeptId int `uri:"id" comment:"编码"` // 编码
|
||||||
ParentId int `json:"parentId" comment:"上级部门"` //上级部门
|
ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门
|
||||||
DeptPath string `json:"deptPath" comment:""` //路径
|
DeptPath string `json:"deptPath" comment:""` //路径
|
||||||
DeptName string `json:"deptName" comment:"部门名称"` //部门名称
|
DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称
|
||||||
Sort int `json:"sort" comment:"排序"` //排序
|
Sort int `json:"sort" comment:"排序" vd:"?"` //排序
|
||||||
Leader string `json:"leader" comment:"负责人"` //负责人
|
Leader string `json:"leader,required" comment:"负责人" vd:"@:len($)>0;msg:validation failed:该字段不能为空"` //负责人
|
||||||
Phone string `json:"phone" comment:"手机"` //手机
|
Phone string `json:"phone" comment:"手机" vd:"?"` //手机
|
||||||
Email string `json:"email" comment:"邮箱"` //邮箱
|
Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱
|
||||||
Status int `json:"status" comment:"状态"` //状态
|
Status int `json:"status" comment:"状态" vd:"$>0"` //状态
|
||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
common "go-admin/common/models"
|
common "go-admin/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SysOperaLogSearch struct {
|
type SysOperaLogGetPageReq struct {
|
||||||
dto.Pagination `search:"-"`
|
dto.Pagination `search:"-"`
|
||||||
Title string `form:"title" search:"type:contains;column:title;table:sys_opera_log" comment:"操作模块"`
|
Title string `form:"title" search:"type:contains;column:title;table:sys_opera_log" comment:"操作模块"`
|
||||||
Method string `form:"method" search:"type:contains;column:method;table:sys_opera_log" comment:"函数"`
|
Method string `form:"method" search:"type:contains;column:method;table:sys_opera_log" comment:"函数"`
|
||||||
@@ -25,7 +25,7 @@ type SysOperaLogOrder struct {
|
|||||||
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_opera_log" form:"createdAtOrder"`
|
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_opera_log" form:"createdAtOrder"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysOperaLogSearch) GetNeedSearch() interface{} {
|
func (m *SysOperaLogGetPageReq) GetNeedSearch() interface{} {
|
||||||
return *m
|
return *m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"go-admin/common/dto"
|
"go-admin/common/dto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SysPostSearch 列表或者搜索使用结构体
|
// SysPostPageReq 列表或者搜索使用结构体
|
||||||
type SysPostSearch struct {
|
type SysPostPageReq struct {
|
||||||
dto.Pagination `search:"-"`
|
dto.Pagination `search:"-"`
|
||||||
PostId int `form:"postId" search:"type:exact;column:post_id;table:sys_post" comment:"id"` // id
|
PostId int `form:"postId" search:"type:exact;column:post_id;table:sys_post" comment:"id"` // id
|
||||||
PostName string `form:"postName" search:"type:contains;column:post_name;table:sys_post" comment:"名称"` // 名称
|
PostName string `form:"postName" search:"type:contains;column:post_name;table:sys_post" comment:"名称"` // 名称
|
||||||
@@ -18,12 +18,12 @@ type SysPostSearch struct {
|
|||||||
Remark string `form:"remark" search:"type:exact;column:remark;table:sys_post" comment:"备注"` // 备注
|
Remark string `form:"remark" search:"type:exact;column:remark;table:sys_post" comment:"备注"` // 备注
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysPostSearch) GetNeedSearch() interface{} {
|
func (m *SysPostPageReq) GetNeedSearch() interface{} {
|
||||||
return *m
|
return *m
|
||||||
}
|
}
|
||||||
|
|
||||||
// SysPostControl 增、改使用的结构体
|
// SysPostInsertReq 增使用的结构体
|
||||||
type SysPostControl struct {
|
type SysPostInsertReq struct {
|
||||||
PostId int `uri:"id" comment:"id"`
|
PostId int `uri:"id" comment:"id"`
|
||||||
PostName string `form:"postName" comment:"名称"`
|
PostName string `form:"postName" comment:"名称"`
|
||||||
PostCode string `form:"postCode" comment:"编码"`
|
PostCode string `form:"postCode" comment:"编码"`
|
||||||
@@ -33,11 +33,7 @@ type SysPostControl struct {
|
|||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
|
func (s *SysPostInsertReq) Generate(model *models.SysPost) {
|
||||||
func (s *SysPostControl) Generate(model *models.SysPost) {
|
|
||||||
if s.PostId != 0 {
|
|
||||||
model.PostId = s.PostId
|
|
||||||
}
|
|
||||||
model.PostName = s.PostName
|
model.PostName = s.PostName
|
||||||
model.PostCode = s.PostCode
|
model.PostCode = s.PostCode
|
||||||
model.Sort = s.Sort
|
model.Sort = s.Sort
|
||||||
@@ -52,18 +48,28 @@ func (s *SysPostControl) Generate(model *models.SysPost) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetId 获取数据对应的ID
|
// GetId 获取数据对应的ID
|
||||||
func (s *SysPostControl) GetId() interface{} {
|
func (s *SysPostInsertReq) GetId() interface{} {
|
||||||
return s.PostId
|
return s.PostId
|
||||||
}
|
}
|
||||||
|
|
||||||
// SysPostById 获取单个或者删除的结构体
|
// SysPostUpdateReq 改使用的结构体
|
||||||
type SysPostById struct {
|
type SysPostUpdateReq struct {
|
||||||
Id int `uri:"id"`
|
PostId int `uri:"id" comment:"id"`
|
||||||
Ids []int `json:"ids"`
|
PostName string `form:"postName" comment:"名称"`
|
||||||
|
PostCode string `form:"postCode" comment:"编码"`
|
||||||
|
Sort int `form:"sort" comment:"排序"`
|
||||||
|
Status int `form:"status" comment:"状态"`
|
||||||
|
Remark string `form:"remark" comment:"备注"`
|
||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysPostById) Generate(model *models.SysPost) {
|
func (s *SysPostUpdateReq) Generate(model *models.SysPost) {
|
||||||
|
model.PostId = s.PostId
|
||||||
|
model.PostName = s.PostName
|
||||||
|
model.PostCode = s.PostCode
|
||||||
|
model.Sort = s.Sort
|
||||||
|
model.Status = s.Status
|
||||||
|
model.Remark = s.Remark
|
||||||
if s.ControlBy.UpdateBy != 0 {
|
if s.ControlBy.UpdateBy != 0 {
|
||||||
model.UpdateBy = s.UpdateBy
|
model.UpdateBy = s.UpdateBy
|
||||||
}
|
}
|
||||||
@@ -72,14 +78,34 @@ func (s *SysPostById) Generate(model *models.SysPost) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysPostById) GetId() interface{} {
|
func (s *SysPostUpdateReq) GetId() interface{} {
|
||||||
if len(s.Ids) > 0 {
|
return s.PostId
|
||||||
s.Ids = append(s.Ids, s.Id)
|
}
|
||||||
return s.Ids
|
|
||||||
}
|
// SysPostGetReq 获取单个的结构体
|
||||||
|
type SysPostGetReq struct {
|
||||||
|
Id int `uri:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SysPostGetReq) GetId() interface{} {
|
||||||
return s.Id
|
return s.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SysPostById) GenerateM() (*models.SysPost, error) {
|
// SysPostDeleteReq 删除的结构体
|
||||||
return &models.SysPost{}, nil
|
type SysPostDeleteReq struct {
|
||||||
|
Ids []int `json:"ids"`
|
||||||
|
common.ControlBy
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SysPostDeleteReq) Generate(model *models.SysPost) {
|
||||||
|
if s.ControlBy.UpdateBy != 0 {
|
||||||
|
model.UpdateBy = s.UpdateBy
|
||||||
|
}
|
||||||
|
if s.ControlBy.CreateBy != 0 {
|
||||||
|
model.CreateBy = s.CreateBy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SysPostDeleteReq) GetId() interface{} {
|
||||||
|
return s.Ids
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
common "go-admin/common/models"
|
common "go-admin/common/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SysUserSearch struct {
|
type SysUserGetPageReq struct {
|
||||||
dto.Pagination `search:"-"`
|
dto.Pagination `search:"-"`
|
||||||
UserId int `form:"userId" search:"type:exact;column:user_id;table:sys_user" comment:"用户ID"`
|
UserId int `form:"userId" search:"type:exact;column:user_id;table:sys_user" comment:"用户ID"`
|
||||||
Username string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
|
Username string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
|
||||||
@@ -33,7 +33,7 @@ type DeptJoin struct {
|
|||||||
DeptId string `search:"type:contains;column:dept_path;table:sys_dept" form:"deptId"`
|
DeptId string `search:"type:contains;column:dept_path;table:sys_dept" form:"deptId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SysUserSearch) GetNeedSearch() interface{} {
|
func (m *SysUserGetPageReq) GetNeedSearch() interface{} {
|
||||||
return *m
|
return *m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type SysApi struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPage 获取SysApi列表
|
// GetPage 获取SysApi列表
|
||||||
func (e *SysApi) GetPage(c *dto.SysApiSearch, p *actions.DataPermission, list *[]models.SysApi, count *int64) error {
|
func (e *SysApi) GetPage(c *dto.SysApiGetPageReq, p *actions.DataPermission, list *[]models.SysApi, count *int64) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.SysApi
|
var data models.SysApi
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ func (e *SysApi) GetPage(c *dto.SysApiSearch, p *actions.DataPermission, list *[
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get 获取SysApi对象with id
|
// Get 获取SysApi对象with id
|
||||||
func (e *SysApi) Get(d *dto.SysApiById, p *actions.DataPermission, model *models.SysApi) *SysApi {
|
func (e *SysApi) Get(d *dto.SysApiGetReq, p *actions.DataPermission, model *models.SysApi) *SysApi {
|
||||||
var data models.SysApi
|
var data models.SysApi
|
||||||
err := e.Orm.Model(&data).
|
err := e.Orm.Model(&data).
|
||||||
Scopes(
|
Scopes(
|
||||||
@@ -61,7 +61,7 @@ func (e *SysApi) Get(d *dto.SysApiById, p *actions.DataPermission, model *models
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update 修改SysApi对象
|
// Update 修改SysApi对象
|
||||||
func (e *SysApi) Update(c *dto.SysApiControl, p *actions.DataPermission) error {
|
func (e *SysApi) Update(c *dto.SysApiUpdateReq, p *actions.DataPermission) error {
|
||||||
var model = models.SysApi{}
|
var model = models.SysApi{}
|
||||||
db := e.Orm.Debug().First(&model, c.GetId())
|
db := e.Orm.Debug().First(&model, c.GetId())
|
||||||
if db.RowsAffected == 0 {
|
if db.RowsAffected == 0 {
|
||||||
@@ -78,7 +78,7 @@ func (e *SysApi) Update(c *dto.SysApiControl, p *actions.DataPermission) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove 删除SysApi
|
// Remove 删除SysApi
|
||||||
func (e *SysApi) Remove(d *dto.SysApiById, p *actions.DataPermission) error {
|
func (e *SysApi) Remove(d *dto.SysApiDeleteReq, p *actions.DataPermission) error {
|
||||||
var data models.SysApi
|
var data models.SysApi
|
||||||
|
|
||||||
db := e.Orm.Model(&data).
|
db := e.Orm.Model(&data).
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type SysOperaLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPage 获取SysOperaLog列表
|
// GetPage 获取SysOperaLog列表
|
||||||
func (e *SysOperaLog) GetPage(c *dto.SysOperaLogSearch, list *[]models.SysOperaLog, count *int64) error {
|
func (e *SysOperaLog) GetPage(c *dto.SysOperaLogGetPageReq, list *[]models.SysOperaLog, count *int64) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.SysOperaLog
|
var data models.SysOperaLog
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type SysPost struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPage 获取SysPost列表
|
// GetPage 获取SysPost列表
|
||||||
func (e *SysPost) GetPage(c *dto.SysPostSearch, list *[]models.SysPost, count *int64) error {
|
func (e *SysPost) GetPage(c *dto.SysPostPageReq, list *[]models.SysPost, count *int64) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.SysPost
|
var data models.SysPost
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ func (e *SysPost) GetPage(c *dto.SysPostSearch, list *[]models.SysPost, count *i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get 获取SysPost对象
|
// Get 获取SysPost对象
|
||||||
func (e *SysPost) Get(d *dto.SysPostById, model *models.SysPost) error {
|
func (e *SysPost) Get(d *dto.SysPostGetReq, model *models.SysPost) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.SysPost
|
var data models.SysPost
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ func (e *SysPost) Get(d *dto.SysPostById, model *models.SysPost) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Insert 创建SysPost对象
|
// Insert 创建SysPost对象
|
||||||
func (e *SysPost) Insert(c *dto.SysPostControl) error {
|
func (e *SysPost) Insert(c *dto.SysPostInsertReq) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.SysPost
|
var data models.SysPost
|
||||||
c.Generate(&data)
|
c.Generate(&data)
|
||||||
@@ -68,7 +68,7 @@ func (e *SysPost) Insert(c *dto.SysPostControl) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update 修改SysPost对象
|
// Update 修改SysPost对象
|
||||||
func (e *SysPost) Update(c *dto.SysPostControl) error {
|
func (e *SysPost) Update(c *dto.SysPostUpdateReq) error {
|
||||||
var err error
|
var err error
|
||||||
var model = models.SysPost{}
|
var model = models.SysPost{}
|
||||||
e.Orm.First(&model, c.GetId())
|
e.Orm.First(&model, c.GetId())
|
||||||
@@ -87,7 +87,7 @@ func (e *SysPost) Update(c *dto.SysPostControl) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove 删除SysPost
|
// Remove 删除SysPost
|
||||||
func (e *SysPost) Remove(d *dto.SysPostById) error {
|
func (e *SysPost) Remove(d *dto.SysPostDeleteReq) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.SysPost
|
var data models.SysPost
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type SysUser struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPage 获取SysUser列表
|
// GetPage 获取SysUser列表
|
||||||
func (e *SysUser) GetPage(c *dto.SysUserSearch, p *actions.DataPermission, list *[]models.SysUser, count *int64) error {
|
func (e *SysUser) GetPage(c *dto.SysUserGetPageReq, p *actions.DataPermission, list *[]models.SysUser, count *int64) error {
|
||||||
var err error
|
var err error
|
||||||
var data models.SysUser
|
var data models.SysUser
|
||||||
|
|
||||||
|
|||||||
@@ -51,3 +51,56 @@ func (s *ObjectById) GetId() interface{} {
|
|||||||
}
|
}
|
||||||
return s.Id
|
return s.Id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ObjectGetReq struct {
|
||||||
|
Id int `uri:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ObjectGetReq) Bind(ctx *gin.Context) error {
|
||||||
|
var err error
|
||||||
|
log := api.GetRequestLogger(ctx)
|
||||||
|
err = ctx.ShouldBindUri(s)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("ShouldBindUri error: %s", err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = vd.Validate(s); err != nil {
|
||||||
|
log.Errorf("Validate error: %s", err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ObjectGetReq) GetId() interface{} {
|
||||||
|
return s.Id
|
||||||
|
}
|
||||||
|
|
||||||
|
type ObjectDeleteReq struct {
|
||||||
|
Ids []int `json:"ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ObjectDeleteReq) Bind(ctx *gin.Context) error {
|
||||||
|
var err error
|
||||||
|
log := api.GetRequestLogger(ctx)
|
||||||
|
err = ctx.ShouldBind(&s)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("ShouldBind error: %s", err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(s.Ids) > 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if s.Ids == nil {
|
||||||
|
s.Ids = make([]int, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = vd.Validate(s); err != nil {
|
||||||
|
log.Errorf("Validate error: %s", err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ObjectDeleteReq) GetId() interface{} {
|
||||||
|
return s.Ids
|
||||||
|
}
|
||||||
Reference in new issue
Block a user