package com.supervision.pdfqaserver.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.supervision.pdfqaserver.domain.ErAttribute; import com.supervision.pdfqaserver.service.ErAttributeService; import com.supervision.pdfqaserver.mapper.ErAttributeMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * @author Administrator * @description 针对表【er_attribute(实体关系属性表)】的数据库操作Service实现 * @createDate 2025-05-14 15:23:54 */ @Slf4j @Service public class ErAttributeServiceImpl extends ServiceImpl implements ErAttributeService{ @Override public void saveIfAbsents(ErAttribute erAttribute, String domainMetadataId) { Assert.notEmpty(domainMetadataId, "领域分类id不能为空"); List erAttributes = this.listByDomainMetadataId(domainMetadataId); boolean exists = erAttributes.stream().anyMatch(item -> StrUtil.equals(item.getAttrName(), erAttribute.getAttrName()) && StrUtil.equals(item.getErLabel(), erAttribute.getErLabel()) && StrUtil.equals(item.getErType(), erAttribute.getErType())); if (exists){ log.info("属性已存在,{},不进行保存...", erAttribute.getAttrName()); return; } erAttribute.setDomainMetadataId(domainMetadataId); super.save(erAttribute); } @Override public List listByDomainMetadataId(String domainMetadataId) { return super.lambdaQuery().eq(ErAttribute::getDomainMetadataId, domainMetadataId).list(); } @Override public List listByDomainMetadataIds(List domainMetadataIds) { if (CollUtil.isEmpty(domainMetadataIds)){ return List.of(); } return this.lambdaQuery().in(ErAttribute::getDomainMetadataId, domainMetadataIds).list(); } @Override public List listByDomainCategoryId(String domainCategoryId) { if (StrUtil.isEmpty(domainCategoryId)){ return new ArrayList<>(); } return super.getBaseMapper().listByDomainCategoryId(domainCategoryId); } }