123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package dwmini
- import (
- "encoding/json"
- "errors"
- "eta/eta_chart_lib/models"
- "eta/eta_chart_lib/services/alarm_msg"
- "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
- }
- alarm_msg.SendAlarmMsg(string(reqBody), 1)
- 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
- }
|