|
@@ -1,9 +1,6 @@
|
|
|
package com.ywt.alipaympapi.web.controller;
|
|
|
|
|
|
-import com.ywt.alipaympapi.core.utils.CheckUtil;
|
|
|
-import com.ywt.alipaympapi.core.utils.Checker;
|
|
|
-import com.ywt.alipaympapi.core.utils.ContextHelper;
|
|
|
-import com.ywt.alipaympapi.core.utils.JsonSerializer;
|
|
|
+import com.ywt.alipaympapi.core.utils.*;
|
|
|
import com.ywt.alipaympapi.models.BaseResponse;
|
|
|
import com.ywt.alipaympapi.models.BaseResponse2;
|
|
|
import com.ywt.alipaympapi.models.Constants;
|
|
@@ -46,11 +43,9 @@ public class AuthController {
|
|
|
BindAlipayMpReq reqData) {
|
|
|
BaseResponse2<BindAlipayMpResp> baseResponse = new BaseResponse2<>();
|
|
|
try {
|
|
|
- int terminal = ContextHelper.getCurrentTerminalWrapped();
|
|
|
+ int terminal = reqData.getTerminal();
|
|
|
String ip = WebAppContext.current().getIP();
|
|
|
String ticket = reqData.getTicket();
|
|
|
- String gwAppId = reqData.getGwAppId();
|
|
|
- CheckUtil.ensureNotEmpty(gwAppId, "gwAppId 不能为空");
|
|
|
CheckUtil.ensureNotEmpty(ticket, "ticket 不能为空");
|
|
|
AlipayMpCfg cfg = authService.getCfg(terminal);
|
|
|
// 获取用户信息
|
|
@@ -81,29 +76,12 @@ public class AuthController {
|
|
|
.build());
|
|
|
if (response.getCode() == BaseResponse.SUCCEED) {
|
|
|
int userId = response.getUserId();
|
|
|
- // 生成鉴权信息
|
|
|
- HashMap<String, Object> authData = new HashMap<>();
|
|
|
- authData.put("userId", userId);
|
|
|
- authData.put("alipayUid", alipayUid);
|
|
|
- IssueJWTRequest issueJWTRequest = IssueJWTRequest.newBuilder()
|
|
|
- .setAppid(gwAppId)
|
|
|
- .setAuthData(JsonSerializer.toJson(authData))
|
|
|
- .setExpire(0)
|
|
|
- .build();
|
|
|
- IssueJWTResponse issueJWTResponse = authServiceBlockingStub.issueJWT(issueJWTRequest);
|
|
|
- if (issueJWTResponse.getCode() != BaseResponse.SUCCEED) {
|
|
|
- log.error("AuthController#bind(reqData={} ):授权失败:{}", reqData, issueJWTResponse.getMsg());
|
|
|
- return baseResponse.failed(BaseResponse2.APP_ERROR, String.format("用户授权失败:%s", issueJWTResponse.getMsg()));
|
|
|
- }
|
|
|
BindAlipayMpResp r = new BindAlipayMpResp();
|
|
|
r.setUserId(userId);
|
|
|
- r.setToken(issueJWTResponse.getToken());
|
|
|
r.setAlipayUid(alipayUid);
|
|
|
r.setMobile(mobile);
|
|
|
// 根据终端判断医院信息
|
|
|
- if (TerminalEnum.valueOf(terminal) == TerminalEnum.NFYYBYFY_ALIPAY_MP) {
|
|
|
- r.setHospitalId(Constants.HOSPITAL_ID_NFYYBYFY);
|
|
|
- }
|
|
|
+ r.setHospitalId(BizUtil.getCurrentHospitalId());
|
|
|
return baseResponse.succeed(r);
|
|
|
}
|
|
|
return baseResponse.failed(BaseResponse.APP_ERROR, response.getInfo());
|