Commit 9179d002 by 徐高华

login

parent f959cb0c
......@@ -87,47 +87,49 @@ public class LoginController extends WebBaseController {
* @param response
*/
@RequestMapping("login")
public void login(String auth_code, HttpServletResponse response) {
@IgnoreLogin
public HaobanResponse login(String auth_code, HttpServletResponse response) {
String userJson = qywxCorpApiService.getLoginUserInfo(config.getCorpid(), auth_code);
if (StringUtils.isBlank(userJson)) {
logger.info("未查询到用户:auth_code:{}", auth_code);
return;
logger.info("企微登录失败auth_code={}", auth_code);
return this.fail("auth_code解析失败");
}
UserDTO user = JSON.parseObject(userJson, UserDTO.class);
String corpId = user.getCorpid();
logger.info("【企业微信登录】userId={},auth_code={},corpId={}", user.getUserid(), auth_code, corpId);
UserDTO wxUser = JSON.parseObject(userJson, UserDTO.class);
logger.info("企微登录user={}", JSON.toJSONString(wxUser));
String corpId = wxUser.getCorpid();
WxEnterpriseDTO wxEnterprise = wxEnterpriseApiService.getEnterpriseBycorpId(corpId);
logger.info("【企业微信】enterprise={}", JSON.toJSONString(wxEnterprise));
StaffDTO loginStaff = null;
if (wxEnterprise != null) {
loginStaff = staffApiService.selectByUserIdAndEnterpriseId(user.getUserid(),
wxEnterprise.getWxEnterpriseId());
if(null == wxEnterprise) {
logger.info("微信企业不存在corpId={}", corpId);
return this.fail("微信企业不存在,corpId="+corpId);
}
logger.info("企微登录wxenterprise={}", JSON.toJSONString(wxEnterprise));
String wxEnterpriseId = wxEnterprise.getWxEnterpriseId() ;
StaffDTO loginStaff = staffApiService.selectByUserIdAndEnterpriseId(wxUser.getUserid(),wxEnterpriseId);
if (loginStaff == null) {
if (wxEnterprise != null) {
staffApiService.wxFristAdd(JSON.toJSONString(user), wxEnterprise.getWxEnterpriseId());
loginStaff = staffApiService.selectByUserIdAndEnterpriseId(user.getUserid(),
wxEnterprise.getWxEnterpriseId());
}
staffApiService.wxFristAdd(JSON.toJSONString(wxUser), wxEnterprise.getWxEnterpriseId());
loginStaff = staffApiService.selectByUserIdAndEnterpriseId(wxUser.getUserid(),wxEnterprise.getWxEnterpriseId());
}
logger.info("【好办web登录】staff={}", JSON.toJSONString(loginStaff));
logger.info("企微登录staff={}", JSON.toJSONString(loginStaff));
if (loginStaff == null) {
return;
return this.fail("登录失败,好办管理员不存在");
}
String wxEnterpriseId = wxEnterprise.getWxEnterpriseId();
List<EnterpriseDetailDTO> list = this.wxEnterpriseRelatedApiService
.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(list)) {
logger.info("企微下无关联GIC商户");
return;
}
String gicEnterpriseId = list.get(0).getEnterpriseId();
String loginPhoneNumber = loginStaff.getPhoneNumber();
if (StringUtils.isBlank(loginPhoneNumber)) {
logger.info("未配置手机号,staffId ={}", loginStaff.getStaffId());
return;
return this.fail("登录失败,未配置手机号");
}
List<EnterpriseDetailDTO> list = this.wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId,loginPhoneNumber);
if (CollectionUtils.isEmpty(list)) {
logger.info("企微下无管理GIC商户");
return this.fail("企微下无管理GIC商户");
}
String gicEnterpriseId = list.get(0).getEnterpriseId();
String ret = this.doLogin(wxEnterpriseId, gicEnterpriseId, loginPhoneNumber, "gic", response);
if(StringUtils.isNotBlank(ret)) {
return this.fail(ret) ;
}else {
return this.success(null) ;
}
this.doLogin(wxEnterpriseId, gicEnterpriseId, loginPhoneNumber, "gic", response);
}
/**
......@@ -347,6 +349,7 @@ public class LoginController extends WebBaseController {
* @return
*/
@RequestMapping("login-wx-enterprise-list")
@IgnoreLogin
public HaobanResponse loginWxEnterpriseList(String random) {
// 判断是否存在random
AES aes = SecureUtil.aes(LOGIN_KEY.getBytes());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment