sys_post.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package dto
  2. import (
  3. "go-admin/app/admin/models"
  4. common "go-admin/common/models"
  5. "go-admin/common/dto"
  6. )
  7. // SysPostPageReq 列表或者搜索使用结构体
  8. type SysPostPageReq struct {
  9. dto.Pagination `search:"-"`
  10. PostId int `form:"postId" search:"type:exact;column:post_id;table:sys_post" comment:"id"` // id
  11. PostName string `form:"postName" search:"type:contains;column:post_name;table:sys_post" comment:"名称"` // 名称
  12. PostCode string `form:"postCode" search:"type:contains;column:post_code;table:sys_post" comment:"编码"` // 编码
  13. Sort int `form:"sort" search:"type:exact;column:sort;table:sys_post" comment:"排序"` // 排序
  14. Status int `form:"status" search:"type:exact;column:status;table:sys_post" comment:"状态"` // 状态
  15. Remark string `form:"remark" search:"type:exact;column:remark;table:sys_post" comment:"备注"` // 备注
  16. }
  17. func (m *SysPostPageReq) GetNeedSearch() interface{} {
  18. return *m
  19. }
  20. // SysPostInsertReq 增使用的结构体
  21. type SysPostInsertReq struct {
  22. PostId int `uri:"id" comment:"id"`
  23. PostName string `form:"postName" comment:"名称"`
  24. PostCode string `form:"postCode" comment:"编码"`
  25. Sort int `form:"sort" comment:"排序"`
  26. Status int `form:"status" comment:"状态"`
  27. Remark string `form:"remark" comment:"备注"`
  28. common.ControlBy
  29. }
  30. func (s *SysPostInsertReq) Generate(model *models.SysPost) {
  31. model.PostName = s.PostName
  32. model.PostCode = s.PostCode
  33. model.Sort = s.Sort
  34. model.Status = s.Status
  35. model.Remark = s.Remark
  36. if s.ControlBy.UpdateBy != 0 {
  37. model.UpdateBy = s.UpdateBy
  38. }
  39. if s.ControlBy.CreateBy != 0 {
  40. model.CreateBy = s.CreateBy
  41. }
  42. }
  43. // GetId 获取数据对应的ID
  44. func (s *SysPostInsertReq) GetId() interface{} {
  45. return s.PostId
  46. }
  47. // SysPostUpdateReq 改使用的结构体
  48. type SysPostUpdateReq struct {
  49. PostId int `uri:"id" comment:"id"`
  50. PostName string `form:"postName" comment:"名称"`
  51. PostCode string `form:"postCode" comment:"编码"`
  52. Sort int `form:"sort" comment:"排序"`
  53. Status int `form:"status" comment:"状态"`
  54. Remark string `form:"remark" comment:"备注"`
  55. common.ControlBy
  56. }
  57. func (s *SysPostUpdateReq) Generate(model *models.SysPost) {
  58. model.PostId = s.PostId
  59. model.PostName = s.PostName
  60. model.PostCode = s.PostCode
  61. model.Sort = s.Sort
  62. model.Status = s.Status
  63. model.Remark = s.Remark
  64. if s.ControlBy.UpdateBy != 0 {
  65. model.UpdateBy = s.UpdateBy
  66. }
  67. if s.ControlBy.CreateBy != 0 {
  68. model.CreateBy = s.CreateBy
  69. }
  70. }
  71. func (s *SysPostUpdateReq) GetId() interface{} {
  72. return s.PostId
  73. }
  74. // SysPostGetReq 获取单个的结构体
  75. type SysPostGetReq struct {
  76. Id int `uri:"id"`
  77. }
  78. func (s *SysPostGetReq) GetId() interface{} {
  79. return s.Id
  80. }
  81. // SysPostDeleteReq 删除的结构体
  82. type SysPostDeleteReq struct {
  83. Ids []int `json:"ids"`
  84. common.ControlBy
  85. }
  86. func (s *SysPostDeleteReq) Generate(model *models.SysPost) {
  87. if s.ControlBy.UpdateBy != 0 {
  88. model.UpdateBy = s.UpdateBy
  89. }
  90. if s.ControlBy.CreateBy != 0 {
  91. model.CreateBy = s.CreateBy
  92. }
  93. }
  94. func (s *SysPostDeleteReq) GetId() interface{} {
  95. return s.Ids
  96. }