package com.yuchen.saas.park.service.mapper.property;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yuchen.saas.park.api.entity.property.PropertyDepositHouse;
import com.yuchen.saas.park.api.vo.property.PropertyDepositHouseGroupListVo;
import com.yuchen.saas.park.api.vo.property.PropertyDepositHouseListVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PropertyDepositHouseMapper extends BaseMapper<PropertyDepositHouse> {

    @Select("select dh.id,dh.deposit_id,dh.house_id,h.house_name,h.resource_code" +
            " from property_deposit_house dh" +
            " left join property_houses h on dh.house_id = h.id" +
            " where dh.deposit_id in (${depositIds})")
    List<PropertyDepositHouseListVo> listDepositHouse(@Param("depositIds") String depositIds);


    @Select("select deposit_id,GROUP_CONCAT(h.id) as house_ids,GROUP_CONCAT(h.house_name) as house_name,GROUP_CONCAT(h.resource_code) as resource_code" +
            " from property_deposit_house dh" +
            " left join property_houses h on dh.house_id = h.id" +
            " where dh.deposit_id in (${depositIds})" +
            " GROUP BY dh.deposit_id")
    List<PropertyDepositHouseGroupListVo> listDepositHouseGroup(@Param("depositIds") String depositIds);


}
