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" "fmt" "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) ViewPointAcquire(c *gin.Context) { var req knowledgeDao.KnowledgeRefreshReq if e := c.Bind(&req); e != nil { resp.FailData("参数解析失败", "Err:"+e.Error(), c) return } global.LOG.Info(fmt.Sprintf("ViewPointAcquire, PageSize: %d, UpdateTime: %s", req.PageSize, req.UpdateTime)) param := make(map[string]interface{}) var res *index_data.MarketOverviewResp pageNum := 1 pageSize := 100 for { global.LOG.Info(fmt.Sprintf("ViewPointAcquire, 当前pageNo: %d, size: %d", pageNum, pageSize)) //param["pageNum"] = pageNum //param["pageSize"] = req.PageSize param["pageNo"] = pageNum param["size"] = pageSize if req.UpdateTime != "" { param["UPDATE_TIME"] = req.UpdateTime } tmp, err := index_data.GetMarketOverview(param) if err != nil { global.LOG.Error("GetMarketOverview 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("GetMarketOverview Res: %v ", res) continue } global.LOG.Info(fmt.Sprintf("ViewPointAcquire, Total: %d", res.Data.Total)) if len(res.Data.Records) != req.PageSize { global.LOG.Info(fmt.Sprintf("ViewPointAcquire, End")) break } pageNum++ } resp.OkData("保存成功", res, c) }