|
@@ -33,23 +33,14 @@ public class LoginController {
|
|
|
protected static final Logger logger = LoggerFactory.getLogger(LoginController.class);
|
|
|
@Autowired
|
|
|
private LoginService loginService;
|
|
|
- private static String AppId;
|
|
|
- private static String AppSecret;
|
|
|
-
|
|
|
@Value("${miniprogram.ValidTime}")
|
|
|
private Integer ValidTime;
|
|
|
-
|
|
|
@Value("${miniprogram.AppId}")
|
|
|
- public void setAppId(String appId) {
|
|
|
- AppId = appId;
|
|
|
- }
|
|
|
-
|
|
|
+ private String AppId;
|
|
|
@Value("${miniprogram.AppSecret}")
|
|
|
- public void setAppSecret(String appSecret) {
|
|
|
- AppSecret = appSecret;
|
|
|
- }
|
|
|
+ private String AppSecret;
|
|
|
|
|
|
- public static WxJsonModel login(String code, HttpServletRequest request) {
|
|
|
+ public WxJsonModel login(String code, HttpServletRequest request) {
|
|
|
logger.info("Start get SessionKey");
|
|
|
WxJsonModel res = WxJsonModel.newInstance();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -106,13 +97,17 @@ public class LoginController {
|
|
|
return model;
|
|
|
}
|
|
|
String openid = (String) model.getData();
|
|
|
+ //传入session,返回用户信息,更新sessionId
|
|
|
HttpSession session = SessionHelper.getSession();
|
|
|
+ String sessionId = session.getId();
|
|
|
session.setAttribute("openid", openid);
|
|
|
+ session.setAttribute("organizeID", userOrganizeID);
|
|
|
CmOperationUser operationUser = loginService.doLogin(openid, userOrganizeID);
|
|
|
if (operationUser == null) {
|
|
|
String mobile = loginService.cellPhone(userOrganizeID);
|
|
|
return res.error("-1", mobile, "游客,请登录");
|
|
|
}
|
|
|
+ operationUser.setSessionId(sessionId);
|
|
|
return res.success("1", operationUser);
|
|
|
}
|
|
|
|
|
@@ -174,24 +169,7 @@ public class LoginController {
|
|
|
}
|
|
|
String openid = (String) model.getData();
|
|
|
operationUser.setOpenid(openid);
|
|
|
- WxJsonModel jsonModel = loginService.update(operationUser);
|
|
|
+ WxJsonModel jsonModel = loginService.update(operationUser, request);
|
|
|
return jsonModel;
|
|
|
}
|
|
|
-
|
|
|
- @RequestMapping("/testSession")
|
|
|
- @ResponseBody
|
|
|
- public WxJsonModel testSession() {
|
|
|
- HttpSession session = SessionHelper.getSession();
|
|
|
- session.setAttribute("testSession","testSessiontestSessiontestSessiontestSession");
|
|
|
- return new WxJsonModel();
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping("/getSession")
|
|
|
- @ResponseBody
|
|
|
- public WxJsonModel getSession() {
|
|
|
- HttpSession session = SessionHelper.getSession();
|
|
|
- String getSession = (String) session.getAttribute("testSession");
|
|
|
- return new WxJsonModel();
|
|
|
- }
|
|
|
-
|
|
|
}
|