report_selection_log_apply.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxReportSelectionLogApply struct {
  7. ReportSelectionLogApplyId int `orm:"column(report_selection_log_apply_id);pk"`
  8. UserId int
  9. CreateTime time.Time
  10. Mobile string `description:"手机号"`
  11. Email string `description:"邮箱"`
  12. CompanyId int `description:"公司id"`
  13. CompanyName string `description:"公司名称"`
  14. ModifyTime time.Time `description:"修改时间"`
  15. RealName string `description:"用户实际名称"`
  16. SellerName string `description:"所属销售"`
  17. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  18. ArticleId int `description:"报告Id"`
  19. IndustrialSubjectId int `description:"标的ID"`
  20. SubjectName string `description:"标的名称"`
  21. }
  22. type CygxReportSelectionLogApplyReq struct {
  23. ArticleId int `description:"报告Id"`
  24. SubjectName string `description:"标的ID"`
  25. }
  26. // 添加信息
  27. func AddCygxReportSelectionLogApply(item *CygxReportSelectionLogApply) (lastId int64, err error) {
  28. o, err := orm.NewOrm().Begin()
  29. if err != nil {
  30. return
  31. }
  32. defer func() {
  33. if err == nil {
  34. o.Commit()
  35. } else {
  36. o.Rollback()
  37. }
  38. }()
  39. //更新申请数量
  40. sql := ` UPDATE cygx_report_selection SET apply_total= 1 + apply_total WHERE article_id = ?`
  41. _, err = o.Raw(sql, item.ArticleId).Exec()
  42. if err != nil {
  43. return
  44. }
  45. lastId, err = o.Insert(item)
  46. return
  47. }
  48. // 获取数量
  49. func GetCygxReportSelectionLogApplyCount(condition string, pars []interface{}) (count int, err error) {
  50. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_report_selection_log_apply as art WHERE 1= 1 `
  51. if condition != "" {
  52. sqlCount += condition
  53. }
  54. o := orm.NewOrm()
  55. err = o.Raw(sqlCount, pars).QueryRow(&count)
  56. return
  57. }