| 
					
				 | 
			
			
				@@ -9,6 +9,7 @@ package lib 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"encoding/json" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"errors" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"fmt" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"io/ioutil" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"net/http" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"net/url" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -18,8 +19,9 @@ import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 type Cld struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	AuthUrl string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Token   string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	AuthUrl     string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	CategoryUrl string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Token       string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 type Result struct { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -32,7 +34,8 @@ type Result struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //创建项目用户service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func NewCld() *Cld { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return &Cld{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		AuthUrl: "http://cld.smartcost.com.cn/cm/auth", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		AuthUrl:     "http://cld.smartcost.com.cn/cm/auth", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		CategoryUrl: "http://cld.com/cm/category", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// AuthUrl: "http://cld.com/cm/auth", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Token: "sc@ConS!tru@ct*88", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -75,6 +78,35 @@ func (c *Cld) LoginValid(loginData viewmodels.StaffCld) (*Result, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 获得cld办事处和员工 列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *Cld) GetList(lcategoryId int) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (c *Cld) GetList(categoryId int) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	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) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (c *Cld) cldRequest(Method string, url string, parameter *strings.Reader) (*Result, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	client := &http.Client{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fmt.Println("====================") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	reqest, err := http.NewRequest(Method, url, parameter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return nil, errors.New("CLD网络出现问题") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	reqest.Header.Add("Content-Type", "application/x-www-form-urlencoded") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// 发送请求 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	response, err := client.Do(reqest) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return nil, errors.New("CLD网络出现问题") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if response.StatusCode != 200 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return nil, errors.New("请求CLD发送错误") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	body, _ := ioutil.ReadAll(response.Body) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	fmt.Println(string(body)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return nil, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |