# EventSourceLocationServiceImpl.java

    package cloud.wconnect.rateshop.service.rateshop.impl;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.rateshop.entity.rateshop.EventSourceLocation;
    import cloud.wconnect.rateshop.mapper.rateshop.EventSourceLocationMapper;
    import cloud.wconnect.rateshop.service.rateshop.IEventSourceLocationService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.stereotype.Service;

    import java.util.Objects;

    /**
     * <p>
     * 事件源的地址表。一个location可以有多个数据源（url） 服务实现类
     * </p>
     *
     * @author lichen
     * @since 2024-03-01
     */
    @Service
    @DS("rate_shop")
    public class EventSourceLocationServiceImpl extends ServiceImpl<EventSourceLocationMapper, EventSourceLocation> implements IEventSourceLocationService {

        /**
         * 校验location是否存在
         *
         * @param locationId 地址ID
         * @return void
         * @author lichen
         * @date 2024/3/4
         */
        @Override
        public EventSourceLocation checkExist(Integer locationId) {
            EventSourceLocation eventSourceLocation = getById(locationId);
            if (Objects.isNull(eventSourceLocation)) {
                throw new BadRequestException(CommonErrorI18nConstant.DATA_NOT_FOUND,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(),
                        "The location is not found; location id : " + locationId);
            }
            return eventSourceLocation;
        }
    }