Roc 3 سال پیش
والد
کامیت
ac9b6e09b6

+ 1 - 2
models/data_manage/edb_data_coal.go

@@ -38,8 +38,7 @@ func GetCoalSurveyDataByTradeCode(condition string, pars []interface{}) (item []
 	sql := ` SELECT  a.* FROM longzhong_survey_data AS a
 				INNER JOIN longzhong_survey_product AS b ON a.survey_product_id=b.survey_product_id
 				WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	if condition != "" {
 		sql += condition
 	}

+ 1 - 2
models/data_manage/edb_data_gl.go

@@ -36,8 +36,7 @@ type GlData struct {
 
 func GetGlDataByTradeCode(condition string, pars []interface{}) (item []*GlData, err error) {
 	sql := ` SELECT * FROM mb_index_main_data WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("gl")
+	o := orm.NewOrmUsingDB("gl")
 	if condition != "" {
 		sql += condition
 	}

+ 1 - 2
models/data_manage/edb_data_lz.go

@@ -38,8 +38,7 @@ func GetLzSurveyDataByTradeCode(condition string, pars []interface{}) (item []*l
 	sql := ` SELECT  a.* FROM longzhong_survey_data AS a
 				INNER JOIN longzhong_survey_product AS b ON a.survey_product_id=b.survey_product_id
 				WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	if condition != "" {
 		sql += condition
 	}

+ 1 - 2
models/data_manage/edb_data_manual.go

@@ -31,8 +31,7 @@ type ManualEdbdata struct {
 
 func GetEdbdataManualByTradeCode(condition string, pars []interface{}) (item []*ManualEdbdata, err error) {
 	sql := ` SELECT  * FROM edbdata WHERE 1=1 `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	if condition != "" {
 		sql += condition
 	}

+ 6 - 12
models/data_manage/gl_data.go

@@ -11,8 +11,7 @@ type GlClassify struct {
 
 func GetGlSurveyClassify() (items []*GlClassify, err error) {
 	sql := ` SELECT CASE WHEN BREED_SHORT_NAME IS NULL THEN '无' ELSE BREED_SHORT_NAME END BREED_SHORT_NAME  FROM mb_index_main_info GROUP BY BREED_SHORT_NAME ORDER BY BREED_SHORT_NAME ASC `
-	o := orm.NewOrm()
-	o.Using("gl")
+	o := orm.NewOrmUsingDB("gl")
 	o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -22,8 +21,7 @@ type GlFrequency struct {
 }
 
 func GetGlFrequencyByClassifyId(breedShortName string) (items []*GlFrequency, err error) {
-	o := orm.NewOrm()
-	o.Using("gl")
+	o := orm.NewOrmUsingDB("gl")
 	if breedShortName == "无" {
 		sql := ` SELECT FREQUENCY_NAME AS frequency FROM mb_index_main_info WHERE BREED_SHORT_NAME IS NULL GROUP BY FREQUENCY_CODE ORDER BY FREQUENCY_CODE ASC `
 		_, err = o.Raw(sql).QueryRows(&items)
@@ -45,8 +43,7 @@ type GlIndex struct {
 }
 
 func GetGlIndex(breedShortName, frequency string) (items []*GlIndex, err error) {
-	o := orm.NewOrm()
-	o.Using("gl")
+	o := orm.NewOrmUsingDB("gl")
 	if breedShortName == "无" {
 		sql := ` SELECT * FROM mb_index_main_info WHERE BREED_SHORT_NAME IS NULL AND FREQUENCY_NAME=? ORDER BY INDEX_CODE ASC `
 		_, err = o.Raw(sql, frequency).QueryRows(&items)
@@ -82,23 +79,20 @@ func GetGlIndexData(indexCode string, startSize, pageSize int) (items []*GlIndex
 	)AS t
 	GROUP BY t.DATA_DATE
 	ORDER BY t.DATA_DATE DESC LIMIT ?,? `
-	o := orm.NewOrm()
-	o.Using("gl")
+	o := orm.NewOrmUsingDB("gl")
 	_, err = o.Raw(sql, indexCode, startSize, pageSize).QueryRows(&items)
 	return
 }
 
 func GetGlIndexByCode(indexCode string) (items *GlIndex, err error) {
 	sql := ` SELECT *  FROM mb_index_main_info WHERE INDEX_CODE=? `
-	o := orm.NewOrm()
-	o.Using("gl")
+	o := orm.NewOrmUsingDB("gl")
 	err = o.Raw(sql, indexCode).QueryRow(&items)
 	return
 }
 
 func GetGlIndexDataCount(indexCode string) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("gl")
+	o := orm.NewOrmUsingDB("gl")
 	sql := `SELECT COUNT(1) AS count FROM (
 			SELECT * FROM (
 				SELECT DISTINCT a.INDEX_CODE,a.DATA_VALUE,a.DATA_DATE FROM mb_index_main_data AS a WHERE INDEX_CODE=?

+ 5 - 10
models/data_manage/lz_data.go

@@ -12,8 +12,7 @@ type LzClassify struct {
 
 func GetLzSurveyClassify() (items []*LzClassify, err error) {
 	sql := ` SELECT breed_id,breed_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
 }
