UserMapper.xml 6.59 KB
<?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.bjivt.job.robot.entity.User">
  <resultMap id="BaseResultMap" type="com.bjivt.job.robot.entity.User">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="msisdn" jdbcType="VARCHAR" property="msisdn" />
    <result column="captcha" jdbcType="VARCHAR" property="captcha" />
    <result column="avatar" jdbcType="VARCHAR" property="avatar" />
    <result column="signature" jdbcType="VARCHAR" property="signature" />
    <result column="exp" jdbcType="INTEGER" property="exp" />
    <result column="sex" jdbcType="VARCHAR" property="sex" />
    <result column="age" jdbcType="INTEGER" property="age" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="chat_auth" jdbcType="SMALLINT" property="chatAuth" />
    <result column="is_star" jdbcType="SMALLINT" property="isStar" />
    <result column="active" jdbcType="CHAR" property="active" />
    <result column="is_robot" jdbcType="INTEGER" property="isRobot" />
    <result column="is_robot_use" jdbcType="INTEGER" property="isRobotUse" />
  </resultMap>
  <sql id="Base_Column_List">
    id, name, msisdn, captcha, avatar, signature, exp, sex, 
    age, create_time, chat_auth, is_star, active,is_robot,is_robot_use
  </sql>
  <select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tbl_user_list
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteById" parameterType="java.lang.Integer">
    delete from tbl_user_list
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <update id="updateByIdSelective" parameterType="com.bjivt.job.robot.entity.User">
    update tbl_user_list
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="msisdn != null">
        msisdn = #{msisdn,jdbcType=VARCHAR},
      </if>
      <if test="captcha != null">
        captcha = #{captcha,jdbcType=VARCHAR},
      </if>
      <if test="avatar != null">
        avatar = #{avatar,jdbcType=VARCHAR},
      </if>
      <if test="email != null">
        email = #{email,jdbcType=VARCHAR},
      </if>
      <if test="signature != null">
        signature = #{signature,jdbcType=VARCHAR},
      </if>
      <if test="liveCount != null">
        live_count = #{liveCount,jdbcType=INTEGER},
      </if>
      <if test="likeCount != null">
        like_count = #{likeCount,jdbcType=INTEGER},
      </if>
      <if test="exp != null">
        exp = #{exp,jdbcType=INTEGER},
      </if>
      <if test="fansCount != null">
        fans_count = #{fansCount,jdbcType=INTEGER},
      </if>
      <if test="followerCount != null">
        follower_count = #{followerCount,jdbcType=INTEGER},
      </if>
      <if test="chineseCoin != null">
        chinese_coin = #{chineseCoin,jdbcType=INTEGER},
      </if>
      <if test="meCoinTotal != null">
        me_coin_total = #{meCoinTotal,jdbcType=INTEGER},
      </if>
      <if test="meCoinBalance != null">
        me_coin_balance = #{meCoinBalance,jdbcType=INTEGER},
      </if>
      <if test="sentGiftCount != null">
        sent_gift_count = #{sentGiftCount,jdbcType=INTEGER},
      </if>
      <if test="sentGiftMoneyCount != null">
        sent_gift_money_count = #{sentGiftMoneyCount,jdbcType=INTEGER},
      </if>
      <if test="sentRedEnvelopCount != null">
        sent_red_envelop_count = #{sentRedEnvelopCount,jdbcType=INTEGER},
      </if>
      <if test="sentRedEnvelopMoneyCount != null">
        sent_red_envelop_money_count = #{sentRedEnvelopMoneyCount,jdbcType=INTEGER},
      </if>
      <if test="sex != null">
        sex = #{sex,jdbcType=VARCHAR},
      </if>
      <if test="age != null">
        age = #{age,jdbcType=INTEGER},
      </if>
      <if test="hometown != null">
        hometown = #{hometown,jdbcType=VARCHAR},
      </if>
      <if test="profession != null">
        profession = #{profession,jdbcType=VARCHAR},
      </if>
      <if test="password != null">
        password = #{password,jdbcType=VARCHAR},
      </if>
      <if test="thirdPartyType != null">
        third_party_type = #{thirdPartyType,jdbcType=VARCHAR},
      </if>
      <if test="thirdPartyAccount != null">
        third_party_account = #{thirdPartyAccount,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="lastLoginTime != null">
        last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="lastLoginIp != null">
        last_login_ip = #{lastLoginIp,jdbcType=VARCHAR},
      </if>
      <if test="chatAuth != null">
        chat_auth = #{chatAuth,jdbcType=SMALLINT},
      </if>
      <if test="isStar != null">
        is_star = #{isStar,jdbcType=SMALLINT},
      </if>
      <if test="lastLoginLocation != null">
        last_login_location = #{lastLoginLocation,jdbcType=VARCHAR},
      </if>
      <if test="active != null">
        active = #{active,jdbcType=CHAR},
      </if>
      <if test="active != null">
        is_robot = #{isRobot,jdbcType=INTEGER},
      </if>
      <if test="active != null">
        is_robot_use = #{isRobotUse,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateById" parameterType="com.bjivt.job.robot.entity.User">
    update tbl_user_list
    set is_robot_use = #{isRobotUse,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!-- 更新所有使用的机器人信息 -->
  <update id="updateAllRobot" parameterType="com.bjivt.job.robot.entity.User">
    update tbl_user_list
    set is_robot_use = 0
    where is_robot_use = 1 and is_robot=1
  </update>
  
  <select id="getCountBy" resultType="java.lang.Integer" parameterType="com.bjivt.job.robot.entity.User">
    SELECT
				count(id)
			FROM
				tbl_user_list tl
    <trim prefix="where" prefixOverrides="and|or">
     			  <if test="name != null and name != ''" >
		        	 and   tl.is_robot_use =0
		    	  </if>
     			  <if test="id != null and id != ''" >
		        	 and   tl.is_robot=1
		    	  </if>
    </trim>
  </select>
  	<!-- 是属于机器人的,未被使用的 -->
     <select id="findListByMap" resultMap="BaseResultMap" parameterType="java.util.Map">
     	SELECT
				<include refid="Base_Column_List"/>
			FROM tbl_user_list tl
		        where   tl.is_robot=1
  	  	order by create_time  limit  #{start,jdbcType=INTEGER}, #{end,jdbcType=INTEGER}
  </select>
</mapper>