|
@@ -38,8 +38,7 @@ func GetDataList(condition string, pars []interface{}, startSize, pageSize int)
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += ` order by c.DT desc limit ?,? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -52,8 +51,7 @@ func GetDataListCount(condition string, pars []interface{}) (count int, err erro
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
@@ -73,15 +71,13 @@ type Edbdata struct {
|
|
|
|
|
|
func GetDataInfo(tradeCode, creteDate string) (item *Edbdata, err error) {
|
|
|
sql := " SELECT * FROM edbdata WHERE TRADE_CODE=? AND DT=? "
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, tradeCode, creteDate).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func AddEdbdata(item *Edbdata) (lastId int64, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
lastId, err = o.Insert(item)
|
|
|
return
|
|
|
}
|
|
@@ -102,8 +98,7 @@ type BatchDataEditReq struct {
|
|
|
|
|
|
//编辑数据
|
|
|
func EditEdbdata(item *Edbdata) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := ` UPDATE edbdata SET CLOSE = ?,modify_time=NOW() WHERE TRADE_CODE = ? AND DT = ? `
|
|
|
_, err = o.Raw(sql, item.Close, item.TradeCode, item.Dt).Exec()
|
|
|
return
|
|
@@ -120,16 +115,14 @@ type EdbdataDeleteRecord struct {
|
|
|
}
|
|
|
|
|
|
func AddEdbdataDeleteRecord(item *EdbdataDeleteRecord) (lastId int64, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
lastId, err = o.Insert(item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//删除数据
|
|
|
func DeleteEdbData(tradeCode, dt string) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := ` DELETE FROM edbdata WHERE TRADE_CODE = ? AND DT = ? `
|
|
|
_, err = o.Raw(sql, tradeCode, dt).Exec()
|
|
|
return
|
|
@@ -151,8 +144,7 @@ type Edbinfo struct {
|
|
|
}
|
|
|
|
|
|
func GetEdbinfoListCount(condition string, pars []interface{}, mobile string, roleType int) (count int, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := ``
|
|
|
if mobile != "" && roleType == 1 {
|
|
|
sql = `SELECT COUNT(1) AS count FROM edbinfo AS a
|
|
@@ -175,8 +167,7 @@ func GetEdbinfoListCount(condition string, pars []interface{}, mobile string, ro
|
|
|
}
|
|
|
|
|
|
func GetEdbinfoList(condition string, pars []interface{}, startSize, pageSize int, mobile string, roleType int) (items []*Edbinfo, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := ``
|
|
|
if mobile != "" && roleType == 1 {
|
|
|
sql = ` SELECT DISTINCT a.*,b.classify_name FROM edbinfo AS a
|
|
@@ -209,8 +200,7 @@ type EdbParamsInfo struct {
|
|
|
|
|
|
// GetEdbUnitList 获取指标单位
|
|
|
func GetEdbUnitList() (items []*EdbParamsInfo, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := `SELECT UNIT from edbinfo group by UNIT`
|
|
|
_, err = o.Raw(sql).QueryRows(&items)
|
|
|
return
|
|
@@ -218,8 +208,7 @@ func GetEdbUnitList() (items []*EdbParamsInfo, err error) {
|
|
|
|
|
|
// GetEdbFrequencyList 获取指标频度
|
|
|
func GetEdbFrequencyList(classifyId, userId int) (items []*EdbParamsInfo, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := `SELECT frequency from edbinfo a
|
|
|
join edbdata b on a.TRADE_CODE=b.TRADE_CODE
|
|
|
where classify_id = ? `
|
|
@@ -247,24 +236,21 @@ type EdbinfoAddReq struct {
|
|
|
//获取指标最大trade_code
|
|
|
func GetMaxTradeCode() (max_trade_code string, err error) {
|
|
|
sql := " SELECT MAX(TRADE_CODE) AS max_trade_code FROM edbinfo WHERE LEFT(TRADE_CODE,1)='W' "
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql).QueryRow(&max_trade_code)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEdbinfoBySecName(secName string) (item *Edbinfo, err error) {
|
|
|
sql := `SELECT * FROM edbinfo WHERE SEC_NAME=? AND left(TRADE_CODE,1)='W' AND REMARK='手动' `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, secName).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEdbinfoByTradeCode(tradeCode string) (item *Edbinfo, err error) {
|
|
|
sql := `SELECT * FROM edbinfo WHERE TRADE_CODE=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, tradeCode).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
@@ -272,15 +258,13 @@ func GetEdbinfoByTradeCode(tradeCode string) (item *Edbinfo, err error) {
|
|
|
func AddEdbinfo(tradeCode, secName, unit, remark, frequency, noticeTime string, classifyId int, userId int) (err error) {
|
|
|
sql := `INSERT INTO edbinfo(TRADE_CODE, SEC_NAME,UNIT, REMARK,frequency, classify_id,notice_time,user_id)
|
|
|
VALUES(?,?,?,?,?,?,?,?) `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, tradeCode, secName, unit, remark, frequency, classifyId, noticeTime, userId).Exec()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func AddEdbinfoUser(tradeCode, mobile string) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := `INSERT INTO edbinfo_user(TRADE_CODE, mobile) VALUES (?,?)`
|
|
|
_, err = o.Raw(sql, tradeCode, mobile).Exec()
|
|
|
return
|
|
@@ -297,8 +281,7 @@ type EdbinfoEditReq struct {
|
|
|
|
|
|
func EditEdbinfo(tradeCode, secName, unit, frequency, noticeTime string, classifyId int) (err error) {
|
|
|
sql := `UPDATE edbinfo SET SEC_NAME= ?, UNIT = ?,classify_id=?,frequency=?,notice_time=?,create_date=NOW() WHERE TRADE_CODE=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, secName, unit, classifyId, frequency, noticeTime, tradeCode).Exec()
|
|
|
return
|
|
|
}
|
|
@@ -310,8 +293,7 @@ func SearchTargetEntry(classifyId int, keyWord string) (items []*Edbinfo, err er
|
|
|
}
|
|
|
sql := `SELECT * FROM edbinfo WHERE LEFT(TRADE_CODE,1)='W' AND REMARK='手动' AND classify_id>0 AND classify_id=? `
|
|
|
sql += where
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, classifyId).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -329,8 +311,7 @@ type EdbdataClassify struct {
|
|
|
|
|
|
func GetEdbdataClassifyByClassifyName(classifyName string) (item *EdbdataClassify, err error) {
|
|
|
sql := `SELECT * FROM edbdata_classify WHERE classify_name=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, classifyName).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
@@ -344,8 +325,7 @@ type EdbdataClassifyList struct {
|
|
|
|
|
|
func GetEdbdataClassify(userId int64) (items []*EdbdataClassifyList, err error) {
|
|
|
var newItems []*EdbdataClassifyList
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := ` SELECT classify_id,classify_name,parent_id FROM edbdata_classify WHERE parent_id=0 `
|
|
|
_, err = o.Raw(sql).QueryRows(&newItems)
|
|
|
if err != nil {
|
|
@@ -407,56 +387,49 @@ type EdbdataClassifyResp struct {
|
|
|
|
|
|
func GetTargetBySecName(secName string) (item *Edbinfo, err error) {
|
|
|
sql := `SELECT * FROM edbinfo WHERE SEC_NAME=? AND left(TRADE_CODE,1)='W' AND REMARK='手动' `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, secName).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//更新指标数据信息
|
|
|
func (edbinfo *Edbinfo) Update(cols []string) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Update(edbinfo, cols...)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func ModifyTargetClassifyId(tradeCode string, classifyId int) (err error) {
|
|
|
sql := `UPDATE edbinfo SET classify_id=? WHERE TRADE_CODE=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, classifyId, tradeCode).Exec()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetTargetsDataCount(tradeCode, dt string) (count int, err error) {
|
|
|
sql := `SELECT COUNT(1) AS count FROM edbdata WHERE TRADE_CODE=? AND DT=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, tradeCode, dt).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetTargetsData(tradeCode, dt string) (item *Edbdata, err error) {
|
|
|
sql := `SELECT * FROM edbdata WHERE TRADE_CODE=? AND DT=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, tradeCode, dt).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func ModifyTargetsDataByImport(tradeCode, dt, close string) (err error) {
|
|
|
sql := `UPDATE edbdata SET CLOSE=?,modify_time=NOW() WHERE TRADE_CODE=? AND DT=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, close, tradeCode, dt).Exec()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func AddTargetsDataByImport(tradeCode, dt, close string) (err error) {
|
|
|
sql := `INSERT INTO edbdata(TRADE_CODE, DT,CLOSE, modify_time)VALUES(?,?,?,NOW()) `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, tradeCode, dt, close).Exec()
|
|
|
return
|
|
|
}
|
|
@@ -511,8 +484,7 @@ func GetDataListForExport(startDate, endDate, frequency, keyWord string, classif
|
|
|
sql += where
|
|
|
}
|
|
|
sql = sql + " ORDER BY c.DT DESC "
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -523,8 +495,7 @@ type DataDeleteReq struct {
|
|
|
}
|
|
|
|
|
|
func DataDelete(tradeCode, createDate, close string, modifyTime time.Time, sysUserId int) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
o.Begin()
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -545,8 +516,7 @@ func GetTargetInfoCount(tradeCode string) (count int, err error) {
|
|
|
sql := ` SELECT COUNT(1) AS count FROM edbdata AS c
|
|
|
INNER JOIN edbinfo AS a ON a.TRADE_CODE=c.TRADE_CODE
|
|
|
WHERE a.TRADE_CODE=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, tradeCode).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
@@ -556,14 +526,16 @@ type TargetDeleteReq struct {
|
|
|
}
|
|
|
|
|
|
func TargetDelete(tradeCode string) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
- o.Begin()
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
+ tx, err := o.Begin()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
- o.Rollback()
|
|
|
+ _ = tx.Rollback()
|
|
|
} else {
|
|
|
- o.Commit()
|
|
|
+ _ = tx.Commit()
|
|
|
}
|
|
|
}()
|
|
|
|
|
@@ -594,8 +566,7 @@ func GetResearcherEntry() (items []*Researcher, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
_, err = o.Raw(sql).QueryRows(&items)
|
|
|
researchLen := len(items)
|
|
|
- edbO := orm.NewOrm()
|
|
|
- edbO.Using("edb")
|
|
|
+ edbO := orm.NewOrmUsingDB("edb")
|
|
|
for i := 0; i < researchLen; i++ {
|
|
|
var count int
|
|
|
mobile := items[i].Mobile
|
|
@@ -616,8 +587,7 @@ func GetResearcherEntryByMobile(mobile string) (items []*Researcher, err error)
|
|
|
o := orm.NewOrm()
|
|
|
_, err = o.Raw(sql).QueryRows(&items)
|
|
|
researchLen := len(items)
|
|
|
- edbO := orm.NewOrm()
|
|
|
- edbO.Using("edb")
|
|
|
+ edbO := orm.NewOrmUsingDB("edb")
|
|
|
for i := 0; i < researchLen; i++ {
|
|
|
var count int
|
|
|
mobile := items[i].Mobile
|
|
@@ -654,8 +624,7 @@ type SortEdbInfo []EdbinfoItems
|
|
|
|
|
|
func GetTargetItems(mobile string, classifyId int) (lastItems SortEdbInfo, err error) {
|
|
|
var items []*EdbinfoItems
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
//sql := ` SELECT *,'' modify_date,'' status FROM edbinfo AS a WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0 `
|
|
|
|
|
|
sql := ` SELECT *,'' modify_date,'' STATUS FROM edbinfo AS a
|
|
@@ -972,8 +941,7 @@ func GetEdbdataSecName(condition string, pars []interface{}) (items []*EdbdataEx
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += " GROUP BY a.TRADE_CODE ORDER BY a.TRADE_CODE ASC "
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -984,8 +952,7 @@ type EdbdataList struct {
|
|
|
|
|
|
func GetEdbdataList(tradeCode string) (items []*EdbdataList, err error) {
|
|
|
sql := ` SELECT DT FROM edbdata WHERE TRADE_CODE IN(` + tradeCode + `) GROUP BY DT ORDER BY DT DESC `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -998,16 +965,14 @@ type EdbdataItem struct {
|
|
|
|
|
|
func GetEdbdataValueByTradeCode(tradeCode, dt string) (item *EdbdataItem, err error) {
|
|
|
sql := ` SELECT TRADE_CODE,DT,CLOSE FROM edbdata WHERE TRADE_CODE=? AND DT=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
err = o.Raw(sql, tradeCode, dt).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetEdbdataClassifyByParentId(parentId int) (items []*EdbdataClassify, err error) {
|
|
|
sql := ` SELECT * FROM edbdata_classify WHERE parent_id=? `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
o.Raw(sql, parentId).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -1018,8 +983,7 @@ type LzPriceClassify struct {
|
|
|
|
|
|
func GetLzPriceClassify() (items []*LzPriceClassify, err error) {
|
|
|
sql := ` SELECT product_name FROM longzhongpriceinfo GROUP BY product_name ORDER BY product_name DESC `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
o.Raw(sql).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -1042,15 +1006,13 @@ type Longzhongpriceinfo struct {
|
|
|
|
|
|
func GetLongzhongpriceinfoByClassifyName(productName string) (items []*Longzhongpriceinfo, err error) {
|
|
|
sql := `SELECT * FROM longzhongpriceinfo WHERE product_name=? ORDER BY longzhongpriceinfo_id ASC `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, productName).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetLongzhongPriceDataMaxCount(productName string) (count int, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := `SELECT MAX(t.num) AS count FROM (
|
|
|
SELECT COUNT(1) AS num FROM longzhongpriceinfo AS a
|
|
|
INNER JOIN longzhongpricedata AS b ON a.longzhongpriceinfo_id=b.longzhongpriceinfo_id
|
|
@@ -1079,8 +1041,7 @@ type LongzhongpricedataItems struct {
|
|
|
}
|
|
|
|
|
|
func GetLongzhongPriceDataById(lzPriceInfoId int) (items []*LongzhongpricedataItems, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := ` SELECT DISTINCT a.longzhongpriceinfo_id,a.price_date,a.memo,a.price,a.cny_price,a.zsy_price,a.zsh_price,a.low_price,a.high_price,a.rise_price,a.ton_price,a.price_type,a.update_date
|
|
|
FROM longzhongpricedata AS a
|
|
|
WHERE longzhongpriceinfo_id=? ORDER BY price_date DESC `
|
|
@@ -1090,8 +1051,7 @@ func GetLongzhongPriceDataById(lzPriceInfoId int) (items []*LongzhongpricedataIt
|
|
|
|
|
|
func GetLzSurveyClassify() (items []*LzPriceClassify, err error) {
|
|
|
sql := ` SELECT breed_name AS product_name FROM longzhong_survey_product GROUP BY breed_name ORDER BY breed_name DESC `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
o.Raw(sql).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -1128,8 +1088,7 @@ type LongzhongSurveyProduct struct {
|
|
|
|
|
|
func GetLongzhongSurveyProductByClassifyName(productName string) (items []*LongzhongSurveyProduct, err error) {
|
|
|
sql := `SELECT * FROM longzhong_survey_product WHERE breed_name=? ORDER BY survey_product_id ASC `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql, productName).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -1154,8 +1113,7 @@ type EdbInfoItem struct {
|
|
|
|
|
|
// GetTargetItemList 获取指标列表数据
|
|
|
func GetTargetItemList(classifyId, edbShowType int, frequency, keyword, tradeCode string, classifyIdStrList []string) (items []*EdbInfoItem, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
|
|
|
sql := ` SELECT a.*,'' modify_date,'' STATUS FROM edbinfo AS a `
|
|
|
if edbShowType != 0 {
|
|
@@ -1204,8 +1162,7 @@ left join edbdata b on a.TRADE_CODE=b.TRADE_CODE `
|
|
|
// GetEdbDataListByCodes 通过指标ID获取所有数据
|
|
|
func GetEdbDataListByCodes(tradeCode string) (items []*Edbdata, err error) {
|
|
|
sql := ` SELECT TRADE_CODE,DT,round(CLOSE,4) CLOSE,modify_time FROM edbdata WHERE TRADE_CODE IN(` + tradeCode + `) GROUP BY TRADE_CODE,DT ORDER BY DT DESC `
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
_, err = o.Raw(sql).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -1224,8 +1181,7 @@ type BatchDataDeleteReq struct {
|
|
|
|
|
|
// BatchDeleteEdbDataByDate 批量删除某日的指标数据
|
|
|
func BatchDeleteEdbDataByDate(tradeCodes, dt string, opUserId int) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
var list []*Edbdata
|
|
|
sql := ` select * FROM edbdata WHERE TRADE_CODE in (` + tradeCodes + `) AND DT = ? `
|
|
|
_, err = o.Raw(sql, dt).QueryRows(&list)
|
|
@@ -1258,8 +1214,7 @@ func BatchDeleteEdbDataByDate(tradeCodes, dt string, opUserId int) (err error) {
|
|
|
|
|
|
// BatchDeleteEdbData 批量删除指标数据
|
|
|
func BatchDeleteEdbData(tradeCode string, opUserId int) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
var list []*Edbdata
|
|
|
sql := ` select * FROM edbdata WHERE TRADE_CODE = ? `
|
|
|
_, err = o.Raw(sql, tradeCode).QueryRows(&list)
|
|
@@ -1289,8 +1244,7 @@ func BatchDeleteEdbData(tradeCode string, opUserId int) (err error) {
|
|
|
|
|
|
// GetEdbInfoCountByClassifyId 根据指标分类id获取当前分类下的指标数量
|
|
|
func GetEdbInfoCountByClassifyId(classifyId int) (count int, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := `SELECT COUNT(1) AS count FROM ( SELECT a.*,b.CLOSE FROM edbinfo AS a
|
|
|
INNER JOIN edbdata AS b ON a.TRADE_CODE=b.TRADE_CODE
|
|
|
WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id=? group by a.TRADE_CODE) d `
|
|
@@ -1306,8 +1260,7 @@ type EdbInfoGroupCount struct {
|
|
|
|
|
|
// GetEdbInfoGroupCountByClassifyIds 根据指标分类id获取当前分类下的指标数量
|
|
|
func GetEdbInfoGroupCountByClassifyIds(classifyIds string) (list []*EdbInfoGroupCount, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- o.Using("edb")
|
|
|
+ o := orm.NewOrmUsingDB("edb")
|
|
|
sql := `SELECT COUNT(1) AS count,classify_id FROM ( SELECT a.*,b.CLOSE FROM edbinfo AS a
|
|
|
INNER JOIN edbdata AS b ON a.TRADE_CODE=b.TRADE_CODE
|
|
|
WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' and a.classify_id in (` + classifyIds + `) group by a.TRADE_CODE) d
|