financial_analyst.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 `description:"主键"`
  14. ETAId int `description:"eta_id"`
  15. HTId int `description:"ht_id"`
  16. Name string `description:"姓名"`
  17. HeadImgURL string `orm:"column(head_img_url)" description:"头像"`
  18. Introduction string `description:"介绍"`
  19. Status AnalystStatus `description:"状态"`
  20. Deleted bool `description:"是否删除"`
  21. CreatedTime time.Time `description:"创建时间"`
  22. UpdatedTime time.Time `description:"更新时间"`
  23. }
  24. func (m *CrmFinancialAnalyst) TableName() string {
  25. return "crm_financial_analysts"
  26. }
  27. type AnalystView struct {
  28. Id int `json:"Id"`
  29. Name string `json:"Name"`
  30. HeadImgURL string `json:"HeadImgURL"`
  31. Introduction string `json:"Introduction"`
  32. CreatedTime string `json:"CreatedTime"`
  33. }
  34. func GetAnalystByName(name string) (analyst CrmFinancialAnalyst, err error) {
  35. o := orm.NewOrm()
  36. sql := `SELECT * FROM crm_financial_analysts where name =?`
  37. err = o.Raw(sql, name).QueryRow(&analyst)
  38. return
  39. }
  40. func GetAnalystCount() (count int, err error) {
  41. o := orm.NewOrm()
  42. sql := `SELECT COUNT(*) AS count FROM crm_financial_analysts`
  43. err = o.Raw(sql).QueryRow(&count)
  44. return
  45. }
  46. func GetAnalystList(startSize int, pageSize int) (item []*CrmFinancialAnalyst, err error) {
  47. o := orm.NewOrm()
  48. sql := `SELECT * FROM crm_financial_analysts ORDER BY created_time desc LIMIT ?,?`
  49. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&item)
  50. return
  51. }
  52. // GetAnalystById
  53. // @Description: 根据ID获取信息
  54. // @author: Roc
  55. // @datetime 2024-08-09 18:24:58
  56. // @param id int
  57. // @return analyst CrmFinancialAnalyst
  58. // @return err error
  59. func GetAnalystById(id int) (analyst CrmFinancialAnalyst, err error) {
  60. o := orm.NewOrm()
  61. sql := `SELECT * FROM crm_financial_analysts where id =?`
  62. err = o.Raw(sql, id).QueryRow(&analyst)
  63. return
  64. }
  65. func (m *CrmFinancialAnalyst) Update(cols []string) (err error) {
  66. o := orm.NewOrm()
  67. _, err = o.Update(m, cols...)
  68. return
  69. }