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