58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
|
package photomange10
|
|||
|
|
|||
|
import (
|
|||
|
"context"
|
|||
|
"encoding/json"
|
|||
|
"github.com/gogf/gf/v2/frame/g"
|
|||
|
"github.com/gogf/gf/v2/util/gconv"
|
|||
|
"github.com/tiger1103/gfast/v3/api/constant"
|
|||
|
"io"
|
|||
|
"net/http"
|
|||
|
"net/url"
|
|||
|
)
|
|||
|
|
|||
|
// 获取照片
|
|||
|
type GetPicturesReq struct {
|
|||
|
g.Meta `path:"/getpictures" method:"post" tags:"视频安全帽相关" summary:"获取照片"`
|
|||
|
DevNum string `json:"devNum" dc:"设备号"`
|
|||
|
Date string `json:"date" dc:"格式 yyyy-mm-dd(不是必填参数)"`
|
|||
|
PageNum string `json:"pageNum" dc:"当前页数"`
|
|||
|
}
|
|||
|
|
|||
|
// 获取照片相应
|
|||
|
type GetPicturesRes struct {
|
|||
|
ResponseData ResponseData `json:"responseData"`
|
|||
|
}
|
|||
|
|
|||
|
func (v Pictures) GetPictures(ctx context.Context, req *GetPicturesReq) (res *GetPicturesRes, err error) {
|
|||
|
var userId string
|
|||
|
id, _ := g.Model("device_video_hat").Fields("uid AS userId").Where("dev_num", req.DevNum).Value()
|
|||
|
userId = gconv.String(id)
|
|||
|
res = new(GetPicturesRes)
|
|||
|
data := url.Values{}
|
|||
|
data.Set("user_id", userId)
|
|||
|
if req.Date != "" {
|
|||
|
data.Set("date", req.Date)
|
|||
|
}
|
|||
|
data.Set("p", req.PageNum)
|
|||
|
data.Set("token", constant.Token)
|
|||
|
|
|||
|
resp, err := http.PostForm("https://caps.runde.pro/api/index.php?ctl=report&act=get_user_image", data)
|
|||
|
if err != nil {
|
|||
|
return nil, err
|
|||
|
}
|
|||
|
defer resp.Body.Close()
|
|||
|
|
|||
|
respBody, err := io.ReadAll(resp.Body)
|
|||
|
if err != nil {
|
|||
|
return nil, err
|
|||
|
}
|
|||
|
|
|||
|
err = json.Unmarshal(respBody, &res.ResponseData)
|
|||
|
if err != nil {
|
|||
|
return nil, err
|
|||
|
}
|
|||
|
|
|||
|
return res, nil
|
|||
|
}
|