瀏覽代碼

。。。

wangwei 7 年之前
父節點
當前提交
31a92d0089

+ 15 - 8
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/UserController.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -32,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
@@ -213,7 +215,7 @@ public class UserController extends ControllerSupport {
 	 */
 	@ApiOperation(value = "新增用户", notes = "新增")
 	@PostMapping
-	public Long addUser(@RequestBody UserForm userForm) {
+	public Map<String, Object> addUser(@RequestBody UserForm userForm) {
 		userForm.setId(null);
 		return insertOrUpdateUser(userForm);
 	}
@@ -227,7 +229,7 @@ public class UserController extends ControllerSupport {
 	 */
 	@ApiOperation(value = "更新用户", notes = "更新")
 	@PutMapping
-	public Long updateUser(@RequestBody UserForm userForm) {
+	public Map<String, Object> updateUser(@RequestBody UserForm userForm) {
 		if (null == userForm.getId()) {
 			throw new StatusException("B-150009", "user ID is null");
 		}
@@ -253,7 +255,7 @@ public class UserController extends ControllerSupport {
 	 * @param userForm
 	 * @return
 	 */
-	private Long insertOrUpdateUser(UserForm userForm) {
+	private Map<String, Object> insertOrUpdateUser(UserForm userForm) {
 		cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
 		Long rootOrgId = userForm.getRootOrgId();
 		Org rootOrg = orgRepo.findOne(rootOrgId);
@@ -279,6 +281,8 @@ public class UserController extends ControllerSupport {
 		userEntity.setPassword(userForm.getPassword());
 		userEntity.setUpdateTime(new Date());
 
+		UserEntity saved = userService.save(userEntity);
+
 		List<UserRoleRelationEntity> userRoles = Lists.newArrayList();
 		List<Long> roleIds = userForm.getRoleIds();
 		for (Long cur : roleIds) {
@@ -289,16 +293,19 @@ public class UserController extends ControllerSupport {
 			if (curRoleEntity.getCode().equals(RoleMeta.SUPER_ADMIN.getCode())) {
 				throw new StatusException("B-150007", "不允许新增或修改超级管理员");
 			}
-			UserRoleRelationEntity relation = new UserRoleRelationEntity(userEntity.getId(),
+			UserRoleRelationEntity relation = new UserRoleRelationEntity(saved.getId(),
 					curRoleEntity.getId(), curRoleEntity.getCode());
 			userRoles.add(relation);
 		}
 
-		userRoleRelationRepo.deleteByUserId(userEntity.getId());
-		userRoleRelationRepo.save(userRoles);
-		UserEntity saved = userService.save(userEntity);
+		userRoleRelationRepo.deleteByUserId(saved.getId());
+		List<UserRoleRelationEntity> savedRelationList = userRoleRelationRepo.save(userRoles);
 
-		return saved.getId();
+		Map<String, Object> ret = Maps.newHashMap();
+		ret.put("userId", saved.getId());
+		ret.put("loginName", saved.getLoginName());
+		ret.put("roleList", savedRelationList);
+		return ret;
 	}
 
 	@ApiOperation(value = "重置用户密码", notes = "重置密码")

+ 1 - 1
sql/云平台2.0升级-数据割接-基础信息.sql

@@ -1,8 +1,8 @@
+--删除ecs_core_user的scope,type字段
 update ecs_core_user t set t.type='COMMON' where t.type='NOT_STUDENT';
 
 update ecs_core_org t set t.type='QMTH' where t.type='PRINT_QMTH';
 update ecs_core_org t set t.type='PRINTER' where t.type='PRINT_SUPPLIER';
-
 update ecs_core_org t set t.parent_id=null ,t.root_id=t.id where t.parent_id=0;
 
 --删除ecs_exam_student,ecs_core_user_role的外键 user_id