@Override
public List<BuildListVo> getBuildListLike(Long estateId, Long courtId, String buildName) {
//QueryWrapper queryWrapper = new QueryWrapper();
LambdaQueryWrapper<Build> wrapper = new LambdaQueryWrapper<>();
if(estateId != null){
wrapper.eq(Build::getEstateId, estateId);
}
if(courtId != null){
wrapper.eq(Build::getCourtId, courtId);
}else{
wrapper.isNull(Build::getCourtId);
}
if(StringUtils.isNotBlank(buildName)){
wrapper.like(Build::getBuildName, buildName);
}
wrapper.orderByDesc(Build::getBuildName);
List<Build> list = baseMapper.selectList(wrapper);
List<BuildListVo> buildListVoList = new ArrayList<>();
for(Build build : list){
BuildListVo buildListVo = new BuildListVo();
BeanUtils.copyProperties(build,buildListVo);
if(buildListVo.getEstateId() != null){
Estate estate = estateMapper.selectById(buildListVo.getEstateId());
buildListVo.setEstateName(estate.getEstateName());
}
if(buildListVo.getCourtId() != null){
Court court = courtMapper.selectById(buildListVo.getCourtId());
buildListVo.setCourtName(court.getCourtName());
}
buildListVoList.add(buildListVo);
}
return buildListVoList;
}
@Override
public List<BuildListVo> getBuildListLike(Long estateId, Long courtId, String buildName) {
//QueryWrapper queryWrapper = new QueryWrapper();
QueryWrapper<Build> wrapper = new QueryWrapper<>();
if(estateId != null){
wrapper.eq("estate_id", estateId);
}
if(courtId != null){
wrapper.eq("court_id", courtId);
}else{
wrapper.isNull("court_id");
}
if(StringUtils.isNotBlank(buildName)){
wrapper.like("build_name", buildName);
}
wrapper.orderByAsc("CAST(build_name as int)");
wrapper.orderByAsc("build_name");
List<Build> list = baseMapper.selectList(wrapper);
List<BuildListVo> buildListVoList = new ArrayList<>();
for(Build build : list){
BuildListVo buildListVo = new BuildListVo();
BeanUtils.copyProperties(build,buildListVo);
if(buildListVo.getEstateId() != null){
Estate estate = estateMapper.selectById(buildListVo.getEstateId());
buildListVo.setEstateName(estate.getEstateName());
}
if(buildListVo.getCourtId() != null){
Court court = courtMapper.selectById(buildListVo.getCourtId());
buildListVo.setCourtName(court.getCourtName());
}
buildListVoList.add(buildListVo);
}
return buildListVoList;
}
<select id="getBuildListByCourt" resultType="com.easy.hotel.pms.api.vo.BuildListVo">
select
e.estate_id ,
e.estate_name,
e.community_code,
b.build_type,
b.build_id,
b.build_name,
cour.court_id,
cour.court_name,
CAST(cour.court_name as int) as courtIntSort,
CAST(b.build_name as int) as buildIntSort
from build b
left join court cour on b.court_id = cour.court_id
inner join estate e on b.estate_id = e.estate_id
<where>
and b.estate_id = #{estateId}
and b.del_flag = 0
and e.del_flag = 0
<if test="courtId != null">
and b.court_id = #{courtId}
</if>
<if test="courtId == null">
and b.court_id is null
</if>
<if test="buildName != null and buildName != ''">
and (
b.build_name like concat( '%', #{buildName}, '%')
or cour.court_name like concat( '%', #{buildName}, '%')
or e.estate_name like concat( '%', #{buildName}, '%')
)
</if>
</where>
GROUP BY b.build_id
order by e.community_code, e.estate_id, courtIntSort , cour.court_name , buildIntSort , b.build_name
</select>
<select id="getEstateCourtList" resultType="com.easy.hotel.pms.api.vo.EstateListVo">
select
e.estate_id,
e.estate_no,
e.estate_name,
e.community_code,
cour.court_id ,
cour.court_name,
CAST(cour.court_name as int) as courSort
from estate e
left join court cour on cour.estate_id = e.estate_id
<where>
and e.del_flag = 0
and e.community_code = #{communityCode}
<if test="estateName != null and estateName != ''">
and (
e.estate_name like concat( '%', #{estateName}, '%')
or cour.court_name like concat( '%', #{estateName}, '%')
)
</if>
<if test="estateIdList != null and estateIdList.size() > 0">
and e.estate_id in
<foreach collection="estateIdList" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
order by e.community_code ,e.estate_name , courSort , cour.court_name
</select>