package dwmini import ( "encoding/json" "errors" "eta/eta_chart_lib/models" "eta/eta_chart_lib/utils" ) type MyChartIsCollect struct { IsCollect bool } type BaseResponse struct { Ret int Msg string ErrMsg string ErrCode string Data MyChartIsCollect } type MyChartIsCollectReq struct { UniqueCode string } type MyChartCollectReq struct { UniqueCode string ChartName string ChartImage string ChartInfoId int } type MyChartCollectCancelReq struct { UniqueCode string } func GetMyChartIsCollect(token string, uniqueCode string) (isCollect bool, err error) { url := utils.ETA_MINI_URL + "mychart/isCollect" req := MyChartIsCollectReq{UniqueCode: uniqueCode} reqBody, _ := json.Marshal(req) result, err := HttpPost(url, string(reqBody), token) if err != nil { return } var resp BaseResponse if err = json.Unmarshal(result, &resp); err != nil { return } if resp.Ret != 200 { err = errors.New(resp.ErrMsg) return } isCollect = resp.Data.IsCollect return } func MyChartCollect(token, uniqueCode, chartName, chartImage string, chartInfoId int) (resp *models.BaseResponse, err error) { url := utils.ETA_MINI_URL + "mychart/collect" req := MyChartCollectReq{ UniqueCode: uniqueCode, ChartName: chartName, ChartImage: chartImage, ChartInfoId: chartInfoId, } reqBody, _ := json.Marshal(req) result, err := HttpPost(url, string(reqBody), token) if err != nil { return } if err = json.Unmarshal(result, &resp); err != nil { return } if resp.Ret != 200 { return } return } func MyChartCollectCancel(token string, uniqueCode string) (resp *models.BaseResponse, err error) { url := utils.ETA_MINI_URL + "mychart/collectCancel" req := MyChartCollectCancelReq{UniqueCode: uniqueCode} reqBody, _ := json.Marshal(req) result, err := HttpPost(url, string(reqBody), token) if err != nil { return } if err = json.Unmarshal(result, &resp); err != nil { return } if resp.Ret != 200 { return } return }