agent.go 960 B

12345678910111213141516171819202122232425262728293031
  1. package schema
  2. import (
  3. "errors"
  4. "github.com/jinzhu/gorm"
  5. )
  6. // Agent 代理商表
  7. type Agent struct {
  8. gorm.Model
  9. AgentCode string `gorm:"not null;primary_key"` // 代理商编号
  10. AgentName string `gorm:"not null;size:50;"` // 代理商名称
  11. ParentAgentCode string `gorm:"not nulll;default:'0'"` //父级代理商编号
  12. Operator string //操作人
  13. AgentUserName string `gorm:"not null;unique;size:25"` //代理商用户名
  14. AgentPassWord string `gorm:"not null;size:25;default:''"` //代理商密码
  15. Adress string `gorm:"size:100"` //地址
  16. Contact string `gorm:"size:10"` // 联系人
  17. Phone string // 联系电话
  18. }
  19. // Validate 验证
  20. func (a *Agent) Validate() error {
  21. if a.AgentName == "" ||
  22. a.AgentUserName == "" ||
  23. a.AgentPassWord == "" {
  24. return errors.New("参数不能为空[AgentName,AgentUserName,AgentPassword]")
  25. }
  26. return nil
  27. }