jl.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * @description:
  3. * @Author: CP
  4. * @Date: 2021-12-25 15:06:19
  5. * @FilePath: \construction_management\web\viewmodels\jl.go
  6. */
  7. package viewmodels
  8. import (
  9. // jwtmiddleware "github.com/iris-contrib/middleware/jwt"
  10. validation "github.com/go-ozzo/ozzo-validation/v3"
  11. )
  12. type Jl struct {
  13. Token string `form:"token" json:"token" `
  14. Code string `form:"code" json:"code" `
  15. Account string `form:"account" json:"account" `
  16. NewAccount string `form:"newAccount" json:"newAccount" `
  17. }
  18. // 校验项目接口
  19. func (l Jl) ValidateToken() error {
  20. return validation.ValidateStruct(&l,
  21. validation.Field(&l.Token, validation.Required.Error("token不能为空")),
  22. )
  23. }
  24. // 校验项目接口
  25. func (l Jl) ValidateCodeAToken() error {
  26. return validation.ValidateStruct(&l,
  27. validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
  28. validation.Field(&l.Token, validation.Required.Error("token不能为空")),
  29. )
  30. }
  31. // 校验项目接口
  32. func (l Jl) ValidateCode() error {
  33. return validation.ValidateStruct(&l,
  34. validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
  35. )
  36. }
  37. // 验证检验项目
  38. func (l Jl) ValidateParameter() error {
  39. return validation.ValidateStruct(&l,
  40. validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
  41. )
  42. }
  43. // 添加项目和账号验证
  44. func (l Jl) ValidateProjectAdd() error {
  45. return validation.ValidateStruct(&l,
  46. validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
  47. validation.Field(&l.Account, validation.Required.Error("账号不能为空")),
  48. )
  49. }
  50. // 添加项目和账号验证
  51. func (l Jl) ValidateAccountUpdate() error {
  52. return validation.ValidateStruct(&l,
  53. validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
  54. validation.Field(&l.Account, validation.Required.Error("账号不能为空")),
  55. validation.Field(&l.NewAccount, validation.Required.Error("修改账号不能为空")),
  56. )
  57. }