package com.yuchen.saas.park.service.service.pldoor.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuchen.saas.park.api.entity.pldoor.PlVisitorPowerSet;
import com.yuchen.saas.park.api.request.PlVisitorParkingSpotRequest;
import com.yuchen.saas.park.api.vo.pldoor.PlVisitorSpotVO;
import com.yuchen.saas.park.service.mapper.pldoor.PlVisitorPowerSetMapper;
import com.yuchen.saas.park.service.service.pldoor.PlVisitorPowerSetService;
import org.apache.ibatis.annotations.Param;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 访客权限设置 服务实现类
 * </p>
 *
 * @author miaoqs
 * @since 2024-05-28
 */
@Service
public class PlVisitorPowerSetServiceImpl extends BaseServiceImpl<PlVisitorPowerSetMapper, PlVisitorPowerSet> implements PlVisitorPowerSetService {

    @Resource
    private PlVisitorPowerSetMapper plVisitorPowerSetMapper;

    @Override
    public PlVisitorPowerSet getByProjectId(Long parkId) {
        return getOne(new LambdaQueryWrapper<PlVisitorPowerSet>().eq(PlVisitorPowerSet::getParkId, parkId).last("limit 1"));
    }

    @Override
    public List<PlVisitorSpotVO> getParkingSpotIdListByParam(PlVisitorParkingSpotRequest request) {
        return plVisitorPowerSetMapper.getParkingSpotIdListByParam(request);
    }
}
