1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package edge_service
- import (
- "fmt"
- "io/ioutil"
- "iot_manager_service/config"
- "net/http"
- "net/url"
- )
- // ForRewindService 回放记录
- type ForRewindService struct {
- }
- // getRewindApi 公用请求接口
- func (f *ForRewindService) getRewindApi(url string) (string, error) {
- method := "GET"
- client := &http.Client{}
- req, err := http.NewRequest(method, url, nil)
- if err != nil {
- return "", nil
- }
- res, err := client.Do(req)
- if err != nil {
- return "", nil
- }
- defer res.Body.Close()
- body, err := ioutil.ReadAll(res.Body)
- if err != nil {
- return "", nil
- }
- return string(body), err
- }
- // GetRewindText 请求回话加密数据
- func (f *ForRewindService) GetRewindText(streamId string, date string) (string, error) {
- cfg := config.Instance()
- api := cfg.Foreign.SecurityRewindUrl + "/list/%v/%v"
- url2 := fmt.Sprintf(api, (streamId), url.QueryEscape(date))
- return f.getRewindApi(url2)
- }
|