|
|
@@ -1,7 +1,7 @@ |
|
|
|
package com.ningdatech.pmapi.sys.controller; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.ningdatech.basic.auth.AbstractLoginUserUtil; |
|
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.log.annotation.WebLog; |
|
|
|
import com.ningdatech.pmapi.sys.entity.Role; |
|
|
@@ -11,6 +11,7 @@ import com.ningdatech.pmapi.sys.entity.dto.RoleUpdateDTO; |
|
|
|
import com.ningdatech.pmapi.sys.entity.vo.RoleVO; |
|
|
|
import com.ningdatech.pmapi.sys.manage.RoleManage; |
|
|
|
import com.ningdatech.pmapi.sys.service.IRoleService; |
|
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
@@ -20,7 +21,6 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
@@ -58,34 +58,32 @@ public class RoleController { |
|
|
|
@GetMapping("/details") |
|
|
|
public RoleVO getDetails(@Valid @RequestParam Long id) { |
|
|
|
Role role = roleService.getById(id); |
|
|
|
Assert.notNull(role, "角色不存在"); |
|
|
|
RoleVO query = BeanUtil.toBean(role, RoleVO.class); |
|
|
|
if (Objects.isNull(query)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
//菜单 |
|
|
|
// 菜单 |
|
|
|
roleManage.buildMenu(query); |
|
|
|
return query; |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "保存新角色", notes = "保存新角色") |
|
|
|
@PostMapping("/save") |
|
|
|
@WebLog |
|
|
|
@WebLog("保存新角色") |
|
|
|
public RoleVO handlerSave(@Valid @RequestBody RoleSaveDTO data) { |
|
|
|
roleService.saveRole(data, null); |
|
|
|
roleService.saveRole(data, LoginUserUtil.getUserId()); |
|
|
|
return BeanUtil.toBean(data, RoleVO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "编辑角色", notes = "编辑角色") |
|
|
|
@PostMapping("/modify") |
|
|
|
@WebLog |
|
|
|
@WebLog("编辑角色") |
|
|
|
public RoleVO handlerUpdate(@Valid @RequestBody RoleUpdateDTO data) { |
|
|
|
roleService.updateRole(data, AbstractLoginUserUtil.getUserId()); |
|
|
|
roleService.updateRole(data, LoginUserUtil.getUserId()); |
|
|
|
return BeanUtil.toBean(data, RoleVO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "删除角色", notes = "删除角色") |
|
|
|
@PostMapping("/remove") |
|
|
|
@WebLog |
|
|
|
@WebLog("删除角色") |
|
|
|
public Boolean handlerDelete(@Valid @RequestBody List<Long> ids) { |
|
|
|
return roleService.removeByIdWithCache(ids); |
|
|
|
} |
|
|
|