mirror of https://gitee.com/stylefeng/roses
【8.0.1】【system】更新角色维护的日志
parent
310d3dd186
commit
95e3e0f5fb
|
@ -17,6 +17,13 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!--日志相关api-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.stylefeng.roses</groupId>
|
||||||
|
<artifactId>log-api</artifactId>
|
||||||
|
<version>${roses.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 数据源容器 -->
|
<!-- 数据源容器 -->
|
||||||
<!-- 用来获取当前的数据源的类型 -->
|
<!-- 用来获取当前的数据源的类型 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.stylefeng.roses.kernel.sys.modular.role.controller;
|
package cn.stylefeng.roses.kernel.sys.modular.role.controller;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.annotation.BizLog;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||||
|
@ -38,6 +39,7 @@ public class SysRoleController {
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "添加角色", path = "/sysRole/add", requiredPermission = true,
|
@PostResource(name = "添加角色", path = "/sysRole/add", requiredPermission = true,
|
||||||
requirePermissionCode = PermissionCodeConstants.ADD_ROLE)
|
requirePermissionCode = PermissionCodeConstants.ADD_ROLE)
|
||||||
|
@BizLog(logTypeCode = PermissionCodeConstants.ADD_ROLE)
|
||||||
public ResponseData<SysRole> add(@RequestBody @Validated(SysRoleRequest.add.class) SysRoleRequest sysRoleRequest) {
|
public ResponseData<SysRole> add(@RequestBody @Validated(SysRoleRequest.add.class) SysRoleRequest sysRoleRequest) {
|
||||||
sysRoleService.add(sysRoleRequest);
|
sysRoleService.add(sysRoleRequest);
|
||||||
return new SuccessResponseData<>();
|
return new SuccessResponseData<>();
|
||||||
|
@ -51,6 +53,7 @@ public class SysRoleController {
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "删除角色", path = "/sysRole/delete", requiredPermission = true,
|
@PostResource(name = "删除角色", path = "/sysRole/delete", requiredPermission = true,
|
||||||
requirePermissionCode = PermissionCodeConstants.DELETE_ROLE)
|
requirePermissionCode = PermissionCodeConstants.DELETE_ROLE)
|
||||||
|
@BizLog(logTypeCode = PermissionCodeConstants.DELETE_ROLE)
|
||||||
public ResponseData<?> delete(@RequestBody @Validated(SysRoleRequest.delete.class) SysRoleRequest sysRoleRequest) {
|
public ResponseData<?> delete(@RequestBody @Validated(SysRoleRequest.delete.class) SysRoleRequest sysRoleRequest) {
|
||||||
sysRoleService.del(sysRoleRequest);
|
sysRoleService.del(sysRoleRequest);
|
||||||
return new SuccessResponseData<>();
|
return new SuccessResponseData<>();
|
||||||
|
@ -64,6 +67,7 @@ public class SysRoleController {
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "批量删除角色", path = "/sysRole/batchDelete", requiredPermission = true,
|
@PostResource(name = "批量删除角色", path = "/sysRole/batchDelete", requiredPermission = true,
|
||||||
requirePermissionCode = PermissionCodeConstants.DELETE_ROLE)
|
requirePermissionCode = PermissionCodeConstants.DELETE_ROLE)
|
||||||
|
@BizLog(logTypeCode = PermissionCodeConstants.DELETE_ROLE)
|
||||||
public ResponseData<?> batchDelete(@RequestBody @Validated(SysRoleRequest.batchDelete.class) SysRoleRequest sysRoleRequest) {
|
public ResponseData<?> batchDelete(@RequestBody @Validated(SysRoleRequest.batchDelete.class) SysRoleRequest sysRoleRequest) {
|
||||||
sysRoleService.batchDelete(sysRoleRequest);
|
sysRoleService.batchDelete(sysRoleRequest);
|
||||||
return new SuccessResponseData<>();
|
return new SuccessResponseData<>();
|
||||||
|
@ -77,6 +81,7 @@ public class SysRoleController {
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "编辑角色", path = "/sysRole/edit", requiredPermission = true,
|
@PostResource(name = "编辑角色", path = "/sysRole/edit", requiredPermission = true,
|
||||||
requirePermissionCode = PermissionCodeConstants.EDIT_ROLE)
|
requirePermissionCode = PermissionCodeConstants.EDIT_ROLE)
|
||||||
|
@BizLog(logTypeCode = PermissionCodeConstants.EDIT_ROLE)
|
||||||
public ResponseData<?> edit(@RequestBody @Validated(SysRoleRequest.edit.class) SysRoleRequest sysRoleRequest) {
|
public ResponseData<?> edit(@RequestBody @Validated(SysRoleRequest.edit.class) SysRoleRequest sysRoleRequest) {
|
||||||
sysRoleService.edit(sysRoleRequest);
|
sysRoleService.edit(sysRoleRequest);
|
||||||
return new SuccessResponseData<>();
|
return new SuccessResponseData<>();
|
||||||
|
|
|
@ -9,6 +9,7 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
|
import cn.stylefeng.roses.kernel.log.api.util.BusinessLogUtil;
|
||||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||||
import cn.stylefeng.roses.kernel.sys.api.SysUserRoleServiceApi;
|
import cn.stylefeng.roses.kernel.sys.api.SysUserRoleServiceApi;
|
||||||
|
@ -53,6 +54,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
sysRole.setDataScopeType(DataScopeTypeEnum.ALL.getCode());
|
sysRole.setDataScopeType(DataScopeTypeEnum.ALL.getCode());
|
||||||
|
|
||||||
this.save(sysRole);
|
this.save(sysRole);
|
||||||
|
|
||||||
|
// 添加日志
|
||||||
|
BusinessLogUtil.setLogTitle("添加角色,角色名称:", sysRoleRequest.getRoleName());
|
||||||
|
BusinessLogUtil.addContent("角色信息详情如下:\n", sysRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,6 +79,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
|
|
||||||
// 删除角色
|
// 删除角色
|
||||||
this.baseDelete(CollectionUtil.set(false, sysRole.getRoleId()));
|
this.baseDelete(CollectionUtil.set(false, sysRole.getRoleId()));
|
||||||
|
|
||||||
|
// 添加日志
|
||||||
|
BusinessLogUtil.setLogTitle("删除角色,角色名称:", sysRole.getRoleName());
|
||||||
|
BusinessLogUtil.addContent("角色信息详情如下:\n", sysRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -102,12 +111,20 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
|
|
||||||
// 执行删除角色
|
// 执行删除角色
|
||||||
this.baseDelete(sysRoleRequest.getRoleIdList());
|
this.baseDelete(sysRoleRequest.getRoleIdList());
|
||||||
|
|
||||||
|
// 添加日志
|
||||||
|
BusinessLogUtil.setLogTitle("批量删除角色");
|
||||||
|
BusinessLogUtil.addContent("角色id集合如下:\n", sysRoleRequest.getRoleIdList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void edit(SysRoleRequest sysRoleRequest) {
|
public void edit(SysRoleRequest sysRoleRequest) {
|
||||||
SysRole sysRole = this.querySysRole(sysRoleRequest);
|
SysRole sysRole = this.querySysRole(sysRoleRequest);
|
||||||
|
|
||||||
|
// 添加日志
|
||||||
|
BusinessLogUtil.setLogTitle("修改角色信息");
|
||||||
|
BusinessLogUtil.addContent("原角色信息如下:\n", sysRole);
|
||||||
|
|
||||||
// 不允许修改角色编码
|
// 不允许修改角色编码
|
||||||
if (!sysRole.getRoleCode().equals(sysRoleRequest.getRoleCode())) {
|
if (!sysRole.getRoleCode().equals(sysRoleRequest.getRoleCode())) {
|
||||||
throw new ServiceException(SysRoleExceptionEnum.SUPER_ADMIN_ROLE_CODE_ERROR);
|
throw new ServiceException(SysRoleExceptionEnum.SUPER_ADMIN_ROLE_CODE_ERROR);
|
||||||
|
@ -115,6 +132,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||||
|
|
||||||
BeanUtil.copyProperties(sysRoleRequest, sysRole);
|
BeanUtil.copyProperties(sysRoleRequest, sysRole);
|
||||||
this.updateById(sysRole);
|
this.updateById(sysRole);
|
||||||
|
|
||||||
|
BusinessLogUtil.addContent("修改后角色信息如下:\n", sysRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue