|
@@ -138,3 +138,378 @@ func (this *BaseFromLyController) Refresh() {
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|
|
|
}
|
|
|
+
|
|
|
+// GetLyClassifyByName
|
|
|
+// @Title 获取分类
|
|
|
+// @Description 获取分类
|
|
|
+// @Success 200 {object} models.BaseFromLyClassify
|
|
|
+// @router /get/ly/classify/by/name [get]
|
|
|
+func (this *BaseFromLyController) GetLyClassifyByName() {
|
|
|
+ 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()
|
|
|
+ }()
|
|
|
+
|
|
|
+ categoryName := this.GetString("CategoryName")
|
|
|
+
|
|
|
+ if categoryName == "" {
|
|
|
+ br.Msg = "请输入分类!"
|
|
|
+ br.ErrMsg = "请输入分类"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ lyClassify, err := models.GetLyClassifyByName(categoryName)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = lyClassify
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// GetLyIndexRecordByUrl
|
|
|
+// @Title 根据url获取指标已读取记录
|
|
|
+// @Description 根据url获取指标已读取记录
|
|
|
+// @Success 200 {object} models.BaseFromLyIndexRecord
|
|
|
+// @router /get/ly/index/record/by/url [get]
|
|
|
+func (this *BaseFromLyController) GetLyIndexRecordByUrl() {
|
|
|
+ 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()
|
|
|
+ }()
|
|
|
+
|
|
|
+ url := this.GetString("Url")
|
|
|
+
|
|
|
+ if url == "" {
|
|
|
+ br.Msg = "请输入地址链接!"
|
|
|
+ br.ErrMsg = "请输入地址链接"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ lyIndexRecord, err := models.GetLyIndexRecordByUrl(url)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = lyIndexRecord
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// AddLyIndexRecord
|
|
|
+// @Title 维护指标数据读取进度到数据库
|
|
|
+// @Description 维护指标数据读取进度到数据库
|
|
|
+// @Success 200 string "处理成功"
|
|
|
+// @router /add/ly/index/record [post]
|
|
|
+func (this *BaseFromLyController) AddLyIndexRecord() {
|
|
|
+ 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.BaseFromLyIndexRecord
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = models.AddLyIndexRecord(&req)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "处理成功"
|
|
|
+}
|
|
|
+
|
|
|
+// AddLyDataList
|
|
|
+// @Title 新增指标数据
|
|
|
+// @Description 新增指标数据列表
|
|
|
+// @Success 200 string "处理成功"
|
|
|
+// @router /add/ly/data/list [post]
|
|
|
+func (this *BaseFromLyController) AddLyDataList() {
|
|
|
+ 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.BaseFromLyData
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = models.AddLyDataList(req)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "处理成功"
|
|
|
+}
|
|
|
+
|
|
|
+// AddLyIndex
|
|
|
+// @Title 新增指标
|
|
|
+// @Description 新增指标
|
|
|
+// @Success 200 string "处理成功"
|
|
|
+// @router /add/ly/index [post]
|
|
|
+func (this *BaseFromLyController) AddLyIndex() {
|
|
|
+ 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.BaseFromLyIndex
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ indexId, err := models.AddLyIndex(&req)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = indexId
|
|
|
+ br.Msg = "处理成功"
|
|
|
+}
|
|
|
+
|
|
|
+// GetLyDataByIndexIdAndDataTime
|
|
|
+// @Title 根据指标id和时间获取指标数据
|
|
|
+// @Description 根据指标id和时间获取指标数据
|
|
|
+// @Success 200 {object} models.BaseFromLyData
|
|
|
+// @router /get/ly/data/by/index/id/and/data/time [get]
|
|
|
+func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTime() {
|
|
|
+ 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()
|
|
|
+ }()
|
|
|
+
|
|
|
+ indexId, err := this.GetInt("IndexId")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if indexId == 0 {
|
|
|
+ br.Msg = "请输入指标id!"
|
|
|
+ br.ErrMsg = "请输入指标id"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ dataTime := this.GetString("DataTime")
|
|
|
+
|
|
|
+ if dataTime == "" {
|
|
|
+ br.Msg = "请输入时间!"
|
|
|
+ br.ErrMsg = "请输入时间"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ lyData, err := models.GetLyDataByIndexIdAndDataTime(indexId, dataTime)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = lyData
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// GetLyDataByIndexIdAndDataTimeYM
|
|
|
+// @Title 根据指标id和年月时间获取指标数据
|
|
|
+// @Description 根据指标id和年月时间获取指标数据
|
|
|
+// @Success 200 {object} models.BaseFromLyData
|
|
|
+// @router /get/ly/data/by/index/id/and/data/time/ym [get]
|
|
|
+func (this *BaseFromLyController) GetLyDataByIndexIdAndDataTimeYM() {
|
|
|
+ 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()
|
|
|
+ }()
|
|
|
+
|
|
|
+ indexId, err := this.GetInt("IndexId")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if indexId == 0 {
|
|
|
+ br.Msg = "请输入指标id!"
|
|
|
+ br.ErrMsg = "请输入指标id"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ yearMonth := this.GetString("YearMonth")
|
|
|
+
|
|
|
+ if yearMonth == "" {
|
|
|
+ br.Msg = "请输入时间!"
|
|
|
+ br.ErrMsg = "请输入时间"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ lyData, err := models.GetLyDataByIndexIdAndDataTimeYM(indexId, yearMonth)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = lyData
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateLyDataById
|
|
|
+// @Title 更新数据源指标数据
|
|
|
+// @Description 更新数据源指标数据
|
|
|
+// @Success 200 string "处理成功"
|
|
|
+// @router /update/ly/data/by/id [get]
|
|
|
+func (this *BaseFromLyController) UpdateLyDataById() {
|
|
|
+ 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()
|
|
|
+ }()
|
|
|
+
|
|
|
+ id, err := this.GetInt("Id")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ if value == 0 {
|
|
|
+ br.Msg = "请输入值!"
|
|
|
+ br.ErrMsg = "请输入值"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = models.UpdateLyDataById(id, value)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "处理成功"
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateLyEdbDataById
|
|
|
+// @Title 更新指标库指标数据
|
|
|
+// @Description 更新数据源指标数据
|
|
|
+// @Success 200 string "处理成功"
|
|
|
+// @router /update/ly/edb/data/by/id [get]
|
|
|
+func (this *BaseFromLyController) UpdateLyEdbDataById() {
|
|
|
+ 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()
|
|
|
+ }()
|
|
|
+
|
|
|
+ id, err := this.GetInt("Id")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ if value == 0 {
|
|
|
+ br.Msg = "请输入值!"
|
|
|
+ br.ErrMsg = "请输入值"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = models.UpdateLyDataById(id, value)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "处理成功"
|
|
|
+}
|