sys_dept.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package dto
  2. import (
  3. "go-admin/app/admin/models"
  4. common "go-admin/common/models"
  5. )
  6. // SysDeptGetPageReq 列表或者搜索使用结构体
  7. type SysDeptGetPageReq struct {
  8. DeptId int `form:"deptId" search:"type:exact;column:dept_id;table:sys_dept" comment:"id"` //id
  9. ParentId int `form:"parentId" search:"type:exact;column:parent_id;table:sys_dept" comment:"上级部门"` //上级部门
  10. DeptPath string `form:"deptPath" search:"type:exact;column:dept_path;table:sys_dept" comment:""` //路径
  11. DeptName string `form:"deptName" search:"type:exact;column:dept_name;table:sys_dept" comment:"部门名称"` //部门名称
  12. Sort int `form:"sort" search:"type:exact;column:sort;table:sys_dept" comment:"排序"` //排序
  13. Leader string `form:"leader" search:"type:exact;column:leader;table:sys_dept" comment:"负责人"` //负责人
  14. Phone string `form:"phone" search:"type:exact;column:phone;table:sys_dept" comment:"手机"` //手机
  15. Email string `form:"email" search:"type:exact;column:email;table:sys_dept" comment:"邮箱"` //邮箱
  16. Status string `form:"status" search:"type:exact;column:status;table:sys_dept" comment:"状态"` //状态
  17. }
  18. func (m *SysDeptGetPageReq) GetNeedSearch() interface{} {
  19. return *m
  20. }
  21. type SysDeptInsertReq struct {
  22. DeptId int `uri:"id" comment:"编码"` // 编码
  23. ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门
  24. DeptPath string `json:"deptPath" comment:""` //路径
  25. DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称
  26. Sort int `json:"sort" comment:"排序" vd:"?"` //排序
  27. Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人
  28. Phone string `json:"phone" comment:"手机" vd:"?"` //手机
  29. Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱
  30. Status int `json:"status" comment:"状态" vd:"$>0"` //状态
  31. common.ControlBy
  32. }
  33. func (s *SysDeptInsertReq) Generate(model *models.SysDept) {
  34. if s.DeptId != 0 {
  35. model.DeptId = s.DeptId
  36. }
  37. model.DeptName = s.DeptName
  38. model.ParentId = s.ParentId
  39. model.DeptPath = s.DeptPath
  40. model.Sort = s.Sort
  41. model.Leader = s.Leader
  42. model.Phone = s.Phone
  43. model.Email = s.Email
  44. model.Status = s.Status
  45. }
  46. // GetId 获取数据对应的ID
  47. func (s *SysDeptInsertReq) GetId() interface{} {
  48. return s.DeptId
  49. }
  50. type SysDeptUpdateReq struct {
  51. DeptId int `uri:"id" comment:"编码"` // 编码
  52. ParentId int `json:"parentId" comment:"上级部门" vd:"?"` //上级部门
  53. DeptPath string `json:"deptPath" comment:""` //路径
  54. DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"` //部门名称
  55. Sort int `json:"sort" comment:"排序" vd:"?"` //排序
  56. Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人
  57. Phone string `json:"phone" comment:"手机" vd:"?"` //手机
  58. Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱
  59. Status int `json:"status" comment:"状态" vd:"$>0"` //状态
  60. common.ControlBy
  61. }
  62. // Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型
  63. func (s *SysDeptUpdateReq) Generate(model *models.SysDept) {
  64. if s.DeptId != 0 {
  65. model.DeptId = s.DeptId
  66. }
  67. model.DeptName = s.DeptName
  68. model.ParentId = s.ParentId
  69. model.DeptPath = s.DeptPath
  70. model.Sort = s.Sort
  71. model.Leader = s.Leader
  72. model.Phone = s.Phone
  73. model.Email = s.Email
  74. model.Status = s.Status
  75. }
  76. // GetId 获取数据对应的ID
  77. func (s *SysDeptUpdateReq) GetId() interface{} {
  78. return s.DeptId
  79. }
  80. type SysDeptGetReq struct {
  81. Id int `uri:"id"`
  82. }
  83. func (s *SysDeptGetReq) GetId() interface{} {
  84. return s.Id
  85. }
  86. type SysDeptDeleteReq struct {
  87. Ids []int `json:"ids"`
  88. }
  89. func (s *SysDeptDeleteReq) GetId() interface{} {
  90. return s.Ids
  91. }
  92. type DeptLabel struct {
  93. Id int `gorm:"-" json:"id"`
  94. Label string `gorm:"-" json:"label"`
  95. Children []DeptLabel `gorm:"-" json:"children"`
  96. }