⚡ 批量删除后端服务.
This commit is contained in:
@@ -98,6 +98,15 @@ public class ExecJobController {
|
||||
return execJobService.deleteExecJobById(id);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecJobOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除计划任务")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-job:delete')")
|
||||
public Integer batchDeleteExecJob(@RequestParam("idList") List<Long> idList) {
|
||||
return execJobService.deleteExecJobByIdList(idList);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecJobOperatorType.TRIGGER)
|
||||
@PostMapping("/trigger")
|
||||
@Operation(summary = "手动触发计划任务")
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 执行模板 api
|
||||
@@ -92,5 +93,14 @@ public class ExecTemplateController {
|
||||
return execTemplateService.deleteExecTemplateById(id);
|
||||
}
|
||||
|
||||
@OperatorLog(ExecTemplateOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除执行模板")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:exec-template:delete')")
|
||||
public Integer batchDeleteExecTemplate(@RequestParam("idList") List<Long> idList) {
|
||||
return execTemplateService.deleteExecTemplateByIdList(idList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -96,5 +96,15 @@ public class HostController {
|
||||
return hostService.deleteHostById(id);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(HostOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除主机")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:host:delete')")
|
||||
public Integer batchDeleteHost(@RequestParam("idList") List<Long> idList) {
|
||||
return hostService.deleteHostByIdList(idList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -97,5 +97,15 @@ public class HostIdentityController {
|
||||
return hostIdentityService.deleteHostIdentityById(id);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(HostIdentityOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除主机身份")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-identity:delete')")
|
||||
public Integer batchDeleteHostIdentity(@RequestParam("idList") List<Long> idList) {
|
||||
return hostIdentityService.deleteHostIdentityByIdList(idList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -96,5 +96,15 @@ public class HostKeyController {
|
||||
return hostKeyService.deleteHostKeyById(id);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(HostKeyOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除主机密钥")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('asset:host-key:delete')")
|
||||
public Integer batchDeleteHostKey(@RequestParam("idList") List<Long> idList) {
|
||||
return hostKeyService.deleteHostKeyByIdList(idList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,18 @@ public interface ExecJobHostDAO extends IMapper<ExecJobHostDO> {
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 jobId 删除
|
||||
*
|
||||
* @param jobIdList jobIdList
|
||||
* @return effect
|
||||
*/
|
||||
default Integer deleteByJobIdList(List<Long> jobIdList) {
|
||||
LambdaQueryWrapper<ExecJobHostDO> wrapper = this.wrapper()
|
||||
.in(ExecJobHostDO::getJobId, jobIdList);
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 hostId 删除
|
||||
*
|
||||
@@ -56,4 +68,16 @@ public interface ExecJobHostDAO extends IMapper<ExecJobHostDO> {
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 hostId 删除
|
||||
*
|
||||
* @param hostIdList hostIdList
|
||||
* @return effect
|
||||
*/
|
||||
default Integer deleteByHostIdList(List<Long> hostIdList) {
|
||||
LambdaQueryWrapper<ExecJobHostDO> wrapper = this.wrapper()
|
||||
.in(ExecJobHostDO::getHostId, hostIdList);
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,17 +95,17 @@ public interface HostConfigDAO extends IMapper<HostConfigDO> {
|
||||
/**
|
||||
* 设置 keyId 为 NULL
|
||||
*
|
||||
* @param keyId keyId
|
||||
* @param keyIdList keyIdList
|
||||
* @return effect
|
||||
*/
|
||||
int setKeyIdWithNull(@Param("keyId") Long keyId);
|
||||
int setKeyIdWithNull(@Param("keyIdList") List<Long> keyIdList);
|
||||
|
||||
/**
|
||||
* 设置 identityId 为 NULL
|
||||
*
|
||||
* @param identityId identityId
|
||||
* @param identityIdList identityIdList
|
||||
* @return effect
|
||||
*/
|
||||
int setIdentityIdWithNull(@Param("identityId") Long identityId);
|
||||
int setIdentityIdWithNull(@Param("identityIdList") List<Long> identityIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.orion.visor.framework.mybatis.core.mapper.IMapper;
|
||||
import com.orion.visor.module.asset.entity.domain.HostIdentityDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 主机身份 Mapper 接口
|
||||
@@ -20,13 +21,13 @@ public interface HostIdentityDAO extends IMapper<HostIdentityDO> {
|
||||
/**
|
||||
* 设置 keyId 为 null
|
||||
*
|
||||
* @param keyId keyId
|
||||
* @param keyIdList keyIdList
|
||||
* @return effect
|
||||
*/
|
||||
default int setKeyWithNull(@Param("keyId") Long keyId) {
|
||||
default int setKeyWithNull(List<Long> keyIdList) {
|
||||
LambdaUpdateWrapper<HostIdentityDO> updateWrapper = Wrappers.<HostIdentityDO>lambdaUpdate()
|
||||
.set(HostIdentityDO::getKeyId, null)
|
||||
.eq(HostIdentityDO::getKeyId, keyId);
|
||||
.in(HostIdentityDO::getKeyId, keyIdList);
|
||||
return this.update(null, updateWrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,14 @@ public interface ExecJobHostService {
|
||||
*/
|
||||
Integer deleteByJobId(Long jobId);
|
||||
|
||||
/**
|
||||
* 通过 jobId 删除
|
||||
*
|
||||
* @param jobIdList jobIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteByJobIdList(List<Long> jobIdList);
|
||||
|
||||
/**
|
||||
* 通过 hostId 删除
|
||||
*
|
||||
@@ -43,4 +51,12 @@ public interface ExecJobHostService {
|
||||
*/
|
||||
Integer deleteByHostId(Long hostId);
|
||||
|
||||
/**
|
||||
* 通过 hostId 删除
|
||||
*
|
||||
* @param hostIdList hostIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteByHostIdList(List<Long> hostIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,14 @@ public interface ExecJobService {
|
||||
*/
|
||||
Integer deleteExecJobById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除计划任务
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteExecJobByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 手动触发任务
|
||||
*
|
||||
|
||||
@@ -45,6 +45,14 @@ public interface ExecTemplateHostService {
|
||||
*/
|
||||
Integer deleteByTemplateId(Long templateId);
|
||||
|
||||
/**
|
||||
* 通过 templateId 删除
|
||||
*
|
||||
* @param templateIdList templateIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteByTemplateIdList(List<Long> templateIdList);
|
||||
|
||||
/**
|
||||
* 通过 hostId 删除
|
||||
*
|
||||
@@ -53,4 +61,12 @@ public interface ExecTemplateHostService {
|
||||
*/
|
||||
Integer deleteByHostId(Long hostId);
|
||||
|
||||
/**
|
||||
* 通过 hostId 删除
|
||||
*
|
||||
* @param hostIdList hostIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteByHostIdList(List<Long> hostIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.orion.visor.module.asset.entity.request.exec.ExecTemplateQueryRequest
|
||||
import com.orion.visor.module.asset.entity.request.exec.ExecTemplateUpdateRequest;
|
||||
import com.orion.visor.module.asset.entity.vo.ExecTemplateVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 执行模板 服务类
|
||||
*
|
||||
@@ -63,4 +65,12 @@ public interface ExecTemplateService {
|
||||
*/
|
||||
Integer deleteExecTemplateById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除执行模板
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteExecTemplateByIdList(List<Long> idList);
|
||||
|
||||
}
|
||||
|
||||
@@ -64,4 +64,12 @@ public interface HostIdentityService {
|
||||
*/
|
||||
Integer deleteHostIdentityById(Long id);
|
||||
|
||||
/**
|
||||
* 通过 id 批量删除主机身份
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteHostIdentityByIdList(List<Long> idList);
|
||||
|
||||
}
|
||||
|
||||
@@ -66,11 +66,19 @@ public interface HostKeyService {
|
||||
DataGrid<HostKeyVO> getHostKeyPage(HostKeyQueryRequest request);
|
||||
|
||||
/**
|
||||
* 通过 id 删除主机密钥
|
||||
* 通过 id 批量删除主机密钥
|
||||
*
|
||||
* @param id id
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteHostKeyById(Long id);
|
||||
|
||||
/**
|
||||
* 通过 id 删除主机密钥
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteHostKeyByIdList(List<Long> idList);
|
||||
|
||||
}
|
||||
|
||||
@@ -64,11 +64,19 @@ public interface HostService {
|
||||
*/
|
||||
Integer deleteHostById(Long id);
|
||||
|
||||
/**
|
||||
* 通过 id 批量删除主机
|
||||
*
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteHostByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 通过 id 删除主机引用
|
||||
*
|
||||
* @param id id
|
||||
* @param idList idList
|
||||
*/
|
||||
void deleteHostRelByIdAsync(Long id);
|
||||
void deleteHostRelByIdListAsync(List<Long> idList);
|
||||
|
||||
}
|
||||
|
||||
@@ -49,9 +49,19 @@ public class ExecJobHostServiceImpl implements ExecJobHostService {
|
||||
return execJobHostDAO.deleteByJobId(jobId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByJobIdList(List<Long> jobIdList) {
|
||||
return execJobHostDAO.deleteByJobIdList(jobIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByHostId(Long hostId) {
|
||||
return execJobHostDAO.deleteByHostId(hostId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByHostIdList(List<Long> hostIdList) {
|
||||
return execJobHostDAO.deleteByHostIdList(hostIdList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.time.cron.Cron;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.job.core.utils.QuartzUtils;
|
||||
@@ -235,19 +236,30 @@ public class ExecJobServiceImpl implements ExecJobService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteExecJobById(Long id) {
|
||||
log.info("ExecJobService-deleteExecJobById id: {}", id);
|
||||
return this.deleteExecJobByIdList(Lists.singleton(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteExecJobByIdList(List<Long> idList) {
|
||||
log.info("ExecJobService-deleteExecJobByIdList idList: {}", idList);
|
||||
// 检查数据是否存在
|
||||
ExecJobDO record = execJobDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
List<ExecJobDO> jobList = execJobDAO.selectBatchIds(idList);
|
||||
Valid.notEmpty(jobList, ErrorMessage.DATA_ABSENT);
|
||||
// 删除任务
|
||||
int effect = execJobDAO.deleteById(id);
|
||||
int effect = execJobDAO.deleteBatchIds(idList);
|
||||
// 删除任务主机
|
||||
effect += execJobHostService.deleteByJobId(id);
|
||||
effect += execJobHostService.deleteByJobIdList(idList);
|
||||
// 设置日志参数
|
||||
OperatorLogs.add(OperatorLogs.NAME, record.getName());
|
||||
String name = jobList.stream()
|
||||
.map(ExecJobDO::getName)
|
||||
.collect(Collectors.joining(Const.COMMA));
|
||||
OperatorLogs.add(OperatorLogs.NAME, name);
|
||||
// 设置 quartz 状态
|
||||
this.setQuartzJobStatus(record, true, false);
|
||||
log.info("ExecJobService-deleteExecJobById id: {}, effect: {}", id, effect);
|
||||
for (ExecJobDO job : jobList) {
|
||||
this.setQuartzJobStatus(job, true, false);
|
||||
}
|
||||
log.info("ExecJobService-deleteExecJobByIdList idList: {}, effect: {}", idList, effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,20 +97,40 @@ public class ExecTemplateHostServiceImpl implements ExecTemplateHostService {
|
||||
public Integer deleteByTemplateId(Long templateId) {
|
||||
LambdaQueryWrapper<ExecTemplateHostDO> wrapper = execTemplateHostDAO.lambda()
|
||||
.eq(ExecTemplateHostDO::getTemplateId, templateId);
|
||||
log.info("ExecTemplateHostService-deleteByTemplateId idList: {}", templateId);
|
||||
log.info("ExecTemplateHostService-deleteByTemplateId id: {}", templateId);
|
||||
int effect = execTemplateHostDAO.delete(wrapper);
|
||||
log.info("ExecTemplateHostService-deleteByTemplateId effect: {}", effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByTemplateIdList(List<Long> templateIdList) {
|
||||
LambdaQueryWrapper<ExecTemplateHostDO> wrapper = execTemplateHostDAO.lambda()
|
||||
.in(ExecTemplateHostDO::getTemplateId, templateIdList);
|
||||
log.info("ExecTemplateHostService-deleteByTemplateIdList idList: {}", templateIdList);
|
||||
int effect = execTemplateHostDAO.delete(wrapper);
|
||||
log.info("ExecTemplateHostService-deleteByTemplateIdList effect: {}", effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByHostId(Long hostId) {
|
||||
LambdaQueryWrapper<ExecTemplateHostDO> wrapper = execTemplateHostDAO.lambda()
|
||||
.eq(ExecTemplateHostDO::getHostId, hostId);
|
||||
log.info("ExecTemplateHostService-deleteByHostId idList: {}", hostId);
|
||||
log.info("ExecTemplateHostService-deleteByHostId id: {}", hostId);
|
||||
int effect = execTemplateHostDAO.delete(wrapper);
|
||||
log.info("ExecTemplateHostService-deleteByHostId effect: {}", effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByHostIdList(List<Long> hostIdList) {
|
||||
LambdaQueryWrapper<ExecTemplateHostDO> wrapper = execTemplateHostDAO.lambda()
|
||||
.in(ExecTemplateHostDO::getHostId, hostIdList);
|
||||
log.info("ExecTemplateHostService-deleteByHostIdList id: {}", hostIdList);
|
||||
int effect = execTemplateHostDAO.delete(wrapper);
|
||||
log.info("ExecTemplateHostService-deleteByHostIdList effect: {}", effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.security.core.utils.SecurityUtils;
|
||||
@@ -21,10 +23,12 @@ import com.orion.visor.module.asset.service.ExecTemplateHostService;
|
||||
import com.orion.visor.module.asset.service.ExecTemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 执行模板 服务实现类
|
||||
@@ -126,16 +130,28 @@ public class ExecTemplateServiceImpl implements ExecTemplateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteExecTemplateById(Long id) {
|
||||
log.info("ExecTemplateService-deleteExecTemplateById id: {}", id);
|
||||
return this.deleteExecTemplateByIdList(Lists.singleton(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteExecTemplateByIdList(List<Long> idList) {
|
||||
log.info("ExecTemplateService-deleteExecTemplateByIdList idList: {}", idList);
|
||||
// 检查数据是否存在
|
||||
ExecTemplateDO record = execTemplateDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
List<ExecTemplateDO> recordList = execTemplateDAO.selectBatchIds(idList);
|
||||
Valid.notEmpty(recordList, ErrorMessage.DATA_ABSENT);
|
||||
// 设置日志参数
|
||||
String name = recordList.stream()
|
||||
.map(ExecTemplateDO::getName)
|
||||
.collect(Collectors.joining(Const.COMMA));
|
||||
OperatorLogs.add(OperatorLogs.NAME, name);
|
||||
// 删除模板
|
||||
int effect = execTemplateDAO.deleteById(id);
|
||||
log.info("ExecTemplateService-deleteExecTemplateById id: {}, effect: {}", id, effect);
|
||||
int effect = execTemplateDAO.deleteBatchIds(idList);
|
||||
log.info("ExecTemplateService-deleteExecTemplateByIdList idList: {}, effect: {}", idList, effect);
|
||||
// 删除模板主机
|
||||
effect += execTemplateHostService.deleteByTemplateId(id);
|
||||
effect += execTemplateHostService.deleteByTemplateIdList(idList);
|
||||
return effect;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,15 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.security.PasswordModifier;
|
||||
import com.orion.visor.framework.common.utils.CryptoUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisMaps;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
import com.orion.visor.module.asset.convert.HostIdentityConvert;
|
||||
import com.orion.visor.module.asset.dao.HostConfigDAO;
|
||||
@@ -32,6 +35,7 @@ import com.orion.visor.module.infra.api.DataPermissionApi;
|
||||
import com.orion.visor.module.infra.enums.DataPermissionTypeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
@@ -185,24 +189,34 @@ public class HostIdentityServiceImpl implements HostIdentityService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteHostIdentityById(Long id) {
|
||||
log.info("HostIdentityService-deleteHostIdentityById id: {}", id);
|
||||
return this.deleteHostIdentityByIdList(Lists.singleton(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteHostIdentityByIdList(List<Long> idList) {
|
||||
log.info("HostIdentityService-deleteHostIdentityByIdList idList: {}", idList);
|
||||
// 检查数据是否存在
|
||||
HostIdentityDO record = hostIdentityDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
List<HostIdentityDO> list = hostIdentityDAO.selectBatchIds(idList);
|
||||
Valid.notEmpty(list, ErrorMessage.DATA_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.NAME, record.getName());
|
||||
String name = list.stream()
|
||||
.map(HostIdentityDO::getName)
|
||||
.collect(Collectors.joining(Const.COMMA));
|
||||
OperatorLogs.add(OperatorLogs.NAME, name);
|
||||
// 删除数据库
|
||||
int effect = hostIdentityDAO.deleteById(id);
|
||||
int effect = hostIdentityDAO.deleteBatchIds(idList);
|
||||
// 删除主机配置
|
||||
hostConfigDAO.setIdentityIdWithNull(id);
|
||||
hostConfigDAO.setIdentityIdWithNull(idList);
|
||||
// 删除主机身份额外配置
|
||||
dataExtraApi.deleteHostIdentityExtra(id);
|
||||
dataExtraApi.deleteHostIdentityExtra(idList);
|
||||
// 删除数据权限
|
||||
dataPermissionApi.deleteByRelId(DataPermissionTypeEnum.HOST_IDENTITY, id);
|
||||
dataPermissionApi.deleteByRelIdList(DataPermissionTypeEnum.HOST_IDENTITY, idList);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(HostCacheKeyDefine.HOST_IDENTITY.getKey(), record.getId());
|
||||
log.info("HostIdentityService-deleteHostIdentityById effect: {}", effect);
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_IDENTITY);
|
||||
log.info("HostIdentityService-deleteHostIdentityByIdList effect: {}", effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,15 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.security.PasswordModifier;
|
||||
import com.orion.visor.framework.common.utils.CryptoUtils;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisMaps;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
import com.orion.visor.module.asset.convert.HostKeyConvert;
|
||||
import com.orion.visor.module.asset.dao.HostConfigDAO;
|
||||
@@ -170,24 +173,33 @@ public class HostKeyServiceImpl implements HostKeyService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteHostKeyById(Long id) {
|
||||
log.info("HostKeyService-deleteHostKeyById id: {}", id);
|
||||
return this.deleteHostKeyByIdList(Lists.singleton(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteHostKeyByIdList(List<Long> idList) {
|
||||
log.info("HostKeyService-deleteHostKeyById idList: {}", idList);
|
||||
// 检查数据是否存在
|
||||
HostKeyDO record = hostKeyDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
List<HostKeyDO> list = hostKeyDAO.selectBatchIds(idList);
|
||||
Valid.notEmpty(list, ErrorMessage.DATA_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.NAME, record.getName());
|
||||
String name = list.stream()
|
||||
.map(HostKeyDO::getName)
|
||||
.collect(Collectors.joining(Const.COMMA));
|
||||
OperatorLogs.add(OperatorLogs.NAME, name);
|
||||
// 删除数据库
|
||||
int effect = hostKeyDAO.deleteById(id);
|
||||
int effect = hostKeyDAO.deleteBatchIds(idList);
|
||||
// 删除关联
|
||||
hostIdentityDAO.setKeyWithNull(id);
|
||||
hostIdentityDAO.setKeyWithNull(idList);
|
||||
// 删除主机配置
|
||||
hostConfigDAO.setKeyIdWithNull(id);
|
||||
hostConfigDAO.setKeyIdWithNull(idList);
|
||||
// 删除主机密钥额外配置
|
||||
dataExtraApi.deleteHostKeyExtra(id);
|
||||
dataExtraApi.deleteHostKeyExtra(idList);
|
||||
// 删除数据权限
|
||||
dataPermissionApi.deleteByRelId(DataPermissionTypeEnum.HOST_KEY, id);
|
||||
dataPermissionApi.deleteByRelIdList(DataPermissionTypeEnum.HOST_KEY, idList);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(HostCacheKeyDefine.HOST_KEY.getKey(), record.getId());
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_KEY);
|
||||
log.info("HostKeyService-deleteHostKeyById effect: {}", effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.spring.SpringHolder;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisMaps;
|
||||
import com.orion.visor.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
import com.orion.visor.module.asset.convert.HostConvert;
|
||||
import com.orion.visor.module.asset.dao.HostConfigDAO;
|
||||
@@ -191,41 +193,49 @@ public class HostServiceImpl implements HostService {
|
||||
|
||||
@Override
|
||||
public Integer deleteHostById(Long id) {
|
||||
log.info("HostService-deleteHostById id: {}", id);
|
||||
return this.deleteHostByIdList(Lists.singleton(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteHostByIdList(List<Long> idList) {
|
||||
log.info("HostService-deleteHostByIdList idList: {}", idList);
|
||||
// 查询
|
||||
HostDO record = hostDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.HOST_ABSENT);
|
||||
List<HostDO> hosts = hostDAO.selectBatchIds(idList);
|
||||
Valid.notEmpty(hosts, ErrorMessage.HOST_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.NAME, record.getName());
|
||||
String name = hosts.stream()
|
||||
.map(HostDO::getName)
|
||||
.collect(Collectors.joining(Const.COMMA));
|
||||
OperatorLogs.add(OperatorLogs.NAME, name);
|
||||
// 删除
|
||||
int effect = hostDAO.deleteById(id);
|
||||
log.info("HostService-deleteHostById effect: {}", effect);
|
||||
int effect = hostDAO.deleteBatchIds(hosts);
|
||||
log.info("HostService-deleteHostByIdList effect: {}", effect);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(HostCacheKeyDefine.HOST_INFO, id);
|
||||
RedisUtils.delete(HostCacheKeyDefine.HOST_INFO);
|
||||
// 删除主机引用
|
||||
SpringHolder.getBean(HostService.class)
|
||||
.deleteHostRelByIdAsync(id);
|
||||
.deleteHostRelByIdListAsync(idList);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void deleteHostRelByIdAsync(Long id) {
|
||||
log.info("HostService-deleteHostRelByIdAsync id: {}", id);
|
||||
public void deleteHostRelByIdListAsync(List<Long> idList) {
|
||||
log.info("HostService-deleteHostRelByIdListAsync idList: {}", idList);
|
||||
// 删除主机配置
|
||||
hostConfigDAO.deleteByHostId(id);
|
||||
hostConfigDAO.deleteByHostIdList(idList);
|
||||
// 删除计划任务主机
|
||||
execJobHostService.deleteByHostId(id);
|
||||
execJobHostService.deleteByHostIdList(idList);
|
||||
// 删除执行模板主机
|
||||
execTemplateHostService.deleteByHostId(id);
|
||||
execTemplateHostService.deleteByHostIdList(idList);
|
||||
// 删除分组
|
||||
dataGroupRelApi.deleteByRelId(DataGroupTypeEnum.HOST, id);
|
||||
dataGroupRelApi.deleteByRelIdList(DataGroupTypeEnum.HOST, idList);
|
||||
// 删除 tag 引用
|
||||
tagRelApi.deleteRelId(TagTypeEnum.HOST, id);
|
||||
tagRelApi.deleteRelIdList(TagTypeEnum.HOST, idList);
|
||||
// 删除收藏引用
|
||||
favoriteApi.deleteByRelId(FavoriteTypeEnum.HOST, id);
|
||||
favoriteApi.deleteByRelIdList(FavoriteTypeEnum.HOST, idList);
|
||||
// 删除额外配置
|
||||
dataExtraApi.deleteByRelId(DataExtraTypeEnum.HOST, id);
|
||||
dataExtraApi.deleteByRelIdList(DataExtraTypeEnum.HOST, idList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,11 +151,13 @@ public class HostTerminalServiceImpl implements HostTerminalService {
|
||||
HostExtraSshAuthTypeEnum extraAuthType = HostExtraSshAuthTypeEnum.of(extra.getAuthType());
|
||||
if (HostExtraSshAuthTypeEnum.CUSTOM_KEY.equals(extraAuthType)) {
|
||||
// 验证主机密钥是否有权限
|
||||
Valid.notNull(extra.getKeyId(), ErrorMessage.KEY_ABSENT);
|
||||
Valid.isTrue(dataPermissionApi.hasPermission(DataPermissionTypeEnum.HOST_KEY, userId, extra.getKeyId()),
|
||||
ErrorMessage.ANY_NO_PERMISSION,
|
||||
DataPermissionTypeEnum.HOST_KEY.getPermissionName());
|
||||
} else if (HostExtraSshAuthTypeEnum.CUSTOM_IDENTITY.equals(extraAuthType)) {
|
||||
// 验证主机身份是否有权限
|
||||
Valid.notNull(extra.getIdentityId(), ErrorMessage.IDENTITY_ABSENT);
|
||||
Valid.isTrue(dataPermissionApi.hasPermission(DataPermissionTypeEnum.HOST_IDENTITY, userId, extra.getIdentityId()),
|
||||
ErrorMessage.ANY_NO_PERMISSION,
|
||||
DataPermissionTypeEnum.HOST_IDENTITY.getPermissionName());
|
||||
@@ -270,6 +272,7 @@ public class HostTerminalServiceImpl implements HostTerminalService {
|
||||
HostSshAuthTypeEnum authType = HostSshAuthTypeEnum.of(config.getAuthType());
|
||||
if (HostSshAuthTypeEnum.IDENTITY.equals(authType)) {
|
||||
// 身份认证
|
||||
Valid.notNull(config.getIdentityId(), ErrorMessage.IDENTITY_ABSENT);
|
||||
HostIdentityDO identity = hostIdentityDAO.selectById(config.getIdentityId());
|
||||
Valid.notNull(identity, ErrorMessage.IDENTITY_ABSENT);
|
||||
config.setUsername(identity.getUsername());
|
||||
@@ -293,6 +296,7 @@ public class HostTerminalServiceImpl implements HostTerminalService {
|
||||
} else if (HostSshAuthTypeEnum.KEY.equals(authType)) {
|
||||
// 密钥认证
|
||||
Long keyId = config.getKeyId();
|
||||
Valid.notNull(keyId, ErrorMessage.KEY_ABSENT);
|
||||
HostKeyDO key = hostKeyDAO.selectById(keyId);
|
||||
Valid.notNull(key, ErrorMessage.KEY_ABSENT);
|
||||
conn.setKeyId(keyId);
|
||||
|
||||
@@ -25,17 +25,21 @@
|
||||
<update id="setKeyIdWithNull">
|
||||
UPDATE host_config
|
||||
SET version = version + 1,
|
||||
config = JSON_REMOVE(config, '$.keyId')
|
||||
config = JSON_REMOVE(config, '$.keyId')
|
||||
WHERE deleted = 0
|
||||
AND JSON_CONTAINS(config, JSON_OBJECT('keyId', #{keyId}))
|
||||
<foreach collection="keyIdList" item="item" separator="OR" open="AND (" close=")">
|
||||
JSON_CONTAINS(config, JSON_OBJECT('keyId', #{item}))
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="setIdentityIdWithNull">
|
||||
UPDATE host_config
|
||||
SET version = version + 1,
|
||||
config = JSON_REMOVE(config, '$.identityId')
|
||||
config = JSON_REMOVE(config, '$.identityId')
|
||||
WHERE deleted = 0
|
||||
AND JSON_CONTAINS(config, JSON_OBJECT('identityId', #{identityId}))
|
||||
<foreach collection="identityIdList" item="item" separator="OR" open="AND (" close=")">
|
||||
JSON_CONTAINS(config, JSON_OBJECT('identityId', #{item}))
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -139,19 +139,28 @@ public interface DataExtraApi {
|
||||
Integer deleteByRelId(DataExtraTypeEnum type, Long relId);
|
||||
|
||||
/**
|
||||
* 删除主机密钥
|
||||
* 通过 relId 删除
|
||||
*
|
||||
* @param keyId keyId
|
||||
* @param type type
|
||||
* @param relIdList relIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteHostKeyExtra(Long keyId);
|
||||
Integer deleteByRelIdList(DataExtraTypeEnum type, List<Long> relIdList);
|
||||
|
||||
/**
|
||||
* 删除主机密钥
|
||||
*
|
||||
* @param keyIdList keyIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteHostKeyExtra(List<Long> keyIdList);
|
||||
|
||||
/**
|
||||
* 删除主机身份
|
||||
*
|
||||
* @param identityId identityId
|
||||
* @param identityIdList identityIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteHostIdentityExtra(Long identityId);
|
||||
int deleteHostIdentityExtra(List<Long> identityIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -76,4 +76,13 @@ public interface DataPermissionApi {
|
||||
*/
|
||||
int deleteByRelId(DataPermissionTypeEnum type, Long relId);
|
||||
|
||||
/**
|
||||
* 通过 relId 删除
|
||||
*
|
||||
* @param type type
|
||||
* @param relIdList relIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteByRelIdList(DataPermissionTypeEnum type, List<Long> relIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -134,15 +134,20 @@ public class DataExtraApiImpl implements DataExtraApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteHostKeyExtra(Long keyId) {
|
||||
Valid.notNull(keyId);
|
||||
return dataExtraDAO.deleteHostKey(keyId);
|
||||
public Integer deleteByRelIdList(DataExtraTypeEnum type, List<Long> relIdList) {
|
||||
return dataExtraService.deleteByRelIdList(type.name(), relIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteHostIdentityExtra(Long identityId) {
|
||||
Valid.notNull(identityId);
|
||||
return dataExtraDAO.deleteHostIdentity(identityId);
|
||||
public int deleteHostKeyExtra(List<Long> keyIdList) {
|
||||
Valid.notEmpty(keyIdList);
|
||||
return dataExtraDAO.deleteHostKey(keyIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteHostIdentityExtra(List<Long> identityIdList) {
|
||||
Valid.notEmpty(identityIdList);
|
||||
return dataExtraDAO.deleteHostIdentity(identityIdList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,4 +75,9 @@ public class DataPermissionApiImpl implements DataPermissionApi {
|
||||
return dataPermissionService.deleteByRelId(type.name(), relId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByRelIdList(DataPermissionTypeEnum type, List<Long> relIdList) {
|
||||
return dataPermissionService.deleteByRelIdList(type.name(), relIdList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -150,6 +150,16 @@ public class SystemUserController {
|
||||
return systemUserService.deleteSystemUserById(id);
|
||||
}
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(SystemUserOperatorType.DELETE)
|
||||
@DeleteMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除用户")
|
||||
@Parameter(name = "idList", description = "idList", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:delete')")
|
||||
public Integer batchDeleteSystemUser(@RequestParam("idList") List<Long> idList) {
|
||||
return systemUserService.deleteSystemUserByIdList(idList);
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/session/list")
|
||||
@Operation(summary = "获取用户会话列表")
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.orion.visor.module.infra.entity.domain.DataExtraDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据拓展信息 Mapper 接口
|
||||
*
|
||||
@@ -28,6 +30,18 @@ public interface DataExtraDAO extends IMapper<DataExtraDO> {
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 userId 删除
|
||||
*
|
||||
* @param userIdList userIdList
|
||||
* @return effect
|
||||
*/
|
||||
default int deleteByUserIdList(List<Long> userIdList) {
|
||||
LambdaQueryWrapper<DataExtraDO> wrapper = this.lambda()
|
||||
.in(DataExtraDO::getUserId, userIdList);
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 relId 删除
|
||||
*
|
||||
@@ -43,19 +57,33 @@ public interface DataExtraDAO extends IMapper<DataExtraDO> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除主机密钥
|
||||
* 通过 relId 删除
|
||||
*
|
||||
* @param keyId keyId
|
||||
* @param type type
|
||||
* @param relIdList relIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteHostKey(@Param("keyId") Long keyId);
|
||||
default int deleteByRelIdList(String type, List<Long> relIdList) {
|
||||
LambdaQueryWrapper<DataExtraDO> wrapper = this.lambda()
|
||||
.eq(DataExtraDO::getType, type)
|
||||
.in(DataExtraDO::getRelId, relIdList);
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除主机密钥
|
||||
*
|
||||
* @param keyIdList keyIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteHostKey(@Param("keyIdList") List<Long> keyIdList);
|
||||
|
||||
/**
|
||||
* 删除主机身份
|
||||
*
|
||||
* @param identityId identityId
|
||||
* @param identityIdList identityIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteHostIdentity(@Param("identityId") Long identityId);
|
||||
int deleteHostIdentity(@Param("identityIdList") List<Long> identityIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.orion.visor.framework.mybatis.core.mapper.IMapper;
|
||||
import com.orion.visor.module.infra.entity.domain.OperatorLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志 Mapper 接口
|
||||
*
|
||||
@@ -27,4 +29,16 @@ public interface OperatorLogDAO extends IMapper<OperatorLogDO> {
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 userId 删除
|
||||
*
|
||||
* @param userIdList userIdList
|
||||
* @return effect
|
||||
*/
|
||||
default int deleteByUserIdList(List<Long> userIdList) {
|
||||
LambdaQueryWrapper<OperatorLogDO> wrapper = this.wrapper()
|
||||
.in(OperatorLogDO::getUserId, userIdList);
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.orion.visor.framework.mybatis.core.query.Conditions;
|
||||
import com.orion.visor.module.infra.entity.domain.PreferenceDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户偏好 Mapper 接口
|
||||
*
|
||||
@@ -25,4 +27,14 @@ public interface PreferenceDAO extends IMapper<PreferenceDO> {
|
||||
return this.delete(Conditions.eq(PreferenceDO::getUserId, userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 userId 删除
|
||||
*
|
||||
* @param userIdList userIdList
|
||||
* @return effect
|
||||
*/
|
||||
default int deleteByUserIdList(List<Long> userIdList) {
|
||||
return this.delete(Conditions.in(PreferenceDO::getUserId, userIdList));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,6 +76,18 @@ public interface SystemUserRoleDAO extends IMapper<SystemUserRoleDO> {
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 userId 删除
|
||||
*
|
||||
* @param userIdList userIdList
|
||||
* @return effect
|
||||
*/
|
||||
default int deleteByUserIdList(List<Long> userIdList) {
|
||||
LambdaQueryWrapper<SystemUserRoleDO> wrapper = this.wrapper()
|
||||
.in(SystemUserRoleDO::getUserId, userIdList);
|
||||
return this.delete(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 roleId 删除
|
||||
*
|
||||
|
||||
@@ -119,6 +119,14 @@ public interface DataExtraService {
|
||||
*/
|
||||
Integer deleteByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 通过 userId 删除
|
||||
*
|
||||
* @param userIdList userIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteByUserIdList(List<Long> userIdList);
|
||||
|
||||
/**
|
||||
* 通过 relId 删除
|
||||
*
|
||||
@@ -128,4 +136,13 @@ public interface DataExtraService {
|
||||
*/
|
||||
Integer deleteByRelId(String type, Long relId);
|
||||
|
||||
/**
|
||||
* 通过 relId 删除
|
||||
*
|
||||
* @param type type
|
||||
* @param relIdList relIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteByRelIdList(String type, List<Long> relIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -84,4 +84,12 @@ public interface DataGroupService {
|
||||
*/
|
||||
Integer deleteDataGroupByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 通过 userId 删除数据分组
|
||||
*
|
||||
* @param userIdList userIdList
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataGroupByUserIdList(List<Long> userIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -73,6 +73,15 @@ public interface DataPermissionService {
|
||||
*/
|
||||
int deleteByRelId(String type, Long relId);
|
||||
|
||||
/**
|
||||
* 通过 relId 删除
|
||||
*
|
||||
* @param type type
|
||||
* @param relIdList relIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteByRelIdList(String type, List<Long> relIdList);
|
||||
|
||||
/**
|
||||
* 通过 userId 删除
|
||||
*
|
||||
@@ -81,6 +90,14 @@ public interface DataPermissionService {
|
||||
*/
|
||||
int deleteByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 通过 userId 删除
|
||||
*
|
||||
* @param userIdList userIdList
|
||||
* @return effect
|
||||
*/
|
||||
int deleteByUserIdList(List<Long> userIdList);
|
||||
|
||||
/**
|
||||
* 通过 roleId 删除
|
||||
*
|
||||
|
||||
@@ -66,4 +66,11 @@ public interface PreferenceService {
|
||||
*/
|
||||
void deletePreferenceByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 删除用户偏好
|
||||
*
|
||||
* @param userIdList userIdList
|
||||
*/
|
||||
void deletePreferenceByUserIdList(List<Long> userIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -71,12 +71,19 @@ public interface SystemUserService {
|
||||
Integer deleteSystemUserById(Long id);
|
||||
|
||||
/**
|
||||
* 删除 id 删除用户拓展信息
|
||||
* 通过 id 批量删除用户
|
||||
*
|
||||
* @param id id
|
||||
* @param username username
|
||||
* @param idList idList
|
||||
* @return effect
|
||||
*/
|
||||
void deleteSystemUserRelAsync(Long id, String username);
|
||||
Integer deleteSystemUserByIdList(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 通过 idList 删除用户拓展信息
|
||||
*
|
||||
* @param idList idList
|
||||
*/
|
||||
void deleteSystemUserListRelAsync(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
|
||||
@@ -192,32 +192,56 @@ public class DataExtraServiceImpl implements DataExtraService {
|
||||
|
||||
@Override
|
||||
public Integer deleteByUserId(Long userId) {
|
||||
List<DataExtraDO> list = this.getCacheSelectWrapper()
|
||||
.eq(DataExtraDO::getUserId, userId)
|
||||
.then()
|
||||
.list();
|
||||
if (list.isEmpty()) {
|
||||
return Const.N_0;
|
||||
if (userId == null) {
|
||||
return 0;
|
||||
}
|
||||
// 删除
|
||||
return this.deleteByUserIdList(Lists.singleton(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByUserIdList(List<Long> userIdList) {
|
||||
if (Lists.isEmpty(userIdList)) {
|
||||
return 0;
|
||||
}
|
||||
// 删除数据
|
||||
int effect = dataExtraDAO.deleteByUserId(userId);
|
||||
// 删除缓存
|
||||
this.deleteCache(list);
|
||||
return effect;
|
||||
return dataExtraDAO.deleteByUserIdList(userIdList);
|
||||
// // 查询数据
|
||||
// List<DataExtraDO> list = this.getCacheSelectWrapper()
|
||||
// .in(DataExtraDO::getUserId, userIdList)
|
||||
// .then()
|
||||
// .list();
|
||||
// if (list.isEmpty()) {
|
||||
// return Const.N_0;
|
||||
// }
|
||||
// // 删除缓存 让其自动过期
|
||||
// this.deleteCache(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByRelId(String type, Long relId) {
|
||||
if (relId == null) {
|
||||
return 0;
|
||||
}
|
||||
// 删除
|
||||
return this.deleteByRelIdList(type, Lists.singleton(relId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByRelIdList(String type, List<Long> relIdList) {
|
||||
if (Lists.isEmpty(relIdList)) {
|
||||
return 0;
|
||||
}
|
||||
List<DataExtraDO> list = this.getCacheSelectWrapper()
|
||||
.eq(DataExtraDO::getType, type)
|
||||
.eq(DataExtraDO::getRelId, relId)
|
||||
.in(DataExtraDO::getRelId, relIdList)
|
||||
.then()
|
||||
.list();
|
||||
if (list.isEmpty()) {
|
||||
return Const.N_0;
|
||||
}
|
||||
// 删除数据
|
||||
int effect = dataExtraDAO.deleteByRelId(type, relId);
|
||||
int effect = dataExtraDAO.deleteByRelIdList(type, relIdList);
|
||||
// 删除缓存
|
||||
this.deleteCache(list);
|
||||
return effect;
|
||||
|
||||
@@ -250,15 +250,27 @@ public class DataGroupServiceImpl implements DataGroupService {
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroupByUserId(Long userId) {
|
||||
if (userId == null) {
|
||||
return 0;
|
||||
}
|
||||
// 删除
|
||||
return this.deleteDataGroupByUserIdList(Lists.singleton(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataGroupByUserIdList(List<Long> userIdList) {
|
||||
if (Lists.isEmpty(userIdList)) {
|
||||
return 0;
|
||||
}
|
||||
// 删除分组
|
||||
LambdaQueryWrapper<DataGroupDO> deleteGroup = dataGroupDAO.wrapper()
|
||||
.eq(DataGroupDO::getUserId, userId);
|
||||
.in(DataGroupDO::getUserId, userIdList);
|
||||
int effect = dataGroupDAO.delete(deleteGroup);
|
||||
// 删除分组引用
|
||||
LambdaQueryWrapper<DataGroupRelDO> deleteRel = dataGroupRelDAO.wrapper()
|
||||
.eq(DataGroupRelDO::getUserId, userId);
|
||||
.in(DataGroupRelDO::getUserId, userIdList);
|
||||
effect += dataGroupRelDAO.delete(deleteRel);
|
||||
// 不删除缓存 自动过期
|
||||
// 不删除缓存 让其自动过期
|
||||
return effect;
|
||||
}
|
||||
|
||||
|
||||
@@ -182,9 +182,21 @@ public class DataPermissionServiceImpl implements DataPermissionService {
|
||||
|
||||
@Override
|
||||
public int deleteByRelId(String type, Long relId) {
|
||||
if (relId == null) {
|
||||
return 0;
|
||||
}
|
||||
// 删除
|
||||
return this.deleteByRelIdList(type, Lists.singleton(relId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByRelIdList(String type, List<Long> relIdList) {
|
||||
if (Lists.isEmpty(relIdList)) {
|
||||
return 0;
|
||||
}
|
||||
LambdaQueryWrapper<DataPermissionDO> wrapper = dataPermissionDAO.wrapper()
|
||||
.eq(DataPermissionDO::getType, type)
|
||||
.eq(DataPermissionDO::getRelId, relId);
|
||||
.in(DataPermissionDO::getRelId, relIdList);
|
||||
// 查询
|
||||
List<DataPermissionDO> rows = dataPermissionDAO.selectList(wrapper);
|
||||
// 删除
|
||||
@@ -204,12 +216,23 @@ public class DataPermissionServiceImpl implements DataPermissionService {
|
||||
|
||||
@Override
|
||||
public int deleteByUserId(Long userId) {
|
||||
LambdaQueryWrapper<DataPermissionDO> wrapper = Conditions.eq(DataPermissionDO::getUserId, userId);
|
||||
if (userId == null) {
|
||||
return 0;
|
||||
}
|
||||
// 删除
|
||||
int effect = dataPermissionDAO.delete(wrapper);
|
||||
// 删除缓存
|
||||
this.deleteCache(null, Lists.singleton(userId), null);
|
||||
return effect;
|
||||
return this.deleteByUserIdList(Lists.singleton(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByUserIdList(List<Long> userIdList) {
|
||||
if (Lists.isEmpty(userIdList)) {
|
||||
return 0;
|
||||
}
|
||||
LambdaQueryWrapper<DataPermissionDO> wrapper = Conditions.in(DataPermissionDO::getUserId, userIdList);
|
||||
// 删除
|
||||
return dataPermissionDAO.delete(wrapper);
|
||||
// 删除缓存 让其自动过期
|
||||
// this.deleteCache(null, userIdList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Objects1;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
@@ -176,24 +177,13 @@ public class DictKeyServiceImpl implements DictKeyService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteDictKeyById(Long id) {
|
||||
log.info("DictKeyService-deleteDictKeyById id: {}", id);
|
||||
// 检查数据是否存在
|
||||
DictKeyDO record = dictKeyDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.CONFIG_ABSENT);
|
||||
OperatorLogs.add(OperatorLogs.KEY_NAME, record.getKeyName());
|
||||
// 删除配置项
|
||||
int effect = dictKeyDAO.deleteById(id);
|
||||
// 删除配置值
|
||||
dictValueService.deleteDictValueByKeyId(id);
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DictCacheKeyDefine.DICT_KEY, id);
|
||||
RedisUtils.delete(DictCacheKeyDefine.DICT_SCHEMA.format(record.getKeyName()));
|
||||
log.info("DictKeyService-deleteDictKeyById id: {}, effect: {}", id, effect);
|
||||
return effect;
|
||||
return this.deleteDictKeyByIdList(Lists.singleton(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteDictKeyByIdList(List<Long> idList) {
|
||||
log.info("DictKeyService-deleteDictKeyByIdList idList: {}", idList);
|
||||
// 检查数据是否存在
|
||||
|
||||
@@ -20,8 +20,6 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -118,13 +116,8 @@ public class FavoriteServiceImpl implements FavoriteService {
|
||||
if (userId == null) {
|
||||
return;
|
||||
}
|
||||
// 删除库
|
||||
favoriteDAO.deleteFavoriteByUserId(userId);
|
||||
// 删除缓存
|
||||
List<String> favoriteKeyList = Arrays.stream(FavoriteTypeEnum.values())
|
||||
.map(s -> FavoriteCacheKeyDefine.FAVORITE.format(s, userId))
|
||||
.collect(Collectors.toList());
|
||||
redisTemplate.delete(favoriteKeyList);
|
||||
// 删除
|
||||
this.deleteFavoriteByUserIdList(Lists.singleton(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,14 +127,14 @@ public class FavoriteServiceImpl implements FavoriteService {
|
||||
}
|
||||
// 删除库
|
||||
favoriteDAO.deleteFavoriteByUserIdList(userIdList);
|
||||
// 删除缓存
|
||||
List<String> favoriteKeyList = new ArrayList<>();
|
||||
for (Long userId : userIdList) {
|
||||
Arrays.stream(FavoriteTypeEnum.values())
|
||||
.map(s -> FavoriteCacheKeyDefine.FAVORITE.format(s, userId))
|
||||
.forEach(favoriteKeyList::add);
|
||||
}
|
||||
redisTemplate.delete(favoriteKeyList);
|
||||
// 缓存自动过期
|
||||
// List<String> favoriteKeyList = new ArrayList<>();
|
||||
// for (Long userId : userIdList) {
|
||||
// Arrays.stream(FavoriteTypeEnum.values())
|
||||
// .map(s -> FavoriteCacheKeyDefine.FAVORITE.format(s, userId))
|
||||
// .forEach(favoriteKeyList::add);
|
||||
// }
|
||||
// redisTemplate.delete(favoriteKeyList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -164,14 +163,29 @@ public class PreferenceServiceImpl implements PreferenceService {
|
||||
|
||||
@Override
|
||||
public void deletePreferenceByUserId(Long userId) {
|
||||
if (userId == null) {
|
||||
return;
|
||||
}
|
||||
// 删除
|
||||
int effect = preferenceDAO.deleteByUserId(userId);
|
||||
log.info("PreferenceService-deletePreferenceById userId: {}, effect: {}", userId, effect);
|
||||
// 删除缓存
|
||||
List<String> deleteKeys = Arrays.stream(PreferenceTypeEnum.values())
|
||||
.map(s -> PreferenceCacheKeyDefine.PREFERENCE.format(userId, s))
|
||||
.collect(Collectors.toList());
|
||||
RedisMaps.delete(deleteKeys);
|
||||
this.deletePreferenceByUserIdList(Lists.singleton(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePreferenceByUserIdList(List<Long> userIdList) {
|
||||
if (Lists.isEmpty(userIdList)) {
|
||||
return;
|
||||
}
|
||||
// 删除
|
||||
int effect = preferenceDAO.deleteByUserIdList(userIdList);
|
||||
log.info("PreferenceService-deletePreferenceByUserIdList userIdList: {}, effect: {}", userIdList, effect);
|
||||
// 删除缓存 让他自动过期
|
||||
// List<String> deleteKeys = new ArrayList<>();
|
||||
// for (Long userId : userIdList) {
|
||||
// Arrays.stream(PreferenceTypeEnum.values())
|
||||
// .map(s -> PreferenceCacheKeyDefine.PREFERENCE.format(userId, s))
|
||||
// .forEach(deleteKeys::add);
|
||||
// }
|
||||
// RedisMaps.delete(deleteKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.orion.visor.module.infra.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.crypto.Signatures;
|
||||
import com.orion.spring.SpringHolder;
|
||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import com.orion.visor.framework.common.constant.Const;
|
||||
import com.orion.visor.framework.common.constant.ErrorCode;
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
import com.orion.visor.framework.common.security.LoginUser;
|
||||
@@ -38,7 +40,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -212,58 +216,55 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
|
||||
@Override
|
||||
public Integer deleteSystemUserById(Long id) {
|
||||
if (id.equals(SecurityUtils.getLoginUserId())) {
|
||||
return this.deleteSystemUserByIdList(Lists.singleton(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteSystemUserByIdList(List<Long> idList) {
|
||||
if (idList.contains(SecurityUtils.getLoginUserId())) {
|
||||
throw ErrorCode.UNSUPPOETED.exception();
|
||||
}
|
||||
// 查询用户
|
||||
SystemUserDO record = systemUserDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.USER_ABSENT);
|
||||
// 查询用户列表
|
||||
List<SystemUserDO> userList = systemUserDAO.selectBatchIds(idList);
|
||||
Valid.notEmpty(userList, ErrorMessage.USER_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.USERNAME, record.getUsername());
|
||||
idList = userList.stream()
|
||||
.map(SystemUserDO::getId)
|
||||
.collect(Collectors.toList());
|
||||
String username = userList.stream()
|
||||
.map(SystemUserDO::getUsername)
|
||||
.collect(Collectors.joining(Const.COMMA));
|
||||
OperatorLogs.add(OperatorLogs.USERNAME, username);
|
||||
// 删除用户
|
||||
int effect = systemUserDAO.deleteById(id);
|
||||
log.info("SystemUserService-deleteSystemUserById id: {}, effect: {}", id, effect);
|
||||
// 删除用户信息缓存
|
||||
RedisUtils.delete(UserCacheKeyDefine.USER_INFO.format(id));
|
||||
// 删除 token 缓存
|
||||
RedisUtils.scanKeysDelete(
|
||||
// 登录 token
|
||||
UserCacheKeyDefine.LOGIN_TOKEN.format(id, "*"),
|
||||
// 刷新 token
|
||||
UserCacheKeyDefine.LOGIN_REFRESH.format(id, "*")
|
||||
);
|
||||
int effect = systemUserDAO.deleteBatchIds(idList);
|
||||
log.info("SystemUserService-deleteSystemUserByIdList idList: {}, effect: {}", idList, effect);
|
||||
// 删除缓存 其他的缓存自动过期
|
||||
this.deleteUserCacheKey(userList);
|
||||
// 异步删除额外信息
|
||||
SpringHolder.getBean(SystemUserService.class).deleteSystemUserRelAsync(id, record.getUsername());
|
||||
SpringHolder.getBean(SystemUserService.class)
|
||||
.deleteSystemUserListRelAsync(idList);
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void deleteSystemUserRelAsync(Long id, String username) {
|
||||
log.info("SystemUserService-deleteSystemUserRel id: {}", id);
|
||||
// 删除用户列表缓存
|
||||
RedisMaps.delete(UserCacheKeyDefine.USER_LIST, id);
|
||||
// 删除用户缓存 其他的 key 让其自动过期
|
||||
RedisUtils.delete(
|
||||
// 登录失败次数
|
||||
UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(username),
|
||||
// 用户提示
|
||||
TipsCacheKeyDefine.TIPS.format(id)
|
||||
);
|
||||
public void deleteSystemUserListRelAsync(List<Long> idList) {
|
||||
log.info("SystemUserService-deleteSystemUserListRelAsync idList: {}", idList);
|
||||
// 删除角色关联
|
||||
systemUserRoleDAO.deleteByUserId(id);
|
||||
systemUserRoleDAO.deleteByUserIdList(idList);
|
||||
// 删除操作日志
|
||||
operatorLogDAO.deleteByUserId(id);
|
||||
operatorLogDAO.deleteByUserIdList(idList);
|
||||
// 删除用户收藏
|
||||
favoriteService.deleteFavoriteByUserId(id);
|
||||
favoriteService.deleteFavoriteByUserIdList(idList);
|
||||
// 删除用户偏好
|
||||
preferenceService.deletePreferenceByUserId(id);
|
||||
preferenceService.deletePreferenceByUserIdList(idList);
|
||||
// 删除用户数据权限
|
||||
dataPermissionService.deleteByUserId(id);
|
||||
dataPermissionService.deleteByUserIdList(idList);
|
||||
// 删除用户拓展数据
|
||||
dataExtraService.deleteByUserId(id);
|
||||
dataExtraService.deleteByUserIdList(idList);
|
||||
// 删除分组数据
|
||||
dataGroupService.deleteDataGroupByUserId(id);
|
||||
dataGroupService.deleteDataGroupByUserIdList(idList);
|
||||
// TODO snippet
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -327,4 +328,29 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
Valid.isFalse(present, ErrorMessage.NICKNAME_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除主要用户缓存 其他的缓存自动过期
|
||||
*
|
||||
* @param userList
|
||||
*/
|
||||
private void deleteUserCacheKey(List<SystemUserDO> userList) {
|
||||
Set<String> deleteKeys = new HashSet<>();
|
||||
// 用户列表缓存
|
||||
deleteKeys.add(UserCacheKeyDefine.USER_LIST.getKey());
|
||||
userList.forEach(s -> {
|
||||
Long id = s.getId();
|
||||
// 用户提示
|
||||
deleteKeys.add(TipsCacheKeyDefine.TIPS.format(id));
|
||||
// 用户信息缓存
|
||||
deleteKeys.add(UserCacheKeyDefine.USER_INFO.format(id));
|
||||
// 登录失败次数
|
||||
deleteKeys.add(UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(s.getUsername()));
|
||||
// 登录 token
|
||||
deleteKeys.addAll(RedisUtils.scanKeys(UserCacheKeyDefine.LOGIN_TOKEN.format(id, "*")));
|
||||
// 刷新 token
|
||||
deleteKeys.addAll(RedisUtils.scanKeys(UserCacheKeyDefine.LOGIN_REFRESH.format(id, "*")));
|
||||
});
|
||||
RedisUtils.delete(deleteKeys);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,30 +26,44 @@
|
||||
UPDATE data_extra
|
||||
SET value = JSON_REPLACE(value,
|
||||
"$.keyId", NULL,
|
||||
"$.authType", IF(
|
||||
JSON_EXTRACT(value, "$.authType") = 'CUSTOM_KEY',
|
||||
'DEFAULT',
|
||||
JSON_EXTRACT(value, "$.authType")
|
||||
))
|
||||
"$.authType",
|
||||
REPLACE(
|
||||
IF(JSON_EXTRACT(value, "$.authType") = 'CUSTOM_KEY',
|
||||
'DEFAULT',
|
||||
JSON_EXTRACT(value, "$.authType")
|
||||
),
|
||||
'"',
|
||||
''
|
||||
)
|
||||
)
|
||||
WHERE deleted = 0
|
||||
AND type = 'HOST'
|
||||
AND item = 'ssh'
|
||||
AND JSON_CONTAINS(value, JSON_OBJECT('keyId', #{keyId}))
|
||||
AND type = 'HOST'
|
||||
AND item = 'ssh'
|
||||
<foreach collection="keyIdList" item="item" separator="OR" open="AND (" close=")">
|
||||
JSON_CONTAINS(value, JSON_OBJECT('keyId', #{item}))
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteHostIdentity">
|
||||
UPDATE data_extra
|
||||
SET value = JSON_REPLACE(value,
|
||||
"$.identityId", NULL,
|
||||
"$.authType", IF(
|
||||
JSON_EXTRACT(value, "$.authType") = 'CUSTOM_IDENTITY',
|
||||
'DEFAULT',
|
||||
JSON_EXTRACT(value, "$.authType")
|
||||
))
|
||||
"$.authType",
|
||||
REPLACE(
|
||||
IF(JSON_EXTRACT(value, "$.authType") = 'CUSTOM_IDENTITY',
|
||||
'DEFAULT',
|
||||
JSON_EXTRACT(value, "$.authType")
|
||||
),
|
||||
'"',
|
||||
''
|
||||
)
|
||||
)
|
||||
WHERE deleted = 0
|
||||
AND type = 'HOST'
|
||||
AND item = 'ssh'
|
||||
AND JSON_CONTAINS(value, JSON_OBJECT('identityId', #{identityId}))
|
||||
AND type = 'HOST'
|
||||
AND item = 'ssh'
|
||||
<foreach collection="identityIdList" item="item" separator="OR" open="AND (" close=")">
|
||||
JSON_CONTAINS(value, JSON_OBJECT('identityId', #{item}))
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user