mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 10:13:01 +00:00
refactor🎨: 修改请求参数命名
This commit is contained in:
@@ -6,7 +6,8 @@ import (
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type SysApiSearch struct {
|
||||
// SysApiGetPageReq 功能列表请求参数
|
||||
type SysApiGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
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:"地址"`
|
||||
@@ -21,11 +22,35 @@ type SysApiOrder struct {
|
||||
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
|
||||
}
|
||||
|
||||
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:"编码"` // 编码
|
||||
Handle string `json:"handle" comment:"handle"`
|
||||
Title string `json:"title" comment:"标题"`
|
||||
@@ -35,7 +60,7 @@ type SysApiControl struct {
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysApiControl) Generate(model *models.SysApi) {
|
||||
func (s *SysApiUpdateReq) Generate(model *models.SysApi) {
|
||||
if s.Id != 0 {
|
||||
model.Id = s.Id
|
||||
}
|
||||
@@ -46,28 +71,16 @@ func (s *SysApiControl) Generate(model *models.SysApi) {
|
||||
model.Action = s.Action
|
||||
}
|
||||
|
||||
func (s *SysApiControl) GetId() interface{} {
|
||||
func (s *SysApiUpdateReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type SysApiById struct {
|
||||
dto.ObjectById
|
||||
common.ControlBy
|
||||
// SysApiGetReq 功能获取请求参数
|
||||
type SysApiGetReq struct {
|
||||
dto.ObjectGetReq
|
||||
}
|
||||
|
||||
func (s *SysApiById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
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
|
||||
// SysApiDeleteReq 功能删除请求参数
|
||||
type SysApiDeleteReq struct {
|
||||
dto.ObjectDeleteReq
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ func (m *SysDeptSearch) GetNeedSearch() interface{} {
|
||||
|
||||
// SysDeptControl 增、改使用的结构体
|
||||
type SysDeptControl struct {
|
||||
DeptId int `uri:"id" comment:"编码"` // 编码
|
||||
ParentId int `json:"parentId" comment:"上级部门"` //上级部门
|
||||
DeptPath string `json:"deptPath" comment:""` //路径
|
||||
DeptName string `json:"deptName" comment:"部门名称"` //部门名称
|
||||
Sort int `json:"sort" comment:"排序"` //排序
|
||||
Leader string `json:"leader" comment:"负责人"` //负责人
|
||||
Phone string `json:"phone" comment:"手机"` //手机
|
||||
Email string `json:"email" comment:"邮箱"` //邮箱
|
||||
Status int `json:"status" comment:"状态"` //状态
|
||||
DeptId int `uri:"id" comment:"编码"` // 编码
|
||||
ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门
|
||||
DeptPath string `json:"deptPath" comment:""` //路径
|
||||
DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称
|
||||
Sort int `json:"sort" comment:"排序" vd:"?"` //排序
|
||||
Leader string `json:"leader,required" comment:"负责人" vd:"@:len($)>0;msg:validation failed:该字段不能为空"` //负责人
|
||||
Phone string `json:"phone" comment:"手机" vd:"?"` //手机
|
||||
Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱
|
||||
Status int `json:"status" comment:"状态" vd:"$>0"` //状态
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type SysOperaLogSearch struct {
|
||||
type SysOperaLogGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
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:"函数"`
|
||||
@@ -25,7 +25,7 @@ type SysOperaLogOrder struct {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"go-admin/common/dto"
|
||||
)
|
||||
|
||||
// SysPostSearch 列表或者搜索使用结构体
|
||||
type SysPostSearch struct {
|
||||
// SysPostPageReq 列表或者搜索使用结构体
|
||||
type SysPostPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
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:"名称"` // 名称
|
||||
@@ -18,12 +18,12 @@ type SysPostSearch struct {
|
||||
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
|
||||
}
|
||||
|
||||
// SysPostControl 增、改使用的结构体
|
||||
type SysPostControl struct {
|
||||
// SysPostInsertReq 增使用的结构体
|
||||
type SysPostInsertReq struct {
|
||||
PostId int `uri:"id" comment:"id"`
|
||||
PostName string `form:"postName" comment:"名称"`
|
||||
PostCode string `form:"postCode" comment:"编码"`
|
||||
@@ -33,11 +33,7 @@ type SysPostControl struct {
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
|
||||
func (s *SysPostControl) Generate(model *models.SysPost) {
|
||||
if s.PostId != 0 {
|
||||
model.PostId = s.PostId
|
||||
}
|
||||
func (s *SysPostInsertReq) Generate(model *models.SysPost) {
|
||||
model.PostName = s.PostName
|
||||
model.PostCode = s.PostCode
|
||||
model.Sort = s.Sort
|
||||
@@ -52,18 +48,28 @@ func (s *SysPostControl) Generate(model *models.SysPost) {
|
||||
}
|
||||
|
||||
// GetId 获取数据对应的ID
|
||||
func (s *SysPostControl) GetId() interface{} {
|
||||
func (s *SysPostInsertReq) GetId() interface{} {
|
||||
return s.PostId
|
||||
}
|
||||
|
||||
// SysPostById 获取单个或者删除的结构体
|
||||
type SysPostById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
// SysPostUpdateReq 改使用的结构体
|
||||
type SysPostUpdateReq struct {
|
||||
PostId int `uri:"id" comment:"id"`
|
||||
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
|
||||
}
|
||||
|
||||
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 {
|
||||
model.UpdateBy = s.UpdateBy
|
||||
}
|
||||
@@ -72,14 +78,34 @@ func (s *SysPostById) Generate(model *models.SysPost) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SysPostById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
func (s *SysPostUpdateReq) GetId() interface{} {
|
||||
return s.PostId
|
||||
}
|
||||
|
||||
// SysPostGetReq 获取单个的结构体
|
||||
type SysPostGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
|
||||
func (s *SysPostGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysPostById) GenerateM() (*models.SysPost, error) {
|
||||
return &models.SysPost{}, nil
|
||||
// SysPostDeleteReq 删除的结构体
|
||||
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"
|
||||
)
|
||||
|
||||
type SysUserSearch struct {
|
||||
type SysUserGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
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:"用户名"`
|
||||
@@ -33,7 +33,7 @@ type DeptJoin struct {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user