69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
|
package mkt
|
||
|
|
||
|
import (
|
||
|
"crypto/md5"
|
||
|
"encoding/hex"
|
||
|
"fmt"
|
||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
const appKey = "fc1f841#@de!!08"
|
||
|
|
||
|
type SubjectListRequest struct {
|
||
|
*requests.RpcRequest
|
||
|
}
|
||
|
|
||
|
type SubjectListResponse struct {
|
||
|
*responses.BaseResponse
|
||
|
Status bool `json:"status"`
|
||
|
Code int `json:"code"`
|
||
|
Msg string `json:"msg"`
|
||
|
Data struct {
|
||
|
List map[int]Data `json:"list"`
|
||
|
} `json:"data"`
|
||
|
}
|
||
|
|
||
|
type Data struct {
|
||
|
Abbr string `json:"abbr"`
|
||
|
AbbrSign string `json:"abbr_sign"`
|
||
|
Id int `json:"id"`
|
||
|
Name string `json:"name"`
|
||
|
State int `json:"state"`
|
||
|
System string `json:"system"`
|
||
|
Type int `json:"type"`
|
||
|
}
|
||
|
|
||
|
// CreateSubjectListRequest 公司列表请求
|
||
|
func CreateSubjectListRequest(state int) (req *SubjectListRequest) {
|
||
|
ts := time.Now().Unix()
|
||
|
hash := md5.New()
|
||
|
hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey)))
|
||
|
hashBytes := hash.Sum(nil)
|
||
|
|
||
|
token := hex.EncodeToString(hashBytes)
|
||
|
|
||
|
req = &SubjectListRequest{
|
||
|
RpcRequest: &requests.RpcRequest{},
|
||
|
}
|
||
|
|
||
|
req.InitWithApiInfo(HOST, VERSION, fmt.Sprintf("/api/subject/list"))
|
||
|
|
||
|
req.FormParams = map[string]string{
|
||
|
"token": token,
|
||
|
"ts": fmt.Sprintf("%v", ts),
|
||
|
"state": fmt.Sprintf("%v", state),
|
||
|
}
|
||
|
req.Method = requests.POST
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// CreateSubjectListResponse 公司列表请求响应
|
||
|
func CreateSubjectListResponse() (response *SubjectListResponse) {
|
||
|
response = &SubjectListResponse{
|
||
|
BaseResponse: &responses.BaseResponse{},
|
||
|
}
|
||
|
return
|
||
|
}
|