12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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 `gorm:"primaryKey;autoIncrement;column:id;comment:主键"`
- ETAId int `gorm:"column:eta_id"`
- HTId int `gorm:"column:ht_id"`
- Name string `gorm:"column:name"`
- HeadImgURL string `gorm:"column:head_img_url"`
- Introduction string `gorm:"column:introduction"`
- Status AnalystStatus `gorm:"column:status"`
- Deleted bool `gorm:"column:deleted"`
- CreatedTime time.Time `gorm:"column:created_time;type:timestamps;comment:创建时间"`
- UpdatedTime time.Time `gorm:"column:updated_time;type:timestamps;comment:更新时间"`
- }
- 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
- }
|