sys_config.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package dto
  2. import (
  3. "go-admin/app/admin/models"
  4. "go-admin/common/dto"
  5. common "go-admin/common/models"
  6. )
  7. // SysConfigGetPageReq 列表或者搜索使用结构体
  8. type SysConfigGetPageReq struct {
  9. dto.Pagination `search:"-"`
  10. ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config"`
  11. ConfigKey string `form:"configKey" search:"type:contains;column:config_key;table:sys_config"`
  12. ConfigType string `form:"configType" search:"type:exact;column:config_type;table:sys_config"`
  13. IsFrontend string `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"`
  14. SysConfigOrder
  15. }
  16. type SysConfigOrder struct {
  17. IdOrder string `search:"type:order;column:id;table:sys_config" form:"idOrder"`
  18. ConfigNameOrder string `search:"type:order;column:config_name;table:sys_config" form:"configNameOrder"`
  19. ConfigKeyOrder string `search:"type:order;column:config_key;table:sys_config" form:"configKeyOrder"`
  20. ConfigTypeOrder string `search:"type:order;column:config_type;table:sys_config" form:"configTypeOrder"`
  21. CreatedAtOrder string `search:"type:order;column:created_at;table:sys_config" form:"createdAtOrder"`
  22. }
  23. func (m *SysConfigGetPageReq) GetNeedSearch() interface{} {
  24. return *m
  25. }
  26. type SysConfigGetToSysAppReq struct {
  27. IsFrontend string `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"`
  28. }
  29. func (m *SysConfigGetToSysAppReq) GetNeedSearch() interface{} {
  30. return *m
  31. }
  32. // SysConfigControl 增、改使用的结构体
  33. type SysConfigControl struct {
  34. Id int `uri:"Id" comment:"编码"` // 编码
  35. ConfigName string `json:"configName" comment:""`
  36. ConfigKey string `uri:"configKey" json:"configKey" comment:""`
  37. ConfigValue string `json:"configValue" comment:""`
  38. ConfigType string `json:"configType" comment:""`
  39. IsFrontend string `json:"isFrontend"`
  40. Remark string `json:"remark" comment:""`
  41. common.ControlBy
  42. }
  43. // Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
  44. func (s *SysConfigControl) Generate(model *models.SysConfig) {
  45. if s.Id == 0 {
  46. model.Model = common.Model{Id: s.Id}
  47. }
  48. model.ConfigName = s.ConfigName
  49. model.ConfigKey = s.ConfigKey
  50. model.ConfigValue = s.ConfigValue
  51. model.ConfigType = s.ConfigType
  52. model.IsFrontend = s.IsFrontend
  53. model.Remark = s.Remark
  54. }
  55. // GetId 获取数据对应的ID
  56. func (s *SysConfigControl) GetId() interface{} {
  57. return s.Id
  58. }
  59. // GetSetSysConfigReq 增、改使用的结构体
  60. type GetSetSysConfigReq struct {
  61. ConfigKey string `json:"configKey" comment:""`
  62. ConfigValue string `json:"configValue" comment:""`
  63. }
  64. // Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
  65. func (s *GetSetSysConfigReq) Generate(model *models.SysConfig) {
  66. model.ConfigValue = s.ConfigValue
  67. }
  68. type UpdateSetSysConfigReq map[string]string
  69. // SysConfigByKeyReq 根据Key获取配置
  70. type SysConfigByKeyReq struct {
  71. ConfigKey string `uri:"configKey" search:"type:contains;column:config_key;table:sys_config"`
  72. }
  73. func (m *SysConfigByKeyReq) GetNeedSearch() interface{} {
  74. return *m
  75. }
  76. type GetSysConfigByKEYForServiceResp struct {
  77. ConfigKey string `json:"configKey" comment:""`
  78. ConfigValue string `json:"configValue" comment:""`
  79. }
  80. type SysConfigGetReq struct {
  81. Id int `uri:"id"`
  82. }
  83. func (s *SysConfigGetReq) GetId() interface{} {
  84. return s.Id
  85. }
  86. type SysConfigDeleteReq struct {
  87. Ids []int `json:"ids"`
  88. common.ControlBy
  89. }
  90. func (s *SysConfigDeleteReq) GetId() interface{} {
  91. return s.Ids
  92. }