This commit is contained in:
六如
2024-10-22 14:13:12 +08:00
parent 89304e8004
commit 483e3969be
18 changed files with 204 additions and 52 deletions

View File

@@ -85,7 +85,7 @@ public class PermGroupController {
*/
@PostMapping("/delete")
public Result<Integer> delete(@Validated @RequestBody IdParam param) {
return Result.ok(permGroupService.deleteById(param.getId()));
return Result.ok(permGroupService.delete(param.getId()));
}

View File

@@ -25,7 +25,7 @@ public class ApiInfo {
private Long id;
/**
* 应用名称
* 所属应用
*/
private String application;

View File

@@ -3,10 +3,14 @@ package com.gitee.sop.adminbackend.service.isv;
import com.gitee.fastmybatis.core.PageInfo;
import com.gitee.fastmybatis.core.query.LambdaQuery;
import com.gitee.fastmybatis.core.support.LambdaService;
import com.gitee.sop.adminbackend.common.exception.BizException;
import com.gitee.sop.adminbackend.dao.entity.PermGroup;
import com.gitee.sop.adminbackend.dao.entity.PermIsvGroup;
import com.gitee.sop.adminbackend.dao.mapper.PermGroupMapper;
import com.gitee.sop.adminbackend.dao.mapper.PermIsvGroupMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Map;
@@ -17,8 +21,11 @@ import java.util.Map;
@Service
public class PermGroupService implements LambdaService<PermGroup, PermGroupMapper> {
public PageInfo<PermGroup> doPage(LambdaQuery<PermGroup> query) {
query.orderByDesc(PermGroup::getId);
@Resource
PermIsvGroupMapper permIsvGroupMapper;
public PageInfo<PermGroup> doPage(LambdaQuery<PermGroup> query) {
query.orderByDesc(PermGroup::getId);
PageInfo<PermGroup> page = this.page(query);
// 格式转换
@@ -34,5 +41,15 @@ public class PermGroupService implements LambdaService<PermGroup, PermGroupMappe
.map(PermGroup::getId, PermGroup::getGroupName);
}
public int delete(Long groupId) {
boolean used = permIsvGroupMapper.query()
.eq(PermIsvGroup::getGroupId, groupId)
.get() != null;
if (used) {
throw new BizException("无法删除:分组已被使用");
}
return this.deleteById(groupId);
}
}

View File

@@ -82,7 +82,12 @@ public class PermIsvGroupService implements LambdaService<PermIsvGroup, PermIsvG
return new ArrayList<>(0);
}
return list.stream().map(PermIsvGroup::getGroupId).distinct().collect(Collectors.toList());
}
public boolean isUsed(Long groupId) {
return this.query()
.eq(PermIsvGroup::getGroupId, groupId)
.get() != null;
}
}