123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?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.enteprise.enterprise.mapper.EnterpriseMapper">
-
- <resultMap type="Enterprise" id="EnterpriseResult">
- <result property="id" column="id" />
- <result property="enterpriseName" column="enterprise_name" />
- <result property="location" column="location" />
- <result property="code" column="code" />
- </resultMap>
- <sql id="selectEnterpriseVo">
- select id, enterprise_name, location, code from enterprise
- </sql>
- <select id="selectEnterpriseList" parameterType="Enterprise" resultMap="EnterpriseResult">
- <include refid="selectEnterpriseVo"/>
- <where>
- <if test="enterpriseName != null and enterpriseName != ''"> and enterprise_name like concat('%', #{enterpriseName}, '%')</if>
- <if test="location != null and location != ''"> and location = #{location}</if>
- <if test="code != null and code != ''"> and code = #{code}</if>
- <if test="typeNum != null and typeNum != ''"> and type_num = #{typeNum}</if>
- </where>
- </select>
-
- <select id="selectEnterpriseById" parameterType="Long" >
- SELECT a.id, a.enterprise_name enterpriseName, a.location, a.code, a.type_num typeNum, b.name typeName
- from enterprise a
- left join enterprise_type b
- on a.type_num = b.number
- where a.id = #{id}
- </select>
- <insert id="insertEnterprise" parameterType="Enterprise" useGeneratedKeys="true" keyProperty="id">
- insert into enterprise
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="enterpriseName != null and enterpriseName != ''">enterprise_name,</if>
- <if test="location != null">location,</if>
- <if test="code != null">code,</if>
- <if test="typeNum != null">type_num,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="enterpriseName != null and enterpriseName != ''">#{enterpriseName},</if>
- <if test="location != null">#{location},</if>
- <if test="code != null">#{code},</if>
- <if test="typeNum != null">#{typeNum}</if>>
- </trim>
- </insert>
- <update id="updateEnterprise" parameterType="Enterprise">
- update enterprise
- <trim prefix="SET" suffixOverrides=",">
- <if test="enterpriseName != null and enterpriseName != ''">enterprise_name = #{enterpriseName},</if>
- <if test="location != null">location = #{location},</if>
- <if test="code != null">code = #{code},</if>
- <if test="typeNum != null">type_num = #{typeNum}</if>>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteEnterpriseById" parameterType="Long">
- delete from enterprise where id = #{id}
- </delete>
- <delete id="deleteEnterpriseByIds" parameterType="String">
- delete from enterprise where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="selectAllWithType" parameterType="Enterprise">
- SELECT a.id, a.enterprise_name enterpriseName, a.location, a.code, a.type_num typeNum, b.name typeName
- from enterprise a
- left join enterprise_type b
- on a.type_num = b.number
- <where>
- <if test="enterpriseName != null and enterpriseName != ''"> and a.enterprise_name like concat('%', #{enterpriseName}, '%')</if>
- <if test="location != null and location != ''"> and a.location = #{location}</if>
- <if test="code != null and code != ''"> and a.code = #{code}</if>
- <if test="typeNum != null and typeNum != ''"> and a.type_num = #{typeNum}</if>
- </where>
- </select>
-
- <insert id="insertOrUpdateBatch">
- INSERT INTO enterprise (enterprise_name, type_num)
- VALUES
- <foreach collection="list" item="item" separator=",">
- (#{item.enterpriseName}, #{item.typeNum})
- </foreach>
- ON DUPLICATE KEY UPDATE
- type_num = IF(VALUES(type_num) != '', VALUES(type_num), type_num)
- </insert>
- </mapper>
|