日期:2014-05-16 浏览次数:20553 次
<!-- 根据用户id查询某一个人的寻宝 --> <select id="selectTreasureLogListByUseId" parameterType="string" resultMap="huntTreasureLogResult"> SELECT h.id,h.userId,h.treasureId,h.huntedCount FROM hunt_treasure_log h WHERE userId=#{userId} </select>
<!-- hunt_treasure_log查询HuntTreasureLog对象时的huntTreasureLogResult --> <resultMap type="user" id="treasureLogUserResult"> <id property="id" column="userId" /> </resultMap> <resultMap type="huntTreasureLog" id="huntTreasureLogResult"> <id property="id" column="id" /> <result property="huntedCount" column="huntedCount" /> <association property="treasure" column="id" javaType="treasure" resultMap="treasureResult"> </association> <association property="userByUserId" column="id" javaType="user" resultMap="treasureLogUserResult"> </association> </resultMap>
<!-- ++++++++++++宝贝交换记录exchange_record表CRUD部分++++++++++++ --> <!-- start: exchage_record查询ExchageRecord对象时的exchangeRecordResult --> <resultMap type="user" id="recordHostUserResult"> <id property="id" column="hostUserId" /> <result property="userName" column="hostUserName" /> <result property="headImagePath" column="hostUserHeadImg" /> </resultMap> <resultMap type="user" id="recordFriendUserResult"> <id property="id" column="friendUserId" /> <result property="userName" column="friendUserName" /> <result property="headImagePath" column="friendUserHeadImg" /> </resultMap> <resultMap type="chip" id="recordHostChipResult"> <id property="id" column="hostChipId" /> </resultMap> <resultMap type="chip" id="recordFriendChipResult"> <id property="id" column="friendChipId" /> </resultMap> <resultMap type="huntTreasureLog" id="exchangeRecordResult"> <id property="id" column="id" /> <result property="huntedCount" column="huntedCount" /> <association property="hostUserId" column="id" javaType="user" resultMap="recordHostUserResult"> </association> <association property="friendUserId" column="id" javaType="user" resultMap="recordFriendUserResult"> </association> <association property="hostChipId" column="id" javaType="chip" resultMap="recordHostChipResult"> </association> <association property="friendChipId" column="id" javaType="chip" resultMap="recordFriendChipResult"> </association> </resultMap> <!-- end: exchage_record查询ExchageRecord对象时的exchangeRecordResult --> <!-- 插入一条交换记录 --> <insert id="insertExchangeRecord" parameterType="exchangeRecord"> INSERT exchange_record (hostUserId,hostChipId,friendUserId,friendChipId,createDate) VALUES(#{hostUserId.id},#{hostChipId.id},#{friendUserId.id},#{friendChipId.id},NOW()) </insert> <!-- 根据id删除一条记录 --> <delete id="deleteExchangeRecord" parameterType="string"> DELETE FROM exchange_record WHERE id=#{exchangeRecordId} </delete> <!-- 获取交换记录作为提示信息给用户 --> <select id="selectExchangeRecordList" parameterType="string" resultMap="exchangeRecordResult"> SELECT e.id, hostUser.id AS hostUserId,host.headImagePath AS hostUserHeadImg, friendUser.id AS friendUserId,friendUser.headImagePath AS friendUserHeadImg, hostChip.id AS hostChipId,friendChip.id AS friendChipId FROM exchange_record e LEFT OUTER JOIN user hostUser ON e.houstUserId=hostUser.id LEFT OUTER JOIN user friendUser ON e.friendUserId=fr