123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?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.fdkankan.agent.mapper.IAgentAuditMapper">
- <resultMap id="resultMap" type="com.fdkankan.agent.entity.AgentAudit">
- <id column="id" jdbcType="VARCHAR" property="id" />
- <result column="audit_name" jdbcType="VARCHAR" property="auditName" />
- <result column="country" jdbcType="VARCHAR" property="country" />
- <result column="region" jdbcType="VARCHAR" property="region" />
- <result column="address" jdbcType="VARCHAR" property="address" />
- <result column="audit_type" jdbcType="INTEGER" property="auditType" />
- <result column="store_address" jdbcType="VARCHAR" property="storeAddress" />
- <result column="sur_name" jdbcType="VARCHAR" property="surName" />
- <result column="user_name" jdbcType="VARCHAR" property="userName" />
- <result column="post" jdbcType="VARCHAR" property="post" />
- <result column="area_code" jdbcType="VARCHAR" property="areaCode" />
- <result column="phone" jdbcType="VARCHAR" property="phone" />
- <result column="email" jdbcType="VARCHAR" property="email" />
- <result column="state" jdbcType="INTEGER" property="state" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="rec_status" jdbcType="VARCHAR" property="recStatus" />
- <result column="note_type" jdbcType="INTEGER" property="noteType" />
- <result column="note_content" jdbcType="VARCHAR" property="noteContent" />
- <result column="tb_status" jdbcType="INTEGER" property="tbStatus" />
- </resultMap>
- <sql id="columnList">
- id,audit_name,country,region,address,audit_type,store_address,sur_name,user_name,post,area_code,phone,email,state,create_time,update_time,rec_status,note_type,note_content,tb_status </sql>
- <insert id="insert" useGeneratedKeys="true" keyProperty="entity.id">
- INSERT INTO ${tableName} (
- audit_name, country, region, address, audit_type, store_address, sur_name, user_name, post, area_code, phone, email, state, rec_status, note_type, note_content
- ) VALUES (
- #{entity.auditName}, #{entity.country}, #{entity.region}, #{entity.address}, #{entity.auditType}, #{entity.storeAddress}, #{entity.surName}, #{entity.userName}, #{entity.post}, #{entity.areaCode}, #{entity.phone}, #{entity.email}, #{entity.state}, #{entity.recStatus}, #{entity.noteType}, #{entity.noteContent}
- ) </insert>
- <insert id="insertByBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" >
- INSERT INTO ${tableName} (
- audit_name, country, region, address, audit_type, store_address, sur_name, user_name, post, area_code, phone, email, state, rec_status, note_type, note_content
- ) VALUES
- <foreach collection="list" item="entity" index="index" separator=",">
- (#{entity.auditName}, #{entity.country}, #{entity.region}, #{entity.address}, #{entity.auditType}, #{entity.storeAddress}, #{entity.surName}, #{entity.userName}, #{entity.post}, #{entity.areaCode}, #{entity.phone}, #{entity.email}, #{entity.state}, #{entity.recStatus}, #{entity.noteType}, #{entity.noteContent})
- </foreach>
- </insert>
- <update id="update" parameterType="java.util.List" >
- <foreach collection="list" item="entity" index="index" separator=";">
- UPDATE ${tableName} SET
- audit_name=#{entity.auditName}, country=#{entity.country}, region=#{entity.region}, address=#{entity.address}, audit_type=#{entity.auditType}, store_address=#{entity.storeAddress}, sur_name=#{entity.surName}, user_name=#{entity.userName}, post=#{entity.post}, area_code=#{entity.areaCode}, phone=#{entity.phone}, email=#{entity.email}, state=#{entity.state}, rec_status=#{entity.recStatus}, note_type=#{entity.noteType}, note_content=#{entity.noteContent}, tb_status=#{entity.tbStatus}
- WHERE
- id = #{entity.id}
- </foreach>
- </update>
- <update id="updateByBatch" >
- UPDATE ${tableName} SET
- ${field}
- <where>
- <foreach collection="condition" index="key" item="value">
- ${value} ${key}
- </foreach>
- </where>
- </update>
- <select id="getById" parameterType="java.lang.Integer" resultMap="resultMap">
- select
- <include refid="columnList" />
- from ${tableName}
- where id = #{id}
- </select>
- <select id="getOne" parameterType="java.util.Map" resultMap="resultMap">
- select
- <if test="field == null">
- <include refid="columnList" />
- </if>
- <if test="field != null">
- ${field}
- </if>
- from ${tableName}
- <where>
- <foreach collection="condition" index="key" item="value">
- ${value} ${key}
- </foreach>
- </where>
- limit 1;
- </select>
- <select id="getCount" parameterType="java.util.Map" resultType="java.lang.Integer">
- select
- count(id)
- from ${tableName}
- <where>
- <foreach collection="condition" index="key" item="value">
- ${value} ${key}
- </foreach>
- </where>
- </select>
- <!-- 这部分为根据传递参数,自动生成SQL -->
- <select id="getList" parameterType="java.util.Map" resultMap="resultMap">
- select
- <if test="field == null">
- <include refid="columnList" />
- </if>
- <if test="field != null">
- ${field}
- </if>
- from ${tableName}
- <where>
- <foreach collection="condition" index="key" item="value">
- ${value} ${key}
- </foreach>
- </where>
- <if test="order != null">
- order by ${order}
- </if>
- <if test="limit != 0">
- <if test="offset != 0">
- limit ${offset}, ${limit}
- </if>
- <if test="offset == 0">
- limit ${limit}
- </if>
- </if>
- </select>
- <!-- 判断表格是否存在,如果不存在可以配合createTable使用,用于动态创建表格 -->
- <select id="existTable" parameterType="String" resultType="java.lang.Integer">
- select count(table_name) from information_schema.TABLES WHERE table_name=#{tableName} ;
- </select>
- <update id="createTable" parameterType="String">
- <!-- 这里是创建表格的SQL,复制过来,表名作为参数传递 -->
- <!-- create table ${tableName} ( // 表名要这样写 -->
- </update>
- </mapper>
|