project.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * @description: 项目展示项
  3. * @Author: CP
  4. * @Date: 2020-09-23 11:01:47
  5. * @FilePath: \construction_management\web\viewmodels\project.go
  6. */
  7. package viewmodels
  8. import (
  9. "fmt"
  10. validation "github.com/go-ozzo/ozzo-validation/v3"
  11. )
  12. type Project struct {
  13. Id string `form:"id" json:"id"`
  14. Code string `form:"code" json:"code"`
  15. Name string `form:"name" json:"name"`
  16. UserId string `form:"userId" json:"userId"`
  17. UserAccount string `form:"userAccount" json:"userAccount"`
  18. CategoryId string `form:"categoryId" json:"categoryId"`
  19. Category string `form:"category" json:"category"`
  20. StaffId string `form:"staffId" json:"staffId"`
  21. StaffName string `form:"staffName" json:"staffName"`
  22. CreateTime string `form:"createTime" json:"createTime"`
  23. CreateName string `form:"createName" json:"createName"`
  24. CreateCategory string `form:"createCategory" json:"createCategory"`
  25. InsideCategoryId string `form:"insideCategoryId" json:"insideCategoryId"`
  26. InsideCategory string `form:"insideCategory" json:"insideCategory"`
  27. Remark string `form:"remark" json:"remark"`
  28. }
  29. type ProjectInfo struct {
  30. ProjectName string `from:"project_name" json:"projectName"`
  31. Code string `from:"code" json:"code"`
  32. CreateTime string `from:"create_time" json:"createTime"`
  33. Mobile string `from:"mobile" json:"mobile"`
  34. Name string `from:"name" json:"name"`
  35. }
  36. type ProjectPage struct {
  37. Page int `form:"page" json:"page"`
  38. Size int `form:"size" json:"size"`
  39. }
  40. func (l ProjectPage) ValidatePage() error {
  41. return validation.ValidateStruct(&l,
  42. // 字符的4倍
  43. validation.Field(&l.Page, validation.Required.Error("当前页不能为空")),
  44. validation.Field(&l.Size, validation.Required.Error("每页数量不能为空")),
  45. )
  46. }
  47. func (l Project) ValidateId() error {
  48. return validation.ValidateStruct(&l,
  49. // 字符的4倍
  50. validation.Field(&l.Id, validation.Required.Error("项目ID不能为空")),
  51. )
  52. }
  53. func (l Project) ValidateAdd() error {
  54. return validation.ValidateStruct(&l,
  55. validation.Field(&l.Code, validation.Required.Error("项目编号不能为空")),
  56. validation.Field(&l.Name, validation.Required.Error("项目名称不能为空")),
  57. validation.Field(&l.Category, validation.Required.Error("办事处不能为空")),
  58. validation.Field(&l.CategoryId, validation.Required.Error("办事处ID不能为空")),
  59. validation.Field(&l.StaffName, validation.Required.Error("负责人不能为空")),
  60. validation.Field(&l.StaffId, validation.Required.Error("负责人ID不能为空")),
  61. )
  62. }
  63. func (l Project) ValidateSave() error {
  64. return validation.ValidateStruct(&l,
  65. validation.Field(&l.Id, validation.Required.Error("项目ID不能为空")),
  66. validation.Field(&l.Name, validation.Required.Error("项目名称不能为空")),
  67. validation.Field(&l.InsideCategoryId, validation.Required.Error("所在办事处ID不能为空")),
  68. validation.Field(&l.InsideCategory, validation.Required.Error("所在办事处不能为空")),
  69. validation.Field(&l.Category, validation.Required.Error("负责人办事处不能为空")),
  70. validation.Field(&l.CategoryId, validation.Required.Error("负责人办事处ID不能为空")),
  71. validation.Field(&l.StaffName, validation.Required.Error("负责人不能为空")),
  72. validation.Field(&l.StaffId, validation.Required.Error("负责人ID不能为空")),
  73. )
  74. }
  75. func (l Project) Validate() error {
  76. return validation.ValidateStruct(&l,
  77. // 字符的4倍
  78. validation.Field(&l.Name, validation.Required.Error("项目名称不能为空"), validation.Length(1, 512).Error("最多 128 个字")),
  79. validation.Field(&l.Code, validation.Required.Error("项目编号不能为空"), validation.Length(12, 128).Error("不得少于 3 个字")),
  80. )
  81. }
  82. func (l Project) ValidateName() error {
  83. fmt.Println(l)
  84. return validation.ValidateStruct(&l,
  85. // 字符的4倍
  86. validation.Field(&l.Name, validation.Required.Error("项目名称不能为空"), validation.Length(1, 512).Error("最多 128 个字")),
  87. )
  88. }
  89. // EnterpriseId int `xorm:"comment('企业id') INT(11)"`
  90. // UserId int `xorm:"comment('管理员id(sso用户)') INT(11)"`
  91. // UserAccount string `xorm:"comment('管理员名字(sso用户名)') VARCHAR(32)"`
  92. // CreateTime int `xorm:"comment('创建时间') INT(11)"`
  93. // MaxUser int `xorm:"comment('最大创建用户数(删除)') TINYINT(4)"`
  94. // Creator int64 `xorm:"comment('创建者') BIGINT(20)"`
  95. // Status int `xorm:"comment('项目状态') TINYINT(1)"`
  96. // Remark string `xorm:"comment('备注') VARCHAR(128)"`
  97. // ManagerId int `xorm:"comment('销售负责人') INT(11)"`
  98. // ManagerOffice int `xorm:"comment('负责人办事处') TINYINT(4)"`
  99. // Office int `xorm:"comment('办事处id(项目所属)') TINYINT(4)"`
  100. // OfficeShare string `xorm:"comment('办事处共享(office id列表') VARCHAR(1024)"`
  101. // BillId string `xorm:"comment('工程量清单id列表') VARCHAR(128)"`
  102. // ChapterId string `xorm:"comment('项目节清单id列表') VARCHAR(128)"`
  103. // StandardId int `xorm:"comment('标准清单id') TINYINT(4)"`
  104. // Valuation string `xorm:"comment('清单规范id列表(删除)') VARCHAR(128)"`
  105. // QrcodeJson string `xorm:"comment('项目二维码信息') TEXT"`
  106. // DealpayJson string `xorm:"TEXT"`
  107. // Custom int `xorm:"comment('是否是定制项目') TINYINT(1)"`
  108. // CanApi int `xorm:"comment('定制项目接口是否可用') TINYINT(1)"`
  109. // Secret string `xorm:"comment('定制项目私钥') VARCHAR(255)"`
  110. // PageShow string `xorm:"comment('前台页面或功能展示与隐藏') VARCHAR(3072)"`
  111. // PagePath string `xorm:"VARCHAR(11)"`