|
|
|
@ -5,12 +5,14 @@ import cn.hutool.core.thread.ThreadUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import cn.hutool.jwt.Claims;
|
|
|
|
|
import cn.jlw.Interceptor.RequestReferer;
|
|
|
|
|
import cn.jlw.Interceptor.SCoreUser;
|
|
|
|
|
import cn.jlw.Interceptor.TStudent;
|
|
|
|
|
import cn.jlw.Interceptor.TTeacher;
|
|
|
|
|
import cn.jlw.token.TokenService;
|
|
|
|
|
import cn.jlw.util.EnumUtil;
|
|
|
|
|
import cn.jlw.util.JwtUtils;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.auth0.jwt.JWT;
|
|
|
|
@ -19,6 +21,8 @@ import com.auth0.jwt.algorithms.Algorithm;
|
|
|
|
|
import com.auth0.jwt.exceptions.JWTVerificationException;
|
|
|
|
|
import com.auth0.jwt.interfaces.Claim;
|
|
|
|
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.ibeetl.admin.core.dao.CoreOrgDao;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreOrg;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.enums.MenuEnums;
|
|
|
|
@ -105,6 +109,9 @@ public class IndexController {
|
|
|
|
|
private WebPlatformService webPlatformService;
|
|
|
|
|
private UniversitiesCollegesDao universitiesCollegesDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
CoreOrgDao orgDao;
|
|
|
|
|
|
|
|
|
|
private final Log log = LogFactory.getLog(this.getClass());
|
|
|
|
|
|
|
|
|
|
public static final String previewIndex = ResourceBundle.getBundle("application").getString("we_chat.baseUrl").replace("server","")+"previewIndex.html";
|
|
|
|
@ -723,17 +730,49 @@ public class IndexController {
|
|
|
|
|
|
|
|
|
|
@PostMapping("/login.json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public JsonResult login(HttpServletRequest request, HttpServletResponse response,String code, String password, Integer type, Long typeId) {
|
|
|
|
|
public JsonResult login(HttpServletRequest request, HttpServletResponse response,String code, String password, Integer type, Long typeId
|
|
|
|
|
,@RequestParam(required = false) String TOKEN ) {
|
|
|
|
|
UniversitiesCollegesJurisdictionExperimentalSystem uSystem = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
|
|
|
uSystem.setType(type);
|
|
|
|
|
uSystem.setTypeId(typeId);
|
|
|
|
|
UserLoginInfo info = null;
|
|
|
|
|
|
|
|
|
|
if (org.springframework.util.StringUtils.hasText(TOKEN))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
io.jsonwebtoken.Claims claims = JwtUtils.parseJWT(TOKEN);
|
|
|
|
|
|
|
|
|
|
if (claims == null) {
|
|
|
|
|
return JsonResult.failMessage("token无效");
|
|
|
|
|
}
|
|
|
|
|
String userInfoJsonEncry = (String) claims.get("userInfo");
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapperEncry = new ObjectMapper();
|
|
|
|
|
CoreUser user = objectMapperEncry.readValue(userInfoJsonEncry, CoreUser.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CoreOrg> orgs = getUserOrg(user.getId(), user.getOrgId());
|
|
|
|
|
|
|
|
|
|
info = new UserLoginInfo();
|
|
|
|
|
|
|
|
|
|
info.setUser(user);
|
|
|
|
|
|
|
|
|
|
info.setOrgs(orgs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return JsonResult.failMessage("token无效");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
try {
|
|
|
|
|
info = userService.login(code, password);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return JsonResult.failMessage(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CoreUser user = info.getUser();
|
|
|
|
|
|
|
|
|
|
CoreOrg currentOrg = info.getOrgs().get(0);
|
|
|
|
@ -1116,4 +1155,15 @@ public class IndexController {
|
|
|
|
|
public JsonResult<List<AuthResourcesAndSystemInfo>> getAuthResourcesAndSystemInfo(@SCoreUser CoreUser coreUser) {
|
|
|
|
|
return JsonResult.success(webPlatformService.getAuthResourcesAndSystemInfo(coreUser));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CoreOrg> getUserOrg(long userId, long orgId) {
|
|
|
|
|
List<CoreOrg> orgs = orgDao.queryOrgByUser(userId);
|
|
|
|
|
if (orgs.isEmpty()) {
|
|
|
|
|
//没有赋值任何角色,默认给一个所在部门
|
|
|
|
|
CoreOrg userOrg = orgDao.unique(orgId);
|
|
|
|
|
orgs.add(userOrg);
|
|
|
|
|
}
|
|
|
|
|
return orgs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|