正在显示
11 个修改的文件
包含
156 行增加
和
81 行删除
@@ -12,10 +12,10 @@ AdminPort = 8088 | @@ -12,10 +12,10 @@ AdminPort = 8088 | ||
12 | ##数据库连接 | 12 | ##数据库连接 |
13 | # sqlconn ="${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8&loc=Asia%2FShanghai}" | 13 | # sqlconn ="${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8&loc=Asia%2FShanghai}" |
14 | mysql_user = "${MYSQL_USER||root}" | 14 | mysql_user = "${MYSQL_USER||root}" |
15 | -mysql_password = "${MYSQL_PASSWORD||sutianxia2015}" | ||
16 | -mysql_host = "${MYSQL_HOST||115.29.205.99}" | 15 | +mysql_password = "${MYSQL_PASSWORD||sutianxia2018}" |
16 | +mysql_host = "${MYSQL_HOST||101.37.68.23}" | ||
17 | mysql_port = "${MYSQL_PORT||3306}" | 17 | mysql_port = "${MYSQL_PORT||3306}" |
18 | -mysql_db_name = "${MYSQL_DB_NAME||opportunity}" | 18 | +mysql_db_name = "${MYSQL_DB_NAME||opportunity_dev}" |
19 | ##redis相关配置 | 19 | ##redis相关配置 |
20 | redis_add = "${REDIS_HOST||127.0.0.1}" | 20 | redis_add = "${REDIS_HOST||127.0.0.1}" |
21 | redis_add_port = "${REDIS_PORT||6379}" | 21 | redis_add_port = "${REDIS_PORT||6379}" |
@@ -102,27 +102,14 @@ func (c *AuthController) LoginSms() { | @@ -102,27 +102,14 @@ func (c *AuthController) LoginSms() { | ||
102 | return | 102 | return |
103 | } | 103 | } |
104 | 104 | ||
105 | - //短信校验接口调用 | ||
106 | - // logintoken, err := serveauth.LoginAuthByUCenter(param.Account, param.Password) | ||
107 | - // if err != nil { | ||
108 | - // msg = protocol.NewReturnResponse(nil, err) | ||
109 | - // return | ||
110 | - // } | ||
111 | - // err = serveauth.ResetLoginToken(logintoken) | ||
112 | - // if err != nil { | ||
113 | - // log.Error("token 信息记录数据库失败") | ||
114 | - // } | ||
115 | - // err = serveauth.ResetLoginTokenRedis(logintoken) | ||
116 | - // if err != nil { | ||
117 | - // log.Error("token 信息记录redis失败") | ||
118 | - // } | ||
119 | - // data := map[string]interface{}{ | ||
120 | - // "access": logintoken, | ||
121 | - // } | 105 | + // logintoken |
106 | + | ||
122 | msg = protocol.NewReturnResponse(nil, nil) | 107 | msg = protocol.NewReturnResponse(nil, nil) |
123 | return | 108 | return |
124 | } | 109 | } |
125 | 110 | ||
111 | +//SmsCode 发送验证码短信 | ||
112 | +//@router /auth/smscode | ||
126 | func (c *AuthController) SmsCode() { | 113 | func (c *AuthController) SmsCode() { |
127 | var msg *protocol.ResponseMessage | 114 | var msg *protocol.ResponseMessage |
128 | defer func() { | 115 | defer func() { |
@@ -141,7 +128,8 @@ func (c *AuthController) SmsCode() { | @@ -141,7 +128,8 @@ func (c *AuthController) SmsCode() { | ||
141 | msg = protocol.BadRequestParam("1") | 128 | msg = protocol.BadRequestParam("1") |
142 | return | 129 | return |
143 | } | 130 | } |
144 | - msg = protocol.NewReturnResponse(nil, nil) | 131 | + err := serveauth.LoginSmsCodeSend(param.Phone) |
132 | + msg = protocol.NewReturnResponse(nil, err) | ||
145 | return | 133 | return |
146 | } | 134 | } |
147 | 135 |
@@ -68,7 +68,6 @@ var AuthToken = func(ctx *context.Context) { | @@ -68,7 +68,6 @@ var AuthToken = func(ctx *context.Context) { | ||
68 | redisdata.RefreshLoginTokenExpires(mtoken.UID, mtoken.CompanyID) | 68 | redisdata.RefreshLoginTokenExpires(mtoken.UID, mtoken.CompanyID) |
69 | ctx.Input.SetData(protocol.HeaderCompanyid, mtoken.CompanyID) | 69 | ctx.Input.SetData(protocol.HeaderCompanyid, mtoken.CompanyID) |
70 | ctx.Input.SetData(protocol.HeaderUserid, mtoken.UID) | 70 | ctx.Input.SetData(protocol.HeaderUserid, mtoken.UID) |
71 | - | ||
72 | return | 71 | return |
73 | } | 72 | } |
74 | if ok := serveauth.IsJwtErrorExpired(err); ok { | 73 | if ok := serveauth.IsJwtErrorExpired(err); ok { |
@@ -97,7 +96,7 @@ var AllowOption = func(ctx *context.Context) { | @@ -97,7 +96,7 @@ var AllowOption = func(ctx *context.Context) { | ||
97 | }) | 96 | }) |
98 | f(ctx) | 97 | f(ctx) |
99 | ctx.Output.SetStatus(204) | 98 | ctx.Output.SetStatus(204) |
100 | - ctx.Output.Body([]byte("{}")) | 99 | + ctx.Output.Body(nil) |
101 | return | 100 | return |
102 | } | 101 | } |
103 | 102 |
@@ -72,11 +72,11 @@ func CountUserDepartByDepart(departid int64) (int64, error) { | @@ -72,11 +72,11 @@ func CountUserDepartByDepart(departid int64) (int64, error) { | ||
72 | cnt int64 | 72 | cnt int64 |
73 | err error | 73 | err error |
74 | ) | 74 | ) |
75 | + sql := `SELECT COUNT(*) FROM user_department AS a | ||
76 | + JOIN user_company AS b ON a.user_company_id = b.id | ||
77 | + WHERE a.enable_status = 1 AND b.delete_at = 0 AND a.department_id =?` | ||
75 | o := orm.NewOrm() | 78 | o := orm.NewOrm() |
76 | - cnt, err = o.QueryTable(&UserDepartment{}). | ||
77 | - Filter("department_id", departid). | ||
78 | - Filter("enable_status", 1). | ||
79 | - Count() | 79 | + err = o.Raw(sql, departid).QueryRow(&cnt) |
80 | return cnt, err | 80 | return cnt, err |
81 | } | 81 | } |
82 | 82 |
@@ -42,7 +42,6 @@ type ResponseDepartmentInfo struct { | @@ -42,7 +42,6 @@ type ResponseDepartmentInfo struct { | ||
42 | Name string `json:"name"` //部门名字 | 42 | Name string `json:"name"` //部门名字 |
43 | ParantID int64 `json:"parentId"` //父级部门Id | 43 | ParantID int64 `json:"parentId"` //父级部门Id |
44 | Manages []DepartmentManager `json:"manages"` //部门管理员 | 44 | Manages []DepartmentManager `json:"manages"` //部门管理员 |
45 | - Members []DepartmentMember `json:"members"` //部门成员 | ||
46 | Member int64 `json:"member"` //成员数 | 45 | Member int64 `json:"member"` //成员数 |
47 | } | 46 | } |
48 | 47 |
@@ -23,6 +23,8 @@ var errmessge ErrorMap = map[string]string{ | @@ -23,6 +23,8 @@ var errmessge ErrorMap = map[string]string{ | ||
23 | "10025": "该账号已在其他地方登录", | 23 | "10025": "该账号已在其他地方登录", |
24 | // "10026": "登录凭证过期", | 24 | // "10026": "登录凭证过期", |
25 | "10027": "无操作权限", | 25 | "10027": "无操作权限", |
26 | + "10028": "验证码错误", | ||
27 | + "10029": "获取验证码失败", | ||
26 | //用户相关 | 28 | //用户相关 |
27 | "10031": "无效角色", | 29 | "10031": "无效角色", |
28 | "10032": "无效部门", | 30 | "10032": "无效部门", |
@@ -182,7 +182,7 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro | @@ -182,7 +182,7 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro | ||
182 | } | 182 | } |
183 | userdata, err = models.GetUserByUCenter(uclientReturn.Data.Id) | 183 | userdata, err = models.GetUserByUCenter(uclientReturn.Data.Id) |
184 | if err != nil { | 184 | if err != nil { |
185 | - log.Debug("GetUserByPhone(%s) err:%s", account, err) | 185 | + log.Debug("GetUserByUCenter(%d) err:%s", uclientReturn.Data.Id, err) |
186 | return logintoken, protocol.NewErrWithMessage("10021") | 186 | return logintoken, protocol.NewErrWithMessage("10021") |
187 | } | 187 | } |
188 | if ok := userdata.IsDelete(); ok { | 188 | if ok := userdata.IsDelete(); ok { |
@@ -231,7 +231,7 @@ type companybase struct { | @@ -231,7 +231,7 @@ type companybase struct { | ||
231 | } | 231 | } |
232 | 232 | ||
233 | //getUserCompanyReal 获取用户有效的公司id | 233 | //getUserCompanyReal 获取用户有效的公司id |
234 | -func getUserCompanyReal(userid int64) ([]companybase, error) { | 234 | +func getUserCompanyReal(userId int64) ([]companybase, error) { |
235 | const ( | 235 | const ( |
236 | datasql0 string = `SELECT b.company_id FROM user_company AS b | 236 | datasql0 string = `SELECT b.company_id FROM user_company AS b |
237 | WHERE b.delete_at=0 AND b.enable = 1 AND b.user_id=?` | 237 | WHERE b.delete_at=0 AND b.enable = 1 AND b.user_id=?` |
@@ -243,7 +243,7 @@ func getUserCompanyReal(userid int64) ([]companybase, error) { | @@ -243,7 +243,7 @@ func getUserCompanyReal(userid int64) ([]companybase, error) { | ||
243 | ids []string | 243 | ids []string |
244 | err error | 244 | err error |
245 | ) | 245 | ) |
246 | - err = utils.ExecuteQueryAll(&ids, datasql0, userid) | 246 | + err = utils.ExecuteQueryAll(&ids, datasql0, userId) |
247 | if err != nil { | 247 | if err != nil { |
248 | log.Error("EXECUTE SQL err:%s", err) | 248 | log.Error("EXECUTE SQL err:%s", err) |
249 | return nil, err | 249 | return nil, err |
@@ -326,3 +326,75 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.PermissionItem, error) | @@ -326,3 +326,75 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.PermissionItem, error) | ||
326 | } | 326 | } |
327 | return list, nil | 327 | return list, nil |
328 | } | 328 | } |
329 | + | ||
330 | +func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) { | ||
331 | + var ( | ||
332 | + err error | ||
333 | + logintoken protocol.LoginAuthToken | ||
334 | + companys []companybase | ||
335 | + companyid int64 | ||
336 | + userdata *models.User | ||
337 | + ) | ||
338 | + var uclientReturn *ucenter.ResponseLoginSms | ||
339 | + uclientReturn, err = ucenter.RequestUCenterLoginSms(phone, code) | ||
340 | + if err != nil { | ||
341 | + return logintoken, protocol.NewErrWithMessage("10028") | ||
342 | + } | ||
343 | + userdata, err = models.GetUserByUCenter(uclientReturn.Data.Cuid) | ||
344 | + if err != nil { | ||
345 | + log.Debug("GetUserByUCenter(%s) err:%s", uclientReturn.Data.Cuid, err) | ||
346 | + return logintoken, protocol.NewErrWithMessage("10021") | ||
347 | + } | ||
348 | + if ok := userdata.IsDelete(); ok { | ||
349 | + log.Debug("userdata.IsDelete()==true") | ||
350 | + return logintoken, protocol.NewErrWithMessage("10021") | ||
351 | + } | ||
352 | + if ok := userdata.IsEnable(); !ok { | ||
353 | + log.Debug("userdata.IsEnable()==false") | ||
354 | + return logintoken, protocol.NewErrWithMessage("10022") | ||
355 | + } | ||
356 | + if companys, err = getUserCompanyReal(userdata.Id); err != nil { | ||
357 | + log.Error("getUserCompanyReal err:%s", err) | ||
358 | + return logintoken, protocol.NewErrWithMessage("10021") | ||
359 | + } | ||
360 | + if len(companys) == 0 { | ||
361 | + log.Debug("no company") | ||
362 | + return logintoken, protocol.NewErrWithMessage("10022") | ||
363 | + } | ||
364 | + //获取上一次登录的公司 | ||
365 | + uAuth, err := models.GetUserAuthByUser(userdata.Id) | ||
366 | + if err == nil { | ||
367 | + companyid = uAuth.CurrentCompanyId | ||
368 | + } else { | ||
369 | + companyid = companys[0].Id | ||
370 | + } | ||
371 | + | ||
372 | + //更新用户数据 | ||
373 | + userdata.Accid = uclientReturn.Data.CsAccountID | ||
374 | + userdata.Icon = uclientReturn.Data.Image.Path | ||
375 | + userdata.ImToken = uclientReturn.Data.Imtoken | ||
376 | + userdata.NickName = uclientReturn.Data.Uname | ||
377 | + userdata.LastLoginTime = time.Now() | ||
378 | + err = models.UpdateUserById(userdata, []string{"Accid", "Icon", "ImToken", "NickName", "LastLoginTime"}) | ||
379 | + if err != nil { | ||
380 | + log.Error("更新用户数据失败:%s", err) | ||
381 | + } | ||
382 | + logintoken, _ = GenerateAuthToken(userdata.Id, companyid) | ||
383 | + return logintoken, err | ||
384 | +} | ||
385 | + | ||
386 | +func LoginSmsCodeSend(phone string) error { | ||
387 | + var ( | ||
388 | + err error | ||
389 | + ) | ||
390 | + _, err = models.GetUserByPhone(phone) | ||
391 | + if err != nil { | ||
392 | + log.Error("GetUserByPhone(%s) err:%s", phone, err) | ||
393 | + return protocol.NewErrWithMessage("10027") | ||
394 | + } | ||
395 | + err = ucenter.RequestUCenterSmsCode(phone) | ||
396 | + if err != nil { | ||
397 | + return protocol.NewErrWithMessage("10029") | ||
398 | + } | ||
399 | + return nil | ||
400 | +} |
@@ -295,12 +295,12 @@ func DepartmentDelete(param protocol.RequestDepartmentDelete) error { | @@ -295,12 +295,12 @@ func DepartmentDelete(param protocol.RequestDepartmentDelete) error { | ||
295 | cnt, err := models.CountUserDepartByDepart(subset.Id) | 295 | cnt, err := models.CountUserDepartByDepart(subset.Id) |
296 | if err != nil { | 296 | if err != nil { |
297 | log.Error("CountUserDepartByDepart err:%s", err) | 297 | log.Error("CountUserDepartByDepart err:%s", err) |
298 | - return protocol.NewErrWithMessage("10047") | 298 | + return protocol.NewErrWithMessage("1") |
299 | } | 299 | } |
300 | if cnt > 0 { | 300 | if cnt > 0 { |
301 | e := fmt.Errorf("user in department,relation:%s", subset.Relation) | 301 | e := fmt.Errorf("user in department,relation:%s", subset.Relation) |
302 | log.Error(e.Error()) | 302 | log.Error(e.Error()) |
303 | - return protocol.NewErrWithMessage("1", e) | 303 | + return protocol.NewErrWithMessage("10047", e) |
304 | } | 304 | } |
305 | if _, ok := toDelete[subset.Id]; ok && subset.Id != pos.Id { | 305 | if _, ok := toDelete[subset.Id]; ok && subset.Id != pos.Id { |
306 | delete(toDelete, subset.Id) | 306 | delete(toDelete, subset.Id) |
@@ -355,7 +355,7 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro | @@ -355,7 +355,7 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro | ||
355 | var manage []protocol.DepartmentManager | 355 | var manage []protocol.DepartmentManager |
356 | manage = v.GetManages() | 356 | manage = v.GetManages() |
357 | depart.Manages = manage | 357 | depart.Manages = manage |
358 | - depart.Members = v.GetMembers() | 358 | + // depart.Members = v.GetMembers() |
359 | departs = append(departs, depart) | 359 | departs = append(departs, depart) |
360 | } | 360 | } |
361 | 361 |
@@ -587,7 +587,7 @@ func GetUserPosition(usercompanyid int64) []protocol.PositionBase { | @@ -587,7 +587,7 @@ func GetUserPosition(usercompanyid int64) []protocol.PositionBase { | ||
587 | WHERE a.enable_status =1 AND a.user_company_id =? ` | 587 | WHERE a.enable_status =1 AND a.user_company_id =? ` |
588 | var ( | 588 | var ( |
589 | err error | 589 | err error |
590 | - data []protocol.PositionBase | 590 | + data = make([]protocol.PositionBase, 0) |
591 | ) | 591 | ) |
592 | err = utils.ExecuteQueryAll(&data, datasql, usercompanyid) | 592 | err = utils.ExecuteQueryAll(&data, datasql, usercompanyid) |
593 | if err != nil { | 593 | if err != nil { |
@@ -604,7 +604,7 @@ func GetUserRole(usercompanyid int64) []protocol.RoleBase { | @@ -604,7 +604,7 @@ func GetUserRole(usercompanyid int64) []protocol.RoleBase { | ||
604 | WHERE a.enable_status =1 AND a.user_company_id =? ` | 604 | WHERE a.enable_status =1 AND a.user_company_id =? ` |
605 | var ( | 605 | var ( |
606 | err error | 606 | err error |
607 | - data []protocol.RoleBase | 607 | + data = make([]protocol.RoleBase, 0) |
608 | ) | 608 | ) |
609 | err = utils.ExecuteQueryAll(&data, datasql, usercompanyid) | 609 | err = utils.ExecuteQueryAll(&data, datasql, usercompanyid) |
610 | if err != nil { | 610 | if err != nil { |
@@ -44,8 +44,8 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo | @@ -44,8 +44,8 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo | ||
44 | Phone: phone, | 44 | Phone: phone, |
45 | Nickname: nickname, | 45 | Nickname: nickname, |
46 | Avatar: avatar, | 46 | Avatar: avatar, |
47 | - Password: "9d1f5048afd96b39a3dae71a99f2c77a30112d29", //默认密码:fmt.Sprintf("%x", sha1.Sum([]byte("mmm1234554321"))) | ||
48 | - RegIm: 1, | 47 | + //Password: "9d1f5048afd96b39a3dae71a99f2c77a30112d29", //默认密码:fmt.Sprintf("%x", sha1.Sum([]byte("mmm1234554321"))) |
48 | + RegIm: 1, | ||
49 | } | 49 | } |
50 | uclient := NewUCenterClient() | 50 | uclient := NewUCenterClient() |
51 | btBody, err := uclient.Call(param) | 51 | btBody, err := uclient.Call(param) |
@@ -92,6 +92,28 @@ func RequestUCenterSmsCode(phone string) error { | @@ -92,6 +92,28 @@ func RequestUCenterSmsCode(phone string) error { | ||
92 | return nil | 92 | return nil |
93 | } | 93 | } |
94 | 94 | ||
95 | +//短信验证码登录 | ||
95 | func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, error) { | 96 | func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, error) { |
96 | - return nil, nil | 97 | + param := RequestLoginSms{ |
98 | + Phone: phone, | ||
99 | + Captcha: captcha, | ||
100 | + GrantType: "signInCaptcha", | ||
101 | + } | ||
102 | + uclient := NewUCenterClient() | ||
103 | + btBody, err := uclient.Call(param) | ||
104 | + if err != nil { | ||
105 | + log.Error("统一用户中心请求失败 err:%s", err) | ||
106 | + return nil, protocol.NewErrWithMessage("1") | ||
107 | + } | ||
108 | + var ucenterReturn *ResponseLoginSms | ||
109 | + err = json.Unmarshal(btBody, ucenterReturn) | ||
110 | + if err != nil { | ||
111 | + log.Error("解析统一用户中心响应失败 err:%s", err) | ||
112 | + return nil, protocol.NewErrWithMessage("1") | ||
113 | + } | ||
114 | + if !(ucenterReturn.Code == ResponseCode0 && | ||
115 | + ucenterReturn.Msg == ResponseMsgOk) { | ||
116 | + return nil, protocol.NewErrWithMessage("10040") | ||
117 | + } | ||
118 | + return ucenterReturn, nil | ||
97 | } | 119 | } |
@@ -18,6 +18,10 @@ type RequesLogin struct { | @@ -18,6 +18,10 @@ type RequesLogin struct { | ||
18 | Phone string `json:"phone"` | 18 | Phone string `json:"phone"` |
19 | } | 19 | } |
20 | 20 | ||
21 | +var ( | ||
22 | + _ IUCenterParam = RequesLogin{} | ||
23 | +) | ||
24 | + | ||
21 | //Format 实现IUCenterParam接口 | 25 | //Format 实现IUCenterParam接口 |
22 | func (r RequesLogin) Format() []byte { | 26 | func (r RequesLogin) Format() []byte { |
23 | var v []byte | 27 | var v []byte |
@@ -47,10 +51,10 @@ type ResponseLogin struct { | @@ -47,10 +51,10 @@ type ResponseLogin struct { | ||
47 | Data struct { | 51 | Data struct { |
48 | Id int64 `json:"id"` | 52 | Id int64 `json:"id"` |
49 | Phone string `json:"phone"` | 53 | Phone string `json:"phone"` |
50 | - NickName string `json:"nickname"` //昵称 | ||
51 | - Avatar string `json:"avatar"` //头像 | ||
52 | - Imtoken string `json:"imtoken"` //网易云imtoken | ||
53 | - Accid int64 `json:"accid"` | 54 | + NickName string `json:"nickname"` //昵称 |
55 | + Avatar string `json:"avatar"` //头像 | ||
56 | + Imtoken string `json:"imtoken"` //网易云imtoken | ||
57 | + Accid int64 `json:"accid"` //网易云id | ||
54 | CustomerAccount int64 `json:"customerAccount"` //客服id | 58 | CustomerAccount int64 `json:"customerAccount"` //客服id |
55 | } `json:"data"` | 59 | } `json:"data"` |
56 | } | 60 | } |
@@ -61,9 +65,13 @@ type RequestAddUser struct { | @@ -61,9 +65,13 @@ type RequestAddUser struct { | ||
61 | RegIm int8 `json:"regIm"` | 65 | RegIm int8 `json:"regIm"` |
62 | Nickname string `json:"nickname"` | 66 | Nickname string `json:"nickname"` |
63 | Avatar string `json:"avatar"` | 67 | Avatar string `json:"avatar"` |
64 | - Password string `json:"password"` | 68 | + // Password string `json:"password"` |
65 | } | 69 | } |
66 | 70 | ||
71 | +var ( | ||
72 | + _ IUCenterParam = RequestAddUser{} | ||
73 | +) | ||
74 | + | ||
67 | //Format 实现IUCenterParam接口 | 75 | //Format 实现IUCenterParam接口 |
68 | func (r RequestAddUser) Format() []byte { | 76 | func (r RequestAddUser) Format() []byte { |
69 | var v []byte | 77 | var v []byte |
@@ -73,14 +81,11 @@ func (r RequestAddUser) Format() []byte { | @@ -73,14 +81,11 @@ func (r RequestAddUser) Format() []byte { | ||
73 | 81 | ||
74 | //Format 实现IUCenterParam接口 | 82 | //Format 实现IUCenterParam接口 |
75 | func (r RequestAddUser) GetPath() (string, string) { | 83 | func (r RequestAddUser) GetPath() (string, string) { |
76 | - return "/users", "POST" | 84 | + return "/users/save", "POST" |
77 | } | 85 | } |
78 | 86 | ||
79 | //Format 实现IUCenterParam接口 | 87 | //Format 实现IUCenterParam接口 |
80 | func (r RequestAddUser) Valid() error { | 88 | func (r RequestAddUser) Valid() error { |
81 | - if len(r.Password) == 0 { | ||
82 | - return errors.New("len(r.Password) == 0") | ||
83 | - } | ||
84 | if len(r.Phone) == 0 { | 89 | if len(r.Phone) == 0 { |
85 | return errors.New("len(r.Phone == 0") | 90 | return errors.New("len(r.Phone == 0") |
86 | } | 91 | } |
@@ -100,43 +105,15 @@ type ResponseAddUser struct { | @@ -100,43 +105,15 @@ type ResponseAddUser struct { | ||
100 | } `json:"data"` | 105 | } `json:"data"` |
101 | } | 106 | } |
102 | 107 | ||
103 | -// type RequestCheckCompany struct { | ||
104 | -// CompanyId int64 `json:"company_id"` | ||
105 | -// } | ||
106 | - | ||
107 | -// //Format 实现IUCenterParam接口 | ||
108 | -// func (r RequestCheckCompany) Format() []byte { | ||
109 | -// return nil | ||
110 | -// } | ||
111 | - | ||
112 | -// //Format 实现IUCenterParam接口 | ||
113 | -// func (r RequestCheckCompany) GetPath() (string, string) { | ||
114 | -// return fmt.Sprintf("/company/%d", r.CompanyId), "GET" | ||
115 | -// } | ||
116 | - | ||
117 | -// //Format 实现IUCenterParam接口 | ||
118 | -// func (r RequestCheckCompany) Valid() error { | ||
119 | -// if r.CompanyId == 0 { | ||
120 | -// return errors.New("r.CompanyId == 0") | ||
121 | -// } | ||
122 | -// return nil | ||
123 | -// } | ||
124 | - | ||
125 | -// type ResponseCheckCompany struct { | ||
126 | -// CommResponse | ||
127 | -// Data struct { | ||
128 | -// CompanyId int64 `json:"id"` //公司的id | ||
129 | -// CompanyName string `json:"name"` //公司的名称 | ||
130 | -// AdminAccount string `json:"admin_account"` //主管账号 | ||
131 | -// AdminName string `json:"admin_name"` //主管名称 | ||
132 | -// } `json:"data"` | ||
133 | -// } | ||
134 | - | ||
135 | //发送验证码短信 | 108 | //发送验证码短信 |
136 | type RequestSmsCodeSend struct { | 109 | type RequestSmsCodeSend struct { |
137 | Phone string `json:"phone"` | 110 | Phone string `json:"phone"` |
138 | } | 111 | } |
139 | 112 | ||
113 | +var ( | ||
114 | + _ IUCenterParam = RequestSmsCodeSend{} | ||
115 | +) | ||
116 | + | ||
140 | func (r RequestSmsCodeSend) Format() []byte { | 117 | func (r RequestSmsCodeSend) Format() []byte { |
141 | var bt []byte | 118 | var bt []byte |
142 | bt, _ = json.Marshal(r) | 119 | bt, _ = json.Marshal(r) |
@@ -155,6 +132,22 @@ type RequestLoginSms struct { | @@ -155,6 +132,22 @@ type RequestLoginSms struct { | ||
155 | GrantType string `json:"grantType"` //登陆方式(signInCaptcha验证码) | 132 | GrantType string `json:"grantType"` //登陆方式(signInCaptcha验证码) |
156 | } | 133 | } |
157 | 134 | ||
135 | +var ( | ||
136 | + _ IUCenterParam = RequestLoginSms{} | ||
137 | +) | ||
138 | + | ||
139 | +//Format 实现IUCenterParam接口 | ||
140 | +func (r RequestLoginSms) Format() []byte { | ||
141 | + var v []byte | ||
142 | + v, _ = json.Marshal(r) | ||
143 | + return v | ||
144 | +} | ||
145 | + | ||
146 | +//GetPath 实现IUCenterParam接口 | ||
147 | +func (r RequestLoginSms) GetPath() (string, string) { | ||
148 | + return "/auth/loginAggregate", "POST" | ||
149 | +} | ||
150 | + | ||
158 | //ResponseLoginSms 短信验证码登录 响应 | 151 | //ResponseLoginSms 短信验证码登录 响应 |
159 | type ResponseLoginSms struct { | 152 | type ResponseLoginSms struct { |
160 | CommResponse | 153 | CommResponse |
@@ -168,6 +161,6 @@ type LoginSmsData struct { | @@ -168,6 +161,6 @@ type LoginSmsData struct { | ||
168 | Image struct { | 161 | Image struct { |
169 | Path string `json:"path"` | 162 | Path string `json:"path"` |
170 | } `json:"image"` | 163 | } `json:"image"` |
171 | - ImToken string `json:"imtoken"` | 164 | + Imtoken string `json:"imToken"` |
172 | CsAccountID int64 `json:"csAccountID"` | 165 | CsAccountID int64 `json:"csAccountID"` |
173 | } | 166 | } |
-
请 注册 或 登录 后发表评论