Commit 6fa6292c by huangjinxin

fix:实验代码

1 parent e655fe84
...@@ -31,6 +31,16 @@ public interface IRole { ...@@ -31,6 +31,16 @@ public interface IRole {
/** /**
* 添加角色
*
* @param roleInfo 角色信息
* @return
*/
@RequestMapping(value = "/pea-user/role/delete2", method = RequestMethod.POST)
Result<RoleInfo> deleteRole2(@RequestBody RoleInfo roleInfo);
/**
* 修改角色 * 修改角色
* *
* @param roleInfo 角色信息 * @param roleInfo 角色信息
......
...@@ -40,6 +40,14 @@ public class RoleController implements IRole { ...@@ -40,6 +40,14 @@ public class RoleController implements IRole {
} }
@Override
public Result<RoleInfo> deleteRole2(@Validated RoleInfo roleInfo) {
roleInfo = roleService.addRole(roleInfo);
return Result.success(roleInfo);
}
@Override @Override
public Result<RoleInfo> updateRole(@Validated RoleInfo roleInfo) { public Result<RoleInfo> updateRole(@Validated RoleInfo roleInfo) {
roleInfo = roleService.updateRole(roleInfo); roleInfo = roleService.updateRole(roleInfo);
......
...@@ -114,9 +114,6 @@ public class RoleService { ...@@ -114,9 +114,6 @@ public class RoleService {
public void deleteRole(String roleId) { public void deleteRole(String roleId) {
// 查询角色是否存在 // 查询角色是否存在
RoleEntity roleEntity = roleDao.findById(roleId).orElse(null); RoleEntity roleEntity = roleDao.findById(roleId).orElse(null);
roleEntity.setUpdatedTime(new Date());
roleEntity.setNotes("chakhca");
roleDao.save(roleEntity);
if (ObjectUtil.isNull(roleEntity)) { if (ObjectUtil.isNull(roleEntity)) {
throw new BusinessException(StatusCodeEnum.ROLE_DOES_NOT_EXIST); throw new BusinessException(StatusCodeEnum.ROLE_DOES_NOT_EXIST);
} }
...@@ -128,6 +125,33 @@ public class RoleService { ...@@ -128,6 +125,33 @@ public class RoleService {
roleResourceDao.deleteByRoleId(roleId); roleResourceDao.deleteByRoleId(roleId);
} }
@Transactional(rollbackFor = Exception.class)
public RoleInfo deleteRole2(RoleInfo roleInfo) {
String name = roleInfo.getName();
String createdBy = roleInfo.getCreatedBy();
String notes = roleInfo.getNotes();
RoleEntity roleEntity = new RoleEntity();
roleEntity.setName(name);
roleEntity.setCreatedBy(createdBy);
roleEntity.setCreatedTime(new Date());
roleEntity.setNotes(notes);
// RoleEntity roleEntity = assembleRole(roleInfo);
log.info("新增角色入参:" + JSONObject.toJSONString(roleEntity));
roleEntity = roleDao.save(roleEntity);
// roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
roleInfo.setId(roleEntity.getId());
List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
if (CollectionUtils.isNotEmpty(resourceInfos)) {
for (RoleResourceInfo resourceInfo : resourceInfos) {
RoleResourceEntity roleResourceEntity = assembleRoleResource(roleInfo.getId(), resourceInfo.getResourceId());
roleResourceDao.save(roleResourceEntity);
}
}
log.info("新增角色信息:" + JSONObject.toJSONString(roleInfo));
return roleInfo;
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addUserRole(String roleId, String userId) { public void addUserRole(String roleId, String userId) {
// 查询角色是否存在 // 查询角色是否存在
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!