package crm import ( "fmt" "server/global" ) type Demand struct { global.GVA_MODEL Content string `json:"content" form:"content" gorm:"comment:需求内容"` CustomerId int `json:"customerId" form:"customerId" gorm:"comment:所属客户id"` ProposeTime string `json:"proposeTime" form:"proposeTime" gorm:"comment:提出时间"` IsFinish bool `json:"isFinish" form:"isFinish" gorm:"comment:是否完成"` } func (Demand) TableName() string { return "demand" } func QueryDemandsByCustomerId(customerId int) (demands []Demand, err error) { err = global.GVA_DB.Model(&Demand{}).Where("customer_id = ?", customerId).Find(&demands).Error return demands, err } func (d Demand) CreateDemand() error { return global.GVA_DB.Create(&d).Error } func (d Demand) UpdateDemand() error { fmt.Print("测试数据", d) return global.GVA_DB.Model(&d).Select("propose_time", "customer_id", "content", "is_finish").Where("id = ?", d.ID).Updates(&d).Error } func DeleteDemand(id int) error { return global.GVA_DB.Unscoped().Delete(&Demand{}, id).Error }