price_driven.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package yb
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // PriceDriven 价格驱动表
  7. type PriceDriven struct {
  8. PriceDrivenId int `orm:"column(price_driven_id);pk" description:"价格驱动ID"`
  9. ChartPermissionId int `json:"chart_permission_id" description:"品种权限ID"`
  10. MainVariable string `json:"main_variable" description:"关键变量"`
  11. CoreDrivenType int `json:"core_driven_type" description:"核心驱动类型 0-多 1-空"`
  12. CoreDrivenContent string `json:"core_driven_content" description:"核心驱动内容"`
  13. CoreContent string `json:"core_content" description:"核心内容"`
  14. LastUpdateAdminId int `json:"last_update_admin_id" description:"最后更新人ID"`
  15. LastUpdateAdminName string `json:"last_update_admin_name" description:"最后更新人名称"`
  16. LastThsMsgTime time.Time `json:"last_ths_msg_time" description:"最后推送同花顺客群消息时间"`
  17. LastTemplateMsgTime time.Time `json:"last_template_msg_time" description:"最后推送模板消息时间"`
  18. CreateTime time.Time `json:"create_time" description:"创建时间"`
  19. ModifyTime time.Time `json:"modify_time" description:"更新时间"`
  20. }
  21. // TableName 表名变更
  22. func (priceDrivenInfo *PriceDriven) TableName() string {
  23. return "yb_price_driven"
  24. }
  25. // Add 新增
  26. func (priceDrivenInfo *PriceDriven) Add() (err error) {
  27. o := orm.NewOrm()
  28. id, err := o.Insert(priceDrivenInfo)
  29. if err != nil {
  30. return
  31. }
  32. priceDrivenInfo.PriceDrivenId = int(id)
  33. return
  34. }
  35. // Update 更新
  36. func (priceDrivenInfo *PriceDriven) Update(cols []string) (err error) {
  37. o := orm.NewOrm()
  38. _, err = o.Update(priceDrivenInfo, cols...)
  39. return
  40. }
  41. // GetPriceDrivenByChartPermissionId 通过品种获取价格驱动
  42. func GetPriceDrivenByChartPermissionId(chartPermissionId int) (item *PriceDriven, err error) {
  43. o := orm.NewOrm()
  44. sql := `SELECT * FROM yb_price_driven WHERE chart_permission_id = ? LIMIT 1`
  45. err = o.Raw(sql, chartPermissionId).QueryRow(&item)
  46. return
  47. }
  48. // GetPriceDrivenById 主键获取价格驱动
  49. func GetPriceDrivenById(priceDrivenId int) (item *PriceDriven, err error) {
  50. o := orm.NewOrm()
  51. sql := `SELECT * FROM yb_price_driven WHERE price_driven_id = ? LIMIT 1`
  52. err = o.Raw(sql, priceDrivenId).QueryRow(&item)
  53. return
  54. }