<?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="cn.reghao.tnb.user.app.db.mapper.UserProfileMapper">
    <insert id="save">
        insert into user_profile
        (`user_id`,`gender`,`signature`,`following`,`follower`)
        values
        (#{userId},#{gender},#{signature},#{following},#{follower})
    </insert>

    <update id="updateSetFollowingCountIncr">
        update user_profile
        set update_time=now(),following_count=following_count+1
        where user_id=#{userId}
    </update>
    <update id="updateSetFollowingCountDecr">
        update user_profile
        set update_time=now(),following_count=if(following_count &lt; 1, 0, following_count-1)
        where user_id=#{userId}
    </update>
    <update id="updateUserSignature">
        update user_profile
        set update_time=now(),signature=#{signature}
        where user_id=#{userId}
    </update>

    <select id="findByUserId" resultType="cn.reghao.tnb.user.app.model.po.UserProfile">
        select *
        from user_profile
        where user_id=#{userId}
    </select>
</mapper>
