|
@@ -8,7 +8,6 @@ import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.transaction.Transactional;
|
|
|
|
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -20,6 +19,7 @@ import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
@@ -43,15 +43,15 @@ import cn.com.qmth.examcloud.commons.web.security.enums.UacPolicy;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.FullUserInfo;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.UserForm;
|
|
|
-import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.UserRoleRelationRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.constants.Consts;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Org;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.UserRoleRelationEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.UserInfo;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.impl.UserServiceImpl;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -76,6 +76,9 @@ public class UserController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
RoleRepo roleRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ UserRoleRelationRepo userRoleRelationRepo;
|
|
|
+
|
|
|
/**
|
|
|
* 重新定义
|
|
|
*
|
|
@@ -154,11 +157,12 @@ public class UserController extends ControllerSupport {
|
|
|
bean.setRootOrgName(rootOrg.getName());
|
|
|
bean.setEnable(next.getEnable());
|
|
|
|
|
|
- List<UserRole> userRoles = next.getUserRoles();
|
|
|
+ List<UserRoleRelationEntity> relationList = userRoleRelationRepo
|
|
|
+ .findAllByUserId(next.getId());
|
|
|
List<String> roleNameList = Lists.newArrayList();
|
|
|
List<Long> roleIdList = Lists.newArrayList();
|
|
|
List<String> roleCodeList = Lists.newArrayList();
|
|
|
- for (UserRole cur : userRoles) {
|
|
|
+ for (UserRoleRelationEntity cur : relationList) {
|
|
|
RoleEntity curRoleEntity = roleRepo.findByCode(cur.getRoleCode());
|
|
|
if (null == curRoleEntity) {
|
|
|
throw new StatusException("B-150002", "角色错误");
|
|
@@ -275,8 +279,7 @@ public class UserController extends ControllerSupport {
|
|
|
userEntity.setPassword(userForm.getPassword());
|
|
|
userEntity.setUpdateTime(new Date());
|
|
|
|
|
|
- List<UserRole> userRoles = Lists.newArrayList();
|
|
|
-
|
|
|
+ List<UserRoleRelationEntity> userRoles = Lists.newArrayList();
|
|
|
List<Long> roleIds = userForm.getRoleIds();
|
|
|
for (Long cur : roleIds) {
|
|
|
RoleEntity curRoleEntity = roleRepo.findOne(cur);
|
|
@@ -286,11 +289,13 @@ public class UserController extends ControllerSupport {
|
|
|
if (curRoleEntity.getCode().equals(RoleMeta.SUPER_ADMIN.getCode())) {
|
|
|
throw new StatusException("B-150007", "不允许新增或修改超级管理员");
|
|
|
}
|
|
|
- UserRole userRole = new UserRole(curRoleEntity.getCode());
|
|
|
- userRoles.add(userRole);
|
|
|
+ UserRoleRelationEntity relation = new UserRoleRelationEntity(userEntity.getId(),
|
|
|
+ curRoleEntity.getId(), curRoleEntity.getCode());
|
|
|
+ userRoles.add(relation);
|
|
|
}
|
|
|
- userEntity.setUserRoles(userRoles);
|
|
|
|
|
|
+ userRoleRelationRepo.deleteByUserId(userEntity.getId());
|
|
|
+ userRoleRelationRepo.save(userRoles);
|
|
|
UserEntity saved = userService.save(userEntity);
|
|
|
|
|
|
return saved.getId();
|
|
@@ -348,7 +353,6 @@ public class UserController extends ControllerSupport {
|
|
|
|
|
|
@ApiOperation(value = "修改用户密码", notes = "修改密码")
|
|
|
@PutMapping("/stu-password")
|
|
|
- @Uac(roles = {RoleMeta.STUDENT}, policy = UacPolicy.IN)
|
|
|
public ResponseEntity stuPassword(@RequestParam("oldPassword") String oldPassword,
|
|
|
@RequestParam("newPassword") String newPassword, HttpServletRequest request) {
|
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
@@ -436,15 +440,6 @@ public class UserController extends ControllerSupport {
|
|
|
return new ResponseEntity(userService.getMarker(accessUser.getRootOrgId()), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "新增评卷员", notes = "新增")
|
|
|
- @PostMapping("/marker")
|
|
|
- public ResponseEntity saveMarker(@RequestParam String loginName, @RequestParam String name,
|
|
|
- HttpServletRequest request) {
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
- return new ResponseEntity(
|
|
|
- userService.saveMarker(accessUser.getRootOrgId(), loginName, name), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
@ApiOperation(value = "查询评卷员带分页", notes = "查询评卷员带分页")
|
|
|
@GetMapping("/all/marker/{curPage}/{pageSize}")
|
|
|
public ResponseEntity getAllMark(@ModelAttribute UserEntity user, @PathVariable Integer curPage,
|