package com.community.huiju.dao;

import com.community.huiju.model.TaUserLicense;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TaUserLicenseMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(TaUserLicense record);

    int insertSelective(TaUserLicense record);

    TaUserLicense selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(TaUserLicense record);

    int updateByPrimaryKey(TaUserLicense record);

    /**
     * 根据用户id 和 小区id 和 车牌号 进行查询
     * @return
     */
    @ResultMap("BaseResultMap")
    @Select("select * from ta_user_license where community_id=#{communityId} and ta_user_id = #{userId} and license_plate = #{licensePlate}")
    TaUserLicense selectByUserIdAndCommunityIdAndLicensePlate(@Param("communityId") Integer communityId, @Param("userId") Integer userId, @Param("licensePlate") String licensePlate);

    /**
     * 根据用户id  和 小区 进行查询
     * @param communityId
     * @param userId
     * @return
     */
    @ResultMap("BaseResultMap")
    @Select("select * from ta_user_license where community_id=#{communityId} and ta_user_id = #{userId}")
    List<TaUserLicense> selectAllByCommunityIdAndUserId(@Param("communityId") Integer communityId, @Param("userId") Integer userId);


    /**
     * 根据用户id 和 小区id 和 车牌id 进行查询
     * @return
     */
    @ResultMap("BaseResultMap")
    @Select("select * from ta_user_license where community_id=#{communityId} and ta_user_id = #{userId} and id = #{id}")
    TaUserLicense selectByUserIdAndCommunityIdAndLicenseId(@Param("communityId") Integer communityId, @Param("userId") Integer userId, @Param("id") Integer id);

}