company_history_remark.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package company
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CompanyHistoryRemark struct {
  7. HistoryId int `orm:"column(history_id);pk" comment:"备注id"`
  8. CompanyId int `comment:"客户ID"`
  9. ProductId int `comment:"产品id"`
  10. Content string `comment:"备注内容"`
  11. SysAdminId int `comment:"创建人ID"`
  12. SysAdminName string `comment:"创建人姓名"`
  13. CreateTime time.Time `comment:"创建时间"`
  14. ModifyTime time.Time `comment:"更新时间"`
  15. TableName string `comment:"表名"`
  16. TableId int `comment:"表ID"`
  17. UserId int `comment:"用户ID"`
  18. Mobile string `comment:"手机号"`
  19. Email string `comment:"邮箱"`
  20. RealName string `comment:"用户实际名称"`
  21. ShowTime time.Time `comment:"对外展示的创建时间"`
  22. }
  23. // CompanyHistoryRemarkReq 新增历史备注请求
  24. type CompanyHistoryRemarkReq struct {
  25. CompanyId int `description:"客户id"`
  26. Content string `description:"备注内容"`
  27. }
  28. // 新增
  29. func AddCompanyHistoryRemark(remark *CompanyHistoryRemark) (err error) {
  30. o := orm.NewOrm()
  31. _, err = o.Insert(remark)
  32. return
  33. }
  34. type CompanyHistoryRemarkResp struct {
  35. CompanyId int `comment:"客户ID"`
  36. Content string `comment:"备注内容"`
  37. SysAdminName string `comment:"创建人姓名"`
  38. RemarkType string `comment:"备注类型"`
  39. CreateTime string `comment:"对外展示的创建时间"`
  40. }
  41. type CompanyHistoryRemarkListResp struct {
  42. List []*CompanyHistoryRemarkResp
  43. }
  44. // GetCompanyHistoryRemarkList 获取备注列表
  45. func GetCompanyHistoryRemarkList(CompanyId, ProductId string) (items []*CompanyHistoryRemark, err error) {
  46. o := orm.NewOrm()
  47. sql := "SELECT * FROM company_history_remark WHERE company_id=? AND product_id=? ORDER BY show_time DESC "
  48. _, err = o.Raw(sql, CompanyId, ProductId).QueryRows(&items)
  49. return
  50. }
  51. // DelCompanyHistoryRemark 删除客户历史备注
  52. func DelCompanyHistoryRemark(tableName string, tableId int) (err error) {
  53. o := orm.NewOrm()
  54. sql := `DELETE FROM company_history_remark WHERE table_name = ? AND table_id = ? `
  55. _, err = o.Raw(sql, tableName, tableId).Exec()
  56. return
  57. }