<?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>