liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?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.com.basic.security.entity.Se_Reward_Punishment_Info" >
  <resultMap id="BaseResultMap" type="cn.com.basic.security.entity.Se_Reward_Punishment_Info" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="personnel_id" property="personnelId" jdbcType="VARCHAR" />
    <result column="type" property="type" jdbcType="TINYINT" />
    <result column="amount" property="amount" jdbcType="DECIMAL" />
    <result column="remarks" property="remarks" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="TINYINT" />
    <result column="is_valid" property="isValid" jdbcType="TINYINT" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
    <result column="update_user_id" property="updateUserId" jdbcType="VARCHAR" />
  </resultMap>
  
  <sql id="Base_Column_List" >
    id, personnel_id, type, amount, remarks, status, is_valid, 
    update_time, update_user_id
  </sql>
 
  <!-- 查询总数 -->
  <select id="selectCount" resultType="java.lang.Long" parameterType="java.util.Map">
     SELECT count(id) FROM se_reward_punishment_info where is_valid = 1 
  </select>
  
  <select id="selectById" 
  resultType="cn.com.basic.security.entity.Se_Reward_Punishment_Info" 
  parameterType="java.util.Map" >
    SELECT 
        r.id,p.id personnelId,p.`name` personnelName,o.`name` orgName,p.post ,p.id_number idNumber , r.type,r.update_time updateTime,r.amount,r.remarks 
    FROM se_reward_punishment_info r
    JOIN se_personnel p ON p.id = r.personnel_id
    JOIN t_sys_organization o ON o.id = p.org_id
    WHERE r.id = #{id,jdbcType=VARCHAR}
  </select>
  
  <select id="select" 
  resultType="cn.com.basic.security.entity.Se_Reward_Punishment_Info" 
  parameterType="java.util.Map" >
    SELECT 
        r.id,p.id personnelId,p.`name` personnelName,o.`name` orgName,p.post ,p.id_number idNumber , r.type,r.update_time updateTime,r.amount,r.remarks 
    FROM se_reward_punishment_info r
    JOIN se_personnel p ON p.id = r.personnel_id
    JOIN t_sys_organization o ON o.id = p.org_id
    where r.is_valid = 1 
    ORDER BY r.update_time desc
    LIMIT #{offset}, #{limit}
  </select>
  
  <delete id="deleteById" parameterType="java.lang.String" >
    delete from se_reward_punishment_info
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  
  <insert id="insert" parameterType="cn.com.basic.security.entity.Se_Reward_Punishment_Info" >
    insert into se_reward_punishment_info (id, personnel_id, type, 
      amount, remarks, status, 
      is_valid, update_time, update_user_id
      )
    values (#{id,jdbcType=VARCHAR}, #{personnelId,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, 
      #{amount,jdbcType=DECIMAL}, #{remarks,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, 
      #{isValid,jdbcType=TINYINT}, #{updateTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=VARCHAR}
      )
  </insert>
  
  <insert id="insertSelective" parameterType="cn.com.basic.security.entity.Se_Reward_Punishment_Info" >
    insert into se_reward_punishment_info
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="personnelId != null" >
        personnel_id,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="amount != null" >
        amount,
      </if>
      <if test="remarks != null" >
        remarks,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="isValid != null" >
        is_valid,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
      <if test="updateUserId != null" >
        update_user_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="personnelId != null" >
        #{personnelId,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        #{type,jdbcType=TINYINT},
      </if>
      <if test="amount != null" >
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="remarks != null" >
        #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        #{status,jdbcType=TINYINT},
      </if>
      <if test="isValid != null" >
        #{isValid,jdbcType=TINYINT},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null" >
        #{updateUserId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  
  <update id="updateByPrimaryKeySelective" parameterType="cn.com.basic.security.entity.Se_Reward_Punishment_Info" >
    update se_reward_punishment_info
    <set >
      <if test="personnelId != null" >
        personnel_id = #{personnelId,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=TINYINT},
      </if>
      <if test="amount != null" >
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="remarks != null" >
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=TINYINT},
      </if>
      <if test="isValid != null" >
        is_valid = #{isValid,jdbcType=TINYINT},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null" >
        update_user_id = #{updateUserId,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
  <update id="updateById" parameterType="cn.com.basic.security.entity.Se_Reward_Punishment_Info" >
    update se_reward_punishment_info
    set personnel_id = #{personnelId,jdbcType=VARCHAR},
      type = #{type,jdbcType=TINYINT},
      amount = #{amount,jdbcType=DECIMAL},
      remarks = #{remarks,jdbcType=VARCHAR},
      status = #{status,jdbcType=TINYINT},
      is_valid = #{isValid,jdbcType=TINYINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{updateUserId,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
  <update id="updateValidById" parameterType="cn.com.basic.security.entity.Se_Reward_Punishment_Info" >
    update se_reward_punishment_info set is_valid = #{isValid,jdbcType=TINYINT}  where id = #{id,jdbcType=VARCHAR}
      </update>
</mapper>