chart_record.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxChartRecord struct {
  7. RecordId int `orm:"column(record_id);pk"`
  8. ChartId int `description:"图表ID"`
  9. UserId int `description:"用户ID"`
  10. Mobile string `description:"手机号"`
  11. Email string `description:"邮箱"`
  12. CompanyId int `description:"公司id"`
  13. CompanyName string `description:"公司名称"`
  14. RealName string `description:"用户实际名称"`
  15. CreateTime time.Time `description:"创建时间"`
  16. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  17. }
  18. // 添加历史信息
  19. func AddCygxChartRecord(item *CygxChartRecord) (lastId int64, err error) {
  20. o := orm.NewOrm()
  21. lastId, err = o.Insert(item)
  22. return
  23. }
  24. type CygxChartRecordResp struct {
  25. ChartId int `description:"图表ID"`
  26. Title string `description:"标题"`
  27. UserId int `description:"用户ID"`
  28. Mobile string `description:"手机号"`
  29. Email string `description:"邮箱"`
  30. CompanyId int `description:"公司id"`
  31. CompanyName string `description:"公司名称"`
  32. RealName string `description:"用户实际名称"`
  33. CreateTime string `description:"创建时间"`
  34. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  35. }
  36. // 列表
  37. func GetCygxChartRecordListNoLimit(condition string, pars []interface{}) (items []*CygxChartRecordResp, err error) {
  38. o := orm.NewOrm()
  39. sql := `SELECT
  40. a.title,
  41. a.chart_id,
  42. b.user_id,
  43. b.real_name,
  44. b.mobile,
  45. b.email,
  46. b.company_id,
  47. b.company_name,
  48. b.create_time
  49. FROM
  50. cygx_chart AS a
  51. INNER JOIN cygx_chart_record AS b ON a.chart_id = b.chart_id WHERE 1= 1 `
  52. if condition != "" {
  53. sql += condition
  54. }
  55. _, err = o.Raw(sql, pars).QueryRows(&items)
  56. return
  57. }