Merge branch 'feature/high-bug' into test

This commit is contained in:
wangli 2026-02-04 18:32:38 +08:00
commit 0c645dcdf0

View File

@ -6,9 +6,11 @@ import cn.axzo.framework.domain.ServiceException;
import cn.axzo.workflow.common.model.request.category.CategoryGroupVarSearchDto;
import cn.axzo.workflow.common.model.request.category.CategoryGroupVarUpsertDto;
import cn.axzo.workflow.common.model.response.category.CategoryGroupVarItemVo;
import cn.axzo.workflow.core.repository.entity.ExtAxDict;
import cn.axzo.workflow.core.repository.entity.ExtAxDictGroup;
import cn.axzo.workflow.core.repository.entity.ExtAxDictGroupVariable;
import cn.axzo.workflow.core.repository.mapper.ExtAxDictGroupMapper;
import cn.axzo.workflow.core.repository.mapper.ExtAxDictMapper;
import cn.axzo.workflow.core.service.CategoryGroupService;
import cn.axzo.workflow.core.service.CategoryGroupVariableService;
import cn.hutool.core.bean.BeanUtil;
@ -37,17 +39,28 @@ import java.util.stream.Collectors;
public class CategoryGroupServiceImpl extends ServiceImpl<ExtAxDictGroupMapper, ExtAxDictGroup> implements CategoryGroupService {
private final CategoryGroupVariableService categoryGroupVariableService;
private final ExtAxDictMapper extAxDictMapper;
@Override
public List<CategoryGroupVarItemVo> searchGroupAndVarList(CategoryGroupVarSearchDto dto) {
if ((dto.getDictId() == null || dto.getDictId() <= 0) && StringUtils.isBlank(dto.getCategory())) {
throw new ServiceException("dictId和category不能同时为空");
}
if ((Objects.isNull(dto.getDictId()) || dto.getDictId() <= 0) && StringUtils.isNotBlank(dto.getCategory())) {
// 通过注入的 mapper 进行安全查询防止 SQL 注入
ExtAxDict dict = extAxDictMapper.selectOne(new QueryWrapper<ExtAxDict>()
.select("id")
.eq("value", dto.getCategory())
.eq("is_delete", TableIsDeleteEnum.NORMAL.value));
if (dict != null) {
dto.setDictId(dict.getId());
} else {
return Collections.emptyList();
}
}
List<ExtAxDictGroup> extAxDictGroups = this.lambdaQuery()
.eq(Objects.nonNull(dto.getDictId()) && dto.getDictId() > 0, ExtAxDictGroup::getDictId, dto.getDictId())
.inSql((Objects.isNull(dto.getDictId()) || dto.getDictId() <= 0) && StringUtils.isNotBlank(dto.getCategory()), ExtAxDictGroup::getDictId,
String.format("SELECT id FROM ext_ax_dict WHERE value = {0}", 0))
.apply((Objects.isNull(dto.getDictId()) || dto.getDictId() <= 0) && StringUtils.isNotBlank(dto.getCategory()), "1=1", dto.getCategory())
.orderByAsc(ExtAxDictGroup::getOrdinal)
.list();
if (CollectionUtils.isEmpty(extAxDictGroups)) {