@@ -24,8 +23,7 @@ type LzFrequency struct {
 
 func GetLzFrequencyByClassifyId(breedId int) (items []*LzFrequency, err error) {
 	sql := ` SELECT frequency  FROM longzhong_survey_product WHERE breed_id=? GROUP BY frequency ORDER BY frequency ASC `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql, breedId).QueryRows(&items)
 	return
 }
@@ -63,8 +61,7 @@ type LongzhongSurveyProduct struct {
 
 func GetLongzhongSurveyProduct(breedId, frequency int) (items []*LongzhongSurveyProduct, err error) {
 	sql := ` SELECT *  FROM longzhong_survey_product WHERE breed_id=? AND frequency=? ORDER BY survey_product_id ASC `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql, breedId, frequency).QueryRows(&items)
 	return
 }
@@ -93,16 +90,14 @@ type LzProductData struct {
 
 func GetLongzhongSurveyProductData(surveyProductId int) (items []*LzProductData, err error) {
 	sql := ` SELECT *  FROM longzhong_survey_data WHERE survey_product_id=? ORDER BY data_time DESC `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql, surveyProductId).QueryRows(&items)
 	return
 }
 
 func GetLongzhongSurveyProductByCode(lzCode string) (items *LongzhongSurveyProduct, err error) {
 	sql := ` SELECT *  FROM longzhong_survey_product WHERE lz_code=? `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	err = o.Raw(sql, lzCode).QueryRow(&items)
 	return
 }

+ 1 - 2
models/data_manage/manual.go

@@ -18,8 +18,7 @@ func GetManualClassifyEdbInfoCount() (items []*ManualClassifyEdbInfoCount, err e
 			INNER JOIN edbinfo AS b ON a.classify_id=b.classify_id
 			WHERE a.is_show=1
 			GROUP BY a.classify_id `
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 8 - 16
models/data_manage/manual_classify.go

@@ -25,8 +25,7 @@ type EdbdataClassifyList struct {
 }
 
 func AddEdbdataClassify(item *EdbdataClassify) (lastId int64, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	lastId, err = o.Insert(item)
 	return
 }
@@ -41,8 +40,7 @@ type ManualClassifyList struct {
 
 func GetManualClassifyAll(adminId int) (items []*ManualClassifyList, err error) {
 	var newItems []*ManualClassifyList
-	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 AND is_show=1 ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&newItems)
 	if err != nil {
@@ -99,24 +97,21 @@ type AddManualClassifyReq struct {
 }
 
 func GetManualClassifyCount(classifyName string, parentId int) (count int, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT COUNT(1) AS count FROM edbdata_classify WHERE parent_id=? AND classify_name=? `
 	err = o.Raw(sql, parentId, classifyName).QueryRow(&count)
 	return
 }
 
 func GetManualClassifyByClassifyName(classifyName string) (item *EdbdataClassify, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `SELECT * FROM edbdata_classify WHERE classify_name=? `
 	err = o.Raw(sql, classifyName).QueryRow(&item)
 	return
 }
 
 func ModifyManualClassifyIsShow(isShow, classifyId, parentId int) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `UPDATE edbdata_classify SET is_show=?,parent_id=? WHERE classify_id=? `
 	_, err = o.Raw(sql, isShow, parentId, classifyId).Exec()
 	return
@@ -128,24 +123,21 @@ type EditManualClassifyReq struct {
 }
 
 func GetManualClassifyById(classifyId int) (item *EdbdataClassify, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ` SELECT * FROM edbdata_classify WHERE classify_id=? `
 	err = o.Raw(sql, classifyId).QueryRow(&item)
 	return
 }
 
 func ModifyManualClassifyName(classifyName string, classifyId int) (err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := `UPDATE edbdata_classify SET classify_name=? WHERE classify_id=? `
 	_, err = o.Raw(sql, classifyName, classifyId).Exec()
 	return
 }
 
 func GetManualClassifyAllByCondition(condition string) (items []*EdbdataClassifyList, err error) {
-	o := orm.NewOrm()
-	o.Using("edb")
+	o := orm.NewOrmUsingDB("edb")
 	sql := ` SELECT classify_id,classify_name,parent_id FROM edbdata_classify WHERE is_show=1 `
 	if condition != "" {
 		sql += condition

+ 56 - 103
models/target.go

@@ -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