demand.go 969 B

1234567891011121314151617181920212223242526272829303132
  1. package crm
  2. import "server/global"
  3. type Demand struct {
  4. global.GVA_MODEL
  5. Content string `json:"content" form:"content" gorm:"comment:需求内容"`
  6. CustomerId int `json:"customerId" form:"customerId" gorm:"comment:所属客户id"`
  7. ProposeTime string `json:"proposeTime" form:"proposeTime" gorm:"comment:提出时间"`
  8. IsFinish bool `json:"isFinish" form:"isFinish" gorm:"comment:是否完成"`
  9. }
  10. func (Demand) TableName() string {
  11. return "demand"
  12. }
  13. func QueryDemandsByCustomerId(customerId int) (demands []Demand, err error) {
  14. err = global.GVA_DB.Model(&Demand{}).Where("customer_id = ?", customerId).Find(&demands).Error
  15. return demands, err
  16. }
  17. func (d Demand) CreateDemand() error {
  18. return global.GVA_DB.Create(&d).Error
  19. }
  20. func (d Demand) UpdateDemand() error {
  21. return global.GVA_DB.Model(&Demand{}).Where("id = ?", d.ID).Updates(&d).Error
  22. }
  23. func DeleteDemand(id int) error {
  24. return global.GVA_DB.Unscoped().Delete(&Demand{}, id).Error
  25. }