financial_analyst.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type AnalystStatus string
  7. const (
  8. AnalystStatusEnabled AnalystStatus = "enabled"
  9. AnalystStatusDisabled AnalystStatus = "disabled"
  10. columns = "id,eta_id,name,head_img_url,introduction"
  11. )
  12. type CrmFinancialAnalyst struct {
  13. Id int `gorm:"primaryKey;autoIncrement;column:id;comment:主键"`
  14. ETAId int `gorm:"column:eta_id"`
  15. HTId int `gorm:"column:ht_id"`
  16. Name string `gorm:"column:name"`
  17. HeadImgURL string `gorm:"column:head_img_url"`
  18. Introduction string `gorm:"column:introduction"`
  19. Status AnalystStatus `gorm:"column:status"`
  20. Deleted bool `gorm:"column:deleted"`
  21. CreatedTime time.Time `gorm:"column:created_time;type:timestamps;comment:创建时间"`
  22. UpdatedTime time.Time `gorm:"column:updated_time;type:timestamps;comment:更新时间"`
  23. }
  24. type AnalystView struct {
  25. Id int `json:"Id"`
  26. Name string `json:"Name"`
  27. HeadImgURL string `json:"HeadImgURL"`
  28. Introduction string `json:"Introduction"`
  29. CreatedTime string `json:"CreatedTime"`
  30. }
  31. func GetAnalystByName(name string) (analyst CrmFinancialAnalyst, err error) {
  32. o := orm.NewOrm()
  33. sql := `SELECT * FROM crm_financial_analysts where name =?`
  34. err = o.Raw(sql, name).QueryRow(&analyst)
  35. return
  36. }
  37. func GetAnalystCount() (count int, err error) {
  38. o := orm.NewOrm()
  39. sql := `SELECT COUNT(*) AS count FROM crm_financial_analysts`
  40. err = o.Raw(sql).QueryRow(&count)
  41. return
  42. }
  43. func GetAnalystList(startSize int, pageSize int) (item []*CrmFinancialAnalyst, err error) {
  44. o := orm.NewOrm()
  45. sql := `SELECT * FROM crm_financial_analysts ORDER BY created_time desc LIMIT ?,?`
  46. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&item)
  47. return
  48. }