yujian
2019-01-22 88b54772dbcf5ecab1e2316e4e4626ac901b8908
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?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.yeshi.fanli.dao.mybatis.user.UserCustomSettingsMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserCustomSettings">
    <id column="ucs_id" property="id" jdbcType="BIGINT"/>
    <result column="ucs_type" property="type"
            typeHandler="com.yeshi.fanli.util.mybatishandler.UserSettingTypeEnumHandler" />
    <result column="ucs_state" property="state" jdbcType="INTEGER"/>
    <result column="ucs_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="ucs_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    
    <association property="userInfo" column="ucs_uid" javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
        <id column="ucs_uid" property="id" jdbcType="BIGINT" />
    </association>
    
  </resultMap>
  <sql id="Base_Column_List">ucs_id,ucs_uid,ucs_type,ucs_state,ucs_create_time,ucs_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_custom_settings where ucs_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_custom_settings where ucs_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserCustomSettings" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_custom_settings (ucs_id,ucs_uid,ucs_type,ucs_state,ucs_create_time,ucs_update_time) values (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{type,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserCustomSettings" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_custom_settings
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">ucs_id,</if>
      <if test="userInfo != null">ucs_uid,</if>
      <if test="type != null">ucs_type,</if>
      <if test="state != null">ucs_state,</if>
      <if test="createTime != null">ucs_create_time,</if>
      <if test="updateTime != null">ucs_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserCustomSettings">update yeshi_ec_user_custom_settings set ucs_uid = #{userInfo.id,jdbcType=BIGINT},ucs_type = #{type,jdbcType=VARCHAR},ucs_state = #{state,jdbcType=INTEGER},ucs_create_time = #{createTime,jdbcType=TIMESTAMP},ucs_update_time = #{updateTime,jdbcType=TIMESTAMP} where ucs_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserCustomSettings">update yeshi_ec_user_custom_settings
    <set>
      <if test="userInfo != null">ucs_uid=#{userInfo.id,jdbcType=BIGINT},</if>
      <if test="type != null">ucs_type=#{type,jdbcType=VARCHAR},</if>
      <if test="state != null">ucs_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">ucs_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">ucs_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where ucs_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="getSettingsByUid" resultMap="BaseResultMap" parameterType="java.lang.Long">
      SELECT * FROM  yeshi_ec_user_custom_settings  
      WHERE ucs_uid = #{uid,jdbcType=BIGINT}
  </select>
  
   <select id="getSettingsByUidAndType" resultMap="BaseResultMap">
      SELECT * FROM  yeshi_ec_user_custom_settings  
      WHERE ucs_uid = #{uid} AND ucs_type=#{type}
  </select>
  
   <select id="getUserID" resultType="java.lang.Long" >
      SELECT ucs_uid FROM  yeshi_ec_user_custom_settings  
      WHERE ucs_state= 1 AND ucs_type=#{type}
  </select>
  
</mapper>