rule.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * @description: 编号规则
  3. * @Author: LanJianRong
  4. * @Date: 2020-11-27
  5. * @FilePath: \construction_management\web\viewmodels\rule.go
  6. */
  7. package viewmodels
  8. import validation "github.com/go-ozzo/ozzo-validation/v3"
  9. type Rule struct {
  10. Id string `form:"id" json:"id" `
  11. ProjectId string `form:"projectId" json:"projectId" `
  12. BidsectionId string `form:"bidsectionId" json:"bidsectionId" `
  13. SafeRule string `form:"safeRule" json:"safeRule" `
  14. QualityRule string `form:"qualityRule" json:"qualityRule" `
  15. ContractReturnRule string `form:"contractReturnRule" json:"contractReturnRule" `
  16. ContractPaidRule string `form:"contractPaidRule" json:"contractPaidRule" `
  17. }
  18. // 页面所需字段
  19. type ViewRule struct {
  20. SafeRule string `form:"safeRule" json:"safeRule" `
  21. QualityRule string `form:"qualityRule" json:"qualityRule" `
  22. ContractReturnRule string `form:"contractReturnRule" json:"contractReturnRule" `
  23. ContractPaidRule string `form:"contractPaidRule" json:"contractPaidRule" `
  24. }
  25. type ValidField struct {
  26. BidsectionId string `form:"bidsectionId" json:"bidsectionId" `
  27. Type string `form:"type" json:"type"`
  28. Rule string `form:"rule" json:"rule"`
  29. }
  30. type RuleCode struct {
  31. Eg string `from:"eg" json:"eg"`
  32. Date string `from:"date" json:"date"`
  33. Text string `from:"text" json:"text"`
  34. Name string `from:"name" json:"name"`
  35. Code string `from:"code" json:"code"`
  36. }
  37. func (l ValidField) Validate() error {
  38. return validation.ValidateStruct(&l,
  39. validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
  40. )
  41. }
  42. func (l ValidField) ValidateAuto() error {
  43. return validation.ValidateStruct(&l,
  44. validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
  45. validation.Field(&l.Type, validation.Required.Error("类型不能为空")),
  46. )
  47. }