|
@@ -2,34 +2,16 @@ package services
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
- "eta/eta_mini_api/models"
|
|
|
"eta/eta_mini_api/utils"
|
|
|
"fmt"
|
|
|
"io"
|
|
|
"net/http"
|
|
|
- "strconv"
|
|
|
"time"
|
|
|
|
|
|
- "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ resp2 "eta/eta_mini_api/models/response"
|
|
|
)
|
|
|
|
|
|
-type ReportList struct {
|
|
|
- List []*models.ReportList
|
|
|
- Paging *paging.PagingItem
|
|
|
-}
|
|
|
-
|
|
|
-type ReportResp[T any] struct {
|
|
|
- Ret int
|
|
|
- Data T
|
|
|
- Msg string
|
|
|
- ErrMsg string
|
|
|
-}
|
|
|
-type ReportDetailResp struct {
|
|
|
- Report *models.ReportDetail `description:"报告"`
|
|
|
- Status int `description:"报告状态"`
|
|
|
-}
|
|
|
-
|
|
|
-func GetReportList(chartPermissionId, level, rangeType, currentIndex, pageSize int) (resp *ReportResp[ReportList], err error) {
|
|
|
+func GetReportList(chartPermissionId, level, rangeType, currentIndex, pageSize int) (resp *resp2.ReportResp[resp2.ReportList], err error) {
|
|
|
url := utils.ETA_MINI_BRIDGE_URL + "/report/list?"
|
|
|
url += fmt.Sprintf("RangeType=%d&ChartPermissionId=%d&Level=%d&PageSize=%d&CurrentIndex=%d", rangeType, chartPermissionId, level, pageSize, currentIndex)
|
|
|
fmt.Println(url)
|
|
@@ -70,7 +52,7 @@ func GetReportList(chartPermissionId, level, rangeType, currentIndex, pageSize i
|
|
|
|
|
|
}
|
|
|
|
|
|
-func GetReportDetail(reportId, userId int) (resp *ReportResp[ReportDetailResp], err error) {
|
|
|
+func GetReportDetail(reportId, userId int) (resp *resp2.ReportResp[resp2.ReportDetailResp], err error) {
|
|
|
url := utils.ETA_MINI_BRIDGE_URL + "/report/detail?"
|
|
|
url += fmt.Sprintf("ReportId=%d&UserId=%d", reportId, userId)
|
|
|
fmt.Println(url)
|
|
@@ -109,18 +91,15 @@ func GetReportDetail(reportId, userId int) (resp *ReportResp[ReportDetailResp],
|
|
|
return resp, nil
|
|
|
}
|
|
|
|
|
|
-func GetReportDailyList(currentIndex, pageSize int) (resp *ReportResp[ReportList], err error) {
|
|
|
- url := utils.ETA_MINI_BRIDGE_URL + "/report/daily/list"
|
|
|
- if currentIndex >= 0 && pageSize > 0 {
|
|
|
- url += "?PageSize=" + strconv.Itoa(pageSize)
|
|
|
- url += "&CurrentIndex=" + strconv.Itoa(currentIndex)
|
|
|
- }
|
|
|
+func GetReportDailyList(currentIndex, pageSize int) (resp *resp2.ReportResp[resp2.ReportList], err error) {
|
|
|
+ url := utils.ETA_MINI_BRIDGE_URL + "/report/daily/list?"
|
|
|
+ url += fmt.Sprintf("PageSize=%d&CurrentIndex=%d", pageSize, currentIndex)
|
|
|
fmt.Println(url)
|
|
|
client := &http.Client{}
|
|
|
// 提交请求
|
|
|
req, err := http.NewRequest("GET", url, nil)
|
|
|
if err != nil {
|
|
|
- return &ReportResp[ReportList]{}, err
|
|
|
+ return
|
|
|
}
|
|
|
nonce := utils.GetRandStringNoSpecialChar(16)
|
|
|
timestamp := time.Now().Format(utils.FormatDateTimeUnSpace)
|
|
@@ -134,14 +113,14 @@ func GetReportDailyList(currentIndex, pageSize int) (resp *ReportResp[ReportList
|
|
|
|
|
|
response, err := client.Do(req)
|
|
|
if err != nil {
|
|
|
- return &ReportResp[ReportList]{}, err
|
|
|
+ return
|
|
|
}
|
|
|
defer response.Body.Close()
|
|
|
|
|
|
body, err := io.ReadAll(response.Body)
|
|
|
|
|
|
if err != nil {
|
|
|
- return &ReportResp[ReportList]{}, err
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
utils.FileLog.Info("result:" + string(body))
|
|
@@ -152,3 +131,44 @@ func GetReportDailyList(currentIndex, pageSize int) (resp *ReportResp[ReportList
|
|
|
return resp, nil
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+func SearchReport(keyWord string, currentIndex, pageSize int) (resp *resp2.ReportResp[resp2.ReportSearchResp], err error) {
|
|
|
+ url := utils.ETA_MINI_BRIDGE_URL + "/report/search?"
|
|
|
+ url += fmt.Sprintf("KeyWord=%s&PageSize=%d&CurrentIndex=%d", keyWord, pageSize, currentIndex)
|
|
|
+ fmt.Println(url)
|
|
|
+ client := &http.Client{}
|
|
|
+ // 提交请求
|
|
|
+ req, err := http.NewRequest("GET", url, nil)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ nonce := utils.GetRandStringNoSpecialChar(16)
|
|
|
+ timestamp := time.Now().Format(utils.FormatDateTimeUnSpace)
|
|
|
+ signature := utils.GetSign(nonce, timestamp, utils.ETA_MINI_APPID, utils.ETA_MINI_APP_SECRET)
|
|
|
+ //增加header选项
|
|
|
+ req.Header.Add("Nonce", nonce)
|
|
|
+ req.Header.Add("Timestamp", timestamp)
|
|
|
+ req.Header.Add("Appid", utils.ETA_MINI_APPID)
|
|
|
+ req.Header.Add("Signature", signature)
|
|
|
+ req.Header.Set("Content-Type", "application/json")
|
|
|
+
|
|
|
+ response, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer response.Body.Close()
|
|
|
+
|
|
|
+ body, err := io.ReadAll(response.Body)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ utils.FileLog.Info("result:" + string(body))
|
|
|
+ err = json.Unmarshal(body, &resp)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+
|
|
|
+}
|