/
expert_client.go
173 lines (143 loc) · 3.9 KB
/
expert_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package expert
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-swagger/go-swagger/client"
"github.com/go-swagger/go-swagger/strfmt"
)
// New creates a new expert API client.
func New(transport client.Transport, formats strfmt.Registry) *Client {
return &Client{transport: transport, formats: formats}
}
/*
Client for expert API
*/
type Client struct {
transport client.Transport
formats strfmt.Registry
}
/*删除专家
删除指定专家
*/
func (a *Client) DeleteExpertsID(params *DeleteExpertsIDParams, authInfo client.AuthInfoWriter) (*DeleteExpertsIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteExpertsIDParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "DeleteExpertsID",
Params: params,
Reader: &DeleteExpertsIDReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*DeleteExpertsIDOK), nil
}
/*查看专家列表
查看所有专家,支持分页和过滤器
*/
func (a *Client) GetExperts(params *GetExpertsParams, authInfo client.AuthInfoWriter) (*GetExpertsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetExpertsParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "GetExperts",
Params: params,
Reader: &GetExpertsReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*GetExpertsOK), nil
}
/*查询专家
得到指定专家的具体信息
*/
func (a *Client) GetExpertsID(params *GetExpertsIDParams, authInfo client.AuthInfoWriter) (*GetExpertsIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetExpertsIDParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "GetExpertsID",
Params: params,
Reader: &GetExpertsIDReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*GetExpertsIDOK), nil
}
/*创建专家
根据请求创建专家
*/
func (a *Client) PostExperts(params *PostExpertsParams, authInfo client.AuthInfoWriter) (*PostExpertsCreated, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPostExpertsParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "PostExperts",
Params: params,
Reader: &PostExpertsReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*PostExpertsCreated), nil
}
/*更新专家
根据请求中指定要更新的属性对专家进行更新
Example:
1. 更新专家姓名和邮件
```json
{
"name":"newName",
"email": "new@email.com"
}
```
*/
func (a *Client) PutExpertsID(params *PutExpertsIDParams, authInfo client.AuthInfoWriter) (*PutExpertsIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPutExpertsIDParams()
}
result, err := a.transport.Submit(&client.Operation{
ID: "PutExpertsID",
Params: params,
Reader: &PutExpertsIDReader{formats: a.formats},
AuthInfo: authInfo,
})
if err != nil {
return nil, err
}
return result.(*PutExpertsIDOK), nil
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport client.Transport) {
a.transport = transport
}
// NewAPIError creates a new API error
func NewAPIError(opName string, response interface{}, code int) APIError {
return APIError{
OperationName: opName,
Response: response,
Code: code,
}
}
// APIError wraps an error model and captures the status code
type APIError struct {
OperationName string
Response interface{}
Code int
}
func (a APIError) Error() string {
return fmt.Sprintf("%s (status %d): %+v ", a.OperationName, a.Code, a.Response)
}