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.user.mapper.IUserMapper">
- <resultMap id="resultMap" type="com.fdkankan.user.entity.User">
- <id column="id" jdbcType="VARCHAR" property="id" />
- <result column="head" jdbcType="VARCHAR" property="head" />
- <result column="password" jdbcType="VARCHAR" property="password" />
- <result column="email" jdbcType="VARCHAR" property="email" />
- <result column="register_time" jdbcType="TIMESTAMP" property="registerTime" />
- <result column="user_name" jdbcType="VARCHAR" property="userName" />
- <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="is_notice" jdbcType="INTEGER" property="isNotice" />
- <result column="organization_name" jdbcType="VARCHAR" property="organizationName" />
- <result column="main_page" jdbcType="VARCHAR" property="mainPage" />
- <result column="country" jdbcType="VARCHAR" property="country" />
- <result column="province" jdbcType="VARCHAR" property="province" />
- <result column="city" jdbcType="VARCHAR" property="city" />
- <result column="download_num_total" jdbcType="INTEGER" property="downloadNumTotal" />
- <result column="download_num" jdbcType="INTEGER" property="downloadNum" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="rec_status" jdbcType="VARCHAR" property="recStatus" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="tb_status" jdbcType="INTEGER" property="tbStatus" />
- </resultMap>
- <sql id="columnList">
- id,head,password,email,register_time,user_name,nick_name,status,is_notice,organization_name,main_page,country,province,city,download_num_total,download_num,create_time,rec_status,update_time,tb_status </sql>
- <insert id="insert" useGeneratedKeys="true" keyProperty="entity.id">
- INSERT INTO ${tableName} (
- head, password, email, register_time, user_name, nick_name, status, is_notice, organization_name, main_page, country, province, city, download_num_total, download_num, rec_status
- ) VALUES (
- #{entity.head}, #{entity.password}, #{entity.email}, #{entity.registerTime}, #{entity.userName}, #{entity.nickName}, #{entity.status}, #{entity.isNotice}, #{entity.organizationName}, #{entity.mainPage}, #{entity.country}, #{entity.province}, #{entity.city}, #{entity.downloadNumTotal}, #{entity.downloadNum}, #{entity.recStatus}
- ) </insert>
- <insert id="insertByBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" >
- INSERT INTO ${tableName} (
- head, password, email, register_time, user_name, nick_name, status, is_notice, organization_name, main_page, country, province, city, download_num_total, download_num, rec_status
- ) VALUES
- <foreach collection="list" item="entity" index="index" separator=",">
- (#{entity.head}, #{entity.password}, #{entity.email}, #{entity.registerTime}, #{entity.userName}, #{entity.nickName}, #{entity.status}, #{entity.isNotice}, #{entity.organizationName}, #{entity.mainPage}, #{entity.country}, #{entity.province}, #{entity.city}, #{entity.downloadNumTotal}, #{entity.downloadNum}, #{entity.recStatus})
- </foreach>
- </insert>
- <update id="update" parameterType="java.util.List" >
- <foreach collection="list" item="entity" index="index" separator=";">
- UPDATE ${tableName} SET
- head=#{entity.head}, password=#{entity.password}, email=#{entity.email}, register_time=#{entity.registerTime}, user_name=#{entity.userName}, nick_name=#{entity.nickName}, status=#{entity.status}, is_notice=#{entity.isNotice}, organization_name=#{entity.organizationName}, main_page=#{entity.mainPage}, country=#{entity.country}, province=#{entity.province}, city=#{entity.city}, download_num_total=#{entity.downloadNumTotal}, download_num=#{entity.downloadNum}, rec_status=#{entity.recStatus}, 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>
|