|
@@ -78,21 +78,19 @@ func (c *Cld) LoginValid(loginData viewmodels.StaffCld) (*Result, error) {
|
|
|
}
|
|
|
|
|
|
// 获得cld办事处和员工 列表
|
|
|
-func (c *Cld) GetList(categoryId int) {
|
|
|
+func (c *Cld) GetList(categoryId int) (map[string]interface{}, error) {
|
|
|
|
|
|
data := url.Values{}
|
|
|
parameter := strings.NewReader(data.Encode())
|
|
|
|
|
|
url := fmt.Sprintf("%s?categoryId=%d", c.CategoryUrl, categoryId)
|
|
|
- fmt.Println(url)
|
|
|
- c.cldRequest("GET", url, parameter)
|
|
|
+
|
|
|
+ return c.cldRequest("GET", url, parameter)
|
|
|
}
|
|
|
|
|
|
-func (c *Cld) cldRequest(Method string, url string, parameter *strings.Reader) (*Result, error) {
|
|
|
+func (c *Cld) cldRequest(Method string, url string, parameter *strings.Reader) (map[string]interface{}, error) {
|
|
|
|
|
|
client := &http.Client{}
|
|
|
- fmt.Println("====================")
|
|
|
-
|
|
|
reqest, err := http.NewRequest(Method, url, parameter)
|
|
|
if err != nil {
|
|
|
return nil, errors.New("CLD网络出现问题")
|
|
@@ -107,6 +105,12 @@ func (c *Cld) cldRequest(Method string, url string, parameter *strings.Reader) (
|
|
|
return nil, errors.New("请求CLD发送错误")
|
|
|
}
|
|
|
body, _ := ioutil.ReadAll(response.Body)
|
|
|
- fmt.Println(string(body))
|
|
|
- return nil, nil
|
|
|
+
|
|
|
+ result := make(map[string]interface{})
|
|
|
+ err = json.Unmarshal(body, &result)
|
|
|
+ if err != nil {
|
|
|
+ return nil, errors.New("解析数据错误")
|
|
|
+ }
|
|
|
+
|
|
|
+ return result, nil
|
|
|
}
|