common.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package TaxSb
  2. import (
  3. "encoding/json"
  4. "git.listensoft.net/tool/jspkit/common/lxhttp"
  5. "github.com/tidwall/gjson"
  6. "net/http"
  7. )
  8. // 我的待办结构体
  9. type MyTaskSt struct {
  10. Name string `json:"name"` // 任务名称
  11. DeadLine string `json:"dead_line"` // 办理期限
  12. Status string `json:"status"` // 标签状态
  13. }
  14. // 获取我的待办信息方便进行对比
  15. func GetMyTask(C *http.Client, BaseUrl string) ([]MyTaskSt, error) {
  16. myTaskList := []MyTaskSt{}
  17. Cookie := []*http.Cookie{}
  18. jsonData := map[string]interface{}{"Csbz": ""}
  19. headers := map[string]string{
  20. "Content-Type": "application/json",
  21. "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
  22. "accept": "application/json;charset=UTF-8",
  23. }
  24. JsonR, _ := json.Marshal(jsonData)
  25. response, err := lxhttp.PostByteReader(C, BaseUrl+"/mhzx/api/mh/wddb/v1/wddbquerybbsmxx", JsonR, headers, Cookie)
  26. if err != nil {
  27. return nil, err
  28. }
  29. array := gjson.GetBytes(response, "Response.Data.wsbxxGrid").Array()
  30. for _, result := range array {
  31. myTaskList = append(myTaskList, MyTaskSt{
  32. Name: result.Get("gnmc").String(),
  33. DeadLine: result.Get("sbqx").String(),
  34. Status: result.Get("zt").String(),
  35. })
  36. }
  37. return myTaskList, nil
  38. }