12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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
- }
|