Blame view

src/main/resources/mapper/AgentMapper.xml 1.66 KB
962b0bfd   louyao   渠道商移动端
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
<?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.sincere.wechatbusiness.mapper.AgentMapper">
    <resultMap id="AgentMap" type="com.sincere.wechatbusiness.model.Agent">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="channelId" jdbcType="INTEGER" property="channelId" />
        <result column="name" jdbcType="VARCHAR" property="name" />
        <result column="mobile" jdbcType="VARCHAR" property="mobile" />
        <result column="state" jdbcType="INTEGER" property="state"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    </resultMap>

    <select id="getList" parameterType="java.lang.Integer" resultMap="AgentMap">
        select * from agent where state=1 and channelId=#{id} order by create_time
    </select>

    <insert id="insert" parameterType="com.sincere.wechatbusiness.model.Agent">
    insert into agent (channelId,name,mobile)
    values (#{channelId,jdbcType=INTEGER},#{name,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}
      )
    </insert>

    <update id="update" parameterType="com.sincere.wechatbusiness.model.Agent">
        update agent
        <trim prefix="set" suffixOverrides=",">
            <if test="name!=null and name!=''">
                name=#{name},
            </if>
            <if test="mobile!=null and mobile!=''">
                mobile=#{mobile},
            </if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteAgent" parameterType="java.lang.Integer">
        update agent set state=0 where id=#{id}
    </update>

</mapper>