sys_dept.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package dto
  2. import (
  3. "Medical_OAuth/app/admin/model"
  4. common "Medical_OAuth/common/model"
  5. )
  6. // SysDeptGetPageReq 列表或者搜索使用结构体
  7. type SysDeptGetPageReq struct {
  8. DeptName string `form:"deptName" search:"type:contains;column:dept_name;table:sys_dept" example:"部门名称"` //部门名称
  9. DeptId int `form:"deptId" search:"-" swaggerignore:"true"` //部门名称
  10. SysDeptOrder
  11. }
  12. type SysDeptOrder struct {
  13. SortOrder string `search:"type:order;column:sort;table:sys_dept" form:"sort" default:"asc"` //排序 ASC 升序 DESC 降序
  14. }
  15. func (m *SysDeptGetPageReq) GetNeedSearch() interface{} {
  16. return *m
  17. }
  18. type SysDeptInsertReq struct {
  19. Id int `json:"id" swaggerignore:"true"`
  20. ParentId int `json:"parentId" example:"0" vd:"?"` //上级部门
  21. DeptName string `json:"deptName" example:"部门名称" vd:"len($)>0"` //部门名称
  22. Sort int `json:"sort" swaggerignore:"true"` //排序
  23. Status int `json:"status" swaggerignore:"true"` //状态 1-停用 2-正常
  24. DeptPath string `swaggerignore:"true"` //路径
  25. common.ControlBy `swaggerignore:"true"`
  26. }
  27. func (s *SysDeptInsertReq) Generate(model *model.SysDept) {
  28. if s.Id != 0 {
  29. model.Id = s.Id
  30. }
  31. model.DeptName = s.DeptName
  32. model.ParentId = s.ParentId
  33. model.Sort = 0
  34. model.Status = 2
  35. }
  36. // GetId 获取数据对应的ID
  37. func (s *SysDeptInsertReq) GetId() interface{} {
  38. return s.Id
  39. }
  40. type SysDeptUpdateReq struct {
  41. Id int `json:"id" comment:"编码"` // 编码
  42. DeptName string `json:"deptName" example:"部门名称" vd:"len($)>0"` //部门名称
  43. Status int `json:"status" swaggerignore:"true"` //状态 1-停用 2-正常
  44. Sort int `json:"sort" swaggerignore:"true"` //排序
  45. DeptPath string `swaggerignore:"true"` //路径
  46. common.ControlBy `swaggerignore:"true"`
  47. }
  48. // Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型
  49. func (s *SysDeptUpdateReq) Generate(model *model.SysDept) {
  50. if s.Id != 0 {
  51. model.Id = s.Id
  52. }
  53. model.DeptName = s.DeptName
  54. model.Sort = 0
  55. model.Status = 2
  56. }
  57. // GetId 获取数据对应的ID
  58. func (s *SysDeptUpdateReq) GetId() interface{} {
  59. return s.Id
  60. }
  61. type SysDeptGetReq struct {
  62. Id int `uri:"id"`
  63. }
  64. func (s *SysDeptGetReq) GetId() interface{} {
  65. return s.Id
  66. }
  67. type SysDeptGetRootIDReq struct {
  68. Id int `form:"id"`
  69. }
  70. func (s *SysDeptGetRootIDReq) GetId() interface{} {
  71. return s.Id
  72. }
  73. type SysDeptDeleteReq struct {
  74. Id int `json:"id"`
  75. }
  76. func (s *SysDeptDeleteReq) GetId() interface{} {
  77. return s.Id
  78. }
  79. type DeptLabel struct {
  80. Id int `gorm:"-" json:"id"`
  81. Label string `gorm:"-" json:"label"`
  82. Children []DeptLabel `gorm:"-" json:"children"`
  83. }
  84. type SysDeptEnterReq struct {
  85. Id int `json:"id"`
  86. }
  87. func (s *SysDeptEnterReq) GetId() interface{} {
  88. return s.Id
  89. }