【尚庭公寓SpringBoot + Vue 项目实战】移动端找房功能(二十一)
文章目录
- 【尚庭公寓SpringBoot + Vue 项目实战】移动端找房功能(二十一)
- 1、业务介绍
- 2、接口开发
- 2.1、地区信息
- 2.2、获取全部支付方式列表
- 2.3、房间信息
- 2.2.1. 根据条件分页查询房间列表
- 2.2.2. 根据ID查询房间详细信息
- 2.2.3.根据公寓ID分页查询房间列表
- 2.4、 公寓信息
1、业务介绍
找房模块一共分为三部分
- 地区信息
- 查询省份列表
- 根据省份id查询城市列表
- 根据城市id查询区县列表
- 公寓信息
- 房间信息
- 根据条件分页查询房间列表
- 根据id查询房间详细信息
- 根据公寓id分页查询房间列表
2、接口开发
2.1、地区信息
对于找房模块,地区信息共需三个接口,分别是查询省份列表、根据省份ID查询城市列表、根据城市ID查询区县列表,具体实现如下
在RegionController
中增加如下内容
@Tag(name = "地区信息")
@RestController
@RequestMapping("/app/region")
public class RegionController {
@Autowired
private ProvinceInfoService provinceInfoService;
@Autowired
private CityInfoService cityInfoService;
@Autowired
private DistrictInfoService districtInfoService;
@Operation(summary="查询省份信息列表")
@GetMapping("province/list")
public Result<List<ProvinceInfo>> listProvince(){
List<ProvinceInfo> list = provinceInfoService.list();
return Result.ok(list);
}
@Operation(summary="根据省份id查询城市信息列表")
@GetMapping("city/listByProvinceId")
public Result<List<CityInfo>> listCityInfoByProvinceId(@RequestParam Long id){
LambdaQueryWrapper<CityInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CityInfo::getProvinceId,id);
List<CityInfo> list = cityInfoService.list(queryWrapper);
return Result.ok(list);
}
@GetMapping("district/listByCityId")
@Operation(summary="根据城市id查询区县信息")
public Result<List<DistrictInfo>> listDistrictInfoByCityId(@RequestParam Long id){
LambdaQueryWrapper<DistrictInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DistrictInfo::getCityId,id);
List<DistrictInfo> list = districtInfoService.list(queryWrapper);
return Result.ok(list);
}
}
2.2、获取全部支付方式列表
对于找房模块,支付方式共需一个接口,即获取全部支付方式列表,具体实现如下
在PaymentTypeController
中增加如下内容
@Tag(name = "支付方式接口")
@RestController
@RequestMapping("/app/payment")
public class PaymentTypeController {
@Autowired
private PaymentTypeService service;
@Operation(summary = "获取全部支付方式列表")
@GetMapping("list")
public Result<List<PaymentType>> list() {
List<PaymentType> list = service.list();
return Result.ok(list);
}
}
2.3、房间信息
房间信息共需三个接口,分别是根据条件分页查询房间列表、根据ID查询房间详细信息、根据公寓ID分页查询房间列表,下面逐一实现
首先在RoomController
中注入RoomInfoService
,如下
@Tag(name = "房间信息")
@RestController
@RequestMapping("/app/room")
public class RoomController {
@Autowired
RoomInfoService roomInfoService;
}
2.2.1. 根据条件分页查询房间列表
-
查看请求和响应的数据结构
-
请求数据结构
-
current
和size
为分页相关参数,分别表示当前所处页面和每个页面的记录数。 -
RoomQueryVo
为房间的查询条件,详细结构如下:@Data @Schema(description = "房间查询实体") public class RoomQueryVo { @Schema(description = "省份Id") private Long provinceId; @Schema(description = "城市Id") private Long cityId; @Schema(description = "区域Id") private Long districtId; @Schema(description = "最小租金") private BigDecimal minRent; @Schema(description = "最大租金") private BigDecimal maxRent; @Schema(description = "支付方式") private Long paymentTypeId; @Schema(description = "价格排序方式", allowableValues = {"desc", "asc"}) private String orderType; }
-
-
响应数据结构
单个房间信息记录可查看
com.atguigu.lease.web.app.vo.room.RoomItemVo
,内容如下:@Schema(description = "APP房间列表实体") @Data public class RoomItemVo { @Schema(description = "房间id") private Long id; @Schema(description = "房间号") private String roomNumber; @Schema(description = "租金(元/月)") private BigDecimal rent; @Schema(description = "房间图片列表") private List<GraphVo> graphVoList; @Schema(description = "房间标签列表") private List<LabelInfo> labelInfoList; @Schema(description = "房间所属公寓信息") private ApartmentInfo apartmentInfo; }
-
-
编写Controller层逻辑
在
RoomController
中增加如下内容@Operation(summary = "分页查询房间列表") @GetMapping("pageItem") public Result<IPage<RoomItemVo>> pageItem(@RequestParam long current, @RequestParam long size, RoomQueryVo queryVo) { Page<RoomItemVo> page = new Page<>(current, size); IPage<RoomItemVo> list = roomInfoService.pageRoomItemByQuery(page, queryVo); return Result.ok(list); }
-
编写Service层逻辑
-
在
RoomInfoService
中增加如下内容IPage<RoomItemVo> pageRoomItemByQuery(Page<RoomItemVo> page, RoomQueryVo queryVo);
-
在
RoomInfoServiceImpl
中增加如下内容@Override public IPage<RoomItemVo> pageRoomItemByQuery(Page<RoomItemVo> page, RoomQueryVo queryVo) { return roomInfoMapper.pageRoomItemByQuery(page, queryVo); }
-
-
编写Mapper层逻辑
-
在
RoomInfoMapper
中增加如下内容IPage<RoomItemVo> pageRoomItemByQuery(Page<RoomItemVo> page, RoomQueryVo queryVo);
-
在
RoomInfoMapper
中增加如下内容<!-- result map --> <resultMap id="RoomItemVoMap" type="com.atguigu.lease.web.app.vo.room.RoomItemVo" autoMapping="true"> <id column="id" property="id"/> <!--映射公寓信息--> <association property="apartmentInfo" javaType="com.atguigu.lease.model.entity.ApartmentInfo" autoMapping="true"> <id column="id" property="id"/> </association> <!--映射图片列表--> <collection property="graphVoList" ofType="com.atguigu.lease.web.app.vo.graph.GraphVo" select="selectGraphVoListByRoomId" column="id"/> <!--映射标签列表--> <collection property="labelInfoList" ofType="com.atguigu.lease.model.entity.LabelInfo" select="selectLabelInfoListByRoomId" column="id"/> </resultMap> <!-- 根据条件查询房间列表 --> <select id="pageItem" resultMap="RoomItemVoMap"> select ri.id, ri.room_number, ri.rent, ai.id apartment_id, ai.name, ai.introduction, ai.district_id, ai.district_name, ai.city_id, ai.city_name, ai.province_id, ai.province_name, ai.address_detail, ai.latitude, ai.longitude, ai.phone, ai.is_release from room_info ri left join apartment_info ai on ri.apartment_id = ai.id and ai.is_deleted = 0 <where> ri.is_deleted = 0 and ri.is_release = 1 and ri.id not in( select room_id from lease_agreement where is_deleted = 0 and status in(2,5)) <if test="queryVo.provinceId != null"> and ai.province_id = #{queryVo.provinceId} </if> <if test="queryVo.cityId != null"> and ai.city_id = #{queryVo.cityId} </if> <if test="queryVo.districtId != null"> and ai.district_id = #{queryVo.districtId} </if> <if test="queryVo.minRent != null and queryVo.maxRent != null"> and (ri.rent >= #{queryVo.minRent} and ri.rent <= #{queryVo.maxRent}) </if> <if test="queryVo.paymentTypeId != null"> and ri.id in ( select room_id from room_payment_type where is_deleted = 0 and payment_type_id = #{queryVo.paymentTypeId} ) </if> </where> <if test="queryVo.orderType == 'desc' or queryVo.orderType == 'asc'"> order by ri.rent ${queryVo.orderType} </if> </select> <!-- 根据房间ID查询图片列表 --> <select id="selectGraphVoListByRoomId" resultType="com.atguigu.lease.web.app.vo.graph.GraphVo"> select id, name, item_type, item_id, url from graph_info where is_deleted = 0 and item_type = 2 and item_id = #{id} </select> <!-- 根据公寓ID查询标签列表 --> <select id="selectLabelInfoListByRoomId" resultType="com.atguigu.lease.model.entity.LabelInfo"> select id, type, name from label_info where is_deleted = 0 and id in (select label_id from room_label where is_deleted = 0 and room_id = #{id}) </select>
知识点:
-
xml文件
<
和>
的转义由于xml文件中的
<
和>
是特殊符号,需要转义处理。原符号 转义符号 <
<
>
>
-
Mybatis-Plus分页插件注意事项
使用Mybatis-Plus的分页插件进行分页查询时,如果结果需要使用
<collection>
进行映射,只能使用**嵌套查询(Nested Select for Collection),而不能使用嵌套结果映射(Nested Results for Collection)**。嵌套查询和嵌套结果映射是Collection映射的两种方式,下面通过一个案例进行介绍
例如有
room_info
和graph_info
两张表,其关系为一对多,如下
现需要查询房间列表及其图片信息,期望返回的结果如下
[ { "id": 1, "number": 201, "rent": 2000, "graphList": [ { "id": 1, "url": "http://", "roomId": 1 }, { "id": 2, "url": "http://", "roomId": 1 } ] }, { "id": 2, "number": 202, "rent": 3000, "graphList": [ { "id": 3, "url": "http://", "roomId": 2 }, { "id": 4, "url": "http://", "roomId": 2 } ] } ]
为得到上述结果,可使用以下两种方式
-
嵌套结果映射
<select id="selectRoomPage" resultMap="RoomPageMap"> select ri.id room_id, ri.number, ri.rent, gi.id graph_id, gi.url, gi.room_id from room_info ri left join graph_info gi on ri.id=gi.room_id </select> <resultMap id="RoomPageMap" type="RoomInfoVo" autoMapping="true"> <id column="room_id" property="id"/> <collection property="graphInfoList" ofType="GraphInfo" autoMapping="true"> <id column="graph_id" property="id"/> </collection> </resultMap>
这种方式的执行原理如下图所示
-
嵌套查询
<select id="selectRoomPage" resultMap="RoomPageMap"> select id, number, rent from room_info </select> <resultMap id="RoomPageMap" type="RoomInfoVo" autoMapping="true"> <id column="id" property="id"/> <collection property="graphInfoList" ofType="GraphInfo" select="selectGraphByRoomId" column="id"/> </resultMap> <select id="selectGraphByRoomId" resultType="GraphInfo"> select id, url, room_id from graph_info where room_id = #{id} </select>
这种方法使用两个独立的查询语句来获取一对多关系的数据。首先,Mybatis会执行主查询来获取
room_info
列表,然后对于每个room_info
,Mybatis都会执行一次子查询来获取其对应的graph_info
。
若现在使用MybatisPlus的分页插件进行分页查询,假如查询的内容是第1页,每页2条记录,则上述两种方式的查询结果分别是
- 嵌套结果映射
-
嵌套查询
显然嵌套结果映射的分页逻辑是存在问题的。
-
-
-
2.2.2. 根据ID查询房间详细信息
-
查看响应数据结构
查看web-app模块下的
com.atguigu.lease.web.app.vo.room.RoomDetailVo
,内容如下@Data @Schema(description = "APP房间详情") public class RoomDetailVo extends RoomInfo { @Schema(description = "所属公寓信息") private ApartmentItemVo apartmentItemVo; @Schema(description = "图片列表") private List<GraphVo> graphVoList; @Schema(description = "属性信息列表") private List<AttrValueVo> attrValueVoList; @Schema(description = "配套信息列表") private List<FacilityInfo> facilityInfoList; @Schema(description = "标签信息列表") private List<LabelInfo> labelInfoList; @Schema(description = "支付方式列表") private List<PaymentType> paymentTypeList; @Schema(description = "杂费列表") private List<FeeValueVo> feeValueVoList; @Schema(description = "租期列表") private List<LeaseTerm> leaseTermList; }
-
编写Controller层逻辑
在
RoomController
中增加如下内容@Operation(summary = "根据id获取房间的详细信息") @GetMapping("getDetailById") public Result<RoomDetailVo> getDetailById(@RequestParam Long id) { RoomDetailVo roomInfo = service.getDetailById(id); return Result.ok(roomInfo); }
-
编写查询房间信息逻辑
-
编写Service层逻辑
-
在
RoomInfoService
中增加如下内容RoomDetailVo getDetailById(Long id);
-
在
RoomInfoServiceImpl
中增加如下内容@Override public RoomDetailVo getDetailById(Long id) { //1.查询房间信息 RoomInfo roomInfo = roomInfoMapper.selectById(id); if (roomInfo == null) { return null; } //2.查询图片 List<GraphVo> graphVoList = graphInfoMapper.selectListByItemTypeAndId(ItemType.ROOM, id); //3.查询租期 List<LeaseTerm> leaseTermList = leaseTermMapper.selectListByRoomId(id); //4.查询配套 List<FacilityInfo> facilityInfoList = facilityInfoMapper.selectListByRoomId(id); //5.查询标签 List<LabelInfo> labelInfoList = labelInfoMapper.selectListByRoomId(id); //6.查询支付方式 List<PaymentType> paymentTypeList = paymentTypeMapper.selectListByRoomId(id); //7.查询基本属性 List<AttrValueVo> attrValueVoList = attrValueMapper.selectListByRoomId(id); //8.查询杂费信息 List<FeeValueVo> feeValueVoList = feeValueMapper.selectListByApartmentId(roomInfo.getApartmentId()); //9.查询公寓信息 ApartmentItemVo apartmentItemVo = apartmentInfoService.selectApartmentItemVoById(roomInfo.getApartmentId()); RoomDetailVo roomDetailVo = new RoomDetailVo(); BeanUtils.copyProperties(roomInfo, roomDetailVo); roomDetailVo.setApartmentItemVo(apartmentItemVo); roomDetailVo.setGraphVoList(graphVoList); roomDetailVo.setAttrValueVoList(attrValueVoList); roomDetailVo.setFacilityInfoList(facilityInfoList); roomDetailVo.setLabelInfoList(labelInfoList); roomDetailVo.setPaymentTypeList(paymentTypeList); roomDetailVo.setFeeValueVoList(feeValueVoList); roomDetailVo.setLeaseTermList(leaseTermList); return roomDetailVo; }
-
-
编写Mapper层逻辑
-
编写查询房间图片逻辑
-
在
GraphInfoMapper
中增加如下内容List<GraphVo> selectListByItemTypeAndId(ItemType itemType, Long id);
-
在
GraphInfoMapper.xml
增加如下内容<select id="selectListByItemTypeAndId" resultType="com.atguigu.lease.web.app.vo.graph.GraphVo"> select name, url from graph_info where is_deleted = 0 and item_type = #{itemType} and item_id = #{id} </select>
-
-
编写查询房间可选租期逻辑
-
在
LeaseTermMapper
中增加如下内容List<LeaseTerm> selectListByRoomId(Long id);
-
在
LeaseTermMapper.xml
中增加如下内容<select id="selectListByRoomId" resultType="com.atguigu.lease.model.entity.LeaseTerm"> select id, month_count, unit from lease_term where is_deleted = 0 and id in (select lease_term_id from room_lease_term where is_deleted = 0 and room_id = #{id}) </select>
-
-
编写查询房间配套逻辑
-
在
FacilityInfoMapper
中增加如下内容List<FacilityInfo> selectListByRoomId(Long id);
-
在
FacilityInfoMapper.xml
中增加如下内容<select id="selectListByRoomId" resultType="com.atguigu.lease.model.entity.FacilityInfo"> select id, type, name, icon from facility_info where is_deleted = 0 and id in (select facility_id from room_facility where is_deleted = 0 and room_id = #{id}) </select>
-
-
编写查询房间标签逻辑
-
在
LabelInfoMapper
中增加如下内容List<LabelInfo> selectListByRoomId(Long id);
-
在
LabelInfoMapper.xml
中增加如下内容<select id="selectListByRoomId" resultType="com.atguigu.lease.model.entity.LabelInfo"> select id, type, name from label_info where is_deleted = 0 and id in (select label_id from room_label where is_deleted = 0 and room_id = #{id}) </select>
-
-
编写查询房间可选支付方式逻辑
-
在
PaymentTypeMapper
中增加如下内容List<PaymentType> selectListByRoomId(Long id);
-
在
PaymentTypeMapper.xml
中增加如下内容<select id="selectListByRoomId" resultType="com.atguigu.lease.model.entity.PaymentType"> select id, name, pay_month_count, additional_info from payment_type where is_deleted = 0 and id in (select payment_type_id from room_payment_type where is_deleted = 0 and room_id = #{id}) </select>
-
-
编写查询房间属性逻辑
-
在
AttrValueMapper
中增加如下内容List<AttrValueVo> selectListByRoomId(Long id);
-
在
AttrValueMapper.xml
中增加如下内容<select id="selectListByRoomId" resultType="com.atguigu.lease.web.app.vo.attr.AttrValueVo"> select av.id, av.name, av.attr_key_id, ak.name attr_key_name from attr_value av left join attr_key ak on av.attr_key_id = ak.id and ak.is_deleted = 0 where av.is_deleted = 0 and av.id in (select attr_value_id from room_attr_value where is_deleted = 0 and room_id = #{id}) </select>
-
-
编写查询房间杂费逻辑
-
在
FeeValueMapper
中增加如下内容List<FeeValueVo> selectListByApartmentId(Long id);
-
在
FeeValueMapper.xml
中增加如下内容<select id="selectListByApartmentId" resultType="com.atguigu.lease.web.app.vo.fee.FeeValueVo"> select fv.id, fv.name, fv.unit, fv.fee_key_id, fk.name fee_key_name from fee_value fv left join fee_key fk on fv.fee_key_id = fk.id and fk.is_deleted = 0 where fv.is_deleted = 0 and fv.id in (select fee_value_id from apartment_fee_value where is_deleted = 0 and apartment_id = #{id}) </select>
-
-
-
-
编写查询所属公寓信息逻辑
-
编写Service层逻辑
在
ApartmentInfoService
中增加如下内容ApartmentItemVo selectApartmentItemVoById(Long id);
在
ApartmentInfoServiceImpl
中增加如下内容@Override public ApartmentItemVo selectApartmentItemVoById(Long id) { ApartmentInfo apartmentInfo = apartmentInfoMapper.selectById(id); List<LabelInfo> labelInfoList = labelInfoMapper.selectListByApartmentId(id); List<GraphVo> graphVoList = graphInfoMapper.selectListByItemTypeAndId(ItemType.APARTMENT, id); BigDecimal minRent = roomInfoMapper.selectMinRentByApartmentId(id); ApartmentItemVo apartmentItemVo = new ApartmentItemVo(); BeanUtils.copyProperties(apartmentInfo, apartmentItemVo); apartmentItemVo.setGraphVoList(graphVoList); apartmentItemVo.setLabelInfoList(labelInfoList); apartmentItemVo.setMinRent(minRent); return apartmentItemVo; }
-
-
编写Mapper层逻辑
-
编写查询标签信息逻辑
-
在
LabelInfoMapper
中增加如下内容List<LabelInfo> selectListByApartmentId(Long id);
-
在
LabelInfoMapper.xml
中增加如下内容<select id="selectListByApartmentId" resultType="com.atguigu.lease.model.entity.LabelInfo"> select id, type, name from label_info where is_deleted = 0 and id in (select label_id from apartment_label where is_deleted = 0 and apartment_id = #{id}) </select>
-
编写查询公寓最小租金逻辑
-
在
RoomInfoMapper
中增加如下内容BigDecimal selectMinRentByApartmentId(Long id);
-
在
RoomInfoMapper.xml
中增加如下内容<select id="selectMinRentByApartmentId" resultType="java.math.BigDecimal"> select min(rent) from room_info where is_deleted = 0 and is_release = 1 and apartment_id = #{id} </select>
-
-
-
2.2.3.根据公寓ID分页查询房间列表
-
查看请求和响应的数据结构
-
请求的数据结构
current
和size
为分页相关参数,分别表示当前所处页面和每个页面的记录数。id
为公寓ID。
-
响应的数据结构
-
查看web-admin模块下的
com.atguigu.lease.web.app.vo.room.RoomItemVo
,如下@Schema(description = "APP房间列表实体") @Data public class RoomItemVo { @Schema(description = "房间id") private Long id; @Schema(description = "房间号") private String roomNumber; @Schema(description = "租金(元/月)") private BigDecimal rent; @Schema(description = "房间图片列表") private List<GraphVo> graphVoList; @Schema(description = "房间标签列表") private List<LabelInfo> labelInfoList; @Schema(description = "房间所属公寓信息") private ApartmentInfo apartmentInfo; }
-
-
-
编写Controller层逻辑
在
RoomController
中增加如下内容@Operation(summary = "根据公寓id分页查询房间列表") @GetMapping("pageItemByApartmentId") public Result<IPage<RoomItemVo>> pageItemByApartmentId(@RequestParam long current, @RequestParam long size, @RequestParam Long id) { IPage<RoomItemVo> page = new Page<>(current, size); IPage<RoomItemVo> result = service.pageItemByApartmentId(page, id); return Result.ok(result); }
-
编写Service层逻辑
在
RoomInfoService
中增加如下内容IPage<RoomItemVo> pageItemByApartmentId(IPage<RoomItemVo> page, Long id);
在
RoomInfoServiceImpl
中增加如下内容@Override public IPage<RoomItemVo> pageItemByApartmentId(IPage<RoomItemVo> page, Long id) { return roomInfoMapper.pageItemByApartmentId(page, id); }
-
编写Mapper层逻辑
在
RoomInfoMapper
中增加如下内容IPage<RoomItemVo> pageItemByApartmentId(IPage<RoomItemVo> page, Long id);
在
RoomInfoMapper.xml
中增加如下内容<select id="pageItemByApartmentId" resultMap="RoomItemVoMap"> select ri.id, ri.room_number, ri.rent, ai.id apartment_id, ai.name, ai.introduction, ai.district_id, ai.district_name, ai.city_id, ai.city_name, ai.province_id, ai.province_name, ai.address_detail, ai.latitude, ai.longitude, ai.phone, ai.is_release from room_info ri left join apartment_info ai on ri.apartment_id = ai.id and ai.is_deleted = 0 where ri.is_deleted = 0 and ri.is_release = 1 and ai.id = #{id} and ri.id not in (select room_id from lease_agreement where is_deleted = 0 and status in (2, 5)) </select>
2.4、 公寓信息
公寓信息只需一个接口,即根据ID查询公寓详细信息,具体实现如下
首先在ApartmentController
中注入ApartmentInfoService
,如下
@RestController
@Tag(name = "公寓信息")
@RequestMapping("/app/apartment")
public class ApartmentController {
@Autowired
private ApartmentInfoService service;
}
-
查看响应的数据结构
查看web-app模块下的
com.atguigu.lease.web.app.vo.apartment.ApartmentDetailVo
,内容如下@Data @Schema(description = "APP端公寓信息详情") public class ApartmentDetailVo extends ApartmentInfo { @Schema(description = "图片列表") private List<GraphVo> graphVoList; @Schema(description = "标签列表") private List<LabelInfo> labelInfoList; @Schema(description = "配套列表") private List<FacilityInfo> facilityInfoList; @Schema(description = "租金最小值") private BigDecimal minRent; }
-
编写Controller层逻辑
在
ApartmentController
中增加如下内容@Operation(summary = "根据id获取公寓信息") @GetMapping("getDetailById") public Result<ApartmentDetailVo> getDetailById(@RequestParam Long id) { ApartmentDetailVo apartmentDetailVo = service.getApartmentDetailById(id); return Result.ok(apartmentDetailVo); }
-
编写Service层逻辑
-
在
ApartmentInfoService
中增加如下内容ApartmentDetailVo getDetailById(Long id);
-
在
ApartmentInfoServiceImpl
中增加如下内容@Override public ApartmentDetailVo getDetailById(Long id) { //1.查询公寓信息 ApartmentInfo apartmentInfo = apartmentInfoMapper.selectById(id); //2.查询图片信息 List<GraphVo> graphVoList = graphInfoMapper.selectListByItemTypeAndId(ItemType.APARTMENT, id); //3.查询标签信息 List<LabelInfo> labelInfoList = labelInfoMapper.selectListByApartmentId(id); //4.查询配套信息 List<FacilityInfo> facilityInfoList = facilityInfoMapper.selectListByApartmentId(id); //5.查询最小租金 BigDecimal minRent = roomInfoMapper.selectMinRentByApartmentId(id); ApartmentDetailVo apartmentDetailVo = new ApartmentDetailVo(); BeanUtils.copyProperties(apartmentInfo, apartmentDetailVo); apartmentDetailVo.setGraphVoList(graphVoList); apartmentDetailVo.setLabelInfoList(labelInfoList); apartmentDetailVo.setFacilityInfoList(facilityInfoList); apartmentDetailVo.setMinRent(minRent); return apartmentDetailVo; }
-
-
编写Mapper层逻辑
-
编写查询公寓配套逻辑
-
在
FacilityInfoMapper
中增加如下内容List<FacilityInfo> selectListByApartmentId(Long id);
-
在
FacilityInfoMapper.xml
中增加如下内容<select id="selectListByApartmentId" resultType="com.atguigu.lease.model.entity.FacilityInfo"> select id, type, name, icon from facility_info where is_deleted = 0 and id in (select facility_id from apartment_facility where is_deleted = 0 and apartment_id = #{id}) </select>
-
-