feat(dormitory): 添加学生信息字段及关联查询

- 在 DormitoryBed 实体中新增学生昵称、手机号和头像字段
- 修改 DormitoryBedMapper.xml 关联查询 SQL
- 增加与 shop_user 表的左连接以获取学生详细信息
- 查询结果中包含学生真实姓名、电话和头像信息
This commit is contained in:
2025-10-03 15:24:46 +08:00
parent 4bc080ce0c
commit b5452e726f
2 changed files with 14 additions and 1 deletions

View File

@@ -55,6 +55,18 @@ public class DormitoryBed implements Serializable {
@Schema(description = "学生ID") @Schema(description = "学生ID")
private Integer userId; private Integer userId;
@Schema(description = "学生昵称")
@TableField(exist = false)
private String realName;
@Schema(description = "手机号码")
@TableField(exist = false)
private String phone;
@Schema(description = "头像")
@TableField(exist = false)
private String avatar;
@Schema(description = "上下铺 1下铺 2上铺 0无") @Schema(description = "上下铺 1下铺 2上铺 0无")
private Boolean bunk; private Boolean bunk;

View File

@@ -4,11 +4,12 @@
<!-- 关联查询sql --> <!-- 关联查询sql -->
<sql id="selectSql"> <sql id="selectSql">
SELECT a.*, b.name AS buildingName, c.name AS floorName, d.name AS recordName SELECT a.*, b.name AS buildingName, c.name AS floorName, d.name AS recordName, e.real_name AS realName, e.phone AS phone, e.avatar
FROM dormitory_bed a FROM dormitory_bed a
LEFT JOIN dormitory_building b ON a.building_id = b.id LEFT JOIN dormitory_building b ON a.building_id = b.id
LEFT JOIN dormitory_floor c ON a.floor_id = c.id LEFT JOIN dormitory_floor c ON a.floor_id = c.id
LEFT JOIN dormitory_record d ON a.record_id = d.id LEFT JOIN dormitory_record d ON a.record_id = d.id
LEFT JOIN shop_user e ON a.user_id = e.user_id
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}