emis-service/emis-biz/src/main/resources/mapper/EmisCountryAreaMapper.xml
2024-07-13 16:42:16 +08:00

142 lines
8.2 KiB
XML

<?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.xdadan.erp.emis.mapper.EmisCountryAreaMapper">
<resultMap type="EmisCountryArea" id="EmisCountryAreaResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="nameEn" column="name_en" />
<result property="countryCode" column="country_code" />
<result property="countryName" column="country_name" />
<result property="siteCode" column="site_code" />
<association property="siteName" column="site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
</resultMap>
<sql id="selectEmisCountryAreaVo">
select id, name, name_en, country_code, country_name, site_code, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_country_area
</sql>
<select id="selectEmisCountryAreaList" parameterType="EmisCountryArea" resultMap="EmisCountryAreaResult">
<include refid="selectEmisCountryAreaVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="nameEn != null and nameEn != ''"> and name_en like concat('%', #{nameEn}, '%')</if>
<if test="countryCode != null and countryCode != ''"> and country_code like concat('%', #{countryCode}, '%')</if>
<if test="countryName != null and countryName != ''"> and country_name like concat('%', #{countryName}, '%')</if>
<if test="siteCode != null and siteCode != ''"> and site_code like concat('%', #{siteCode}, '%')</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id like concat('%', #{tenantId}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
</where>
order by create_time desc
</select>
<select id="checkUnique" parameterType="EmisCountryArea" resultType="int">
select count(1) from emis_country_area
where del_flag='0'
and id = #{id}
and name = #{name}
and name_en = #{nameEn}
and country_code = #{countryCode}
and country_name = #{countryName}
and site_code = #{siteCode}
and remark = #{remark}
and tenant_id = #{tenantId}
and del_flag = #{delFlag}
and create_by = #{createBy}
and create_time = #{createTime}
and update_by = #{updateBy}
and update_time = #{updateTime}
and create_site = #{createSite}
and update_site = #{updateSite}
limit 1
</select>
<select id="selectEmisCountryAreaById" parameterType="Long" resultMap="EmisCountryAreaResult">
select id, name, name_en, country_code, country_name, site_code, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_country_area a
where a.id = #{id}
</select>
<insert id="insertEmisCountryArea" parameterType="EmisCountryArea" useGeneratedKeys="true" keyProperty="id">
insert into emis_country_area
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null and name != ''">name,</if>
<if test="nameEn != null and nameEn != ''">name_en,</if>
<if test="countryCode != null and countryCode != ''">country_code,</if>
<if test="countryName != null and countryName != ''">country_name,</if>
<if test="siteCode != null and siteCode != ''">site_code,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="nameEn != null and nameEn != ''">#{nameEn},</if>
<if test="countryCode != null and countryCode != ''">#{countryCode},</if>
<if test="countryName != null and countryName != ''">#{countryName},</if>
<if test="siteCode != null and siteCode != ''">#{siteCode},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisCountryArea" parameterType="EmisCountryArea">
update emis_country_area
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="nameEn != null and nameEn != ''">name_en = #{nameEn},</if>
<if test="countryCode != null and countryCode != ''">country_code = #{countryCode},</if>
<if test="countryName != null and countryName != ''">country_name = #{countryName},</if>
<if test="siteCode != null and siteCode != ''">site_code = #{siteCode},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmisCountryAreaById" parameterType="Long">
delete from emis_country_area where id = #{id}
</delete>
<delete id="deleteEmisCountryAreaByIds" parameterType="String">
delete from emis_country_area where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>