浏览代码

Merge branch 'bzq1/sci_hq_custom' of eta_server/eta_api into debug

鲍自强 8 月之前
父节点
当前提交
0fa7239279

+ 1 - 1
controllers/data_manage/sci_hq_data.go

@@ -395,7 +395,7 @@ func (this *SciHqDataController) IndexPageList() {
 	}
 	startSize = utils.StartIndex(currrentIndex, pageSize)
 	var total int
-	var indexList []*data_manage.BaseFromSciHqIndex
+	var indexList []*data_manage.BaseFromSciHqIndexView
 	if isListAll {
 		tmpTotal, err := data_manage.GetSciHqIndexCount()
 		if err != nil {

+ 13 - 4
models/data_manage/base_from_sci_hq_index.go

@@ -35,6 +35,7 @@ type BaseFromSciHqIndexView struct {
 	EndDate              string `description:"结束日期"`
 	Sort                 int    `description:"排序"`
 	EdbExist             int    `description:"edb是否存在"`
+	ModifyTime           string
 }
 
 func (b *BaseFromSciHqIndex) Update(cols []string) (err error) {
@@ -135,9 +136,13 @@ func GetSciHqIndexCountByClassifyIds(classifyIds []int) (count int, err error) {
 }
 
 // GetSciHqIndexByClassifyId 根据分类id获取卓创红期指标列表
-func GetSciHqIndexByClassifyId(classifyId, startSize, pageSize int) (items []*BaseFromSciHqIndex, err error) {
+func GetSciHqIndexByClassifyId(classifyId, startSize, pageSize int) (items []*BaseFromSciHqIndexView, err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT * FROM base_from_sci_hq_index WHERE classify_id = ?  ORDER BY sort ASC LIMIT ?,? `
+	sql := ` SELECT b.*, e.edb_info_id,
+	CASE WHEN e.edb_info_id IS NULL THEN 0 ELSE 1 END AS edb_exist
+	FROM base_from_sci_hq_index AS b
+	LEFT JOIN edb_info AS e ON b.index_code=e.edb_code AND e.source=88
+	WHERE b.classify_id = ? ORDER BY b.sort ASC LIMIT ?,? `
 	_, err = o.Raw(sql, classifyId, startSize, pageSize).QueryRows(&items)
 	return
 }
@@ -158,9 +163,13 @@ func GetSciHqIndexCount() (count int, err error) {
 	return
 }
 
-func GetSciHqIndexByPage(startSize, pageSize int) (items []*BaseFromSciHqIndex, err error) {
+func GetSciHqIndexByPage(startSize, pageSize int) (items []*BaseFromSciHqIndexView, err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT * FROM base_from_sci_hq_index ORDER BY modify_time DESC LIMIT ?,?`
+	sql := ` SELECT b.*, e.edb_info_id,
+	CASE WHEN e.edb_info_id IS NULL THEN 0 ELSE 1 END AS edb_exist
+	FROM base_from_sci_hq_index AS b
+	LEFT JOIN edb_info AS e ON b.index_code=e.edb_code AND e.source=88
+	ORDER BY b.modify_time DESC LIMIT ?,?`
 	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 1 - 1
models/data_manage/response/sci_hq_data.go

@@ -7,7 +7,7 @@ import (
 )
 
 type SciHqIndexPageListResp struct {
-	List   []*data_manage.BaseFromSciHqIndex
+	List   []*data_manage.BaseFromSciHqIndexView
 	Paging *paging.PagingItem
 }