Merge remote-tracking branch 'origin/dev' into test
正在显示
18 个修改的文件
包含
342 行增加
和
74 行删除
@@ -45,5 +45,5 @@ suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com" | @@ -45,5 +45,5 @@ suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com" | ||
45 | #阿里云 | 45 | #阿里云 |
46 | cname ="https://media.fjmaimaimai.com/" | 46 | cname ="https://media.fjmaimaimai.com/" |
47 | 47 | ||
48 | -#服务地址 | ||
49 | -VOD_SVR_ADDRESS ="http://mmm-open-api-dev.fjmaimaimai.com" | ||
48 | +#企业平台 | ||
49 | +BUSINESS_ADMIN_SERVICE_HOST ="${BUSINESS_ADMIN_SERVICE_HOST||http://suplus-business-admin-dev.fjmaimaimai.com}" |
@@ -43,11 +43,8 @@ h5_host = "http://mmm-web-open-test.fjmaimaimai.com" | @@ -43,11 +43,8 @@ h5_host = "http://mmm-web-open-test.fjmaimaimai.com" | ||
43 | #审核中心 | 43 | #审核中心 |
44 | suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com" | 44 | suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com" |
45 | 45 | ||
46 | -#阿里云 https://media.goexample.live/ | ||
47 | -cname ="https://media.fjmaimaimai.com/" | 46 | +#阿里云 https://media.fjmaimaimai.com/ |
47 | +cname ="https://media.goexample.live/" | ||
48 | 48 | ||
49 | #企业平台 | 49 | #企业平台 |
50 | -BUSINESS_ADMIN_SERVICE_HOST ="${BUSINESS_ADMIN_SERVICE_HOST||http://suplus-business-admin-test.fjmaimaimai.com}" | ||
51 | - | ||
52 | -#服务地址 | ||
53 | -VOD_SVR_ADDRESS ="http://mmm-open-api-dev.fjmaimaimai.com" | ||
50 | +BUSINESS_ADMIN_SERVICE_HOST ="${BUSINESS_ADMIN_SERVICE_HOST||http://suplus-business-admin-dev.fjmaimaimai.com}" |
@@ -47,6 +47,3 @@ BUSINESS_ADMIN_SERVICE_HOST ="${BUSINESS_ADMIN_SERVICE_HOST||http://suplus-busin | @@ -47,6 +47,3 @@ BUSINESS_ADMIN_SERVICE_HOST ="${BUSINESS_ADMIN_SERVICE_HOST||http://suplus-busin | ||
47 | 47 | ||
48 | #阿里云 | 48 | #阿里云 |
49 | cname ="https://media.fjmaimaimai.com/" | 49 | cname ="https://media.fjmaimaimai.com/" |
50 | - | ||
51 | -#服务地址 | ||
52 | -VOD_SVR_ADDRESS ="http://mmm-open-api-prd.fjmaimaimai.com" |
conf/prod2.conf
0 → 100644
1 | +[prod] | ||
2 | +#数据库相关 | ||
3 | +mysql_user = "${MYSQL_USER||suplus_user}" | ||
4 | +mysql_password = "${MYSQL_PASSWORD||suplus2019!}" | ||
5 | +mysql_host = "${MYSQL_HOST||rm-bp17e26y39qravmwxmo.mysql.rds.aliyuncs.com}" | ||
6 | +mysql_port = "${MYSQL_PORT||3306}" | ||
7 | +mysql_db_name = "${MYSQL_DB_NAME||opportunity}" | ||
8 | + | ||
9 | +#日志 | ||
10 | +log_level = "${LOG_LEVEL||debug}" | ||
11 | +aliyun_logs_access ="${aliyun_logs_access||app.log}" | ||
12 | + | ||
13 | + | ||
14 | +#redis相关配置 | ||
15 | +redis_add = "${REDIS_HOST||127.0.0.1}" | ||
16 | +redis_add_port = "${REDIS_PORT||6379}" | ||
17 | +redis_auth = "123456" | ||
18 | + | ||
19 | +#sms相关配置 | ||
20 | +yunpian_sms_sdk_url ="https://sms.yunpian.com/v2/sms/single_send.json" | ||
21 | +yunpian_app_key ="0bf6fb10a11a68a95dee80901eb545b5" | ||
22 | + | ||
23 | +#存储 http:https://public-interface.fjmaimaimai.com/opportunity/ http://mmm-opp-prd.fjmaimaimai.com/ | ||
24 | +source_host ="https://mmm-opp-prd.fjmaimaimai.com/" | ||
25 | +source_virtual_path=file/opp | ||
26 | +source_path ="${aliyun_file_access||/var/www/opp/file/opportunity}" | ||
27 | + | ||
28 | +#网易云信 IM | ||
29 | +net_im_base_url ="https://api.netease.im/nimserver" | ||
30 | +net_im_app_secret ="a8d231f5c13a" | ||
31 | +net_im_app_key ="9c5410602597a7fe367aeeebd8210262" | ||
32 | + | ||
33 | +#统一用户中心 39aefef9e22744a3b2d2d3791824ae7b | ||
34 | +user_center_url ="https://public-interface.fjmaimaimai.com/ucenter" | ||
35 | +user_center_salt ="rsF0pL!6DwjBO735" | ||
36 | +user_center_app_key ="39aefef9e22744a3b2d2d3791824ae7b" | ||
37 | +user_center_app_secret ="cykbjnfqgctn" | ||
38 | + | ||
39 | +#Html5 | ||
40 | +h5_host = "https://web-open.fjmaimaimai.com" | ||
41 | + | ||
42 | +#审核中心 | ||
43 | +suplus_approve_host ="https://public-interface.fjmaimaimai.com/approve" | ||
44 | + | ||
45 | +#企业平台 | ||
46 | +BUSINESS_ADMIN_SERVICE_HOST ="${BUSINESS_ADMIN_SERVICE_HOST||http://suplus-business-admin-prd.fjmaimaimai.com}" | ||
47 | + | ||
48 | +#阿里云 | ||
49 | +cname ="https://media.fjmaimaimai.com/" |
@@ -202,6 +202,7 @@ func CheckToken(ctx *context.Context) (result bool) { | @@ -202,6 +202,7 @@ func CheckToken(ctx *context.Context) (result bool) { | ||
202 | if strings.HasSuffix(ctx.Request.RequestURI, "loginModule") || | 202 | if strings.HasSuffix(ctx.Request.RequestURI, "loginModule") || |
203 | strings.HasSuffix(ctx.Request.RequestURI, "accessToken") || | 203 | strings.HasSuffix(ctx.Request.RequestURI, "accessToken") || |
204 | strings.HasSuffix(ctx.Request.RequestURI, "refreshToken") || | 204 | strings.HasSuffix(ctx.Request.RequestURI, "refreshToken") || |
205 | + strings.HasSuffix(ctx.Request.RequestURI, "authorize") || | ||
205 | strings.HasSuffix(ctx.Request.RequestURI, "smsCode") { | 206 | strings.HasSuffix(ctx.Request.RequestURI, "smsCode") { |
206 | return true | 207 | return true |
207 | } | 208 | } |
@@ -43,6 +43,27 @@ func (this *AuthController) Login() { | @@ -43,6 +43,27 @@ func (this *AuthController) Login() { | ||
43 | msg = protocol.NewReturnResponse(auth.Login(header, request)) | 43 | msg = protocol.NewReturnResponse(auth.Login(header, request)) |
44 | } | 44 | } |
45 | 45 | ||
46 | +//Authorize 模块认证 (登录V2版本) | ||
47 | +// @router /authorize [post] | ||
48 | +func (this *AuthController) Authorize() { | ||
49 | + var msg *protocol.ResponseMessage | ||
50 | + defer func() { | ||
51 | + this.Resp(msg) | ||
52 | + }() | ||
53 | + var request *protocol.AuthorizeRequest | ||
54 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
55 | + log.Error(err) | ||
56 | + msg = protocol.BadRequestParam(1) | ||
57 | + return | ||
58 | + } | ||
59 | + if b, m := this.Valid(request); !b { | ||
60 | + msg = m | ||
61 | + return | ||
62 | + } | ||
63 | + header := controllers.GetRequestHeader(this.Ctx) | ||
64 | + msg = protocol.NewReturnResponse(auth.Authorize(header, request)) | ||
65 | +} | ||
66 | + | ||
46 | //SmsCode | 67 | //SmsCode |
47 | // @router /smsCode [post] | 68 | // @router /smsCode [post] |
48 | func (this *AuthController) SmsCode() { | 69 | func (this *AuthController) SmsCode() { |
@@ -34,24 +34,3 @@ func (this *ConfigController) GetConfigScore() { | @@ -34,24 +34,3 @@ func (this *ConfigController) GetConfigScore() { | ||
34 | header := controllers.GetRequestHeader(this.Ctx) | 34 | header := controllers.GetRequestHeader(this.Ctx) |
35 | msg = protocol.NewReturnResponse(config.GetConfigScore(header, request)) | 35 | msg = protocol.NewReturnResponse(config.GetConfigScore(header, request)) |
36 | } | 36 | } |
37 | - | ||
38 | -//ServiceConfig 服务配置 | ||
39 | -//@router /service [post] | ||
40 | -func (this *ConfigController) ServiceConfig() { | ||
41 | - var msg *protocol.ResponseMessage | ||
42 | - defer func() { | ||
43 | - this.Resp(msg) | ||
44 | - }() | ||
45 | - var request *protocol.ServiceConfigRequest | ||
46 | - if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
47 | - log.Error(err) | ||
48 | - msg = protocol.BadRequestParam(1) | ||
49 | - return | ||
50 | - } | ||
51 | - if b, m := this.Valid(request); !b { | ||
52 | - msg = m | ||
53 | - return | ||
54 | - } | ||
55 | - header := controllers.GetRequestHeader(this.Ctx) | ||
56 | - msg = protocol.NewReturnResponse(config.ServiceConfig(header, request)) | ||
57 | -} |
@@ -59,6 +59,18 @@ type LoginResponse struct { | @@ -59,6 +59,18 @@ type LoginResponse struct { | ||
59 | AuthCode string `json:"authCode"` | 59 | AuthCode string `json:"authCode"` |
60 | } | 60 | } |
61 | 61 | ||
62 | +/*Authorize 模块认证 (登录V2版本)*/ | ||
63 | +type AuthorizeRequest struct { | ||
64 | + Token string `json:"credentials" valid:"Required;"` //登录凭证 | ||
65 | + ClientId string `json:"clientId"` //客户端密钥 | ||
66 | + Uid int64 `json:"cuid" valid:"Required;"` //统一用户中心用户 UID | ||
67 | + Cid int64 `json:"cid" valid:"Required;"` //统一用户中心公司 ID | ||
68 | + Muid int64 `json:"muid" valid:"Required;"` //企业平台中的用户 UID | ||
69 | +} | ||
70 | +type AuthorizeResponse struct { | ||
71 | + AuthCode string `json:"authCode"` | ||
72 | +} | ||
73 | + | ||
62 | /*统一用户中心登录*/ | 74 | /*统一用户中心登录*/ |
63 | type UserCenterLoginRequest struct { | 75 | type UserCenterLoginRequest struct { |
64 | Phone string `json:"phone"` | 76 | Phone string `json:"phone"` |
@@ -548,6 +548,10 @@ type Picture struct { | @@ -548,6 +548,10 @@ type Picture struct { | ||
548 | //JobId string `json:"job_id"` | 548 | //JobId string `json:"job_id"` |
549 | } | 549 | } |
550 | 550 | ||
551 | +type Avatar struct { | ||
552 | + Path string `json:"path"` | ||
553 | +} | ||
554 | + | ||
551 | //视频 | 555 | //视频 |
552 | type Video struct { | 556 | type Video struct { |
553 | Path string `json:"path"` | 557 | Path string `json:"path"` |
@@ -32,19 +32,3 @@ type ScoreRange struct { | @@ -32,19 +32,3 @@ type ScoreRange struct { | ||
32 | Max float64 `json:"max"` //最大分 | 32 | Max float64 `json:"max"` //最大分 |
33 | Step float64 `json:"step"` //步长 | 33 | Step float64 `json:"step"` //步长 |
34 | } | 34 | } |
35 | - | ||
36 | -/*ServiceConfig 服务配置*/ | ||
37 | -type ServiceConfigRequest struct { | ||
38 | -} | ||
39 | -type ServiceConfigResponse struct { | ||
40 | - ServeConfig *ServeConfig `json:"serveConfig"` //服务配置 | ||
41 | -} | ||
42 | - | ||
43 | -type ServeConfig struct { | ||
44 | - VodAddress string `json:"vodSvrAddress"` //视频服务地址 | ||
45 | -} | ||
46 | - | ||
47 | -func (s *ServeConfig) SetVodAddress(addr string) *ServeConfig { | ||
48 | - s.VodAddress = addr | ||
49 | - return s | ||
50 | -} |
@@ -13,6 +13,10 @@ var errmessge ErrorMap = map[int]string{ | @@ -13,6 +13,10 @@ var errmessge ErrorMap = map[int]string{ | ||
13 | 5: "繁忙,请稍后再试", | 13 | 5: "繁忙,请稍后再试", |
14 | 101: "clientId或clientSecret无效", | 14 | 101: "clientId或clientSecret无效", |
15 | 113: "签名验证失败", | 15 | 113: "签名验证失败", |
16 | + 502: "用户不存在", | ||
17 | + 503: "用户被禁用", | ||
18 | + 601: "公司被禁用", | ||
19 | + 602: "用户无模块权限", | ||
16 | 1009: "验证码已失效", | 20 | 1009: "验证码已失效", |
17 | 1011: "获取验证码次数超出限制,请联系管理员", | 21 | 1011: "获取验证码次数超出限制,请联系管理员", |
18 | 1012: "请输入正确的验证码", | 22 | 1012: "请输入正确的验证码", |
@@ -63,6 +67,16 @@ var errmessge ErrorMap = map[int]string{ | @@ -63,6 +67,16 @@ var errmessge ErrorMap = map[int]string{ | ||
63 | 67 | ||
64 | //评论相关 | 68 | //评论相关 |
65 | 5601: "评论不存在", | 69 | 5601: "评论不存在", |
70 | + | ||
71 | + //企业平台 | ||
72 | + 10001: "用户不存在", | ||
73 | + 10002: "登录凭证已过期,请重新登录", | ||
74 | + 10003: "验证码不能为空", | ||
75 | + 10004: "登录凭证不能为空", | ||
76 | + 10005: "密码不能为空", | ||
77 | + 10006: "用户不存在", | ||
78 | + 10007: "用户已被禁用", | ||
79 | + 10008: "用户无模块权限", | ||
66 | } | 80 | } |
67 | 81 | ||
68 | const ( | 82 | const ( |
@@ -65,9 +65,10 @@ type UserStatisticsResponse struct { | @@ -65,9 +65,10 @@ type UserStatisticsResponse struct { | ||
65 | 65 | ||
66 | type User struct { | 66 | type User struct { |
67 | UserId int64 `json:"uid"` | 67 | UserId int64 `json:"uid"` |
68 | + MUserId int64 `json:"muid"` //中台用户ID | ||
68 | Name string `json:"uname"` | 69 | Name string `json:"uname"` |
69 | Phone string `json:"phone"` | 70 | Phone string `json:"phone"` |
70 | - Image Picture `json:"image"` | 71 | + Image Avatar `json:"image"` |
71 | Department Dep `json:"dep"` | 72 | Department Dep `json:"dep"` |
72 | Position Job `json:"job"` | 73 | Position Job `json:"job"` |
73 | ImToken string `json:"imToken"` | 74 | ImToken string `json:"imToken"` |
@@ -49,6 +49,14 @@ func init() { | @@ -49,6 +49,14 @@ func init() { | ||
49 | 49 | ||
50 | beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], | 50 | beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], |
51 | beego.ControllerComments{ | 51 | beego.ControllerComments{ |
52 | + Method: "Authorize", | ||
53 | + Router: `/authorize`, | ||
54 | + AllowHTTPMethods: []string{"post"}, | ||
55 | + MethodParams: param.Make(), | ||
56 | + Params: nil}) | ||
57 | + | ||
58 | + beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], | ||
59 | + beego.ControllerComments{ | ||
52 | Method: "Login", | 60 | Method: "Login", |
53 | Router: `/loginModule`, | 61 | Router: `/loginModule`, |
54 | AllowHTTPMethods: []string{"post"}, | 62 | AllowHTTPMethods: []string{"post"}, |
@@ -407,14 +415,6 @@ func init() { | @@ -407,14 +415,6 @@ func init() { | ||
407 | MethodParams: param.Make(), | 415 | MethodParams: param.Make(), |
408 | Params: nil}) | 416 | Params: nil}) |
409 | 417 | ||
410 | - beego.GlobalControllerRouter["opp/controllers/v1:ConfigController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ConfigController"], | ||
411 | - beego.ControllerComments{ | ||
412 | - Method: "ServiceConfig", | ||
413 | - Router: `/service`, | ||
414 | - AllowHTTPMethods: []string{"post"}, | ||
415 | - MethodParams: param.Make(), | ||
416 | - Params: nil}) | ||
417 | - | ||
418 | beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"], | 418 | beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"], |
419 | beego.ControllerComments{ | 419 | beego.ControllerComments{ |
420 | Method: "Departments", | 420 | Method: "Departments", |
@@ -161,6 +161,35 @@ func CheckUserModuleAuth(uid int64) (auth bool) { | @@ -161,6 +161,35 @@ func CheckUserModuleAuth(uid int64) (auth bool) { | ||
161 | return response.UserAuth | 161 | return response.UserAuth |
162 | } | 162 | } |
163 | 163 | ||
164 | +func GetUserModuleAuth(uid int64) (message *protocol.Message, auth bool) { | ||
165 | + var req = NewRequest(fmt.Sprintf("%v%v", beego.AppConfig.String("BUSINESS_ADMIN_SERVICE_HOST"), MethodUserAuth), http.MethodPost) | ||
166 | + message = &protocol.Message{} | ||
167 | + auth = false | ||
168 | + var request = struct { | ||
169 | + UserId string `json:"userId"` | ||
170 | + PlatformId string `json:"platformId"` | ||
171 | + }{UserId: fmt.Sprintf("%v", uid), PlatformId: "3"} //平台id:1素+;2问题;3机会;18价值 | ||
172 | + var response = struct { | ||
173 | + UserAuth bool `json:"userAuth"` | ||
174 | + }{} | ||
175 | + if data, err := req.ActionDefault(request, &message); err != nil { | ||
176 | + log.Error(err) | ||
177 | + return | ||
178 | + } else { | ||
179 | + log.Debug(req.Url, uid, string(data)) | ||
180 | + } | ||
181 | + if message.Errno != 0 { | ||
182 | + log.Debug("CheckUserModuleAuth :", message.Errno, message.Errmsg) | ||
183 | + return | ||
184 | + } | ||
185 | + if err := json.Unmarshal(message.Data, &response); err != nil { | ||
186 | + log.Error(err, message, string(message.Data)) | ||
187 | + return | ||
188 | + } | ||
189 | + auth = response.UserAuth | ||
190 | + return | ||
191 | +} | ||
192 | + | ||
164 | type Request struct { | 193 | type Request struct { |
165 | HttpReq *httplib.BeegoHTTPRequest | 194 | HttpReq *httplib.BeegoHTTPRequest |
166 | Url string | 195 | Url string |
@@ -281,6 +281,177 @@ Success: | @@ -281,6 +281,177 @@ Success: | ||
281 | return | 281 | return |
282 | } | 282 | } |
283 | 283 | ||
284 | +//模块认证 (登录V2版本) | ||
285 | +func Authorize(header *protocol.RequestHeader, request *protocol.AuthorizeRequest) (rsp *protocol.AuthorizeResponse, err error) { | ||
286 | + var () | ||
287 | + rsp = &protocol.AuthorizeResponse{} | ||
288 | + var ( | ||
289 | + user *models.User | ||
290 | + userAuth *models.UserAuth | ||
291 | + id = request.Uid | ||
292 | + getUserRequest *protocol.UCenterServerLoginRequest = &protocol.UCenterServerLoginRequest{ | ||
293 | + Uid: id, | ||
294 | + Token: request.Token, | ||
295 | + Type: 2, | ||
296 | + CompanyId: request.Cid, //当前登录的公司编号 | ||
297 | + } | ||
298 | + getUserResponse *protocol.UCenterGetUserResponse | ||
299 | + message *protocol.Message | ||
300 | + //currentCompany *models.Company | ||
301 | + //companys []*models.Company | ||
302 | + userCompany *models.UserCompany | ||
303 | + company *models.Company | ||
304 | + ) | ||
305 | + //验证 当前登录的公司是否有模块权限 | ||
306 | + if err = CheckBusinessAuth(header, request.Muid); err != nil { | ||
307 | + log.Error(request.Muid, err) | ||
308 | + return | ||
309 | + } | ||
310 | + //判断用户是否添加 | ||
311 | + user, err = models.GetUserByUcenterId(id) | ||
312 | + if err != nil { | ||
313 | + log.Error(err) | ||
314 | + err = protocol.NewErrWithMessage(2002, err) //账号不存在 | ||
315 | + return | ||
316 | + } | ||
317 | + //判断用户所属公司是否有权限 | ||
318 | + //if companys, err = models.GetCompanyByPermission(user.Id); err != nil { | ||
319 | + // log.Error(err) | ||
320 | + // err = protocol.NewErrWithMessage(2002, err) //账号不存在 | ||
321 | + // return | ||
322 | + //} | ||
323 | + //if len(companys) == 0 { | ||
324 | + // err = protocol.NewErrWithMessage(2002, err) //账号不存在 | ||
325 | + // return | ||
326 | + //} | ||
327 | + | ||
328 | + //权限验证 判断用户公司是否存在 | ||
329 | + if userCompany, err = models.GetUserCompanyById(request.Muid); err != nil { | ||
330 | + log.Error(err, request.Muid) | ||
331 | + err = protocol.NewErrWithMessage(10008, err) //用户无模块权限 | ||
332 | + return | ||
333 | + } | ||
334 | + if userCompany.Enable != 1 { | ||
335 | + err = protocol.NewErrWithMessage(10006, err) //用户已禁用 | ||
336 | + log.Error(err) | ||
337 | + return | ||
338 | + } | ||
339 | + if company, err = models.GetCompanyById(request.Cid); err != nil { | ||
340 | + log.Error(err, request.Cid) | ||
341 | + err = protocol.NewErrWithMessage(10007, err) //企业已禁用 | ||
342 | + return | ||
343 | + } | ||
344 | + if company.Enable != 1 { | ||
345 | + err = protocol.NewErrWithMessage(10007, err) ///企业已禁用 | ||
346 | + log.Error(err) | ||
347 | + return | ||
348 | + } | ||
349 | + | ||
350 | + if !utils.ValidVersion(header.Version, protocol.RequireVersion) { | ||
351 | + log.Warn(fmt.Sprintf("版本不足 当前手机版本:%v 需要版本大于:%v", header.Version, protocol.RequireVersion)) | ||
352 | + err = protocol.NewCustomMessage(2002, "版本不足,请升级app") //账号不存在 | ||
353 | + return | ||
354 | + } | ||
355 | + //获取最后一次公司编号给统一用户中心 | ||
356 | + //if u, e := models.GetUserAuthByUserId(user.Id, protocol.DeviceType); e == nil && user.UserCenterId == id { | ||
357 | + // if currentCompany, e = models.GetCompanyById(u.CurrentCompanyId); e == nil { | ||
358 | + // getUserRequest.CompanyId = currentCompany.UserCenterId | ||
359 | + // } | ||
360 | + //} | ||
361 | + | ||
362 | + //从用户中心获取用户信息 | ||
363 | + if _, err = agg.RequestUserCenter(protocol.MethodServerLogin, http.MethodPost, getUserRequest, &message); err != nil { | ||
364 | + log.Error(err) | ||
365 | + return | ||
366 | + } | ||
367 | + log.Debug(fmt.Sprintf("ucenter_id:%v user_id:%v getuser response:", request.Uid, request.Muid), message.Errno, message.Errmsg) | ||
368 | + if message.Errno == 0 && message.Errmsg == "ok" { | ||
369 | + if err = message.Unmarshal(&getUserResponse); err != nil { | ||
370 | + log.Error(err) | ||
371 | + return | ||
372 | + } | ||
373 | + } | ||
374 | + switch message.Errno { | ||
375 | + case -1: | ||
376 | + err = protocol.NewErrWithMessage(2002, err) //账号不存在 | ||
377 | + return | ||
378 | + case 0: | ||
379 | + goto Success | ||
380 | + case 2002: | ||
381 | + err = protocol.NewErrWithMessage(2002, err) //账号不存在 | ||
382 | + return | ||
383 | + case 10001: | ||
384 | + err = protocol.NewErrWithMessage(2002, err) //账号不存在 | ||
385 | + return | ||
386 | + case 10003: | ||
387 | + err = protocol.NewErrWithMessage(4140, err) //账号不存在 | ||
388 | + return | ||
389 | + default: | ||
390 | + log.Error(fmt.Sprintf("error_no:%v msg:%v", message.Errno, message.Errmsg)) | ||
391 | + err = protocol.NewErrWithMessage(4140, err) | ||
392 | + return | ||
393 | + } | ||
394 | + | ||
395 | +Success: | ||
396 | + { | ||
397 | + userAuth, err = models.GetUserAuthByUserId(user.Id, 1) | ||
398 | + if err != nil { | ||
399 | + if err == orm.ErrNoRows { | ||
400 | + err = nil | ||
401 | + userAuth = &models.UserAuth{ | ||
402 | + UserId: user.Id, | ||
403 | + DeviceType: 1, //int8(header.DeviceType), | ||
404 | + CurrentCompanyId: request.Muid, | ||
405 | + CurrentUserCompanyId: request.Cid, | ||
406 | + } | ||
407 | + models.AddUserAuth(userAuth) | ||
408 | + } else { | ||
409 | + log.Error(err) | ||
410 | + return | ||
411 | + } | ||
412 | + } | ||
413 | + userAuth.AuthCode = uid.NewV1().StringNoDash() | ||
414 | + userAuth.CurrentCompanyId = request.Cid | ||
415 | + userAuth.CurrentUserCompanyId = request.Muid | ||
416 | + | ||
417 | + /*更新用户信息*/ | ||
418 | + user.CsAccount = getUserResponse.CustomerAccount | ||
419 | + user.ImToken = getUserResponse.ImToken | ||
420 | + user.Icon = getUserResponse.Avatar | ||
421 | + user.NickName = getUserResponse.NickName | ||
422 | + user.Accid = getUserResponse.Accid | ||
423 | + user.UserCenterId = getUserResponse.Id | ||
424 | + if err = models.UpdateUsersById(user); err != nil { | ||
425 | + log.Error(err) | ||
426 | + return | ||
427 | + } | ||
428 | + userAuth.AuthCodeExp = time.Now().Add(time.Second * protocol.TokenExpire) | ||
429 | + if err = models.UpdateUserAuthById(userAuth); err != nil { | ||
430 | + return | ||
431 | + } | ||
432 | + rsp = &protocol.AuthorizeResponse{AuthCode: userAuth.AuthCode} | ||
433 | + } | ||
434 | + err = protocol.NewSuccessWithMessage("登录成功") | ||
435 | + return | ||
436 | +} | ||
437 | + | ||
438 | +//检查企业平台权限 | ||
439 | +func CheckBusinessAuth(header *protocol.RequestHeader, muid int64) (err error) { | ||
440 | + var ( | ||
441 | + hasAuth bool | ||
442 | + authMessage *protocol.Message | ||
443 | + ) | ||
444 | + if authMessage, hasAuth = agg.GetUserModuleAuth(muid); !hasAuth { | ||
445 | + err = protocol.NewCustomMessage(authMessage.Errno, authMessage.Errmsg) //账号不存在 | ||
446 | + return | ||
447 | + } | ||
448 | + if authMessage.Errno != 0 { | ||
449 | + err = protocol.NewCustomMessage(authMessage.Errno, authMessage.Errmsg) //账号不存在 | ||
450 | + return | ||
451 | + } | ||
452 | + return | ||
453 | +} | ||
454 | + | ||
284 | //统一用户中心登录 | 455 | //统一用户中心登录 |
285 | func UCenterLogin(header *protocol.RequestHeader, request *protocol.UCenterLoginRequest) (rsp *protocol.UCenterLoginResponse, err error) { | 456 | func UCenterLogin(header *protocol.RequestHeader, request *protocol.UCenterLoginRequest) (rsp *protocol.UCenterLoginResponse, err error) { |
286 | var ( | 457 | var ( |
@@ -2,7 +2,6 @@ package config | @@ -2,7 +2,6 @@ package config | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | - "github.com/astaxie/beego" | ||
6 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
7 | "opp/models" | 6 | "opp/models" |
8 | "opp/protocol" | 7 | "opp/protocol" |
@@ -23,13 +22,3 @@ func GetConfigScore(header *protocol.RequestHeader, request *protocol.GetConfigS | @@ -23,13 +22,3 @@ func GetConfigScore(header *protocol.RequestHeader, request *protocol.GetConfigS | ||
23 | } | 22 | } |
24 | return | 23 | return |
25 | } | 24 | } |
26 | - | ||
27 | -//ServiceConfig 服务配置 | ||
28 | -func ServiceConfig(header *protocol.RequestHeader, request *protocol.ServiceConfigRequest) (rsp *protocol.ServiceConfigResponse, err error) { | ||
29 | - var () | ||
30 | - rsp = &protocol.ServiceConfigResponse{ | ||
31 | - ServeConfig: new(protocol.ServeConfig), | ||
32 | - } | ||
33 | - rsp.ServeConfig.SetVodAddress(beego.AppConfig.String("VOD_SVR_ADDRESS")) | ||
34 | - return | ||
35 | -} |
@@ -69,3 +69,25 @@ func Test_FixPath(t *testing.T) { | @@ -69,3 +69,25 @@ func Test_FixPath(t *testing.T) { | ||
69 | } | 69 | } |
70 | } | 70 | } |
71 | } | 71 | } |
72 | + | ||
73 | +func Test_UploadImage(t *testing.T) { | ||
74 | + input := "https://upfile.asqql.com/2009pasdfasdfic2009s305985-ts/2019-12/2019123019514565723.gif" | ||
75 | + var ( | ||
76 | + err error | ||
77 | + auth *aliyun.CreateUploadImageResponse | ||
78 | + vodc *vod.Client | ||
79 | + ) | ||
80 | + vodc, err = aliyun.DefaultVodClient() | ||
81 | + if err != nil { | ||
82 | + t.Fatal(err) | ||
83 | + } | ||
84 | + auth, err = aliyun.CreateUploadImage(vodc, &aliyun.CreateUploadImageRequest{FileName: fixPath("https://mmm-opp-prd.fjmaimaimai.com/file/opp/image/20200325/1585134451_FrdwfRHEMc33JwX7FtJAY4baMyD7J6pP.jpg")}) | ||
85 | + if err != nil { | ||
86 | + t.Fatal(err) | ||
87 | + } | ||
88 | + err = upload(fixPath(input), auth.UploadAddress, auth.UploadAuth) | ||
89 | + if err != nil { | ||
90 | + t.Fatal(err) | ||
91 | + } | ||
92 | + t.Log(fmt.Sprintf("%v -> %v", input, auth.ImageURL), UploadSuccess) | ||
93 | +} |
@@ -358,12 +358,11 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) | @@ -358,12 +358,11 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) | ||
358 | rsp = &protocol.UserInfoResponse{ | 358 | rsp = &protocol.UserInfoResponse{ |
359 | User: protocol.User{ | 359 | User: protocol.User{ |
360 | UserId: header.UserId, | 360 | UserId: header.UserId, |
361 | + MUserId: header.UserId, | ||
361 | Name: userBaseAgg.User.NickName, | 362 | Name: userBaseAgg.User.NickName, |
362 | Phone: userBaseAgg.User.Phone, | 363 | Phone: userBaseAgg.User.Phone, |
363 | - Image: protocol.Picture{ | 364 | + Image: protocol.Avatar{ |
364 | Path: userBaseAgg.User.Icon, | 365 | Path: userBaseAgg.User.Icon, |
365 | - H: 0, | ||
366 | - W: 0, | ||
367 | }, | 366 | }, |
368 | ImToken: userBaseAgg.User.ImToken, | 367 | ImToken: userBaseAgg.User.ImToken, |
369 | CompanyId: int(companyId), | 368 | CompanyId: int(companyId), |
@@ -475,12 +474,11 @@ func UserInfoV3(header *protocol.RequestHeader, request *protocol.UserInfoReques | @@ -475,12 +474,11 @@ func UserInfoV3(header *protocol.RequestHeader, request *protocol.UserInfoReques | ||
475 | rsp = &protocol.UserInfoResponse{ | 474 | rsp = &protocol.UserInfoResponse{ |
476 | User: protocol.User{ | 475 | User: protocol.User{ |
477 | UserId: header.UserId, | 476 | UserId: header.UserId, |
477 | + MUserId: header.UserId, | ||
478 | Name: userBaseAgg.User.NickName, | 478 | Name: userBaseAgg.User.NickName, |
479 | Phone: userBaseAgg.User.Phone, | 479 | Phone: userBaseAgg.User.Phone, |
480 | - Image: protocol.Picture{ | 480 | + Image: protocol.Avatar{ |
481 | Path: userBaseAgg.User.Icon, | 481 | Path: userBaseAgg.User.Icon, |
482 | - H: 0, | ||
483 | - W: 0, | ||
484 | }, | 482 | }, |
485 | ImToken: userBaseAgg.User.ImToken, | 483 | ImToken: userBaseAgg.User.ImToken, |
486 | CompanyId: int(companyId), | 484 | CompanyId: int(companyId), |
-
请 注册 或 登录 后发表评论