12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type AnalystStatus string
- const (
- AnalystStatusEnabled AnalystStatus = "enabled"
- AnalystStatusDisabled AnalystStatus = "disabled"
- columns = "id,eta_id,name,head_img_url,introduction"
- )
- type CrmFinancialAnalyst struct {
- Id int `description:"主键"`
- ETAId int `description:"eta_id"`
- HTId int `description:"ht_id"`
- Name string `description:"姓名"`
- HeadImgURL string `orm:"column(head_img_url)" description:"头像"`
- Introduction string `description:"介绍"`
- Status AnalystStatus `description:"状态"`
- Deleted bool `description:"是否删除"`
- CreatedTime time.Time `description:"创建时间"`
- UpdatedTime time.Time `description:"更新时间"`
- }
- func (m *CrmFinancialAnalyst) TableName() string {
- return "crm_financial_analysts"
- }
- type AnalystView struct {
- Id int `json:"Id"`
- Name string `json:"Name"`
- HeadImgURL string `json:"HeadImgURL"`
- Introduction string `json:"Introduction"`
- CreatedTime string `json:"CreatedTime"`
- }
- func GetAnalystByName(name string) (analyst CrmFinancialAnalyst, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM crm_financial_analysts where name =?`
- err = o.Raw(sql, name).QueryRow(&analyst)
- return
- }
- func GetAnalystCount() (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT COUNT(*) AS count FROM crm_financial_analysts`
- err = o.Raw(sql).QueryRow(&count)
- return
- }
- func GetAnalystList(startSize int, pageSize int) (item []*CrmFinancialAnalyst, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM crm_financial_analysts ORDER BY created_time desc LIMIT ?,?`
- _, err = o.Raw(sql, startSize, pageSize).QueryRows(&item)
- return
- }
- // GetAnalystById
- // @Description: 根据ID获取信息
- // @author: Roc
- // @datetime 2024-08-09 18:24:58
- // @param id int
- // @return analyst CrmFinancialAnalyst
- // @return err error
- func GetAnalystById(id int) (analyst CrmFinancialAnalyst, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM crm_financial_analysts where id =?`
- err = o.Raw(sql, id).QueryRow(&analyst)
- return
- }
- func (m *CrmFinancialAnalyst) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(m, cols...)
- return
- }
|