chart_record.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. RecordId int `description:"来源 1小程序,2:网页"`
  36. }
  37. // 列表
  38. func GetCygxChartRecordListNoLimit(condition string, pars []interface{}) (items []*CygxChartRecordResp, err error) {
  39. o := orm.NewOrm()
  40. sql := `SELECT
  41. a.title,
  42. a.chart_id,
  43. b.record_id,
  44. b.user_id,
  45. b.real_name,
  46. b.mobile,
  47. b.email,
  48. b.company_id,
  49. b.company_name,
  50. b.create_time
  51. FROM
  52. cygx_chart AS a
  53. INNER JOIN cygx_chart_record AS b ON a.chart_id = b.chart_id WHERE 1= 1 `
  54. if condition != "" {
  55. sql += condition
  56. }
  57. _, err = o.Raw(sql, pars).QueryRows(&items)
  58. return
  59. }