|
@@ -7,6 +7,7 @@ import (
|
|
|
"eta/eta_index_lib/models"
|
|
|
"eta/eta_index_lib/services"
|
|
|
"eta/eta_index_lib/utils"
|
|
|
+ "fmt"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
|
@@ -143,7 +144,7 @@ func (this *BaseFromLyController) Refresh() {
|
|
|
// @Title 获取分类
|
|
|
// @Description 获取分类
|
|
|
// @Success 200 {object} models.BaseFromLyClassify
|
|
|
-// @router /get/ly/classify/by/name [get]
|
|
|
+// @router /get/ly/classify/by/name [post]
|
|
|
func (this *BaseFromLyController) GetLyClassifyByName() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
var cacheKey string
|
|
@@ -155,9 +156,15 @@ func (this *BaseFromLyController) GetLyClassifyByName() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
- categoryName := this.GetString("CategoryName")
|
|
|
-
|
|
|
+ var reqData struct {
|
|
|
+ CategoryName string `json:"CategoryName"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
+ if err != nil {
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ categoryName := reqData.CategoryName
|
|
|
if categoryName == "" {
|
|
|
br.Msg = "请输入分类!"
|
|
|
br.ErrMsg = "请输入分类"
|
|
@@ -179,7 +186,7 @@ func (this *BaseFromLyController) GetLyClassifyByName() {
|
|
|
// @Title 根据url获取指标已读取记录
|
|
|
// @Description 根据url获取指标已读取记录
|
|
|
// @Success 200 {object} models.BaseFromLyIndexRecord
|
|
|
-// @router /get/ly/index/record/by/url [get]
|
|
|
+// @router /get/ly/index/record/by/url [post]
|
|
|
func (this *BaseFromLyController) GetLyIndexRecordByUrl() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
var cacheKey string
|
|
@@ -191,9 +198,15 @@ func (this *BaseFromLyController) GetLyIndexRecordByUrl() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
- url := this.GetString("Url")
|
|
|
-
|
|
|
+ var reqData struct {
|
|
|
+ Url string `json:"Url"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
+ if err != nil {
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ url := reqData.Url
|
|
|
if url == "" {
|
|
|
br.Msg = "请输入地址链接!"
|
|
|
br.ErrMsg = "请输入地址链接"
|
|
@@ -235,13 +248,14 @@ func (this *BaseFromLyController) AddLyIndexRecord() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- _, err = models.AddLyIndexRecord(&req)
|
|
|
+ id, err := models.AddLyIndexRecord(&req)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
+ br.Data = id
|
|
|
br.Msg = "处理成功"
|
|
|
}
|
|
|
|
|
@@ -262,6 +276,7 @@ func (this *BaseFromLyController) AddLyDataList() {
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
var req []models.BaseFromLyData
|
|
|
+ fmt.Println(string(this.Ctx.Input.RequestBody))
|
|
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
if err != nil {
|
|
|
br.Msg = "参数解析异常!"
|
|
@@ -271,6 +286,8 @@ func (this *BaseFromLyController) AddLyDataList() {
|
|
|
|
|
|
err = models.AddLyDataList(req)
|
|
|
if err != nil {
|
|
|
+ br.Msg = "新增指标数据失败!"
|
|
|
+ br.ErrMsg = "新增指标数据失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -318,7 +335,7 @@ func (this *BaseFromLyController) AddLyIndex() {
|
|
|
// @Title 根据指标id和时间获取指标数据
|
|
|
// @Description 根据指标id和时间获取指标数据
|
|
|
// @Success 200 {object} models.BaseFromLyData
|
|
|
-// @router /get/ly/data/by/index/id/and/data/time [get]
|
|
|
+// @router /get/ly/data/by/index/id/and/data/time [post]
|
|
|
func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTime() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
var cacheKey string
|
|
@@ -330,21 +347,24 @@ func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTime() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
- indexId, err := this.GetInt("IndexId")
|
|
|
+ var reqData struct {
|
|
|
+ IndexId int `json:"IndexId"`
|
|
|
+ DataTime string `json:"DataTime"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ indexId := reqData.IndexId
|
|
|
if indexId == 0 {
|
|
|
br.Msg = "请输入指标id!"
|
|
|
br.ErrMsg = "请输入指标id"
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- dataTime := this.GetString("DataTime")
|
|
|
-
|
|
|
+ dataTime := reqData.DataTime
|
|
|
if dataTime == "" {
|
|
|
br.Msg = "请输入时间!"
|
|
|
br.ErrMsg = "请输入时间"
|
|
@@ -366,7 +386,7 @@ func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTime() {
|
|
|
// @Title 根据指标id和年月时间获取指标数据
|
|
|
// @Description 根据指标id和年月时间获取指标数据
|
|
|
// @Success 200 {object} models.BaseFromLyData
|
|
|
-// @router /get/ly/data/by/index/id/and/data/time/ym [get]
|
|
|
+// @router /get/ly/data/by/index/id/and/data/time/ym [post]
|
|
|
func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTimeYM() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
var cacheKey string
|
|
@@ -378,20 +398,24 @@ func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTimeYM() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
- indexId, err := this.GetInt("IndexId")
|
|
|
+ var reqData struct {
|
|
|
+ IndexId int `json:"IndexId"`
|
|
|
+ YearMonth string `json:"YearMonth"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ indexId := reqData.IndexId
|
|
|
if indexId == 0 {
|
|
|
br.Msg = "请输入指标id!"
|
|
|
br.ErrMsg = "请输入指标id"
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- yearMonth := this.GetString("YearMonth")
|
|
|
+ yearMonth := reqData.YearMonth
|
|
|
|
|
|
if yearMonth == "" {
|
|
|
br.Msg = "请输入时间!"
|
|
@@ -414,7 +438,7 @@ func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTimeYM() {
|
|
|
// @Title 更新数据源指标数据
|
|
|
// @Description 更新数据源指标数据
|
|
|
// @Success 200 string "处理成功"
|
|
|
-// @router /update/ly/data/by/id [get]
|
|
|
+// @router /update/ly/data/by/id [post]
|
|
|
func (this *BaseFromLyController) UpdateLyDataById() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
var cacheKey string
|
|
@@ -426,26 +450,24 @@ func (this *BaseFromLyController) UpdateLyDataById() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
- id, err := this.GetInt("Id")
|
|
|
+ var reqData struct {
|
|
|
+ Id int `json:"Id"`
|
|
|
+ Value float64 `json:"Value"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ id := reqData.Id
|
|
|
if id == 0 {
|
|
|
br.Msg = "请输入id!"
|
|
|
br.ErrMsg = "请输入id"
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- value, err := this.GetFloat("Value")
|
|
|
- if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
+ value := reqData.Value
|
|
|
if value == 0 {
|
|
|
br.Msg = "请输入值!"
|
|
|
br.ErrMsg = "请输入值"
|
|
@@ -462,11 +484,113 @@ func (this *BaseFromLyController) UpdateLyDataById() {
|
|
|
br.Msg = "处理成功"
|
|
|
}
|
|
|
|
|
|
+// GetLyEdbDataByIndexCodeAndDataTime
|
|
|
+// @Title 根据指标编码和模糊日期获取指标库数据
|
|
|
+// @Description 根据指标编码和模糊日期获取指标库数据
|
|
|
+// @Success 200 {object} []models.EdbDataLy
|
|
|
+// @router /get/ly/edb/data/by/index/code/and/data/time [post]
|
|
|
+func (this *BaseFromLyController) GetLyEdbDataByIndexCodeAndDataTime() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ var cacheKey string
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ _ = utils.Rc.Delete(cacheKey)
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ var reqData struct {
|
|
|
+ IndexCode string `json:"IndexCode"`
|
|
|
+ DataTime string `json:"DataTime"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
+ if err != nil {
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ indexCode := reqData.IndexCode
|
|
|
+ if indexCode == "" {
|
|
|
+ br.Msg = "请输入指标id!"
|
|
|
+ br.ErrMsg = "请输入指标id"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ dataTime := reqData.DataTime
|
|
|
+ if dataTime == "" {
|
|
|
+ br.Msg = "请输入时间!"
|
|
|
+ br.ErrMsg = "请输入时间"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ lyEdbData, err := models.GetLyEdbDataByIndexCodeAndDataTime(indexCode, dataTime)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = lyEdbData
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// GetLyEdbDataByIndexCodeAndExactDataTime
|
|
|
+// @Title 根据指标编码和精确日期获取指标库数据
|
|
|
+// @Description 根据指标编码和精确日期获取指标库数据
|
|
|
+// @Success 200 {object} []models.EdbDataLy
|
|
|
+// @router /get/ly/edb/data/by/index/code/and/exact/data/time [post]
|
|
|
+func (this *BaseFromLyController) GetLyEdbDataByIndexCodeAndExactDataTime() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ var cacheKey string
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ _ = utils.Rc.Delete(cacheKey)
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ var reqData struct {
|
|
|
+ IndexCode string `json:"IndexCode"`
|
|
|
+ DataTime string `json:"DataTime"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
+ if err != nil {
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ indexCode := reqData.IndexCode
|
|
|
+ if indexCode == "" {
|
|
|
+ br.Msg = "请输入指标id!"
|
|
|
+ br.ErrMsg = "请输入指标id"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ dataTime := reqData.DataTime
|
|
|
+ if dataTime == "" {
|
|
|
+ br.Msg = "请输入时间!"
|
|
|
+ br.ErrMsg = "请输入时间"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ lyEdbData, err := models.GetLyEdbDataByIndexCodeAndExactDataTime(indexCode, dataTime)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = lyEdbData
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
// UpdateLyEdbDataById
|
|
|
-// @Title 更新指标库指标数据
|
|
|
-// @Description 更新数据源指标数据
|
|
|
+// @Title 更新指标库数据 须根据指标编码和日期更新 仅适合月度数据
|
|
|
+// @Description 更新指标库数据 须根据指标编码和日期更新 仅适合月度数据
|
|
|
// @Success 200 string "处理成功"
|
|
|
-// @router /update/ly/edb/data/by/id [get]
|
|
|
+// @router /update/ly/edb/data/by/id [post]
|
|
|
func (this *BaseFromLyController) UpdateLyEdbDataById() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
var cacheKey string
|
|
@@ -478,33 +602,159 @@ func (this *BaseFromLyController) UpdateLyEdbDataById() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
-
|
|
|
- id, err := this.GetInt("Id")
|
|
|
+ var reqData struct {
|
|
|
+ Id int `json:"Id"`
|
|
|
+ Value float64 `json:"Value"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ id := reqData.Id
|
|
|
if id == 0 {
|
|
|
br.Msg = "请输入id!"
|
|
|
br.ErrMsg = "请输入id"
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- value, err := this.GetFloat("Value")
|
|
|
+ value := reqData.Value
|
|
|
+ if value == 0 {
|
|
|
+ br.Msg = "请输入值!"
|
|
|
+ br.ErrMsg = "请输入值"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = models.UpdateLyEdbDataById(id, value)
|
|
|
if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if value == 0 {
|
|
|
- br.Msg = "请输入值!"
|
|
|
- br.ErrMsg = "请输入值"
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "处理成功"
|
|
|
+}
|
|
|
+
|
|
|
+// GetLyIndexByCode
|
|
|
+// @Title 查询指标编码是否存在
|
|
|
+// @Description 查询指标编码是否存在
|
|
|
+// @Success 200 {object} models.BaseFromLyIndex
|
|
|
+// @router /get/ly/index/by/code [post]
|
|
|
+func (this *BaseFromLyController) GetLyIndexByCode() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ var cacheKey string
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ _ = utils.Rc.Delete(cacheKey)
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ var reqData struct {
|
|
|
+ IndexCode string `json:"IndexCode"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
+ if err != nil {
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- err = models.UpdateLyDataById(id, value)
|
|
|
+ indexCode := reqData.IndexCode
|
|
|
+ if indexCode == "" {
|
|
|
+ br.Msg = "请输入指标id!"
|
|
|
+ br.ErrMsg = "请输入指标id"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ lyIndex, err := models.GetLyIndexByCode(indexCode)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = lyIndex
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// GetEdbInfoByIndexCode
|
|
|
+// @Title 根据指标code获取指标信息
|
|
|
+// @Description 根据指标code获取指标信息
|
|
|
+// @Success 200 {object} models.EdbInfo
|
|
|
+// @router /get/edb/info/by/index/code [post]
|
|
|
+func (this *BaseFromLyController) GetEdbInfoByIndexCode() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ var cacheKey string
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ _ = utils.Rc.Delete(cacheKey)
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ var reqData struct {
|
|
|
+ IndexCode string `json:"IndexCode"`
|
|
|
+ Source int `json:"Source"`
|
|
|
+ }
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqData)
|
|
|
+ if err != nil {
|
|
|
+ br.ErrMsg = "无法解析请求体"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ indexCode := reqData.IndexCode
|
|
|
+ if indexCode == "" {
|
|
|
+ br.Msg = "请输入指标id!"
|
|
|
+ br.ErrMsg = "请输入指标id"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ source := reqData.Source
|
|
|
+ if source == 0 {
|
|
|
+ br.Msg = "请输入来源!"
|
|
|
+ br.ErrMsg = "请输入来源"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ lyEdbData, err := models.GetEdbInfoByEdbCode(source, indexCode)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = lyEdbData
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// AddBatchLyEdbData
|
|
|
+// @Title 批量增加粮油指标库数据
|
|
|
+// @Description 批量增加粮油指标库数据
|
|
|
+// @Success 200 string "处理成功"
|
|
|
+// @router /add/batch/ly/edb/data [post]
|
|
|
+func (this *BaseFromLyController) AddBatchLyEdbData() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ var cacheKey string
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ _ = utils.Rc.Delete(cacheKey)
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ var req []models.EdbDataLy
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = models.AddLyEdbDataList(req)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|