|
@@ -24,7 +24,6 @@ import me.chanjar.weixin.cp.bean.WxCpUser;
|
|
|
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.apache.shiro.subject.Subject;
|
|
|
-import org.eclipse.jetty.util.UrlEncoded;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.system.api.ISysBaseApi;
|
|
@@ -90,17 +89,19 @@ public class LoginController {
|
|
|
}
|
|
|
}
|
|
|
@GetMapping("/feishu/auth")
|
|
|
- public void feishuAuth(HttpServletRequest request,
|
|
|
+ public Map<String,Object> feishuAuth(HttpServletRequest request,
|
|
|
HttpServletResponse response,
|
|
|
@RequestParam(name = "code",defaultValue = "code") String code,
|
|
|
@RequestParam(name = "state",defaultValue = "_t") String state) throws IOException {
|
|
|
- Result<JSONObject> result = new Result<>();
|
|
|
+ Map<String,Object> result = new HashMap<>();
|
|
|
//1:根据code值获取用户飞书信息
|
|
|
try {
|
|
|
if(code.trim().equals("code")){
|
|
|
String url = AuthProvider.getAuthUrl("");
|
|
|
- response.sendRedirect(url);
|
|
|
- return ;
|
|
|
+ result.put("url",url);
|
|
|
+ result.put("type",1);
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
|
|
|
+ return result;
|
|
|
}
|
|
|
JSONObject data = AuthProvider.getFeishuUserInfo(code);
|
|
|
String accessToken = data.getJSONObject("data").getString("access_token");
|
|
@@ -110,27 +111,27 @@ public class LoginController {
|
|
|
JSONObject dataObject = userData.getJSONObject("data");
|
|
|
String email = dataObject.getString("email");
|
|
|
if(null == email||email.trim().equals("")){
|
|
|
- response.sendRedirect(DOMAIN_SERVER+"errorPage?desc="+ UrlEncoded.encodeString("飞书账号未绑定邮箱"));
|
|
|
- return ;
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.CTOP_FEISHU_EMAIL_NOT_EXIST);
|
|
|
+ return result;
|
|
|
}
|
|
|
SysUser sysUser = sysUserService.getUserByEmail(email);
|
|
|
if (sysUser == null) {
|
|
|
- response.sendRedirect(DOMAIN_SERVER+"errorPage?desc="+ UrlEncoded.encodeString("该用户未注册系统账户,请联系管理员"));
|
|
|
- return ;
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.CTOP_FEISHU_ACCOUNT_NOT_EXIST);
|
|
|
+ return result;
|
|
|
}
|
|
|
if(sysUser.getStatus() != 1){
|
|
|
- response.sendRedirect(DOMAIN_SERVER+"errorPage?desc="+UrlEncoded.encodeString("该用户已被冻结,请联系管理员"));
|
|
|
- return ;
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.CTOP_FEISHU_ACCOUNT_NOT_EXIST);
|
|
|
+ return result;
|
|
|
}
|
|
|
String departId = sysDepartService.selectIdByOrdCode(sysUser.getOrgCode());
|
|
|
sysUser.setDepartId(departId);
|
|
|
- result = sysUserService.checkUserIsEffective(sysUser);
|
|
|
- if (!result.isSuccess()) {
|
|
|
- response.sendRedirect(DOMAIN_SERVER+"errorPage?desc="+UrlEncoded.encodeString(result.getMessage()));
|
|
|
- return ;
|
|
|
+ Result<JSONObject> getResult = sysUserService.checkUserIsEffective(sysUser);
|
|
|
+ if (!getResult.isSuccess()) {
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.COMMON_ACCOUNT_ERROR);
|
|
|
+ return result;
|
|
|
}
|
|
|
//用户登录信息
|
|
|
- userInfo(sysUser, result);
|
|
|
+ userInfo(sysUser, getResult);
|
|
|
sysBaseApi.addLog("用户名: " + email + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
|
|
|
CorpFeishuUser feishuUser = corpFeishuUserService.getById(sysUser.getId());
|
|
|
if (feishuUser == null) {
|
|
@@ -148,12 +149,12 @@ public class LoginController {
|
|
|
feishuUser.setUpdateTime(new Date());
|
|
|
corpFeishuUserService.save(feishuUser);
|
|
|
}
|
|
|
- response.sendRedirect(DOMAIN_SERVER+"dashboard/analysis");
|
|
|
- return ;
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
|
|
|
+ return result;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- response.sendRedirect(DOMAIN_SERVER+"errorPage?desc="+ UrlEncoded.encodeString("系统异常,请联系管理员"));
|
|
|
- return;
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.COMMON_SERVER_ERROR);
|
|
|
+ return result;
|
|
|
}
|
|
|
}
|
|
|
|