12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package knowledge
- import (
- "encoding/json"
- "eta_gn/eta_bridge/controller/resp"
- "eta_gn/eta_bridge/global"
- knowledgeDao "eta_gn/eta_bridge/models/request/knowledge"
- "eta_gn/eta_bridge/services/index_data"
- "eta_gn/eta_bridge/services/knowledge"
- "github.com/gin-gonic/gin"
- )
- type KnowledgeController struct{}
- // ReportSave 存储
- func (k *KnowledgeController) ReportSave(c *gin.Context) {
- res, err := knowledge.ForwardRequest(c, global.CONFIG.EtaReport.Host+"v1/report/knowledge/upload")
- if err != nil {
- global.LOG.Error("knowledge save error: ", err)
- resp.Fail("保存失败", c)
- return
- }
- var result knowledge.KnowledgeUploadResp
- if e := json.Unmarshal(res, &result); e != nil {
- global.LOG.Error("knowledge save unmarshal error: ", e)
- resp.Fail("保存失败", c)
- return
- }
- if result.Ret != 200 {
- global.LOG.Info("knowledgeResp Ret:%d, Msg:%s, ErrMsg:%s ", result.Ret, result.Msg, result.ErrMsg)
- resp.Fail("保存失败", c)
- }
- resp.Ok("保存成功", c)
- }
- func (k *KnowledgeController) ViewPointSave(c *gin.Context) {
- var req knowledgeDao.KnowledgeRefreshReq
- if e := c.Bind(&req); e != nil {
- resp.FailData("参数解析失败", "Err:"+e.Error(), c)
- return
- }
- param := make(map[string]interface{})
- var res *index_data.MarketOverviewResp
- pageNum := 1
- for {
- param["pageNum"] = pageNum
- param["pageSize"] = req.PageSise
- if req.UpdateTime != "" {
- param["UPDATE_TIME"] = req.UpdateTime
- }
- tmp, err := index_data.GetMarketOverview(param)
- if err != nil {
- global.LOG.Error("knowledge save error: ", err)
- resp.Fail("保存失败", c)
- return
- }
- if res == nil {
- res = tmp
- } else {
- res.Data.Records = append(res.Data.Records, tmp.Data.Records...)
- }
- if res.Code != "000000" {
- global.LOG.Info("knowledgeResp Res:%v ", res)
- continue
- }
- if len(res.Data.Records) != req.PageSise {
- break
- }
- pageNum++
- }
- resp.OkData("保存成功", res, c)
- }
|