You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1142 lines
47 KiB
Java
1142 lines
47 KiB
Java
package com.ibeetl.jlw.web;
|
|
|
|
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.ToolUtils;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.auth0.jwt.JWT;
|
|
import com.auth0.jwt.JWTVerifier;
|
|
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.ibeetl.admin.core.entity.CoreOrg;
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
import com.ibeetl.admin.core.enums.MenuEnums;
|
|
import com.ibeetl.admin.core.file.FileService;
|
|
import com.ibeetl.admin.core.rbac.UserLoginInfo;
|
|
import com.ibeetl.admin.core.rbac.tree.MenuItem;
|
|
import com.ibeetl.admin.core.service.CorePlatformService;
|
|
import com.ibeetl.admin.core.service.CoreUserService;
|
|
import com.ibeetl.admin.core.util.TimeTool;
|
|
import com.ibeetl.admin.core.util.Tool;
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
import com.ibeetl.jlw.dao.UniversitiesCollegesDao;
|
|
import com.ibeetl.jlw.entity.*;
|
|
import com.ibeetl.jlw.service.*;
|
|
import com.ibeetl.jlw.web.query.CompetitionQuery;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
import javax.servlet.http.Cookie;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpSession;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
|
|
import static cn.jlw.Interceptor.AuthenticationInterceptor.getToken;
|
|
import static cn.jlw.Interceptor.AuthenticationInterceptor.indexTokenMap;
|
|
import static cn.jlw.token.TokenService.updateByIds;
|
|
import static com.ibeetl.admin.core.enums.MenuEnums.JT_S_02;
|
|
import static com.ibeetl.admin.core.service.CorePlatformService.tokenSessionMap;
|
|
|
|
@Controller
|
|
public class IndexController {
|
|
|
|
@Autowired
|
|
private CorePlatformService platformService;
|
|
|
|
@Autowired
|
|
private CoreUserService userService;
|
|
|
|
@Autowired
|
|
private CompetitionService competitionService;
|
|
|
|
@Autowired
|
|
private StudentService studentService;
|
|
|
|
@Autowired
|
|
private TeacherService teacherService;
|
|
|
|
@Autowired
|
|
private TokenService tokenService;
|
|
|
|
@Autowired
|
|
private FileService fileService;
|
|
|
|
@Autowired
|
|
private UniversitiesCollegesService universitiesCollegesService;
|
|
|
|
@Autowired
|
|
private SchoolClassService schoolClassService;
|
|
|
|
@Autowired
|
|
private UniversitiesCollegesJurisdictionExperimentalSystemService universitiesCollegesJurisdictionExperimentalSystemService;
|
|
|
|
@Autowired
|
|
private ResourcesApplicationService resourcesApplicationService;
|
|
@Autowired
|
|
private WebPlatformService webPlatformService;
|
|
private UniversitiesCollegesDao universitiesCollegesDao;
|
|
|
|
private final Log log = LogFactory.getLog(this.getClass());
|
|
|
|
public static final String previewIndex = ResourceBundle.getBundle("application").getString("we_chat.baseUrl").replace("server","")+"previewIndex.html";
|
|
public static final String webSocketServer = ResourceBundle.getBundle("application").getString("we_chat.baseUrl").replace("8080","9090");
|
|
|
|
@GetMapping("/getNowTime.do")
|
|
@ResponseBody
|
|
public JsonResult getNowTime2FrontEnd() {
|
|
return JsonResult.success(TimeTool.getNowTime());
|
|
}
|
|
|
|
@GetMapping("/getNowTime.json")
|
|
@ResponseBody
|
|
public JsonResult getNowTime() {
|
|
return JsonResult.success(TimeTool.getNowTime());
|
|
}
|
|
|
|
|
|
private static class LoginTodo {
|
|
private String username; //账号
|
|
private String password; //密码
|
|
private String roleid; //角色ID
|
|
private String teacherid; //教师ID
|
|
private String studentid; //学生ID
|
|
private String name; //姓名
|
|
private String sex; //性别
|
|
private String school; //学校
|
|
private String college; //院校
|
|
private String major; //专业
|
|
private String schoolclass; //班级
|
|
private String studentNo;//学号
|
|
|
|
public String getUsername() {
|
|
return username;
|
|
}
|
|
public void setUsername(String username) {
|
|
this.username = username;
|
|
}
|
|
public String getPassword() {
|
|
return password;
|
|
}
|
|
public void setPassword(String password) {
|
|
this.password = password;
|
|
}
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
public String getSex() {
|
|
return sex;
|
|
}
|
|
public void setSex(String sex) {
|
|
this.sex = sex;
|
|
}
|
|
public String getSchool() {
|
|
return school;
|
|
}
|
|
public void setSchool(String school) {
|
|
this.school = school;
|
|
}
|
|
public String getCollege() {
|
|
return college;
|
|
}
|
|
public void setCollege(String college) {
|
|
this.college = college;
|
|
}
|
|
public String getMajor() {
|
|
return major;
|
|
}
|
|
public void setMajor(String major) {
|
|
this.major = major;
|
|
}
|
|
public String getSchoolclass() {
|
|
return schoolclass;
|
|
}
|
|
public void setSchoolclass(String schoolclass) {
|
|
this.schoolclass = schoolclass;
|
|
}
|
|
public String getStudentNo() {
|
|
return studentNo;
|
|
}
|
|
public void setStudentNo(String studentNo) {
|
|
this.studentNo = studentNo;
|
|
}
|
|
public String getRoleid() {
|
|
return roleid;
|
|
}
|
|
public void setRoleid(String roleid) {
|
|
this.roleid = roleid;
|
|
}
|
|
public String getTeacherid() {
|
|
return teacherid;
|
|
}
|
|
public void setTeacherid(String teacherid) {
|
|
this.teacherid = teacherid;
|
|
}
|
|
public String getStudentid() {
|
|
return studentid;
|
|
}
|
|
public void setStudentid(String studentid) {
|
|
this.studentid = studentid;
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args){
|
|
LoginTodo loginTodo = new LoginTodo();
|
|
loginTodo.setUsername("测试教师");
|
|
loginTodo.setPassword("123qwe");
|
|
loginTodo.setRoleid("3");
|
|
loginTodo.setTeacherid("1");
|
|
loginTodo.setStudentid(null);
|
|
loginTodo.setName("测试教师");
|
|
loginTodo.setSex("男");
|
|
loginTodo.setSchool("天蚕一瓶123");
|
|
loginTodo.setCollege("天蚕一瓶123");
|
|
loginTodo.setMajor(null);
|
|
loginTodo.setSchoolclass(null);
|
|
loginTodo.setStudentNo(null);
|
|
|
|
// LoginTodo loginTodo = new LoginTodo();
|
|
// loginTodo.setUsername("lalala1");
|
|
// loginTodo.setPassword("123456");
|
|
// loginTodo.setRoleid(null);
|
|
// loginTodo.setTeacherid(null);
|
|
// loginTodo.setStudentid("1");
|
|
// loginTodo.setName("啦啦啦1");
|
|
// loginTodo.setSex("男");
|
|
// loginTodo.setSchool("左右");
|
|
// loginTodo.setCollege("左右");
|
|
// loginTodo.setMajor(null);
|
|
// loginTodo.setSchoolclass("左右一");
|
|
// loginTodo.setStudentNo(null);
|
|
|
|
String json = JSONObject.toJSONString(loginTodo);
|
|
|
|
System.out.println(json);
|
|
|
|
String str = "31415926435738246"+(Integer.parseInt(TimeTool.getNowTime("Y"))*7);
|
|
String key = JWT.create() .withAudience(json) .sign(Algorithm.HMAC256(str));
|
|
|
|
System.out.println(key);
|
|
|
|
//解密
|
|
DecodedJWT jwt = null;
|
|
try {
|
|
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(str)).build();
|
|
jwt = verifier.verify(key);
|
|
System.out.println(jwt.getAudience().get(0));
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
|
|
//?resourcesApplicationId=1&key=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ7XCJjb2xsZWdlXCI6XCLlpKnmi6notKLnu4_lubPlj7BcIixcIm5hbWVcIjpcIueOi-WtkOWYiVwiLFwicGFzc3dvcmRcIjpcIjEyMzQ1NlwiLFwic2Nob29sXCI6XCLlpKnmi6notKLnu4_lubPlj7BcIixcInNjaG9vbGNsYXNzXCI6XCLlpKnmi6nkuIDnj61cIixcInNleFwiOlwi55S3XCIsXCJ1c2VybmFtZVwiOlwiSlIxXzAwMVwifSJ9.huW5OM6ngCXRtbJoXAXhGRm54Qa7RRyMY5dmaNNjeBo
|
|
|
|
|
|
//eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ7XCJjb2xsZWdlXCI6XCLlpKnmi6notKLnu4_lubPlj7BcIixcIm5hbWVcIjpcIuS8jeiAgeW4iFwiLFwicGFzc3dvcmRcIjpcIjEyMzQ1NlwiLFwic2Nob29sXCI6XCLlpKnmi6notKLnu4_lubPlj7BcIixcInNleFwiOlwi55S3XCIsXCJ1c2VybmFtZVwiOlwi5LyN6ICB5biIXCJ9In0.J9A0yKdgcFlL1oLXK9QKsAX3hLDnhcvSVE7jIUQMf5I
|
|
}
|
|
|
|
@RequestMapping("/")
|
|
public ModelAndView login(HttpServletRequest request, HttpServletResponse response, @RequestReferer String referer) {
|
|
Long resourcesApplicationId = null;
|
|
Long universitiesCollegesId = null;
|
|
CoreUser coreUser = new CoreUser();
|
|
|
|
String key = null;
|
|
|
|
try {
|
|
if(null != request){
|
|
Map<String,String[]> param = request.getParameterMap();
|
|
for(Map.Entry<String,String[]> str : param.entrySet()){
|
|
log.info("str.getKey() = "+str.getKey() +" "+str.getValue());
|
|
if(str.getKey().contains("resourcesApplicationId")){
|
|
resourcesApplicationId = Long.parseLong(str.getValue()[0]);
|
|
}
|
|
if(str.getKey().contains("universitiesColleges")) {
|
|
universitiesCollegesId = Long.parseLong(str.getValue()[0]);
|
|
}
|
|
if(str.getKey().contains("key")) {
|
|
key = str.getValue()[0];
|
|
}
|
|
}
|
|
}
|
|
|
|
log.info("queryString :"+request.getQueryString());
|
|
if(StringUtils.isNotBlank(request.getQueryString())){
|
|
if(null == resourcesApplicationId && request.getQueryString().contains("resourcesApplicationId") ){
|
|
resourcesApplicationId = Long.parseLong(ToolUtils.subString(request.getQueryString(),"resourcesApplicationId=","&"));
|
|
}
|
|
if(null == universitiesCollegesId && request.getQueryString().contains("universitiesCollegesId")){
|
|
universitiesCollegesId = Long.parseLong(ToolUtils.subString(request.getQueryString(),"universitiesCollegesId=","&"));
|
|
}
|
|
}
|
|
|
|
log.info("referer :"+referer);
|
|
if(StringUtils.isNotBlank(referer)){
|
|
if(null == resourcesApplicationId && referer.contains("resourcesApplicationId") ){
|
|
resourcesApplicationId = Long.parseLong(ToolUtils.subString(referer,"resourcesApplicationId=","&"));
|
|
}
|
|
if(null == universitiesCollegesId && referer.contains("universitiesCollegesId")){
|
|
universitiesCollegesId = Long.parseLong(ToolUtils.subString(referer,"universitiesCollegesId=","&"));
|
|
}
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(key)){
|
|
//解密
|
|
DecodedJWT jwt = null;
|
|
try {
|
|
String str = "wx_bc_14133";
|
|
//""31415926435738246"+(Integer.parseInt(TimeTool.getNowTime("Y"))*7);
|
|
// 使用了HMAC256加密算法。
|
|
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(str)).build();
|
|
jwt = verifier.verify(key);
|
|
} catch (JWTVerificationException exception) {
|
|
exception.printStackTrace();
|
|
} catch (IllegalArgumentException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
//key转成相应的类型
|
|
LoginTodo loginTodo = null;
|
|
if(null != jwt){
|
|
if(null != jwt.getClaims() && jwt.getClaims().size()>0){
|
|
Map<String, Claim> mapTemp = jwt.getClaims();
|
|
Map<String,String>map = new HashMap<>();
|
|
for (Map.Entry<String, Claim> entry : mapTemp.entrySet()) {
|
|
if(null != entry.getValue()){
|
|
if(null != entry.getValue().asString()){
|
|
map.put(entry.getKey(),entry.getValue().asString());
|
|
}else if(null != entry.getValue().asInt()){
|
|
map.put(entry.getKey(),entry.getValue().asInt().toString());
|
|
}else if(null != entry.getValue().asLong()){
|
|
map.put(entry.getKey(),entry.getValue().asLong().toString());
|
|
}else if(null != entry.getValue().asDouble()){
|
|
map.put(entry.getKey(),entry.getValue().asDouble().toString());
|
|
}else if(null != entry.getValue().asDate()){
|
|
map.put(entry.getKey(),TimeTool.getNowTime(entry.getValue().asDate()));
|
|
}else if(null != entry.getValue().asBoolean()){
|
|
map.put(entry.getKey(),entry.getValue().asBoolean().toString());
|
|
}
|
|
}else {
|
|
map.put(entry.getKey(),null);
|
|
}
|
|
}
|
|
key = JSONObject.toJSONString(map);
|
|
log.info("单点登录:"+key);
|
|
}else {
|
|
key = jwt.getAudience().get(0);
|
|
}
|
|
if(StringUtils.isNotBlank(key)){
|
|
key = key.replace("class","schoolclass");
|
|
}
|
|
try {
|
|
loginTodo = JSONObject.parseObject(key, LoginTodo.class);
|
|
} catch (Exception e1) {}
|
|
}
|
|
|
|
if(null != loginTodo && StringUtils.isNotBlank(loginTodo.getUsername()) && StringUtils.isNotBlank(loginTodo.getPassword())){
|
|
//查询,没有就存
|
|
coreUser.setCode(loginTodo.getUsername());
|
|
List<CoreUser> coreUserList = userService.getCoreUserList(coreUser);
|
|
if(null != coreUserList && coreUserList.size()>0){
|
|
coreUser = coreUserList.get(0);
|
|
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesService.getByOrgId(coreUser.getOrgId());
|
|
|
|
UniversitiesCollegesJurisdictionExperimentalSystem universitiesCollegesJurisdictionExperimentalSystem = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
universitiesCollegesJurisdictionExperimentalSystem.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem> jurisdictionExperimentalSystemList = universitiesCollegesJurisdictionExperimentalSystemService.getValues(universitiesCollegesJurisdictionExperimentalSystem);
|
|
if(null != jurisdictionExperimentalSystemList && jurisdictionExperimentalSystemList.size()>0){
|
|
for(int i=0;i<jurisdictionExperimentalSystemList.size();i++){
|
|
if(jurisdictionExperimentalSystemList.get(i).getType().equals(1) && jurisdictionExperimentalSystemList.get(i).getTypeId().equals(resourcesApplicationId)){
|
|
universitiesCollegesJurisdictionExperimentalSystem = jurisdictionExperimentalSystemList.get(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
//找不到则添加
|
|
if(null != universitiesCollegesJurisdictionExperimentalSystem && null != universitiesCollegesJurisdictionExperimentalSystem.getUniversitiesCollegesJurisdictionExperimentalSystemId()){
|
|
//如果已经过期 则更新一下,避免登录失败
|
|
if(System.currentTimeMillis() > universitiesCollegesJurisdictionExperimentalSystem.getUseEndTime().getTime()){
|
|
UniversitiesCollegesJurisdictionExperimentalSystem ucjes = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
ucjes.setUniversitiesCollegesJurisdictionExperimentalSystemId(universitiesCollegesJurisdictionExperimentalSystem.getUniversitiesCollegesJurisdictionExperimentalSystemId());
|
|
ucjes.setUseType(2);
|
|
ucjes.setUseStartTime(TimeTool.getTime(TimeTool.getNowTime("YMD")+" 00:00:00"));
|
|
ucjes.setUseEndTime(TimeTool.getTime(TimeTool.getNowTime("YMD")+" 23:59:59"));
|
|
universitiesCollegesJurisdictionExperimentalSystemService.updateTemplate(ucjes);
|
|
}
|
|
}else {
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem> ucjesList = new ArrayList<>();
|
|
|
|
List<ResourcesApplication> resourcesApplicationList = resourcesApplicationService.getValues(null);
|
|
for(int i=0;i<resourcesApplicationList.size();i++){
|
|
UniversitiesCollegesJurisdictionExperimentalSystem ucjes = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
ucjes.setType(1);
|
|
ucjes.setTypeId(resourcesApplicationList.get(i).getResourcesApplicationId());
|
|
ucjes.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
ucjes.setUseType(resourcesApplicationList.get(i).getResourcesApplicationId().equals(resourcesApplicationId)?1:0);
|
|
ucjes.setAddTime(new Date());
|
|
ucjes.setSubsystemBottomBar(universitiesColleges.getUniversitiesCollegesName());
|
|
ucjes.setUseStartTime(resourcesApplicationList.get(i).getResourcesApplicationId().equals(resourcesApplicationId)?TimeTool.getTime(TimeTool.getNowTime("YMD")+" 00:00:00"):null);
|
|
ucjes.setUseEndTime(resourcesApplicationList.get(i).getResourcesApplicationId().equals(resourcesApplicationId)?TimeTool.getTime(TimeTool.getNowTime("YMD")+" 23:59:59"):null);
|
|
ucjesList.add(ucjes);
|
|
}
|
|
|
|
if(ucjesList.size()>0){
|
|
universitiesCollegesJurisdictionExperimentalSystemService.insertBatch(ucjesList);
|
|
}
|
|
}
|
|
|
|
}else {
|
|
//查相应的院校ID
|
|
UniversitiesColleges universitiesColleges = new UniversitiesColleges();
|
|
universitiesColleges.setUniversitiesCollegesName(loginTodo.getSchool());
|
|
List<UniversitiesColleges> universitiesCollegesList = universitiesCollegesService.getValues(universitiesColleges);
|
|
if(null != universitiesCollegesList && universitiesCollegesList.size()>0){
|
|
universitiesColleges = universitiesCollegesList.get(0);
|
|
}else {
|
|
//找不到则添加
|
|
universitiesColleges.setAddTime(new Date());
|
|
universitiesColleges.setUniversitiesCollegesStatus(1);
|
|
universitiesCollegesService.add(universitiesColleges);
|
|
platformService.clearOrgCache();
|
|
universitiesColleges = universitiesCollegesService.queryById(universitiesColleges.getUniversitiesCollegesId());
|
|
}
|
|
|
|
//查看是否有相应的访问权限
|
|
if(null != universitiesColleges.getUniversitiesCollegesId()){
|
|
UniversitiesCollegesJurisdictionExperimentalSystem universitiesCollegesJurisdictionExperimentalSystem = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
universitiesCollegesJurisdictionExperimentalSystem.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem> jurisdictionExperimentalSystemList = universitiesCollegesJurisdictionExperimentalSystemService.getValues(universitiesCollegesJurisdictionExperimentalSystem);
|
|
if(null != jurisdictionExperimentalSystemList && jurisdictionExperimentalSystemList.size()>0){
|
|
for(int i=0;i<jurisdictionExperimentalSystemList.size();i++){
|
|
if(jurisdictionExperimentalSystemList.get(i).getType().equals(1) && jurisdictionExperimentalSystemList.get(i).getTypeId().equals(resourcesApplicationId)){
|
|
universitiesCollegesJurisdictionExperimentalSystem = jurisdictionExperimentalSystemList.get(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
//找不到则添加
|
|
if(null != universitiesCollegesJurisdictionExperimentalSystem && null != universitiesCollegesJurisdictionExperimentalSystem.getUniversitiesCollegesJurisdictionExperimentalSystemId()){
|
|
//如果已经过期 则更新一下,避免登录失败
|
|
if(System.currentTimeMillis() > universitiesCollegesJurisdictionExperimentalSystem.getUseEndTime().getTime()){
|
|
UniversitiesCollegesJurisdictionExperimentalSystem ucjes = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
ucjes.setUniversitiesCollegesJurisdictionExperimentalSystemId(universitiesCollegesJurisdictionExperimentalSystem.getUniversitiesCollegesJurisdictionExperimentalSystemId());
|
|
ucjes.setUseType(2);
|
|
ucjes.setUseStartTime(TimeTool.getTime(TimeTool.getNowTime("YMD")+" 00:00:00"));
|
|
ucjes.setUseEndTime(TimeTool.getTime(TimeTool.getNowTime("YMD")+" 23:59:59"));
|
|
universitiesCollegesJurisdictionExperimentalSystemService.updateTemplate(ucjes);
|
|
}
|
|
}else {
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem> ucjesList = new ArrayList<>();
|
|
|
|
List<ResourcesApplication> resourcesApplicationList = resourcesApplicationService.getValues(null);
|
|
for(int i=0;i<resourcesApplicationList.size();i++){
|
|
UniversitiesCollegesJurisdictionExperimentalSystem ucjes = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
ucjes.setType(1);
|
|
ucjes.setTypeId(resourcesApplicationList.get(i).getResourcesApplicationId());
|
|
ucjes.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
ucjes.setUseType(resourcesApplicationList.get(i).getResourcesApplicationId().equals(resourcesApplicationId)?1:0);
|
|
ucjes.setAddTime(new Date());
|
|
ucjes.setSubsystemBottomBar(universitiesColleges.getUniversitiesCollegesName());
|
|
ucjes.setUseStartTime(resourcesApplicationList.get(i).getResourcesApplicationId().equals(resourcesApplicationId)?TimeTool.getTime(TimeTool.getNowTime("YMD")+" 00:00:00"):null);
|
|
ucjes.setUseEndTime(resourcesApplicationList.get(i).getResourcesApplicationId().equals(resourcesApplicationId)?TimeTool.getTime(TimeTool.getNowTime("YMD")+" 23:59:59"):null);
|
|
ucjesList.add(ucjes);
|
|
}
|
|
|
|
if(ucjesList.size()>0){
|
|
universitiesCollegesJurisdictionExperimentalSystemService.insertBatch(ucjesList);
|
|
}
|
|
}
|
|
}
|
|
|
|
if("4".equals(loginTodo.getRoleid())){
|
|
//查相应的班级ID
|
|
SchoolClass schoolClass = new SchoolClass();
|
|
if(StringUtils.isNotBlank(loginTodo.getSchoolclass())){
|
|
schoolClass.setClassName(loginTodo.getSchoolclass());
|
|
List<SchoolClass>schoolClassList = schoolClassService.getValues(schoolClass);
|
|
if(null != schoolClassList && schoolClassList.size()>0){
|
|
for(int i=0;i<schoolClassList.size();i++){
|
|
if(schoolClassList.get(i).getUniversitiesCollegesId().equals(universitiesColleges.getUniversitiesCollegesId())){
|
|
schoolClass = schoolClassList.get(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(null == schoolClass.getClassId()){
|
|
//找不到则添加
|
|
schoolClass.setAddTime(new Date());
|
|
schoolClass.setClassStatus(1);
|
|
schoolClass.setUserId(coreUser.getId());
|
|
schoolClass.setClassName(loginTodo.getSchoolclass());
|
|
schoolClass.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
schoolClass.setOrgId(universitiesColleges.getOrgId());
|
|
|
|
schoolClassService.insert(schoolClass);
|
|
}
|
|
|
|
Student student = new Student();
|
|
student.setStudentName(loginTodo.getName());
|
|
student.setStudentSn(loginTodo.getUsername());
|
|
student.setStudentPassword(loginTodo.getPassword());
|
|
student.setClassId(schoolClass.getClassId());
|
|
student.setOrgId(schoolClass.getOrgId());
|
|
JsonResult jsonResult = studentService.add(student);
|
|
student = studentService.queryById(Long.parseLong(jsonResult.getData().toString()));
|
|
if(null != student){
|
|
//更新缓存
|
|
updateByIds(student.getStudentId().toString());
|
|
}
|
|
coreUser = userService.getUserById(student.getUserId());
|
|
|
|
}else if("3".equals(loginTodo.getRoleid())){
|
|
Teacher teacher = new Teacher();
|
|
teacher.setTeacherName(loginTodo.getName());
|
|
teacher.setTeacherJobNumber(loginTodo.getUsername());
|
|
teacher.setTeacherPassword(loginTodo.getPassword());
|
|
teacher.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
teacher.setOrgId(universitiesColleges.getOrgId());
|
|
JsonResult jsonResult = teacherService.add(teacher);
|
|
teacher = teacherService.queryById(Long.parseLong(jsonResult.getData().toString()));
|
|
coreUser = userService.getUserById(teacher.getUserId());
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
log.info("resourcesApplicationId = "+resourcesApplicationId);
|
|
if(null != resourcesApplicationId){
|
|
UniversitiesCollegesJurisdictionExperimentalSystem uSystem = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
uSystem.setType(1);
|
|
uSystem.setTypeId(resourcesApplicationId);
|
|
if(null !=universitiesCollegesId){
|
|
uSystem.setUniversitiesCollegesId(universitiesCollegesId);
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem>uSystemList = universitiesCollegesJurisdictionExperimentalSystemService.getValues(uSystem);
|
|
if(null != uSystemList && uSystemList.size()>0){
|
|
uSystem = uSystemList.get(0);
|
|
}
|
|
}
|
|
log.info("uSystem = "+uSystem);
|
|
|
|
if(null != coreUser && null != coreUser.getId()){
|
|
//直接登录
|
|
UserLoginInfo info = null;
|
|
try {
|
|
info = userService.login(coreUser.getCode(), coreUser.getPassword());
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
CoreUser user = info.getUser();
|
|
CoreOrg currentOrg = info.getOrgs().get(0);
|
|
for (CoreOrg org : info.getOrgs()) {
|
|
if (org.getId() == user.getOrgId()) {
|
|
currentOrg = org;
|
|
break;
|
|
}
|
|
}
|
|
info.setCurrentOrg(currentOrg);
|
|
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesService.getByOrgId(coreUser.getOrgId());
|
|
if(null != universitiesColleges && ((Integer)1).equals(universitiesColleges.getUniversitiesCollegesStatus())){
|
|
uSystem.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
uSystem.set("useTypes","1,2");
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem>uSystemList = universitiesCollegesJurisdictionExperimentalSystemService.getValues(uSystem);
|
|
if(null != uSystemList && uSystemList.size()>0){
|
|
uSystem = uSystemList.get(0);
|
|
}
|
|
if(null != uSystem && null != uSystem.getUniversitiesCollegesJurisdictionExperimentalSystemId()){
|
|
if(uSystem.getUseStartTime().getTime() <= System.currentTimeMillis() && uSystem.getUseEndTime().getTime() > System.currentTimeMillis()){
|
|
String msg = "";
|
|
if("JT_S_02".equals(user.getJobType1())){//如果是老师 快到期通知
|
|
if(uSystem.getUseEndTime().getTime() - System.currentTimeMillis() < 259200000L){ //少于3天做通知
|
|
msg = "请注意,系统即将过期";
|
|
}
|
|
}
|
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
jsonResult.setMsg(msg);
|
|
|
|
if("JT_S_02".equals(user.getJobType1())){//老师
|
|
// 记录登录信息到session
|
|
this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs(), uSystem);
|
|
try {
|
|
request.getRequestDispatcher("/pc/index.do").forward(request, response);
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}else if("JT_S_03".equals(user.getJobType1())){//学生
|
|
|
|
Student s = studentService.getByUserId(user.getId());
|
|
String token = tokenService.getToken(s);
|
|
|
|
Cookie c2 = new Cookie("token", token);
|
|
c2.setPath("/");
|
|
response.addCookie(c2);
|
|
|
|
if(StringUtils.isNotBlank(token)){
|
|
|
|
String keyId = UUID.randomUUID().toString();
|
|
indexTokenMap.put(keyId,token);
|
|
jsonResult.setData(keyId);
|
|
|
|
//断token的尾巴
|
|
if(StringUtils.isNotBlank(token)){
|
|
if(token.split("\\.").length > 3){
|
|
String loginTime = token.split("\\.")[3];
|
|
token = token.replace("."+loginTime,"");
|
|
}
|
|
}
|
|
|
|
tokenSessionMap.put(token,new Object[]{user, info.getCurrentOrg(), info.getOrgs(), uSystem});
|
|
}
|
|
}
|
|
|
|
String redirectUrl = request.getRequestURL().substring(0,request.getRequestURL().indexOf("/server"));
|
|
|
|
try {
|
|
if(ApplicationRunnerController.isOnline){
|
|
//TODO 根据 uSystem 跳不同的页面
|
|
|
|
if(uSystem.getTypeId().toString().equals("1")){ //大数据基础 子应用
|
|
response.sendRedirect(redirectUrl+"/studentEnd_dsj/index.html");
|
|
}else if(uSystem.getTypeId().toString().equals("2")){ //金融大数据 子应用
|
|
response.sendRedirect(redirectUrl+"/studentEnd_jr/index.html");
|
|
}else if(uSystem.getTypeId().toString().equals("3")){ //财会大数据 子应用
|
|
response.sendRedirect(redirectUrl+"/studentEnd_ch/index.html");
|
|
}else if(uSystem.getTypeId().toString().equals("4")){ //商业大数据 子应用
|
|
response.sendRedirect(redirectUrl+"/studentEnd_sy/index.html");
|
|
}else if(uSystem.getTypeId().toString().equals("5")){ //营销大数据 子应用
|
|
response.sendRedirect(redirectUrl+"/studentEnd_yx/index.html");
|
|
}
|
|
}else {
|
|
if(uSystem.getTypeId().toString().equals("1")){ //大数据基础 子应用
|
|
response.sendRedirect("http://localhost:8080/studentEnd_dsj/index.html");
|
|
}else if(uSystem.getTypeId().toString().equals("2")){ //金融大数据 子应用
|
|
response.sendRedirect("http://localhost:8080/studentEnd_jr/index.html");
|
|
}else if(uSystem.getTypeId().toString().equals("3")){ //财会大数据 子应用
|
|
response.sendRedirect("http://localhost:8080/studentEnd_ch/index.html");
|
|
}else if(uSystem.getTypeId().toString().equals("4")){ //商业大数据 子应用
|
|
response.sendRedirect("http://localhost:8080/studentEnd_sy/index.html");
|
|
}else if(uSystem.getTypeId().toString().equals("5")){ //营销大数据 子应用
|
|
response.sendRedirect("http://localhost:8080/studentEnd_yx/index.html");
|
|
}
|
|
return null;
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
}else {
|
|
try {
|
|
request.getRequestDispatcher(referer).forward(request, response);
|
|
return null;
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
}else if(null != uSystem){
|
|
//TODO 五个不同的页面
|
|
ModelAndView view = new ModelAndView("/login.html");
|
|
view.addObject("uSystem", uSystem);
|
|
return view;
|
|
}
|
|
}
|
|
ModelAndView view = new ModelAndView("/login.html");
|
|
view.addObject("uSystem", new UniversitiesCollegesJurisdictionExperimentalSystem());
|
|
// try {
|
|
// response.sendRedirect("http://localhost:8080/Login");
|
|
// } catch (IOException e) {
|
|
// e.printStackTrace();
|
|
// }
|
|
return view;
|
|
}
|
|
|
|
// @PostMapping("/login.json")
|
|
// @ResponseBody
|
|
// public JsonResult login(HttpServletRequest request, HttpServletResponse response,String code, String password, Integer type, Long typeId) {
|
|
// UniversitiesCollegesJurisdictionExperimentalSystem uSystem = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
// uSystem.setType(type);
|
|
// uSystem.setTypeId(typeId);
|
|
// Cookie c1 = new Cookie("JSESSIONID", request.getSession().getId());
|
|
// c1.setPath("/");
|
|
// response.addCookie(c1);
|
|
// UserLoginInfo info = null;
|
|
// try {
|
|
// info = userService.login(code, password);
|
|
// }catch (Exception e){
|
|
// return JsonResult.failMessage(e.getMessage());
|
|
// }
|
|
// CoreUser user = info.getUser();
|
|
// CoreOrg currentOrg = info.getOrgs().get(0);
|
|
// for (CoreOrg org : info.getOrgs()) {
|
|
// if (org.getId().equals(user.getOrgId())) {
|
|
// currentOrg = org;
|
|
// break;
|
|
// }
|
|
// }
|
|
// info.setCurrentOrg(currentOrg);
|
|
//
|
|
// if(null != user && !Arrays.asList(JT_S_01.name(), JT_S_04.name()).contains(user.getJobType1())){//非管理员(包含学校管理员、超管)
|
|
//// if(null != type && null != typeId){
|
|
// UniversitiesColleges universitiesColleges = universitiesCollegesService.getByOrgId(user.getOrgId());
|
|
// if(null != universitiesColleges && ((Integer)1).equals(universitiesColleges.getUniversitiesCollegesStatus())){
|
|
// uSystem.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
// uSystem.set("useTypes","1,2");
|
|
// List<UniversitiesCollegesJurisdictionExperimentalSystem>uSystemList = universitiesCollegesJurisdictionExperimentalSystemService.getValues(uSystem);
|
|
// if(null != uSystemList && uSystemList.size()>0){
|
|
// uSystem = uSystemList.get(0);
|
|
// }
|
|
// if(null != uSystem && null != uSystem.getUniversitiesCollegesJurisdictionExperimentalSystemId()){
|
|
// if(uSystem.getUseStartTime().getTime() <= System.currentTimeMillis() && uSystem.getUseEndTime().getTime() > System.currentTimeMillis()){
|
|
// String msg = "";
|
|
// if("JT_S_02".equals(user.getJobType1())){//如果是老师 快到期通知
|
|
// if(uSystem.getUseEndTime().getTime() - System.currentTimeMillis() < 259200000L){ //少于3天做通知
|
|
// msg = "请注意,系统即将过期";
|
|
// }
|
|
// }
|
|
//
|
|
// JsonResult jsonResult = new JsonResult();
|
|
// jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
// jsonResult.setMsg(msg);
|
|
//
|
|
// if(JT_S_02.equals(user.getJobType1())){//老师
|
|
// Teacher teacher = teacherService.getByUserId(user.getId());
|
|
// String token = tokenService.getToken(teacher);
|
|
//
|
|
// if(StringUtils.isNotBlank(token)){
|
|
//
|
|
// String keyId = UUID.randomUUID().toString();
|
|
// indexTokenMap.put(keyId,token);
|
|
// jsonResult.setData(keyId);
|
|
//
|
|
// //断token的尾巴
|
|
// if(StringUtils.isNotBlank(token)){
|
|
// if(token.split("\\.").length > 3){
|
|
// String loginTime = token.split("\\.")[3];
|
|
// token = token.replace("."+loginTime,"");
|
|
// }
|
|
// }
|
|
//
|
|
// // 登录信息存放Session
|
|
// webPlatformService.setUserInfoToSessionByIdentity(info.getUser());
|
|
// platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs(), uSystem);
|
|
// tokenSessionMap.put(token,new Object[]{user, info.getCurrentOrg(), info.getOrgs(), uSystem});
|
|
// return jsonResult;
|
|
// }
|
|
//
|
|
// }else if(JT_S_03.equals(user.getJobType1())){//学生
|
|
//
|
|
// Student s = studentService.getByUserId(user.getId());
|
|
// String token = tokenService.getToken(s);
|
|
//
|
|
// if(StringUtils.isNotBlank(token)){
|
|
//
|
|
// String keyId = UUID.randomUUID().toString();
|
|
// indexTokenMap.put(keyId,token);
|
|
// jsonResult.setData(keyId);
|
|
//
|
|
// //断token的尾巴
|
|
// if(StringUtils.isNotBlank(token)){
|
|
// if(token.split("\\.").length > 3){
|
|
// String loginTime = token.split("\\.")[3];
|
|
// token = token.replace("."+loginTime,"");
|
|
// }
|
|
// }
|
|
//
|
|
// tokenSessionMap.put(token,new Object[]{user, info.getCurrentOrg(), info.getOrgs(), uSystem});
|
|
// }
|
|
//
|
|
// // 登录信息存放Session
|
|
// webPlatformService.setUserInfoToSessionByIdentity(info.getUser());
|
|
// platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs(), uSystem);
|
|
// }
|
|
//
|
|
// return jsonResult;
|
|
// }
|
|
// }
|
|
// }else {
|
|
// return JsonResult.failMessage("登录失败,此院校不存在");
|
|
// }
|
|
//// }
|
|
//// return JsonResult.failMessage("登录失败,没有此系统权限");
|
|
// }else {
|
|
// // 记录登录信息到session
|
|
// this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs(), uSystem);
|
|
// // 登录信息存放Session。这里可能是学校管理员
|
|
// webPlatformService.setUserInfoToSessionByIdentity(info.getUser());
|
|
// }
|
|
// return JsonResult.success();
|
|
// }
|
|
|
|
|
|
@PostMapping("/login.json")
|
|
@ResponseBody
|
|
public JsonResult login(HttpServletRequest request, HttpServletResponse response,String code, String password, Integer type, Long typeId) {
|
|
UniversitiesCollegesJurisdictionExperimentalSystem uSystem = new UniversitiesCollegesJurisdictionExperimentalSystem();
|
|
uSystem.setType(type);
|
|
uSystem.setTypeId(typeId);
|
|
Cookie c1 = new Cookie("JSESSIONID", request.getSession().getId());
|
|
c1.setPath("/");
|
|
response.addCookie(c1);
|
|
UserLoginInfo info = null;
|
|
try {
|
|
info = userService.login(code, password);
|
|
}catch (Exception e){
|
|
return JsonResult.failMessage(e.getMessage());
|
|
}
|
|
CoreUser user = info.getUser();
|
|
CoreOrg currentOrg = info.getOrgs().get(0);
|
|
for (CoreOrg org : info.getOrgs()) {
|
|
if (org.getId().equals(user.getOrgId())) {
|
|
currentOrg = org;
|
|
break;
|
|
}
|
|
}
|
|
info.setCurrentOrg(currentOrg);
|
|
|
|
|
|
switch (EnumUtil.fromString(MenuEnums.class, user.getJobType1())) {
|
|
|
|
// 超管和学校管理员
|
|
case JT_S_01:
|
|
case JT_S_04: {
|
|
// 记录登录信息到session
|
|
this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs(), uSystem);
|
|
// 登录信息存放Session。这里可能是学校管理员
|
|
webPlatformService.setUserInfoToSessionByIdentity(info.getUser());
|
|
} break;
|
|
|
|
// 教师
|
|
case JT_S_02: {
|
|
|
|
// 验证使用权,是否到期
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesService.getByOrgId(user.getOrgId());
|
|
|
|
if (universitiesColleges == null) {
|
|
return JsonResult.failMessage("登录失败,此院校不存在");
|
|
}
|
|
|
|
if(null != universitiesColleges && ((Integer)1).equals(universitiesColleges.getUniversitiesCollegesStatus())) {
|
|
uSystem.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
uSystem.set("useTypes", "1,2");
|
|
List<UniversitiesCollegesJurisdictionExperimentalSystem> uSystemList = universitiesCollegesJurisdictionExperimentalSystemService.getValues(uSystem);
|
|
if (null != uSystemList && uSystemList.size() > 0) {
|
|
uSystem = uSystemList.get(0);
|
|
}
|
|
if (null != uSystem && null != uSystem.getUniversitiesCollegesJurisdictionExperimentalSystemId()) {
|
|
if (uSystem.getUseStartTime().getTime() <= System.currentTimeMillis() && uSystem.getUseEndTime().getTime() > System.currentTimeMillis()) {
|
|
|
|
//如果是老师 快到期通知
|
|
if (JT_S_02.name().equals(user.getJobType1())) {
|
|
//少于3天做通知
|
|
if (uSystem.getUseEndTime().getTime() - System.currentTimeMillis() < 259200000L) {
|
|
return JsonResult.successMessage("请注意,系统即将过期");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Teacher teacher = teacherService.getByUserId(user.getId());
|
|
String teacherToken = tokenService.getToken(teacher);
|
|
|
|
if(StringUtils.isNotBlank(teacherToken)) {
|
|
|
|
String keyId = UUID.randomUUID().toString();
|
|
indexTokenMap.put(keyId, teacherToken);
|
|
|
|
//断token的尾巴
|
|
if (StringUtils.isNotBlank(teacherToken)) {
|
|
if (teacherToken.split("\\.").length > 3) {
|
|
String loginTime = teacherToken.split("\\.")[3];
|
|
teacherToken = teacherToken.replace("." + loginTime, "");
|
|
}
|
|
}
|
|
|
|
// 登录信息存放Session
|
|
webPlatformService.setUserInfoToSessionByIdentity(info.getUser());
|
|
platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs(), uSystem);
|
|
tokenSessionMap.put(teacherToken, new Object[]{user, info.getCurrentOrg(), info.getOrgs(), uSystem});
|
|
return JsonResult.success(keyId);
|
|
}
|
|
} break;
|
|
|
|
// 学生
|
|
case JT_S_03: {
|
|
Student s = studentService.getByUserId(user.getId());
|
|
String studentToken = tokenService.getToken(s);
|
|
|
|
if (StringUtils.isNotBlank(studentToken)) {
|
|
|
|
String keyId = UUID.randomUUID().toString();
|
|
indexTokenMap.put(keyId, studentToken);
|
|
|
|
//断token的尾巴
|
|
if (StringUtils.isNotBlank(studentToken)) {
|
|
if (studentToken.split("\\.").length > 3) {
|
|
String loginTime = studentToken.split("\\.")[3];
|
|
studentToken = studentToken.replace("." + loginTime, "");
|
|
}
|
|
}
|
|
|
|
tokenSessionMap.put(studentToken, new Object[]{user, info.getCurrentOrg(), info.getOrgs(), uSystem});
|
|
// 登录信息存放Session
|
|
webPlatformService.setUserInfoToSessionByIdentity(info.getUser());
|
|
platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs(), uSystem);
|
|
return JsonResult.success(keyId);
|
|
}
|
|
} break;
|
|
}
|
|
|
|
return JsonResult.success();
|
|
}
|
|
|
|
//跳转到电脑端首页
|
|
@RequestMapping("/teacherIndex.do")
|
|
public ModelAndView teacherIndex(@SCoreUser CoreUser coreUser) {
|
|
ModelAndView view = new ModelAndView("/teacherIndex.html");
|
|
CoreUser currentUser = platformService.getCurrentUser();
|
|
view.addObject("competitionList",new ArrayList<Competition>());
|
|
if("JT_S_01".equals(currentUser.getJobType1())){//管理员
|
|
|
|
CompetitionQuery competitionQuery = new CompetitionQuery();
|
|
competitionQuery.setCompetitionStatus(1);
|
|
List<Competition> competitionList = competitionService.getValuesByQuery(competitionQuery);
|
|
|
|
view.addObject("competitionList",competitionList);
|
|
}else if("JT_S_02".equals(currentUser.getJobType1())){//教师
|
|
|
|
CompetitionQuery competitionQuery = new CompetitionQuery();
|
|
competitionQuery.setOrgId(coreUser.getOrgId());
|
|
competitionQuery.setCompetitionStatus(1);
|
|
List<Competition> competitionList = competitionService.getValuesByQuery(competitionQuery);
|
|
|
|
view.addObject("competitionList",competitionList);
|
|
}
|
|
return view;
|
|
}
|
|
|
|
//跳转到电脑端首页
|
|
@RequestMapping("/index.do")
|
|
public void index(HttpServletRequest request, HttpServletResponse response,
|
|
@TTeacher Teacher teacher, @TStudent Student student, @SCoreUser CoreUser coreUser) {
|
|
//判断是老师还是学生
|
|
if(null != student || null != teacher){//学生
|
|
try {
|
|
String redirectUrl = "";
|
|
if(request.getHeader("Referer").contains("/server")){
|
|
redirectUrl = request.getHeader("Referer").substring(0,request.getHeader("Referer").indexOf("/server"));
|
|
}else {
|
|
redirectUrl = request.getHeader("Referer").substring(0,request.getHeader("Referer").lastIndexOf("/") + 1);
|
|
}
|
|
|
|
String token = getToken(request);
|
|
|
|
// UniversitiesCollegesJurisdictionExperimentalSystem uSystem = (UniversitiesCollegesJurisdictionExperimentalSystem)platformService.getOther(token);
|
|
|
|
try {
|
|
Cookie c1 = new Cookie("JSESSIONID", request.getSession().getId());
|
|
c1.setPath("/");
|
|
response.addCookie(c1);
|
|
|
|
Cookie c2 = new Cookie("token", token);
|
|
c2.setPath("/");
|
|
response.addCookie(c2);
|
|
|
|
if(ApplicationRunnerController.isOnline){
|
|
//TODO 根据 uSystem 跳不同的页面
|
|
|
|
response.sendRedirect(redirectUrl+"Home");
|
|
// if(uSystem.getTypeId().toString().equals("1")){ //大数据基础 子应用
|
|
// response.sendRedirect(redirectUrl+"/studentEnd_dsj/index.html");
|
|
// }else if(uSystem.getTypeId().toString().equals("2")){ //金融大数据 子应用
|
|
// response.sendRedirect(redirectUrl+"/studentEnd_jr/index.html");
|
|
// }else if(uSystem.getTypeId().toString().equals("3")){ //财会大数据 子应用
|
|
// response.sendRedirect(redirectUrl+"/studentEnd_ch/index.html");
|
|
// }else if(uSystem.getTypeId().toString().equals("4")){ //商业大数据 子应用
|
|
// response.sendRedirect(redirectUrl+"/studentEnd_sy/index.html");
|
|
// }else if(uSystem.getTypeId().toString().equals("5")){ //营销大数据 子应用
|
|
// response.sendRedirect(redirectUrl+"/studentEnd_yx/index.html");
|
|
// }
|
|
}else {
|
|
response.sendRedirect("http://localhost:8080/Home");
|
|
// if(uSystem.getTypeId().toString().equals("1")){ //大数据基础 子应用
|
|
// response.sendRedirect("http://localhost:8080/studentEnd_dsj/index.html");
|
|
// }else if(uSystem.getTypeId().toString().equals("2")){ //金融大数据 子应用
|
|
// response.sendRedirect("http://localhost:8080/studentEnd_jr/index.html");
|
|
// }else if(uSystem.getTypeId().toString().equals("3")){ //财会大数据 子应用
|
|
// response.sendRedirect("http://localhost:8080/studentEnd_ch/index.html");
|
|
// }else if(uSystem.getTypeId().toString().equals("4")){ //商业大数据 子应用
|
|
// response.sendRedirect("http://localhost:8080/studentEnd_sy/index.html");
|
|
// }else if(uSystem.getTypeId().toString().equals("5")){ //营销大数据 子应用
|
|
// response.sendRedirect("http://localhost:8080/studentEnd_yx/index.html");
|
|
// }
|
|
}
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
}else{//老师 或 管理员
|
|
try {
|
|
request.getRequestDispatcher("/pc/index.do").forward(request, response);
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
//跳转到电脑端首页
|
|
@RequestMapping("/pc/index.do")
|
|
public ModelAndView index(@SCoreUser CoreUser coreUser) {
|
|
CoreUser currentUser = platformService.getCurrentUser();
|
|
ModelAndView view = new ModelAndView("/index.html");
|
|
Long orgId = platformService.getCurrentOrgId();
|
|
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
|
|
|
|
UniversitiesCollegesJurisdictionExperimentalSystem uSystem = (UniversitiesCollegesJurisdictionExperimentalSystem)platformService.getOther();
|
|
if(null != uSystem){
|
|
//子系统logo
|
|
view.addObject("subsystemLogo",StringUtils.isNotBlank(uSystem.getSubsystemLogo())?uSystem.getSubsystemLogo():null); // 如果是空则用这个子系统默认的
|
|
//网站底部
|
|
view.addObject("subsystemBottomBar",uSystem.getSubsystemBottomBar());
|
|
}else {
|
|
view.addObject("subsystemLogo", null);
|
|
view.addObject("subsystemBottomBar", null);
|
|
}
|
|
view.addObject("banner", null);
|
|
|
|
view.addObject("competitionList",new ArrayList<Competition>());
|
|
if("JT_S_01".equals(currentUser.getJobType1())){//管理员
|
|
|
|
CompetitionQuery competitionQuery = new CompetitionQuery();
|
|
List<Competition> competitionList = competitionService.getValuesByQuery(competitionQuery);
|
|
|
|
view.addObject("competitionList",competitionList);
|
|
}else if("JT_S_02".equals(currentUser.getJobType1())){//教师
|
|
|
|
CompetitionQuery competitionQuery = new CompetitionQuery();
|
|
competitionQuery.setOrgId(coreUser.getOrgId());
|
|
List<Competition> competitionList = competitionService.getValuesByQuery(competitionQuery);
|
|
|
|
view.addObject("competitionList",competitionList);
|
|
}
|
|
|
|
view.addObject("menus", menuItem);
|
|
view.addObject("htmlUrl", previewIndex);
|
|
view.addObject("webSocketServer", webSocketServer);
|
|
return view;
|
|
}
|
|
|
|
//跳转到手机端首页
|
|
@RequestMapping("/phoneIndex.do")
|
|
public ModelAndView phoneIndex() {
|
|
ModelAndView view = new ModelAndView("/phoneIndex.html");
|
|
|
|
CoreUser currentUser = platformService.getCurrentUser();
|
|
Long orgId = platformService.getCurrentOrgId();
|
|
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
|
|
List<MenuItem> childrenMenuItemList = new ArrayList<>();
|
|
if(null != menuItem){
|
|
List<MenuItem> menuItemList = menuItem.getChildren();
|
|
if(null != menuItemList && menuItemList.size() > 0){
|
|
if(null != menuItem && menuItem.getChildren().size() == 1){
|
|
menuItem = menuItemList.get(0);
|
|
if(null != menuItem){
|
|
menuItemList = menuItem.getChildren();
|
|
for(int i=0;null != menuItemList && i<menuItemList.size();i++){
|
|
if(null != menuItemList.get(i) && null != menuItemList.get(i).getChildren() && menuItemList.get(i).getChildren().size() > 0){
|
|
List<MenuItem> menuItems = Tool.deepCopy(menuItemList.get(i).getChildren());
|
|
for(int j=0;j<menuItems.size();j++){
|
|
Object accessUrl = menuItems.get(j).getData().get("accessUrl");
|
|
if(null != accessUrl && StringUtils.isNotBlank(accessUrl.toString())){
|
|
//跳转地址统一替换为 phone 开头
|
|
String doUrl = accessUrl.toString().substring(accessUrl.toString().lastIndexOf("/")+1);
|
|
String phoneDoUrl = "phone" + StringUtils.upperCase(doUrl.substring(0,1)) + doUrl.substring(1);
|
|
menuItems.get(j).getData().set("accessUrl",accessUrl.toString().replace(doUrl,phoneDoUrl));
|
|
}
|
|
}
|
|
childrenMenuItemList.addAll(menuItems);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
view.addObject("childrenMenus", childrenMenuItemList);
|
|
|
|
return view;
|
|
}
|
|
|
|
@RequestMapping("/logout.do")
|
|
public ModelAndView logout(HttpServletRequest request,@RequestReferer String referer) {
|
|
HttpSession session = request.getSession();
|
|
Enumeration eum = session.getAttributeNames();
|
|
while(eum.hasMoreElements()) {
|
|
String key = (String)eum.nextElement();
|
|
session.removeAttribute(key);
|
|
}
|
|
ModelAndView view = new ModelAndView("redirect:/");
|
|
if(StringUtils.isNotBlank(referer)) {
|
|
if (referer.contains("studentEnd_dsj")) {
|
|
view = new ModelAndView("redirect:/?resourcesApplicationId=1");
|
|
} else if (referer.contains("studentEnd_jr")) {
|
|
view = new ModelAndView("redirect:/?resourcesApplicationId=2");
|
|
} else if (referer.contains("studentEnd_ch")) {
|
|
view = new ModelAndView("redirect:/?resourcesApplicationId=3");
|
|
} else if (referer.contains("studentEnd_sy")) {
|
|
view = new ModelAndView("redirect:/?resourcesApplicationId=4");
|
|
} else if (referer.contains("studentEnd_yx")) {
|
|
view = new ModelAndView("redirect:/?resourcesApplicationId=5");
|
|
}
|
|
}
|
|
return view;
|
|
}
|
|
|
|
@PostMapping("/logout.json")
|
|
@ResponseBody
|
|
public JsonResult logout() {
|
|
return JsonResult.success(platformService.logout());
|
|
}
|
|
|
|
@RequestMapping("/changeOrg.do")
|
|
public ModelAndView changeOrg(HttpServletRequest request,Long orgId) {
|
|
platformService.changeOrg(orgId);
|
|
ModelAndView view = new ModelAndView("redirect:/index.do");
|
|
return view;
|
|
}
|
|
|
|
}
|