package com.fdkanfang.dao.backend;

import com.fdkanfang.dao.backend.provider.HouseProvider;
import com.fdkanfang.domain.backend.HouseEntity;
import com.fdkanfang.domain.response.HouseResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@Mapper
public interface HouseMapper extends IBaseMapper<HouseEntity, Long> {

    @SelectProvider(type = HouseProvider.class, method = "findAllBySearchKey")
    List<HouseResponse> findAllBySearchKey(String searchKey, Long userId, Long handlerId);

    /** 获取最大值 */
    @Select(value = "select MAX(num)  from tb_house")
    Integer findByMaxNum();

    @Select(value = "select id, num from tb_house where num = #{num}")
    List<HouseEntity> findByNum(String num);

    @Select(value = "select * from tb_house where scene_code = #{sceneCode}")
    HouseEntity findBySceneCode(String sceneCode);

    @SelectProvider(type = HouseProvider.class, method = "findBySearchKey")
    List<HouseResponse> findBySearchKey(String searchKey, Long userId, Long handlerId);

    @SelectProvider(type = HouseProvider.class, method = "findBySearchKeyForEditOrUploader")
    List<HouseResponse> findBySearchKeyForEditOrUploader(String searchKey, Long handlerId, Long uploadId);
}