Commit fa04669a by fudahua

登陆接口

parent 0c841bf4
......@@ -8,7 +8,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.ToolUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
......@@ -25,7 +24,6 @@ import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxCorpApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -43,6 +41,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@RestController
......@@ -190,8 +189,8 @@ public class LoginController extends WebBaseController{
//运维登录
@IgnoreLogin
@RequestMapping("gic-login")
public ModelAndView ywLogin(String random,HttpServletResponse response) {
//判断是否存在random
public ModelAndView gicLogin(String random, String wxEnterpriseId, HttpServletResponse response) {
//判断是否存在random
AES aes = SecureUtil.aes(LOGIN_KEY.getBytes());
String o = aes.decryptStr(random);
if(o == null){
......@@ -202,7 +201,6 @@ public class LoginController extends WebBaseController{
JSONObject jsonObject = JSONObject.parseObject(o);
String gicEnterpriseId = jsonObject.getString("enterpriseId");
String loginPhoneNumber = jsonObject.getString("phoneNumber");
String wxEnterpriseId = jsonObject.getString("wxEnterpriseId");
List<WxEnterpriseDTO> enterpriseDTOList = wxEnterpriseRelatedApiService.listWxEnterpriseByEid(gicEnterpriseId);
if (CollectionUtils.isEmpty(enterpriseDTOList)) {
logger.info("登录失败,不存在对应企业:{}",o);
......@@ -210,18 +208,22 @@ public class LoginController extends WebBaseController{
return model;
}
WxEnterpriseDTO detailDTO = null;
if (!StringUtils.isBlank(wxEnterpriseId)) {
//todo 销售线索页面
} else {
if (!StringUtils.isNotBlank(wxEnterpriseId)) {
detailDTO = enterpriseDTOList.stream().filter(dto -> dto.getWxEnterpriseId().equals(wxEnterpriseId)).findFirst().orElse(null);
} else if (enterpriseDTOList.size() > 1) {
detailDTO = enterpriseDTOList.get(0);
} else {
logger.info("登陆选择多个企业:{}", JSONObject.toJSONString(enterpriseDTOList));
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/login", false, false));
return model;
}
if (null == detailDTO) {
logger.info("登录失败,不存在对应企业:{}", o);
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false, false));
return model;
}
enterpriseDTOList.stream().filter(dto -> dto.getWxEnterpriseId().equals(wxEnterpriseId))
//TODO 销售线索 多个选择
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(detailDTO.getWxEnterpriseId(), "86", loginPhoneNumber);
if (null == staff) {
......@@ -229,7 +231,7 @@ public class LoginController extends WebBaseController{
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false,false));
return model;
}
String wxEnterpriseId = detailDTO.getWxEnterpriseId();
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2);
if (null == application) {
logger.info("登录企业应用 没授权!{}");
......@@ -280,7 +282,35 @@ public class LoginController extends WebBaseController{
return null;
}
@RequestMapping("login-wx-enterprise-list")
public HaobanResponse loginOut(String random) {
//判断是否存在random
AES aes = SecureUtil.aes(LOGIN_KEY.getBytes());
String o = aes.decryptStr(random);
if (o == null) {
logger.info("解密异常");
return resultResponse(HaoBanErrCode.ERR_5);
}
JSONObject jsonObject = JSONObject.parseObject(o);
String gicEnterpriseId = jsonObject.getString("enterpriseId");
String wxEnterpriseId = jsonObject.getString("wxEnterpriseId");
List<WxEnterpriseDTO> enterpriseDTOList = wxEnterpriseRelatedApiService.listWxEnterpriseByEid(gicEnterpriseId);
if (CollectionUtils.isEmpty(enterpriseDTOList)) {
logger.info("登录失败,不存在对应企业:{}", o);
return resultResponse(HaoBanErrCode.ERR_6);
}
if (!StringUtils.isNotBlank(wxEnterpriseId)) {
List<WxEnterpriseDTO> enterpriseDTOS = enterpriseDTOList.stream().filter(dto -> dto.getWxEnterpriseId().equals(wxEnterpriseId)).collect(Collectors.toList());
return resultResponse(HaoBanErrCode.ERR_1, enterpriseDTOS);
} else {
logger.info("登陆选择多个企业:{}", JSONObject.toJSONString(enterpriseDTOList));
return resultResponse(HaoBanErrCode.ERR_1, enterpriseDTOList);
}
}
@RequestMapping("login-out")
public HaobanResponse loginOut() {
......
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