|
@@ -4,6 +4,8 @@ import com.github.pagehelper.PageInfo;
|
|
|
import com.xiaoan.common.constant.MsgCode;
|
|
|
import com.xiaoan.common.model.PageDto;
|
|
|
import com.xiaoan.common.util.ResultJson;
|
|
|
+import com.xiaoan.dao.backend.RoleRepository;
|
|
|
+import com.xiaoan.dao.backend.UserRepository;
|
|
|
import com.xiaoan.domain.backend.DepartmentEntity;
|
|
|
import com.xiaoan.domain.backend.RoleEntity;
|
|
|
import com.xiaoan.domain.dto.request.RoleRequest;
|
|
@@ -11,6 +13,7 @@ import com.xiaoan.service.backend.RoleService;
|
|
|
import com.xiaoan.web.aop.WebControllerLog;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -29,6 +32,7 @@ import java.util.List;
|
|
|
* Created by owen on 2020/2/18 0018 12:17
|
|
|
* 需要admin权限
|
|
|
*/
|
|
|
+@Log4j2
|
|
|
@Api(tags = "RoleController", description = "后台角色管理")
|
|
|
@RestController
|
|
|
@RequestMapping("api/manage/role")
|
|
@@ -39,6 +43,9 @@ public class RoleController extends BaseController {
|
|
|
@Autowired
|
|
|
private RoleService roleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RoleRepository roleRepository;
|
|
|
+
|
|
|
@WebControllerLog(description = "角色权限-查询列表")
|
|
|
@ApiOperation("分页获取角色列表/搜索")
|
|
|
// @PostMapping("list")
|
|
@@ -67,27 +74,46 @@ public class RoleController extends BaseController {
|
|
|
@ApiOperation("新增或修改角色信息")
|
|
|
@PostMapping("save")
|
|
|
public ResultJson save(@RequestBody RoleRequest param){
|
|
|
- RoleEntity roleEntity = null;
|
|
|
+// RoleEntity roleEntity = null;
|
|
|
+// int n = 0;
|
|
|
+// if (param.getId() != null) {
|
|
|
+// roleEntity = roleService.findById(param.getId());
|
|
|
+// if(roleEntity == null){
|
|
|
+// return new ResultJson(MsgCode.FAILURE_CODE_6001, MsgCode.FAILURE_MSG_6001);
|
|
|
+// }
|
|
|
+// // 每次修改,删除角色资源表信息,重新添加
|
|
|
+// roleService.deleteRoleResource(param.getId());
|
|
|
+//
|
|
|
+// BeanUtils.copyProperties(param, roleEntity);
|
|
|
+// n = roleService.update(roleEntity);
|
|
|
+// }else {
|
|
|
+// roleEntity = new RoleEntity();
|
|
|
+//
|
|
|
+// BeanUtils.copyProperties(param, roleEntity);
|
|
|
+// roleEntity.setUpdateTime(new Date());
|
|
|
+//
|
|
|
+//
|
|
|
+// n = roleService.save(roleEntity);
|
|
|
+// }
|
|
|
+
|
|
|
+ RoleEntity roleEntity = roleService.findById(param.getId());
|
|
|
+
|
|
|
int n = 0;
|
|
|
- if (param.getId() != null) {
|
|
|
- roleEntity = roleService.findById(param.getId());
|
|
|
- if(roleEntity == null){
|
|
|
- return new ResultJson(MsgCode.FAILURE_CODE_6001, MsgCode.FAILURE_MSG_6001);
|
|
|
- }
|
|
|
- // 每次修改,删除角色资源表信息,重新添加
|
|
|
- roleService.deleteRoleResource(param.getId());
|
|
|
|
|
|
- BeanUtils.copyProperties(param, roleEntity);
|
|
|
- n = roleService.update(roleEntity);
|
|
|
- }else {
|
|
|
+ if (roleEntity == null) {
|
|
|
roleEntity = new RoleEntity();
|
|
|
+ // 保存的时候,如果有id,会出错
|
|
|
+ param.setId(null);
|
|
|
+ BeanUtils.copyProperties(param, roleEntity);
|
|
|
+ n = roleService.save(roleEntity);
|
|
|
|
|
|
+ } else {
|
|
|
BeanUtils.copyProperties(param, roleEntity);
|
|
|
roleEntity.setUpdateTime(new Date());
|
|
|
+ n = roleService.update(roleEntity);
|
|
|
|
|
|
-// roleEntity.setCreateBy(getTokenUserName());
|
|
|
-
|
|
|
- n = roleService.save(roleEntity);
|
|
|
+ // 每次修改,删除角色资源表信息,重新添加
|
|
|
+ roleService.deleteRoleResource(param.getId());
|
|
|
}
|
|
|
|
|
|
if (n >= 0){
|