| | |
| | | type ( |
| | | Client struct { |
| | | Id int `json:"id" gorm:"column:id;primaryKey;autoIncrement;not null"` |
| | | Name string `json:"name" gorm:"column:name;unique;type:varchar(255);comment:客户名称"` |
| | | Name string `json:"name" gorm:"column:name;uniqueIndex:name_isDeleted_idx;type:varchar(255);comment:客户名称"` |
| | | IsDeleted bool `json:"-" gorm:"column:is_deleted;uniqueIndex:name_isDeleted_idx;type:tinyint(1);comment:是否删除"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:客户编号"` |
| | | ClientStatusId int `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:客户状态ID"` |
| | | ClientStatus ClientStatus `json:"client_status" gorm:"foreignKey:ClientStatusId"` |
| | |
| | | } |
| | | } |
| | | |
| | | func (c *Client) BeforeSave(tx *gorm.DB) (err error) { |
| | | if c.DeletedAt.Valid { |
| | | c.IsDeleted = true |
| | | } else { |
| | | c.IsDeleted = false |
| | | } |
| | | return |
| | | } |
| | | |
| | | func (slf *ClientSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Client{}) |
| | | if slf.Id != 0 { |