12345678910111213141516171819202122232425262728293031 |
- package schema
- import (
- "errors"
- "github.com/jinzhu/gorm"
- )
- // Agent 代理商表
- type Agent struct {
- gorm.Model
- AgentCode string `gorm:"not null;primary_key"` // 代理商编号
- AgentName string `gorm:"not null;size:50;"` // 代理商名称
- ParentAgentCode string `gorm:"not nulll;default:'0'"` //父级代理商编号
- Operator string //操作人
- AgentUserName string `gorm:"not null;unique;size:25"` //代理商用户名
- AgentPassWord string `gorm:"not null;size:25;default:''"` //代理商密码
- Adress string `gorm:"size:100"` //地址
- Contact string `gorm:"size:10"` // 联系人
- Phone string // 联系电话
- }
- // Validate 验证
- func (a *Agent) Validate() error {
- if a.AgentName == "" ||
- a.AgentUserName == "" ||
- a.AgentPassWord == "" {
- return errors.New("参数不能为空[AgentName,AgentUserName,AgentPassword]")
- }
- return nil
- }
|