您的位置:首页 > 汽车 > 时评 > 汉服网页设计作品_网站建设广告模板_友情链接交易购买_怎么建网站赚钱

汉服网页设计作品_网站建设广告模板_友情链接交易购买_怎么建网站赚钱

2025/3/10 20:31:09 来源:https://blog.csdn.net/weixin_40918145/article/details/146070250  浏览:    关键词:汉服网页设计作品_网站建设广告模板_友情链接交易购买_怎么建网站赚钱
汉服网页设计作品_网站建设广告模板_友情链接交易购买_怎么建网站赚钱

三个表:房间 + 玩家 + 玩家信息 

知识点:Mybatis中级联有关联(association)、集合(collection)、鉴别器(discriminator)三种。其中,association对应一对一关系、collection对应一对多关系、discriminator可以根据情况选择采用哪个类作为实例,关联不同的结果集。

参考文章:Mybatis级联:关联、集合和鉴别器的使用 - aaron_shu - 博客园

# room.javaprivate List<Player> player;public List<Player> getPlayer(){return player;}public void setPlayer(List<Player> player){this.player = player;}
<resultMap type="Room" id="RoomResult"><id     property="roomId"       column="room_id"      /><result property="roomTitle"     column="room_title"    /><result property="roomOwnerId"     column="room_owner_id"    /><result property="roomTags" column="room_tags" /><result property="scoreMode"  column="score_mode" /><result property="qrCode" column="qr_code" /><result property="appId" column="app_id" /><result property="isPlaten" column="is_platen" /><result property="userId" column="user_id" /><result property="shopId" column="shop_id" /><result property="status"       column="status"       /><result property="delFlag" 		column="del_flag" /><result property="remark"       column="remark"       /><result property="createBy"     column="create_by"    /><result property="createTime"   column="create_time"  /><result property="updateBy"     column="update_by"    /><result property="updateTime"   column="update_time"  /><collection property="player"    javaType="ArrayList"  ofType="Player" resultMap="playerResult" /></resultMap><resultMap id="playerResult" type="Player"><result property="roomId"    column="room_id"       /><result property="playerScore"     	column="player_score"    /><result property="isOnlooker"     	column="is_onlooker"    /><result property="userId"     		column="user_id"    /><association property="customerUser" javaType="CustomerUser"  resultMap="customerUserResult" /></resultMap><resultMap id="customerUserResult" type="CustomerUser"><result property="userId"    	column="user_id"       /><result property="nickName"     column="nick_name"    /><result property="avatar"       column="avatar"       /></resultMap><sql id="selectRoomVo">select d.room_id, d.room_title, d.room_owner_id, d.score_mode, d.room_tags, d.qr_code,d.app_id, d.is_platen, d.del_flag, d.user_id, d.shop_id,p.player_score, p.is_onlooker, p.user_id,c.nick_name, c.avatar,d.remark, d.status, d.create_by, d.update_by, d.create_time, d.update_timefrom tb_room dleft join tb_player p on p.room_id = d.room_idleft join tb_customer_user c on c.user_id = p.user_id</sql>

前端得到的json结构

{"msg": "操作成功","code": 200,"data": {"createBy": "","createTime": "2025-03-06 12:15:09","updateBy": "",,"delFlag": "1","player": [{"createBy": null,"customerUser": {"createBy": null,"createTime": null, "avatar": "https://img1.baidu.com/it/u=2587875867,850432697&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800",}}]}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com