|
@@ -30,7 +30,7 @@ func GetDictIndex(condition string, pars []interface{}) (dictIndexList []DictInd
|
|
|
}
|
|
|
|
|
|
// GetDictPageIndex 分页获取指标
|
|
|
-func GetDictPageIndex(condition string, pars []interface{}, pageIndex, pageSize int) (dictIndexList []DictIndex, err error) {
|
|
|
+func GetDictPageIndex(condition string, pars []interface{}, pageIndex, pageSize, sortField, sortRule int) (dictIndexList []DictIndex, err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Printf("查询指标信息失败 %s", err)
|
|
@@ -39,7 +39,16 @@ func GetDictPageIndex(condition string, pars []interface{}, pageIndex, pageSize
|
|
|
}()
|
|
|
|
|
|
fields := "ID, CODE, NAME, UNIT, FREQUENCY, DESCRIPTION, TABLE_NAME, SOURCE_TYPE, SOURCE_CODE, SOURCE_DESCRIPTION, INDUSTRY, TYPE, COMMODITY, SJB_ID, USER_ID, ROWS_COUNT, DATE_FIRST, DATE_LAST, TIME_LAST_UPDATE, TIME_LAST_REQUEST, PRIORITY, STATUS, SHORT_NAME, UPDATE_DESCRIPTION, FORECAST_FLAG, MANUAL_FLAG, VARIABLE_FLAG, MARKETDATA_FLAG, CREATE_USER, CREATE_TIME, UPDATE_USER, UPDATE_TIME"
|
|
|
- sqlBase := fmt.Sprintf(`SELECT %s, no FROM (SELECT rownum no, a.* FROM %s a WHERE %s) WHERE no BETWEEN %d AND %d`, fields, IndexTableName, condition, (pageIndex-1)*pageSize+1, pageIndex*pageSize)
|
|
|
+
|
|
|
+ // 排序
|
|
|
+ order := ``
|
|
|
+ sortFMap := map[int]string{1: "DateFirst", 2: "DateLast", 3: "TimeLastUpdate"}
|
|
|
+ sortRMap := map[int]string{1: "ASC", 2: "DESC"}
|
|
|
+ if sortFMap[sortField] != "" && sortRMap[sortRule] != "" {
|
|
|
+ order = fmt.Sprintf("ORDER BY %s %s", sortFMap[sortField], sortRMap[sortRule])
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlBase := fmt.Sprintf(`SELECT %s, no FROM (SELECT rownum no, a.* FROM %s a WHERE %s) WHERE no BETWEEN %d AND %d %s`, fields, IndexTableName, condition, (pageIndex-1)*pageSize+1, pageIndex*pageSize, order)
|
|
|
dictIndexList, err = getDictIndex(sqlBase, pars)
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("查询指标信息失败 %s", err)
|