fix
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
@@ -42,6 +42,9 @@ type StratModel struct {
|
||||
AiResisLevel float64
|
||||
AiAction string
|
||||
AiRisk string
|
||||
|
||||
TotalDesc string
|
||||
TotalScore float64
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -53,7 +56,12 @@ func (StratModel) TableName() string {
|
||||
return "strat_model"
|
||||
}
|
||||
|
||||
var (
|
||||
desc []string
|
||||
)
|
||||
|
||||
func NewStratModel(key, code string, ymd int) *StratModel {
|
||||
desc = []string{}
|
||||
obj := StratModel{
|
||||
StratKey: key,
|
||||
Ymd: ymd,
|
||||
@@ -63,22 +71,13 @@ func NewStratModel(key, code string, ymd int) *StratModel {
|
||||
}
|
||||
|
||||
func (s *StratModel) AddDesc(d string) {
|
||||
hash := utils.Md5(fmt.Sprintf("%s-%d-%s:%s", s.StratKey, s.Ymd, s.Code, d))
|
||||
|
||||
var cnt int64
|
||||
impl.DBService.Model(&StratDesc{}).Where("hash=?", hash).Count(&cnt)
|
||||
if cnt > 0 {
|
||||
return
|
||||
}
|
||||
s.Desc = append(s.Desc, StratDesc{
|
||||
Hash: hash,
|
||||
Desc: d,
|
||||
})
|
||||
desc = append(desc, d)
|
||||
}
|
||||
|
||||
func (s *StratModel) Save() error {
|
||||
var cnt int64
|
||||
impl.DBService.Model(&StratModel{}).Where("strat_key=? and ymd=? and code=?", s.StratKey, s.Ymd, s.Code).Count(&cnt)
|
||||
s.TotalDesc = strings.Join(desc, "||")
|
||||
|
||||
if cnt == 0 {
|
||||
// create record.
|
||||
|
||||
Reference in New Issue
Block a user