sys_org.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package dto
  2. import (
  3. "IotAdmin/app/system/models"
  4. common "IotAdmin/common/models"
  5. )
  6. // SysOrgGetPageReq 列表或者搜索使用结构体
  7. type SysOrgGetPageReq struct {
  8. OrgId int `form:"orgId" search:"type:exact;column:org_id;table:sys_org" comment:"id"` //id
  9. ParentId int `form:"parentId" search:"type:exact;column:parent_id;table:sys_org" comment:"上级组织机构"` //上级组织机构
  10. OrgPath string `form:"orgPath" search:"type:exact;column:org_path;table:sys_org" comment:""` //路径
  11. OrgName string `form:"orgName" search:"type:exact;column:org_name;table:sys_org" comment:"组织机构名称"` //组织机构名称
  12. Sort int `form:"sort" search:"type:exact;column:sort;table:sys_org" comment:"排序"` //排序
  13. Leader string `form:"leader" search:"type:exact;column:leader;table:sys_org" comment:"负责人"` //负责人
  14. Phone string `form:"phone" search:"type:exact;column:phone;table:sys_org" comment:"手机"` //手机
  15. Email string `form:"email" search:"type:exact;column:email;table:sys_org" comment:"邮箱"` //邮箱
  16. Status string `form:"status" search:"type:exact;column:status;table:sys_org" comment:"状态"` //状态
  17. }
  18. func (m *SysOrgGetPageReq) GetNeedSearch() interface{} {
  19. return *m
  20. }
  21. type SysOrgInsertReq struct {
  22. OrgId int `uri:"id" comment:"编码"` // 编码
  23. ParentId int `json:"parentId" comment:"上级组织机构" vd:"?"` //上级组织机构
  24. OrgPath string `json:"orgPath" comment:""` //路径
  25. OrgName string `json:"orgName" 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 *SysOrgInsertReq) Generate(model *models.SysOrg) {
  34. if s.OrgId != 0 {
  35. model.OrgId = s.OrgId
  36. }
  37. model.OrgName = s.OrgName
  38. model.ParentId = s.ParentId
  39. model.OrgPath = s.OrgPath
  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 *SysOrgInsertReq) GetId() interface{} {
  48. return s.OrgId
  49. }
  50. type SysOrgUpdateReq struct {
  51. OrgId int `uri:"id" comment:"编码"` // 编码
  52. ParentId int `json:"parentId" comment:"上级组织机构" vd:"?"` //上级组织机构
  53. OrgPath string `json:"orgPath" comment:""` //路径
  54. OrgName string `json:"orgName" 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 结构体数据转化 从 SysOrgControl 至 Org 对应的模型
  63. func (s *SysOrgUpdateReq) Generate(model *models.SysOrg) {
  64. if s.OrgId != 0 {
  65. model.OrgId = s.OrgId
  66. }
  67. model.OrgName = s.OrgName
  68. model.ParentId = s.ParentId
  69. model.OrgPath = s.OrgPath
  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 *SysOrgUpdateReq) GetId() interface{} {
  78. return s.OrgId
  79. }
  80. type SysOrgGetReq struct {
  81. Id int `uri:"id"`
  82. }
  83. func (s *SysOrgGetReq) GetId() interface{} {
  84. return s.Id
  85. }
  86. type SysOrgDeleteReq struct {
  87. Ids []int `json:"ids"`
  88. }
  89. func (s *SysOrgDeleteReq) GetId() interface{} {
  90. return s.Ids
  91. }
  92. type OrgLabel struct {
  93. Id int `gorm:"-" json:"id"`
  94. Label string `gorm:"-" json:"label"`
  95. Children []OrgLabel `gorm:"-" json:"children"`
  96. }