stock.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package model
  2. import (
  3. "time"
  4. "ulink-admin/pkg/base"
  5. )
  6. type Stock struct {
  7. Id int64 `excel:"name= " xorm:"pk autoincr notnull comment('')" json:"id" ` //
  8. CreateDate string `excel:"name=日期 " xorm:"varchar(255) comment('日期')" json:"createDate" binding:"required"` //日期
  9. Type int `excel:"name=交易所 ,format=1=上证,2=深证,3=创业板,4=科创,5=其它" xorm:"int(1) notnull default(2) comment('交易所')" json:"type" binding:"required,oneof=1 2 3 4 5 "` //交易所(1上证 2深证 3创业板 4科创 5其它 )
  10. Label int `excel:"name=大盘走势 ,format=1=上涨,2=下跌,3=未知" xorm:"int(1) notnull default(2) comment('大盘走势')" json:"label" ` //大盘走势(1上涨 2下跌)
  11. Val string `excel:"name=值 " xorm:"varchar(255) comment('值')" json:"val" ` //值
  12. CreateTime time.Time `excel:"name=创建时间 " xorm:"datetime comment('创建时间')" json:"createTime" ` //创建时间
  13. CreateBy string `excel:"name=创建人 " xorm:"varchar(255) comment('创建人')" json:"createBy" ` //创建人
  14. UpdateTime time.Time `excel:"name=更新时间 " xorm:"datetime comment('更新时间')" json:"updateTime" ` //更新时间
  15. UpdateBy string `excel:"name=更新人 " xorm:"varchar(255) comment('更新人')" json:"updateBy" ` //更新人
  16. Details []*StockDetail `xorm:"-" json:"details"` //岗位id组
  17. }
  18. func (this Stock) TableName() string {
  19. return "stock"
  20. }
  21. func (this *Stock) Key() int64 {
  22. return this.Id
  23. }
  24. func (this *Stock) Model() interface{} {
  25. return this
  26. }
  27. func (this *Stock) BeforeUpdate() {
  28. user := base.GetCurUser()
  29. if user != nil {
  30. this.UpdateBy = user.Name
  31. }
  32. }
  33. func (this *Stock) BeforeInsert() {
  34. user := base.GetCurUser()
  35. if user != nil {
  36. this.CreateBy = user.Name
  37. this.UpdateBy = user.Name
  38. }
  39. }