price_driven.go 2.4 KB

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