package chart import ( logger "eta/eta_mini_ht_api/common/component/log" "eta/eta_mini_ht_api/common/exception" "eta/eta_mini_ht_api/controllers" chart "eta/eta_mini_ht_api/service/media" ) type ChartController struct { controllers.ListController } type ChartEsUpdateReq struct { ChartImage string `json:"chartImage"` ChartInfoId int `json:"chartInfoId"` } // UpdateChartImage 更新图表缩略图 // @Description 更新图表缩略图 // @Success 200 {object} // @router /updateChartImage [post] func (m *ChartController) UpdateChartImage() { controllers.Wrap(&m.BaseController, func() (result *controllers.WrapData, err error) { result = m.InitWrapData("更新图表缩略图成功") var chartEsUpdateReq ChartEsUpdateReq m.GetPostParams(&chartEsUpdateReq) if chartEsUpdateReq.ChartImage == "" { err = exception.New(exception.ChartImageEmptyError) m.FailedResult("更新图表缩略图失败", result) return } if chartEsUpdateReq.ChartInfoId == 0 { err = exception.New(exception.IllegalChartId) m.FailedResult("更新图表缩略图失败", result) return } success := chart.UpdateChartImage(chartEsUpdateReq.ChartImage, chartEsUpdateReq.ChartInfoId) if !success { err = exception.New(exception.UpdateChartImageFailed) logger.Error("更新图表缩略图失败,chartInfoId:%d", chartEsUpdateReq.ChartInfoId) m.FailedResult("更新图表缩略图失败", result) return } m.SuccessResult("更新图表缩略图成功", nil, result) return }) }