# ShiftComplaintRequestServiceImpl.java

    package cloud.wconnect.frontoffice.service.endofshift.impl;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.commonlib.exception.ForbiddenException;
    import cloud.wconnect.frontoffice.entity.endofshift.ShiftComplaintRequest;
    import cloud.wconnect.frontoffice.mapper.endofshift.ShiftComplaintRequestMapper;
    import cloud.wconnect.frontoffice.service.endofshift.IShiftComplaintRequestService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.stereotype.Service;

    import java.text.MessageFormat;
    import java.util.List;
    import java.util.Objects;

    /**
     * <p>
     * 服务实现类
     * </p>
     *
     * @author lichen
     * @since 2023-03-07
     */
    @Service
    @DS("ratelog_manage")
    public class ShiftComplaintRequestServiceImpl extends ServiceImpl<ShiftComplaintRequestMapper, ShiftComplaintRequest> implements IShiftComplaintRequestService {

        /**
         * 校验Guest Complaint是否存在且属于资产
         *
         * @param id         Guest Complaint 主键id
         * @param propertyId 资产id
         * @return cloud.wconnect.frontoffice.entity.endofshiftreport.ShiftDigitalCheckIn
         * @author lichen
         * @date 2023/5/12
         */
        @Override
        public ShiftComplaintRequest checkIsExistAndAffiliation(Integer id, Integer propertyId) {
            //查询Guest Complaint
            ShiftComplaintRequest shiftComplaintRequest = getById(id);
            //校验是否存在
            if (Objects.isNull(shiftComplaintRequest)) {
                throw new BadRequestException(CommonErrorI18nConstant.DATA_NOT_FOUND,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(), "The Guest Complaint does not exist");
            }
            //校验是否属于资产
            if (!shiftComplaintRequest.getPropertyId().equals(propertyId)) {
                throw new ForbiddenException(BaseErrorCodeEnum.DATA_FORBIDDEN.getI18nCode(),
                        BaseErrorCodeEnum.DATA_FORBIDDEN.getCode(),
                        MessageFormat.format("The Guest Complaint is not affiliation to propertyId:{0}; Guest Complaint propertyId:{1}",
                                propertyId, shiftComplaintRequest.getPropertyId()));
            }
            return shiftComplaintRequest;
        }

        /**
         * 根据排班id查询Guest Complaint 信息
         *
         * @param shiftId 排班id
         * @return java.util.List<cloud.wconnect.frontoffice.entity.endofshift.ShiftComplaintRequest>
         * @author lichen
         * @date 2025/6/20
         */
        @Override
        public List<ShiftComplaintRequest> listByShiftId(Integer shiftId) {
            return list(new LambdaQueryWrapper<ShiftComplaintRequest>().eq(ShiftComplaintRequest::getShiftId, shiftId));
        }

    }