REQ-2821: 添加一些日志
This commit is contained in:
parent
5b028831a5
commit
615e2e21e0
@ -54,10 +54,15 @@ public enum PermissionRelationOperateLogSceneEnum {
|
|||||||
OLD_OMS_PRODUCT_PERMISSION_POINT__UPDATE("OLD_OMS_PRODUCT_PERMISSION_POINT__UPDATE", "[老]oms后台更新产品权限点"),
|
OLD_OMS_PRODUCT_PERMISSION_POINT__UPDATE("OLD_OMS_PRODUCT_PERMISSION_POINT__UPDATE", "[老]oms后台更新产品权限点"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [老]角色分组
|
* [老]角色分组新增/更新
|
||||||
*/
|
*/
|
||||||
OLD_OMS_ROLE_GROUP__SAVE_OR_UPDATE("OLD_OMS_ROLE_GROUP__SAVE_OR_UPDATE", "[老]角色分组新增/更新"),
|
OLD_OMS_ROLE_GROUP__SAVE_OR_UPDATE("OLD_OMS_ROLE_GROUP__SAVE_OR_UPDATE", "[老]角色分组新增/更新"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [老]角色分组删除
|
||||||
|
*/
|
||||||
|
OLD_OMS_ROLE_GROUP__DELETE("OLD_OMS_ROLE_GROUP__DELETE", "[老]角色分组删除"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [老]权限点删除
|
* [老]权限点删除
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import cn.axzo.framework.domain.web.result.ApiResult;
|
|||||||
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
||||||
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
||||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||||
|
import cn.axzo.tyr.client.model.req.SaasRoleGroupDeleteRequest;
|
||||||
import cn.axzo.tyr.client.model.req.UpdateRoleGroupOffsetReq;
|
import cn.axzo.tyr.client.model.req.UpdateRoleGroupOffsetReq;
|
||||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||||
@ -57,6 +58,14 @@ public interface SaasRoleGroupApi {
|
|||||||
@PostMapping("/api/saasRoleGroup/delete")
|
@PostMapping("/api/saasRoleGroup/delete")
|
||||||
ApiResult<Void> delete(@RequestParam @NotEmpty List<Long> ids);
|
ApiResult<Void> delete(@RequestParam @NotEmpty List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除角色分组
|
||||||
|
* @param request 角色分组ID
|
||||||
|
* @return 返回删除角色分组状态
|
||||||
|
*/
|
||||||
|
@PostMapping("/api/saasRoleGroup/v2/delete")
|
||||||
|
ApiResult<Void> deleteV2(@RequestBody @Valid SaasRoleGroupDeleteRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 通过categoryCode查询分组
|
* 通过categoryCode查询分组
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
package cn.axzo.tyr.client.model.req;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.client.model.vo.OperatorRequest;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yanglin
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class SaasRoleGroupDeleteRequest extends OperatorRequest {
|
||||||
|
|
||||||
|
@NotEmpty(message = "ids不能为空")
|
||||||
|
private List<Long> ids;
|
||||||
|
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ import cn.axzo.tyr.client.feign.SaasRoleGroupApi;
|
|||||||
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
||||||
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
||||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||||
|
import cn.axzo.tyr.client.model.req.SaasRoleGroupDeleteRequest;
|
||||||
import cn.axzo.tyr.client.model.req.UpdateRoleGroupOffsetReq;
|
import cn.axzo.tyr.client.model.req.UpdateRoleGroupOffsetReq;
|
||||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||||
@ -56,6 +57,12 @@ public class SaasRoleGroupController implements SaasRoleGroupApi {
|
|||||||
return ApiResult.ok(roleGroups.get(0));
|
return ApiResult.ok(roleGroups.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<Void> deleteV2(SaasRoleGroupDeleteRequest request) {
|
||||||
|
saasRoleGroupService.deleteV2(request);
|
||||||
|
return ApiResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResult<Void> delete(List<Long> ids) {
|
public ApiResult<Void> delete(List<Long> ids) {
|
||||||
saasRoleGroupService.delete(ids);
|
saasRoleGroupService.delete(ids);
|
||||||
|
|||||||
@ -3,9 +3,21 @@ package cn.axzo.tyr.server.repository.mapper;
|
|||||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SaasRoleGroupMapper extends BaseMapper<SaasRoleGroup> {
|
public interface SaasRoleGroupMapper extends BaseMapper<SaasRoleGroup> {
|
||||||
|
|
||||||
|
@Select("<script>SELECT * FROM saas_role_group WHERE id IN\n" +
|
||||||
|
" <foreach collection=\"ids\" item=\"id\" open=\"(\" separator=\",\" close=\")\">\n" +
|
||||||
|
" #{id}\n" +
|
||||||
|
" </foreach>\n" +
|
||||||
|
"</script>")
|
||||||
|
List<SaasRoleGroup> getByIdsDeleteAware(
|
||||||
|
@Param("ids") List<Long> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import cn.axzo.foundation.page.PageResp;
|
|||||||
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
||||||
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
||||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||||
|
import cn.axzo.tyr.client.model.req.SaasRoleGroupDeleteRequest;
|
||||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
||||||
@ -32,6 +33,8 @@ public interface SaasRoleGroupService extends IService<SaasRoleGroup> {
|
|||||||
|
|
||||||
void delete(List<Long> ids);
|
void delete(List<Long> ids);
|
||||||
|
|
||||||
|
void deleteV2(SaasRoleGroupDeleteRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分组CODE查询角色分组
|
* 分组CODE查询角色分组
|
||||||
* @param categoryCode
|
* @param categoryCode
|
||||||
|
|||||||
@ -6,16 +6,20 @@ import cn.axzo.foundation.dao.support.converter.PageConverter;
|
|||||||
import cn.axzo.foundation.dao.support.mysql.QueryWrapperHelper;
|
import cn.axzo.foundation.dao.support.mysql.QueryWrapperHelper;
|
||||||
import cn.axzo.foundation.exception.Axssert;
|
import cn.axzo.foundation.exception.Axssert;
|
||||||
import cn.axzo.foundation.page.PageResp;
|
import cn.axzo.foundation.page.PageResp;
|
||||||
|
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||||
import cn.axzo.tyr.client.common.enums.PermissionRelationOperateLogSceneEnum;
|
import cn.axzo.tyr.client.common.enums.PermissionRelationOperateLogSceneEnum;
|
||||||
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
||||||
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
||||||
import cn.axzo.tyr.client.model.req.PermissionOperateLogReq;
|
import cn.axzo.tyr.client.model.req.PermissionOperateLogReq;
|
||||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||||
|
import cn.axzo.tyr.client.model.req.SaasRoleGroupDeleteRequest;
|
||||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||||
import cn.axzo.tyr.client.model.res.SaasRoleRes;
|
import cn.axzo.tyr.client.model.res.SaasRoleRes;
|
||||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||||
|
import cn.axzo.tyr.server.model.BasicRoleDO;
|
||||||
import cn.axzo.tyr.server.repository.dao.SaasRoleGroupDao;
|
import cn.axzo.tyr.server.repository.dao.SaasRoleGroupDao;
|
||||||
import cn.axzo.tyr.server.repository.dao.SaasRoleGroupRelationDao;
|
import cn.axzo.tyr.server.repository.dao.SaasRoleGroupRelationDao;
|
||||||
|
import cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelationOperateLog;
|
||||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
||||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
|
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
|
||||||
import cn.axzo.tyr.server.repository.mapper.SaasRoleGroupMapper;
|
import cn.axzo.tyr.server.repository.mapper.SaasRoleGroupMapper;
|
||||||
@ -23,8 +27,10 @@ import cn.axzo.tyr.server.service.RoleService;
|
|||||||
import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationOperateLogService;
|
import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationOperateLogService;
|
||||||
import cn.axzo.tyr.server.service.SaasRoleGroupRelationService;
|
import cn.axzo.tyr.server.service.SaasRoleGroupRelationService;
|
||||||
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
||||||
|
import cn.azxo.framework.common.constatns.Constants;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@ -34,6 +40,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.MDC;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -57,6 +64,8 @@ import static cn.axzo.tyr.server.config.exception.BizResultCode.CANT_DELETE_ROLE
|
|||||||
@Service
|
@Service
|
||||||
public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, SaasRoleGroup>
|
public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, SaasRoleGroup>
|
||||||
implements SaasRoleGroupService {
|
implements SaasRoleGroupService {
|
||||||
|
|
||||||
|
private final SaasRoleGroupMapper saasRoleGroupMapper;
|
||||||
private final SaasRoleGroupDao saasRoleGroupDao;
|
private final SaasRoleGroupDao saasRoleGroupDao;
|
||||||
private final SaasRoleGroupRelationDao saasRoleGroupRelationDao;
|
private final SaasRoleGroupRelationDao saasRoleGroupRelationDao;
|
||||||
private final SaasRoleGroupRelationService saasRoleGroupRelationService;
|
private final SaasRoleGroupRelationService saasRoleGroupRelationService;
|
||||||
@ -134,18 +143,18 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
|
|||||||
SaasRoleGroup saasRoleGroup = validAndBuildGroup(req);
|
SaasRoleGroup saasRoleGroup = validAndBuildGroup(req);
|
||||||
saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
|
saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
|
||||||
try {
|
try {
|
||||||
saveOperateLogForRoleGroup(req);
|
saveOperateLogForInsertOrUpdate(req, saasRoleGroup);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("error save operate log", e);
|
log.warn("error save operate log", e);
|
||||||
}
|
}
|
||||||
return saasRoleGroup.getId();
|
return saasRoleGroup.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveOperateLogForRoleGroup(SaasRoleGroupVO req) {
|
private void saveOperateLogForInsertOrUpdate(SaasRoleGroupVO req, SaasRoleGroup saasRoleGroup) {
|
||||||
PermissionOperateLogReq log = new PermissionOperateLogReq();
|
PermissionOperateLogReq log = new PermissionOperateLogReq();
|
||||||
log.setTableName(SaasPgroupPermissionRelationOperateLogServiceImpl.TABLE_NAME_SAAS_ROLE_GROUP);
|
log.setTableName(SaasPgroupPermissionRelationOperateLogServiceImpl.TABLE_NAME_SAAS_ROLE_GROUP);
|
||||||
log.setScene(PermissionRelationOperateLogSceneEnum.OLD_OMS_ROLE_GROUP__SAVE_OR_UPDATE.getValue());
|
log.setScene(PermissionRelationOperateLogSceneEnum.OLD_OMS_ROLE_GROUP__SAVE_OR_UPDATE.getValue());
|
||||||
log.setSceneId(req.getId() + "");
|
log.setSceneId(saasRoleGroup.getId() + "");
|
||||||
log.setOperatorId(req.determineOperator().getPersonId());
|
log.setOperatorId(req.determineOperator().getPersonId());
|
||||||
log.setRequestData(req);
|
log.setRequestData(req);
|
||||||
SaasRoleGroup updateToDateRoleGroup = saasRoleGroupDao.getById(req.getId());
|
SaasRoleGroup updateToDateRoleGroup = saasRoleGroupDao.getById(req.getId());
|
||||||
@ -153,12 +162,20 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
|
|||||||
saasPgroupPermissionRelationOperateLogService.save(log);
|
saasPgroupPermissionRelationOperateLogService.save(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 只有当分组下面角色为空合分组下没有其他分组时才能删除
|
|
||||||
* @param ids
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(List<Long> ids) {
|
public void delete(List<Long> ids) {
|
||||||
|
SaasRoleGroupDeleteRequest request = new SaasRoleGroupDeleteRequest();
|
||||||
|
request.setIds(ids);
|
||||||
|
deleteV2(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只有当分组下面角色为空合分组下没有其他分组时才能删除
|
||||||
|
* @param request
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteV2(SaasRoleGroupDeleteRequest request) {
|
||||||
|
List<Long> ids = request.getIds();
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -177,6 +194,41 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
|
|||||||
Axssert.check(CollectionUtils.isEmpty(childrenRoleGroups), CANT_DELETE_ROLE_GROUP);
|
Axssert.check(CollectionUtils.isEmpty(childrenRoleGroups), CANT_DELETE_ROLE_GROUP);
|
||||||
|
|
||||||
saasRoleGroupDao.delete(ids);
|
saasRoleGroupDao.delete(ids);
|
||||||
|
|
||||||
|
try {
|
||||||
|
saveOperateLogForDelete(request);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("error save operate log", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveOperateLogForDelete(SaasRoleGroupDeleteRequest request) {
|
||||||
|
List<Long> ids = request.getIds();
|
||||||
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<Long, SaasRoleGroup> id2Group = saasRoleGroupMapper.getByIdsDeleteAware(ids)
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toMap(BaseEntity::getId, Function.identity()));
|
||||||
|
ArrayList<SaasPgroupPermissionRelationOperateLog> logs = new ArrayList<>();
|
||||||
|
List<BasicRoleDO> personBasicRoles = saasPgroupPermissionRelationOperateLogService
|
||||||
|
.getPersonBasicRoles(request.determineOperator().getPersonId());
|
||||||
|
for (Long id : ids) {
|
||||||
|
SaasRoleGroup group = id2Group.get(id);
|
||||||
|
SaasPgroupPermissionRelationOperateLog log = SaasPgroupPermissionRelationOperateLog.builder()
|
||||||
|
.tableName(SaasPgroupPermissionRelationOperateLogServiceImpl.TABLE_NAME_SAAS_ROLE_GROUP)
|
||||||
|
.scene(PermissionRelationOperateLogSceneEnum.OLD_OMS_ROLE_GROUP__DELETE.getValue())
|
||||||
|
.sceneId(id + "")
|
||||||
|
.createBy(request.determineOperator().getPersonId())
|
||||||
|
.createByName(request.determineOperator().getRealName())
|
||||||
|
.traceId(MDC.get(Constants.CTX_LOG_ID_MDC))
|
||||||
|
.requestData(JSONObject.toJSONString(request))
|
||||||
|
.operateData(JSONObject.toJSONString(group))
|
||||||
|
.createByRole(JSONObject.toJSONString(personBasicRoles))
|
||||||
|
.build();
|
||||||
|
logs.add(log);
|
||||||
|
}
|
||||||
|
saasPgroupPermissionRelationOperateLogService.batchSave(logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SaasRoleGroup validAndBuildGroup(SaasRoleGroupVO req) {
|
private SaasRoleGroup validAndBuildGroup(SaasRoleGroupVO req) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user