|
@@ -1,12 +1,15 @@
|
|
package cn.com.qmth.examcloud.core.basic.api.controller;
|
|
package cn.com.qmth.examcloud.core.basic.api.controller;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.enums.BooleanSelect;
|
|
import cn.com.qmth.examcloud.api.commons.enums.BooleanSelect;
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
|
|
-import cn.com.qmth.examcloud.api.commons.security.enums.RoleMeta;
|
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.helpers.poi.ExcelWriter;
|
|
import cn.com.qmth.examcloud.commons.helpers.poi.ExcelWriter;
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.ByteUtil;
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.SHA256;
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.StudentDomain;
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.StudentDomain;
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
@@ -16,7 +19,6 @@ import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.StudentCodeEntity;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.StudentCodeEntity;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
|
|
-import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
|
|
|
|
import cn.com.qmth.examcloud.core.basic.service.StudentService;
|
|
import cn.com.qmth.examcloud.core.basic.service.StudentService;
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
|
|
import cn.com.qmth.examcloud.core.basic.service.cache.StudentCache;
|
|
import cn.com.qmth.examcloud.core.basic.service.cache.StudentCache;
|
|
@@ -29,12 +31,10 @@ import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
|
|
import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
|
|
import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
|
|
import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
|
|
import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
|
|
-import cn.com.qmth.examcloud.support.privilege.PrivilegeDefine.DataAccess.ExamWorkData.StudentInfoData.AllStudentData;
|
|
|
|
-import cn.com.qmth.examcloud.support.privilege.PrivilegeDefine.DataAccess.ExamWorkData.StudentInfoData.OrgStudentData;
|
|
|
|
-import cn.com.qmth.examcloud.support.privilege.PrivilegeManager;
|
|
|
|
import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
|
|
import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
|
|
import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
|
+import cn.com.qmth.examcloud.web.security.DataRule;
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -43,6 +43,7 @@ import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
@@ -107,6 +108,7 @@ public class StudentController extends ControllerSupport {
|
|
* @return
|
|
* @return
|
|
* @author WANGWEI
|
|
* @author WANGWEI
|
|
*/
|
|
*/
|
|
|
|
+ @DataRule(type = DataRuleType.ORG)
|
|
@ApiOperation(value = "查询学生分页数据", notes = "分页")
|
|
@ApiOperation(value = "查询学生分页数据", notes = "分页")
|
|
@GetMapping("studentPage/{curPage}/{pageSize}")
|
|
@GetMapping("studentPage/{curPage}/{pageSize}")
|
|
public PageInfo<StudentDomain> getStudentPage(
|
|
public PageInfo<StudentDomain> getStudentPage(
|
|
@@ -124,9 +126,16 @@ public class StudentController extends ControllerSupport {
|
|
}
|
|
}
|
|
|
|
|
|
validateRootOrgIsolation(rootOrgId);
|
|
validateRootOrgIsolation(rootOrgId);
|
|
-
|
|
|
|
final Long finalRootOrgId = rootOrgId;
|
|
final Long finalRootOrgId = rootOrgId;
|
|
|
|
|
|
|
|
+ PageRequest pageable = PageRequest.of(curPage, pageSize,
|
|
|
|
+ new Sort(Direction.DESC, "updateTime", "id"));
|
|
|
|
+
|
|
|
|
+ UserDataRule userDataRule = super.getUserDataRule(DataRuleType.ORG);
|
|
|
|
+ if (userDataRule.assertEmptyQueryResult()) {
|
|
|
|
+ return new PageInfo(new PageImpl<>(new ArrayList<>(), pageable, 0L));
|
|
|
|
+ }
|
|
|
|
+
|
|
Specification<StudentEntity> specification = (root, query, cb) -> {
|
|
Specification<StudentEntity> specification = (root, query, cb) -> {
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
predicates.add(cb.equal(root.get("rootOrgId"), finalRootOrgId));
|
|
predicates.add(cb.equal(root.get("rootOrgId"), finalRootOrgId));
|
|
@@ -134,6 +143,7 @@ public class StudentController extends ControllerSupport {
|
|
if (StringUtils.isNotEmpty(name)) {
|
|
if (StringUtils.isNotEmpty(name)) {
|
|
predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
|
|
predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
|
|
}
|
|
}
|
|
|
|
+
|
|
if (StringUtils.isNotBlank(identityNumber)) {
|
|
if (StringUtils.isNotBlank(identityNumber)) {
|
|
predicates.add(cb.like(root.get("identityNumber"), toSqlRightLike(identityNumber)));
|
|
predicates.add(cb.like(root.get("identityNumber"), toSqlRightLike(identityNumber)));
|
|
}
|
|
}
|
|
@@ -166,11 +176,20 @@ public class StudentController extends ControllerSupport {
|
|
predicates.add(cb.exists(subquery));
|
|
predicates.add(cb.exists(subquery));
|
|
}
|
|
}
|
|
|
|
|
|
- Boolean orgStudentData = PrivilegeManager.judge(finalRootOrgId,
|
|
|
|
|
|
+
|
|
|
|
+ if (orgId == null) {
|
|
|
|
+ if (userDataRule.assertNeedQueryRefIds()) {
|
|
|
|
+ predicates.add(root.get("orgId").in(userDataRule.getRefIds()));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ predicates.add(cb.equal(root.get("orgId"), orgId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /*Boolean orgStudentData = PrivilegeManager.judge(finalRootOrgId,
|
|
accessUser.getRoleList(), OrgStudentData.CODE);
|
|
accessUser.getRoleList(), OrgStudentData.CODE);
|
|
Boolean allStudentData = PrivilegeManager.judge(finalRootOrgId,
|
|
Boolean allStudentData = PrivilegeManager.judge(finalRootOrgId,
|
|
accessUser.getRoleList(), AllStudentData.CODE);
|
|
accessUser.getRoleList(), AllStudentData.CODE);
|
|
-
|
|
|
|
// 学习中心过滤
|
|
// 学习中心过滤
|
|
if (isSuperAdmin()) {
|
|
if (isSuperAdmin()) {
|
|
if (null != orgId) {
|
|
if (null != orgId) {
|
|
@@ -196,24 +215,19 @@ public class StudentController extends ControllerSupport {
|
|
} else {
|
|
} else {
|
|
predicates.add(cb.equal(root.get("orgId"), -1));
|
|
predicates.add(cb.equal(root.get("orgId"), -1));
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
};
|
|
};
|
|
|
|
|
|
- PageRequest pageRequest = PageRequest.of(curPage, pageSize,
|
|
|
|
- new Sort(Direction.DESC, "updateTime", "id"));
|
|
|
|
-
|
|
|
|
- Page<StudentEntity> studentList = studentRepo.findAll(specification, pageRequest);
|
|
|
|
-
|
|
|
|
|
|
+ Page<StudentEntity> studentList = studentRepo.findAll(specification, pageable);
|
|
Iterator<StudentEntity> iterator = studentList.iterator();
|
|
Iterator<StudentEntity> iterator = studentList.iterator();
|
|
-
|
|
|
|
List<StudentDomain> studentDomainList = Lists.newArrayList();
|
|
List<StudentDomain> studentDomainList = Lists.newArrayList();
|
|
|
|
|
|
-// String upyunDomain = PropertyHolder.getString("$upyun.site.1.domain");
|
|
|
|
-// if (StringUtils.isBlank(upyunDomain)) {
|
|
|
|
-// throw new StatusException("560111", "property[$upyun.site.1.domain] is not configured");
|
|
|
|
-// }
|
|
|
|
|
|
+ // String upyunDomain = PropertyHolder.getString("$upyun.site.1.domain");
|
|
|
|
+ // if (StringUtils.isBlank(upyunDomain)) {
|
|
|
|
+ // throw new StatusException("560111", "property[$upyun.site.1.domain] is not configured");
|
|
|
|
+ // }
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
while (iterator.hasNext()) {
|
|
StudentEntity next = iterator.next();
|
|
StudentEntity next = iterator.next();
|
|
@@ -236,8 +250,8 @@ public class StudentController extends ControllerSupport {
|
|
bean.setIdentityNumber(next.getIdentityNumber());
|
|
bean.setIdentityNumber(next.getIdentityNumber());
|
|
bean.setPrivateIdentityNumber(IdentityNumberHelper.conceal(next.getRootOrgId(), next.getIdentityNumber()));
|
|
bean.setPrivateIdentityNumber(IdentityNumberHelper.conceal(next.getRootOrgId(), next.getIdentityNumber()));
|
|
if (StringUtils.isNotBlank(next.getPhotoPath())) {
|
|
if (StringUtils.isNotBlank(next.getPhotoPath())) {
|
|
-// bean.setPhotoPath(
|
|
|
|
-// UrlUtil.joinUrl(upyunDomain, "student_base_photo", next.getPhotoPath()));
|
|
|
|
|
|
+ // bean.setPhotoPath(
|
|
|
|
+ // UrlUtil.joinUrl(upyunDomain, "student_base_photo", next.getPhotoPath()));
|
|
//通用存储
|
|
//通用存储
|
|
bean.setPhotoPath(FileStorageUtil.realPath(FileStorageUtil.getIntactPath("student_base_photo",
|
|
bean.setPhotoPath(FileStorageUtil.realPath(FileStorageUtil.getIntactPath("student_base_photo",
|
|
next.getPhotoPath())));
|
|
next.getPhotoPath())));
|
|
@@ -265,6 +279,7 @@ public class StudentController extends ControllerSupport {
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @DataRule(type = DataRuleType.ORG)
|
|
@ApiOperation(value = "导出学生", notes = "")
|
|
@ApiOperation(value = "导出学生", notes = "")
|
|
@GetMapping("export")
|
|
@GetMapping("export")
|
|
public void exportStudents(@RequestParam String name,
|
|
public void exportStudents(@RequestParam String name,
|
|
@@ -280,9 +295,14 @@ public class StudentController extends ControllerSupport {
|
|
}
|
|
}
|
|
|
|
|
|
validateRootOrgIsolation(rootOrgId);
|
|
validateRootOrgIsolation(rootOrgId);
|
|
-
|
|
|
|
final Long finalRootOrgId = rootOrgId;
|
|
final Long finalRootOrgId = rootOrgId;
|
|
|
|
|
|
|
|
+ UserDataRule userDataRule = super.getUserDataRule(DataRuleType.ORG);
|
|
|
|
+ if (userDataRule.assertEmptyQueryResult()) {
|
|
|
|
+ this.doExport(new ArrayList<>());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
Specification<StudentEntity> specification = (root, query, cb) -> {
|
|
Specification<StudentEntity> specification = (root, query, cb) -> {
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
predicates.add(cb.equal(root.get("rootOrgId"), finalRootOrgId));
|
|
predicates.add(cb.equal(root.get("rootOrgId"), finalRootOrgId));
|
|
@@ -290,6 +310,7 @@ public class StudentController extends ControllerSupport {
|
|
if (StringUtils.isNotEmpty(name)) {
|
|
if (StringUtils.isNotEmpty(name)) {
|
|
predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
|
|
predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
|
|
}
|
|
}
|
|
|
|
+
|
|
if (StringUtils.isNotBlank(identityNumber)) {
|
|
if (StringUtils.isNotBlank(identityNumber)) {
|
|
predicates.add(cb.like(root.get("identityNumber"), toSqlRightLike(identityNumber)));
|
|
predicates.add(cb.like(root.get("identityNumber"), toSqlRightLike(identityNumber)));
|
|
}
|
|
}
|
|
@@ -315,11 +336,20 @@ public class StudentController extends ControllerSupport {
|
|
predicates.add(cb.exists(subquery));
|
|
predicates.add(cb.exists(subquery));
|
|
}
|
|
}
|
|
|
|
|
|
- Boolean orgStudentData = PrivilegeManager.judge(finalRootOrgId,
|
|
|
|
|
|
+
|
|
|
|
+ if (orgId == null) {
|
|
|
|
+ if (userDataRule.assertNeedQueryRefIds()) {
|
|
|
|
+ predicates.add(root.get("orgId").in(userDataRule.getRefIds()));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ predicates.add(cb.equal(root.get("orgId"), orgId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /*Boolean orgStudentData = PrivilegeManager.judge(finalRootOrgId,
|
|
accessUser.getRoleList(), OrgStudentData.CODE);
|
|
accessUser.getRoleList(), OrgStudentData.CODE);
|
|
Boolean allStudentData = PrivilegeManager.judge(finalRootOrgId,
|
|
Boolean allStudentData = PrivilegeManager.judge(finalRootOrgId,
|
|
accessUser.getRoleList(), AllStudentData.CODE);
|
|
accessUser.getRoleList(), AllStudentData.CODE);
|
|
-
|
|
|
|
// 学习中心过滤
|
|
// 学习中心过滤
|
|
if (isSuperAdmin()) {
|
|
if (isSuperAdmin()) {
|
|
if (null != orgId) {
|
|
if (null != orgId) {
|
|
@@ -345,7 +375,7 @@ public class StudentController extends ControllerSupport {
|
|
} else {
|
|
} else {
|
|
predicates.add(cb.equal(root.get("orgId"), -1));
|
|
predicates.add(cb.equal(root.get("orgId"), -1));
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
};
|
|
};
|
|
@@ -357,7 +387,10 @@ public class StudentController extends ControllerSupport {
|
|
|
|
|
|
List<StudentEntity> studentList = studentRepo.findAll(specification,
|
|
List<StudentEntity> studentList = studentRepo.findAll(specification,
|
|
new Sort(Direction.DESC, "updateTime"));
|
|
new Sort(Direction.DESC, "updateTime"));
|
|
|
|
+ this.doExport(studentList);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private void doExport(List<StudentEntity> studentList) {
|
|
List<Object[]> datas = Lists.newArrayList();
|
|
List<Object[]> datas = Lists.newArrayList();
|
|
|
|
|
|
for (StudentEntity cur : studentList) {
|
|
for (StudentEntity cur : studentList) {
|
|
@@ -415,8 +448,8 @@ public class StudentController extends ControllerSupport {
|
|
s.setEnable(true);
|
|
s.setEnable(true);
|
|
studentRepo.save(s);
|
|
studentRepo.save(s);
|
|
//操作日志
|
|
//操作日志
|
|
- ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(),s.getId(), null, UserType.COMMON,
|
|
|
|
- OperateContent.STUDENT_ENABLE.getDesc()));
|
|
|
|
|
|
+ ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(), null, UserType.COMMON,
|
|
|
|
+ OperateContent.STUDENT_ENABLE.getDesc()));
|
|
ret.add(s.getId() + ":" + s.getName());
|
|
ret.add(s.getId() + ":" + s.getName());
|
|
}
|
|
}
|
|
for (Long cur : studentIds) {
|
|
for (Long cur : studentIds) {
|
|
@@ -444,8 +477,8 @@ public class StudentController extends ControllerSupport {
|
|
s.setEnable(false);
|
|
s.setEnable(false);
|
|
studentRepo.save(s);
|
|
studentRepo.save(s);
|
|
//操作日志
|
|
//操作日志
|
|
- ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(),null, UserType.COMMON,
|
|
|
|
- OperateContent.STUDENT_DISABLE.getDesc()));
|
|
|
|
|
|
+ ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(), null, UserType.COMMON,
|
|
|
|
+ OperateContent.STUDENT_DISABLE.getDesc()));
|
|
ret.add(s.getId() + ":" + s.getName());
|
|
ret.add(s.getId() + ":" + s.getName());
|
|
}
|
|
}
|
|
for (Long cur : studentIds) {
|
|
for (Long cur : studentIds) {
|
|
@@ -466,17 +499,21 @@ public class StudentController extends ControllerSupport {
|
|
throw new StatusException("450110", "学生不存在");
|
|
throw new StatusException("450110", "学生不存在");
|
|
}
|
|
}
|
|
String identityNumber = s.getIdentityNumber();
|
|
String identityNumber = s.getIdentityNumber();
|
|
|
|
+ String passwd = null;
|
|
if (StringUtils.isNotEmpty(identityNumber)
|
|
if (StringUtils.isNotEmpty(identityNumber)
|
|
&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {
|
|
&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {
|
|
- s.setPassword(StringUtils.substring(identityNumber, -6, identityNumber.length()));
|
|
|
|
|
|
+ passwd = StringUtils.substring(identityNumber, -6, identityNumber.length());
|
|
} else {
|
|
} else {
|
|
- s.setPassword(BasicConsts.DEFAULT_PASSWORD);
|
|
|
|
|
|
+ passwd = BasicConsts.DEFAULT_PASSWORD;
|
|
}
|
|
}
|
|
|
|
+ byte[] bytes = SHA256.encode(identityNumber + passwd);
|
|
|
|
+ String encodePassword = ByteUtil.toHexAscii(bytes);
|
|
|
|
+ s.setPassword(encodePassword);
|
|
s.setUpdateTime(new Date());
|
|
s.setUpdateTime(new Date());
|
|
studentRepo.save(s);
|
|
studentRepo.save(s);
|
|
//操作日志
|
|
//操作日志
|
|
- ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(),s.getId(), null, UserType.COMMON,
|
|
|
|
- OperateContent.STUDENT_PASSWORD_RESET.getDesc()));
|
|
|
|
|
|
+ ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(), null, UserType.COMMON,
|
|
|
|
+ OperateContent.STUDENT_PASSWORD_RESET.getDesc()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -491,17 +528,21 @@ public class StudentController extends ControllerSupport {
|
|
List<StudentEntity> stuentList = studentRepo.findByOrgId(org.getId());
|
|
List<StudentEntity> stuentList = studentRepo.findByOrgId(org.getId());
|
|
for (StudentEntity s : stuentList) {
|
|
for (StudentEntity s : stuentList) {
|
|
String identityNumber = s.getIdentityNumber();
|
|
String identityNumber = s.getIdentityNumber();
|
|
|
|
+ String passwd = null;
|
|
if (StringUtils.isNotEmpty(identityNumber)
|
|
if (StringUtils.isNotEmpty(identityNumber)
|
|
&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {
|
|
&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {
|
|
- s.setPassword(StringUtils.substring(identityNumber, -6, identityNumber.length()));
|
|
|
|
|
|
+ passwd = StringUtils.substring(identityNumber, -6, identityNumber.length());
|
|
} else {
|
|
} else {
|
|
- s.setPassword(BasicConsts.DEFAULT_PASSWORD);
|
|
|
|
|
|
+ passwd = BasicConsts.DEFAULT_PASSWORD;
|
|
}
|
|
}
|
|
|
|
+ byte[] bytes = SHA256.encode(identityNumber + passwd);
|
|
|
|
+ String encodePassword = ByteUtil.toHexAscii(bytes);
|
|
|
|
+ s.setPassword(encodePassword);
|
|
s.setUpdateTime(new Date());
|
|
s.setUpdateTime(new Date());
|
|
studentRepo.save(s);
|
|
studentRepo.save(s);
|
|
//操作日志
|
|
//操作日志
|
|
- ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(),s.getId(), null, UserType.COMMON,
|
|
|
|
- OperateContent.STUDENT_PASSWORD_RESET.getDesc()));
|
|
|
|
|
|
+ ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(), null, UserType.COMMON,
|
|
|
|
+ OperateContent.STUDENT_PASSWORD_RESET.getDesc()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -527,11 +568,13 @@ public class StudentController extends ControllerSupport {
|
|
|
|
|
|
StudentEntity s = GlobalHelper.getEntity(studentRepo, accessUser.getUserId(),
|
|
StudentEntity s = GlobalHelper.getEntity(studentRepo, accessUser.getUserId(),
|
|
StudentEntity.class);
|
|
StudentEntity.class);
|
|
- s.setPassword(newPassword);
|
|
|
|
|
|
+ byte[] bytes = SHA256.encode(s.getIdentityNumber() + newPassword);
|
|
|
|
+ String encodePassword = ByteUtil.toHexAscii(bytes);
|
|
|
|
+ s.setPassword(encodePassword);
|
|
studentRepo.save(s);
|
|
studentRepo.save(s);
|
|
//操作日志
|
|
//操作日志
|
|
- ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(),null, UserType.STUDENT,
|
|
|
|
- OperateContent.STUDENT_PASSWORD_UPDATE.getDesc()));
|
|
|
|
|
|
+ ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(), null, UserType.STUDENT,
|
|
|
|
+ OperateContent.STUDENT_PASSWORD_UPDATE.getDesc()));
|
|
return s.getId();
|
|
return s.getId();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -562,14 +605,17 @@ public class StudentController extends ControllerSupport {
|
|
StudentEntity s = GlobalHelper.getEntity(studentRepo, accessUser.getUserId(),
|
|
StudentEntity s = GlobalHelper.getEntity(studentRepo, accessUser.getUserId(),
|
|
StudentEntity.class);
|
|
StudentEntity.class);
|
|
|
|
|
|
- if (StringUtils.isNotBlank(s.getPassword()) && !s.getPassword().equals(password)) {
|
|
|
|
|
|
+ String encodeOldPassword = ByteUtil.toHexAscii(SHA256.encode(s.getIdentityNumber() + password));
|
|
|
|
+ if (StringUtils.isNotBlank(s.getPassword()) && !s.getPassword().equals(encodeOldPassword)) {
|
|
throw new StatusException("450111", "当前密码错误");
|
|
throw new StatusException("450111", "当前密码错误");
|
|
}
|
|
}
|
|
- s.setPassword(newPassword);
|
|
|
|
|
|
+ byte[] bytes = SHA256.encode(s.getIdentityNumber() + newPassword);
|
|
|
|
+ String encodePassword = ByteUtil.toHexAscii(bytes);
|
|
|
|
+ s.setPassword(encodePassword);
|
|
studentRepo.save(s);
|
|
studentRepo.save(s);
|
|
//操作日志
|
|
//操作日志
|
|
- ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(),null, UserType.STUDENT,
|
|
|
|
- OperateContent.STUDENT_PASSWORD_UPDATE.getDesc()));
|
|
|
|
|
|
+ ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(), null, UserType.STUDENT,
|
|
|
|
+ OperateContent.STUDENT_PASSWORD_UPDATE.getDesc()));
|
|
return s.getId();
|
|
return s.getId();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -657,8 +703,8 @@ public class StudentController extends ControllerSupport {
|
|
for (Long cur : studentIdList) {
|
|
for (Long cur : studentIdList) {
|
|
studentCache.remove(cur);
|
|
studentCache.remove(cur);
|
|
//操作日志
|
|
//操作日志
|
|
- ReportsUtil.report(new OperateReport(rootOrgId, getAccessUser().getUserId(),cur, null, UserType.COMMON,
|
|
|
|
- OperateContent.STUDENT_UNBIND_STUDENTCODE.getDesc()));
|
|
|
|
|
|
+ ReportsUtil.report(new OperateReport(rootOrgId, getAccessUser().getUserId(), cur, null, UserType.COMMON,
|
|
|
|
+ OperateContent.STUDENT_UNBIND_STUDENTCODE.getDesc()));
|
|
}
|
|
}
|
|
|
|
|
|
return studentIdList;
|
|
return studentIdList;
|
|
@@ -682,8 +728,8 @@ public class StudentController extends ControllerSupport {
|
|
studentService.unbindSecurityPhone(cur);
|
|
studentService.unbindSecurityPhone(cur);
|
|
StudentEntity s = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
|
|
StudentEntity s = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
|
|
//操作日志
|
|
//操作日志
|
|
- ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(),s.getId(), null, UserType.COMMON,
|
|
|
|
- OperateContent.STUDENT_UNBIND_PHONE.getDesc()));
|
|
|
|
|
|
+ ReportsUtil.report(new OperateReport(s.getRootOrgId(), getAccessUser().getUserId(), s.getId(), null, UserType.COMMON,
|
|
|
|
+ OperateContent.STUDENT_UNBIND_PHONE.getDesc()));
|
|
}
|
|
}
|
|
|
|
|
|
for (Long cur : studentIds) {
|
|
for (Long cur : studentIds) {
|
|
@@ -691,11 +737,11 @@ public class StudentController extends ControllerSupport {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@ApiOperation(value = "学生在线信号", notes = "学生在线信号")
|
|
@ApiOperation(value = "学生在线信号", notes = "学生在线信号")
|
|
@GetMapping("online_signal/{studentId}")
|
|
@GetMapping("online_signal/{studentId}")
|
|
public void onlineSignal(@PathVariable Long studentId) {
|
|
public void onlineSignal(@PathVariable Long studentId) {
|
|
- User accessUser = getAccessUser();
|
|
|
|
|
|
+ User accessUser = getAccessUser();
|
|
|
|
|
|
//在线学生
|
|
//在线学生
|
|
ReportsUtil.report(new OnlineStudentReport(accessUser.getRootOrgId(), studentId));
|
|
ReportsUtil.report(new OnlineStudentReport(accessUser.getRootOrgId(), studentId));
|