71 lines
3.0 KiB
XML
71 lines
3.0 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.datang.pet.mapperExtend.UserInfoMapperExtend">
|
|
|
|
<resultMap id="readUserInfoResultMap" type="com.datang.pet.vo.ReadUserInfo">
|
|
<id column="id" jdbcType="VARCHAR" property="id"/>
|
|
<result column="gender" jdbcType="VARCHAR" property="gender"/>
|
|
<result column="nike_name" jdbcType="VARCHAR" property="nikeName"/>
|
|
<result column="head_portrait" jdbcType="VARCHAR" property="headPortrait"/>
|
|
<result column="fans_quantity" jdbcType="INTEGER" property="fansQuantity"/>
|
|
<result column="concern_quantity" jdbcType="INTEGER" property="concernQuantity"/>
|
|
<result column="like_quantity" jdbcType="INTEGER" property="likeQuantity"/>
|
|
|
|
<collection property="readPetList" ofType="com.datang.pet.vo.ReadPet">
|
|
<result column="pet_id" jdbcType="VARCHAR" property="petId"/>
|
|
<result column="pet_name" jdbcType="VARCHAR" property="petName"/>
|
|
<result column="pet_gender" jdbcType="VARCHAR" property="petGender"/>
|
|
<result column="pet_birthday" jdbcType="TIMESTAMP" property="petBirthday"/>
|
|
<result column="pet_staple" jdbcType="VARCHAR" property="petStaple"/>
|
|
<result column="pet_snacks" jdbcType="VARCHAR" property="petSnacks"/>
|
|
<result column="pet_pictrue" jdbcType="VARCHAR" property="petPictrue"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<update id="contrLikeQuantity">
|
|
update user_info set
|
|
<choose>
|
|
<when test="type == 1">
|
|
like_quantity = like_quantity + 1
|
|
</when>
|
|
<otherwise>
|
|
like_quantity = like_quantity -1
|
|
</otherwise>
|
|
</choose>
|
|
where id = #{userId}
|
|
</update>
|
|
|
|
<update id="contrConcernQuantity">
|
|
update user_info set
|
|
<choose>
|
|
<when test="type == 1">
|
|
concern_quantity = concern_quantity + 1
|
|
</when>
|
|
<otherwise>
|
|
concern_quantity = concern_quantity -1
|
|
</otherwise>
|
|
</choose>
|
|
where id = #{userId}
|
|
</update>
|
|
|
|
<update id="contrFansQuantity">
|
|
update user_info set
|
|
<choose>
|
|
<when test="type == 1">
|
|
fans_quantity = fans_quantity + 1
|
|
</when>
|
|
<otherwise>
|
|
fans_quantity = fans_quantity -1
|
|
</otherwise>
|
|
</choose>
|
|
where id = #{userId}
|
|
</update>
|
|
|
|
<select id="readUserInfo" resultMap="readUserInfoResultMap">
|
|
SELECT u.*,p.id AS pet_id ,p.name AS pet_name,p.gender AS pet_gender,p.birthday AS pet_birthday,
|
|
p.staple AS pet_staple,p.snacks AS pet_snacks,p.pictrue AS pet_pictrue FROM
|
|
(
|
|
SELECT id,gender,nike_name,head_portrait,fans_quantity,concern_quantity,like_quantity FROM user_info WHERE id=#{userId}
|
|
)AS u LEFT JOIN pet AS p ON u.id=p.belong_user_id
|
|
</select>
|
|
</mapper> |