drainage_server.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package forms
  2. import (
  3. "errors"
  4. "strings"
  5. )
  6. type GetDrainageServerReq struct {
  7. }
  8. func (req *GetDrainageServerReq) Check() error {
  9. return nil
  10. }
  11. type EditDrainageServerReq struct {
  12. ServerIds []int32 `json:"server_ids" form:"server_ids"`
  13. }
  14. func (req *EditDrainageServerReq) Check() error {
  15. if len(req.ServerIds) == 0 {
  16. return errors.New("请选择有效的服务器")
  17. }
  18. return nil
  19. }
  20. type GetDisplayServerReq struct {
  21. }
  22. func (req *GetDisplayServerReq) Check() error {
  23. return nil
  24. }
  25. type GetDisplayServerRes struct {
  26. ServerIds []int32 `json:"server_ids"`
  27. MaxOpendServerId int32 `json:"maxOpendServerId"`
  28. MaxDeployServerId int32 `json:"maxDeployServerId" form:"maxDeployServerId"`
  29. }
  30. type EditDisplayServerReq struct {
  31. ServerIds []int32 `json:"server_ids" form:"server_ids"`
  32. MaxOpendServerId int32 `json:"maxOpendServerId" form:"maxOpendServerId"`
  33. MaxDeployServerId int32 `json:"maxDeployServerId" form:"maxDeployServerId"`
  34. }
  35. func (req *EditDisplayServerReq) Check() error {
  36. //if len(req.ServerIds) == 0 {
  37. // return errors.New("请选择有效的服务器")
  38. //}
  39. if req.MaxOpendServerId <= 0 {
  40. return errors.New("最大开放服务器ID必须大于0")
  41. }
  42. return nil
  43. }
  44. type GetWhiteListServerReq struct {
  45. }
  46. func (req *GetWhiteListServerReq) Check() error {
  47. return nil
  48. }
  49. type EditWhiteListServerReq struct {
  50. ServerIds []int `json:"server_ids" form:"server_ids"`
  51. PlayerIds string `json:"player_ids" form:"player_ids"`
  52. }
  53. func (req *EditWhiteListServerReq) Check() error {
  54. if len(req.ServerIds) == 0 {
  55. return errors.New("请选择有效的服务器")
  56. }
  57. if strings.ReplaceAll(req.PlayerIds, " ", "") == "" {
  58. req.PlayerIds = ""
  59. }
  60. return nil
  61. }