交河做网站,263企业邮箱登陆入囗,微信开发者账号,常见的网站布局结构【尚庭公寓SpringBoot Vue 项目实战】预约看房与租约管理#xff08;完结#xff09; 文章目录 【尚庭公寓SpringBoot Vue 项目实战】预约看房与租约管理#xff08;完结#xff09;1、业务说明2、接口开发2.1、预约看房管理2.1.1.保存或更新看房预约2.1.2. 查询个人预约…【尚庭公寓SpringBoot Vue 项目实战】预约看房与租约管理完结 文章目录 【尚庭公寓SpringBoot Vue 项目实战】预约看房与租约管理完结1、业务说明2、接口开发2.1、预约看房管理2.1.1.保存或更新看房预约2.1.2. 查询个人预约看房列表2.1.3. 根据ID查询预约详情信息 2.2、租约管理2.2.1. 获取个人租约基本信息列表2.2.2. 根据ID获取租约详细信息2.2.3. 根据ID更新租约状态2.2.4. 保存或更新租约2.2.5. 根据房间ID获取可选支付方式2.2.6.根据房间ID获取可选租期 1、业务说明
预约看房管理共需三个接口分别是保存或更新看房预约、查询个人预约列表和根据ID查询预约详情信息
租约管理共有六个接口分别是获取个人租约基本信息列表**、**根据ID获取租约详细信息、根据ID更新租约状态、保存或更新租约、根据房间ID获取可选支付方式和根据房间ID获取可选租期
2、接口开发
2.1、预约看房管理 首先在ViewAppointmentController中注入ViewAppointmentService如下
Tag(name 看房预约信息)
RestController
RequestMapping(/app/appointment)
public class ViewAppointmentController {Autowiredprivate ViewAppointmentService service;
}2.1.1.保存或更新看房预约
在ViewAppointmentController中增加如下内容
Operation(summary 保存或更新看房预约)
PostMapping(/saveOrUpdate)
public Result saveOrUpdate(RequestBody ViewAppointment viewAppointment) {viewAppointment.setUserId(LoginUserHolder.getLoginUser().getUserId());service.saveOrUpdate(viewAppointment);return Result.ok();
}2.1.2. 查询个人预约看房列表 查看响应的数据结构 查看web-app模块下的com.atguigu.lease.web.app.vo.appointment.AppointmentItemVo如下 Data
Schema(description APP端预约看房基本信息)
public class AppointmentItemVo {Schema(description 预约Id)private Long id;Schema(description 预约公寓名称)private String apartmentName;Schema(description 公寓图片列表)private ListGraphVo graphVoList;Schema(description 预约时间)JsonFormat(pattern yyyy-MM-dd HH:mm:ss)private Date appointmentTime;Schema(description 当前预约状态)private AppointmentStatus appointmentStatus;
}编写Controller层逻辑 在ViewAppointmentController中增加如下内容 Operation(summary 查询个人预约看房列表)
GetMapping(listItem)
public ResultListAppointmentItemVo listItem() {ListAppointmentItemVo list service.listItemByUserId(LoginUserHolder.getLoginUser().getUserId());return Result.ok(list);
}编写Service层逻辑 在ViewAppointmentService中增加如下内容 ListAppointmentItemVo listItemByUserId(Long userId);在ViewAppointmentServiceImpl中增加如下内容 Override
public ListAppointmentItemVo listItemByUserId(Long userId) {return viewAppointmentMapper.listItemByUserId(userId);
}编写Mapper层逻辑 在ViewAppointmentMapper中增加如下内容 ListAppointmentItemVo listItemByUserId(Long userId);在ViewAppointmentMapper.xml中增加如下内容 resultMap idAppointmentItemVoMap typecom.atguigu.lease.web.app.vo.appointment.AppointmentItemVoautoMappingtrueid columnid propertyid/collection propertygraphVoList ofTypecom.atguigu.lease.web.app.vo.graph.GraphVo autoMappingtrue/
/resultMapselect idlistItemByUserId resultMapAppointmentItemVoMapselect va.id,va.appointment_time,va.appointment_status,ai.name apartment_name,gi.name,gi.urlfrom view_appointment valeft join apartment_info ai on va.apartment_id ai.id and ai.is_deleted 0left join graph_info gi on gi.item_type 1 and gi.item_id ai.id and gi.is_deleted 0where va.is_deleted 0and va.user_id #{userId}order by va.create_time desc
/select2.1.3. 根据ID查询预约详情信息 查看相应的数据结构 查看web-app模块下的com.atguigu.lease.web.app.vo.appointment.AppointmentDetailVo内容如下 Data
Schema(description APP端预约看房详情)
public class AppointmentDetailVo extends ViewAppointment {Schema(description 公寓基本信息)private ApartmentItemVo apartmentItemVo;
}编写Controller层逻辑 在ViewAppointmentController中增加如下内容 GetMapping(getDetailById)
Operation(summary 根据ID查询预约详情信息)
public ResultAppointmentDetailVo getDetailById(Long id) {AppointmentDetailVo appointmentDetailVo service.getDetailById(id);return Result.ok(appointmentDetailVo);
}编写Service层逻辑 在ViewAppointmentService中增加如下内容 AppointmentDetailVo getDetailById(Long id);在ViewAppointmentServiceImpl中增加如下内容 Override
public AppointmentDetailVo getDetailById(Long id) {ViewAppointment viewAppointment viewAppointmentMapper.selectById(id);ApartmentItemVo apartmentItemVo apartmentInfoService.selectApartmentItemVoById(viewAppointment.getApartmentId());AppointmentDetailVo agreementDetailVo new AppointmentDetailVo();BeanUtils.copyProperties(viewAppointment, agreementDetailVo);agreementDetailVo.setApartmentItemVo(apartmentItemVo);return agreementDetailVo;
}2.2、租约管理 首先在LeaseAgreementController中注入LeaseAgreementService如下
RestController
RequestMapping(/app/agreement)
Tag(name 租约信息)
public class LeaseAgreementController {Autowiredprivate LeaseAgreementService service;
}2.2.1. 获取个人租约基本信息列表 查看响应的数据结构 查看web-appp模块下的com.atguigu.lease.web.app.vo.agreement.AgreementItemVo内容如下 Data
Schema(description 租约基本信息)
public class AgreementItemVo {Schema(description 租约id)private Long id;Schema(description 房间图片列表)private ListGraphVo roomGraphVoList;Schema(description 公寓名称)private String apartmentName;Schema(description 房间号)private String roomNumber;Schema(description 租约状态)private LeaseStatus leaseStatus;Schema(description 租约开始日期)JsonFormat(pattern yyyy-MM-dd)private Date leaseStartDate;Schema(description 租约结束日期)JsonFormat(pattern yyyy-MM-dd)private Date leaseEndDate;Schema(description 租约来源)private LeaseSourceType sourceType;Schema(description 租金)private BigDecimal rent;
}编写Controller层逻辑 在LeaseAgreementController中增加如下内容 Operation(summary 获取个人租约基本信息列表)
GetMapping(listItem)
public ResultListAgreementItemVo listItem() {ListAgreementItemVo result service.listItemByPhone(LoginUserHolder.getLoginUser().getUsername());return Result.ok(result);
}编写Service层逻辑 在LeaseAgreementService中增加如下内容 ListAgreementItemVo listItemByPhone(String phone);在LeaseAgreementServiceImpl中增加如下内容 Override
public ListAgreementItemVo listItemByPhone(String phone) {return leaseAgreementMapper.listItemByPhone(phone);
}编写Mapper层逻辑 在LeaseAgreementMapper中增加如下内容 ListAgreementItemVo listItemByPhone(String phone);在LeaseAgreementMapper.xml中增加如下内容 resultMap idAgreementItemVoMap typecom.atguigu.lease.web.app.vo.agreement.AgreementItemVo autoMappingtrueid propertyid columnid/collection propertyroomGraphVoList ofTypecom.atguigu.lease.web.app.vo.graph.GraphVo autoMappingtrue/
/resultMapselect idlistItemByPhone resultMapAgreementItemVoMapselect la.id,la.lease_start_date,la.lease_end_date,la.rent,la.payment_type_id,la.status lease_status,la.source_type,ai.name apartment_name,ri.room_number,gi.name,gi.urlfrom lease_agreement laleft join apartment_info ai on la.apartment_id ai.id and ai.is_deleted 0left join room_info ri on la.room_id ri.id and ri.is_deleted 0left join graph_info gi on gi.item_type 2 and gi.item_id ri.id and gi.is_deleted 0where la.is_deleted 0and la.phone #{phone}/select2.2.2. 根据ID获取租约详细信息 查看响应的数据结构 查看web-app模块下的com.atguigu.lease.web.app.vo.agreement.AgreementDetailVo内容如下 Data
Schema(description 租约详细信息)
public class AgreementDetailVo extends LeaseAgreement {Schema(description 租约id)private Long id;Schema(description 公寓名称)private String apartmentName;Schema(description 公寓图片列表)private ListGraphVo apartmentGraphVoList;Schema(description 房间号)private String roomNumber;Schema(description 房间图片列表)private ListGraphVo roomGraphVoList;Schema(description 支付方式)private String paymentTypeName;Schema(description 租期月数)private Integer leaseTermMonthCount;Schema(description 租期单位)private String leaseTermUnit;}编写Controller层逻辑 在LeaseAgreementController中增加如下内容 Operation(summary 根据id获取租约详细信息)
GetMapping(getDetailById)
public ResultAgreementDetailVo getDetailById(RequestParam Long id) {AgreementDetailVo agreementDetailVo service.getDetailById(id);return Result.ok(agreementDetailVo);
}编写Service层逻辑 在LeaseAgreementService中增加如下内容 AgreementDetailVo getDetailById(Long id);在LeaseAgreementServiceImpl中增加如下内容 Override
public AgreementDetailVo getDetailById(Long id) {//1.查询租约信息LeaseAgreement leaseAgreement leaseAgreementMapper.selectById(id);if (leaseAgreement null) {return null;}//2.查询公寓信息ApartmentInfo apartmentInfo apartmentInfoMapper.selectById(leaseAgreement.getApartmentId());//3.查询房间信息RoomInfo roomInfo roomInfoMapper.selectById(leaseAgreement.getRoomId());//4.查询图片信息ListGraphVo roomGraphVoList graphInfoMapper.selectListByItemTypeAndId(ItemType.ROOM, leaseAgreement.getRoomId());ListGraphVo apartmentGraphVoList graphInfoMapper.selectListByItemTypeAndId(ItemType.APARTMENT, leaseAgreement.getApartmentId());//5.查询支付方式PaymentType paymentType paymentTypeMapper.selectById(leaseAgreement.getPaymentTypeId());//6.查询租期LeaseTerm leaseTerm leaseTermMapper.selectById(leaseAgreement.getLeaseTermId());AgreementDetailVo agreementDetailVo new AgreementDetailVo();BeanUtils.copyProperties(leaseAgreement, agreementDetailVo);agreementDetailVo.setApartmentName(apartmentInfo.getName());agreementDetailVo.setRoomNumber(roomInfo.getRoomNumber());agreementDetailVo.setApartmentGraphVoList(apartmentGraphVoList);agreementDetailVo.setRoomGraphVoList(roomGraphVoList);agreementDetailVo.setPaymentTypeName(paymentType.getName());agreementDetailVo.setLeaseTermMonthCount(leaseTerm.getMonthCount());agreementDetailVo.setLeaseTermUnit(leaseTerm.getUnit());return agreementDetailVo;
}2.2.3. 根据ID更新租约状态 编写Controller层逻辑 在LeaseAgreementController中增加如下内容 Operation(summary 根据id更新租约状态, description 用于确认租约和提前退租)
PostMapping(updateStatusById)
public Result updateStatusById(RequestParam Long id, RequestParam LeaseStatus leaseStatus) {LambdaUpdateWrapperLeaseAgreement updateWrapper new LambdaUpdateWrapper();updateWrapper.eq(LeaseAgreement::getId, id);updateWrapper.set(LeaseAgreement::getStatus, leaseStatus);service.update(updateWrapper);return Result.ok();
}2.2.4. 保存或更新租约 编写Controller层逻辑 在LeaseAgreementController中增加如下内容 Operation(summary 保存或更新租约, description 用于续约)
PostMapping(saveOrUpdate)
public Result saveOrUpdate(RequestBody LeaseAgreement leaseAgreement) {service.saveOrUpdate(leaseAgreement);return Result.ok();
}2.2.5. 根据房间ID获取可选支付方式 编写Controller层逻辑 在PaymentTypeController中增加如下内容 Operation(summary 根据房间id获取可选支付方式列表)
GetMapping(listByRoomId)
public ResultListPaymentType list(RequestParam Long id) {ListPaymentType list service.listByRoomId(id);return Result.ok(list);
}编写Service层逻辑 在PaymentTypeService中增加如下内容 ListPaymentType listByRoomId(Long id);在PaymentTypeServiceImpl中增加如下内容 Override
public ListPaymentType listByRoomId(Long id) {return paymentTypeMapper.selectListByRoomId(id);
}2.2.6.根据房间ID获取可选租期 编写Controller层逻辑 在LeaseTermController中增加如下内容 GetMapping(listByRoomId)
Operation(summary 根据房间id获取可选获取租期列表)
public ResultListLeaseTerm list(RequestParam Long id) {ListLeaseTerm list service.listByRoomId(id);return Result.ok(list);
}编写Service层逻辑 在LeaseTermServcie中曾加如下内容 ListLeaseTerm listByRoomId(Long id);在LeaseTermServiceImpl中增加如下内容 Override
public ListLeaseTerm listByRoomId(Long id) {return leaseTermMapper.selectListByRoomId(id);
}