# ScoreCardGmConfigServiceImpl.java

    package cloud.wconnect.workperformance.service.scorecardgm.impl;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.workperformance.entity.scorecardgm.ScoreCardGmConfig;
    import cloud.wconnect.workperformance.mapper.scorecardgm.ScoreCardGmConfigMapper;
    import cloud.wconnect.workperformance.service.scorecardgm.IScoreCardGmConfigService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.stereotype.Service;

    import java.util.List;
    import java.util.Objects;

    /**
     * <p>
     * 服务实现类
     * </p>
     *
     * @author yyt
     * @since 2023-10-04
     */
    @Service
    @DS("monthly_report")
    public class ScoreCardGmConfigServiceImpl extends ServiceImpl<ScoreCardGmConfigMapper, ScoreCardGmConfig> implements IScoreCardGmConfigService {

        /**
         * 查询资产下指标配置
         *
         * @param propertyId 资产 id
         * @param status     状态
         * @return 指标配置
         * @author yyt
         * @date 2023/10/4
         */
        @Override
        public List<ScoreCardGmConfig> listByStatus(Integer propertyId, Boolean status) {
            return list(new QueryWrapper<ScoreCardGmConfig>().lambda().eq(ScoreCardGmConfig::getPropertyId, propertyId)
                    .eq(Objects.nonNull(status), ScoreCardGmConfig::getStatus, status));
        }

        /**
         * 校验存在
         *
         * @param id 指标 id
         * @return 指标
         * @author yyt
         * @date 2023/10/5
         */
        @Override
        public ScoreCardGmConfig checkExist(int id) {
            ScoreCardGmConfig config = getById(id);
            if (Objects.isNull(config)) {
                throw new BadRequestException(CommonErrorI18nConstant.DATA_NOT_FOUND,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(), "the scoreCardGmConfig is not found;id:" + id);
            }
            return config;
        }

        /**
         * 查询资产下指标配置
         *
         * @param propertyId 资产 id
         * @param ids        指标 id
         * @return 指标配置
         * @author yyt
         * @date 2023/10/4
         */
        @Override
        public List<ScoreCardGmConfig> listByIds(Integer propertyId, List<Integer> ids) {
            return list(new QueryWrapper<ScoreCardGmConfig>().lambda()
                    .in(ScoreCardGmConfig::getId, ids)
                    .eq(ScoreCardGmConfig::getPropertyId, propertyId));
        }

    }