<?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.ruoyi.project.tr.region.mapper.RegionMapper">
|
|
<resultMap type="com.ruoyi.project.tr.region.domain.Region" id="RegionResult">
|
<id property="regionId" column="region_id"/>
|
<result property="companyId" column="company_id"/>
|
<result property="parentId" column="parent_id"/>
|
<result property="ancestors" column="ancestors"/>
|
<result property="regionName" column="region_name"/>
|
<result property="orderNum" column="order_num"/>
|
<result property="leader" column="leader"/>
|
<result property="phone" column="phone"/>
|
<result property="email" column="email"/>
|
<result property="status" column="status"/>
|
<result property="delFlag" column="del_flag"/>
|
<result property="parentName" column="parent_name"/>
|
<result property="createBy" column="create_by"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateBy" column="update_by"/>
|
<result property="updateTime" column="update_time"/>
|
|
<result property="regionType" column="region_type"/>
|
|
<result property="companyUnifiedSocialCreditCode" column="company_unified_social_credit_code" />
|
<result property="companyBusinessLicense" column="company_business_license" />
|
<result property="companyRegisteredAddressOfBusinessLicense" column="company_registered_address_of_business_license" />
|
<result property="companyScale" column="company_scale" />
|
<result property="companyNumberOfEmployees" column="company_number_of_employees" />
|
<result property="companyEstablished" column="company_established" />
|
<result property="companyArea" column="company_area" />
|
<result property="companyRegisteredCapital" column="company_registered_capital" />
|
<result property="companyTotalAssets" column="company_total_assets" />
|
<result property="companyActualIncomeOfThePreviousYear" column="company_actual_income_of_the_previous_year" />
|
<result property="companyAnnualProfit" column="company_annual_profit" />
|
<result property="companyEconomicType" column="company_economic_type" />
|
<result property="companyIndustry" column="company_industry" />
|
<result property="companyLegalRepresentative" column="company_legal_representative" />
|
<result property="companyCorporatePosition" column="company_corporate_position" />
|
<result property="companyLegalPersonPhone" column="company_legal_person_phone" />
|
<result property="companyCorporateOfficePhone" column="company_corporate_office_phone" />
|
<result property="companyPersonInChargeOfRectification" column="company_person_in_charge_of_rectification" />
|
<result property="companyRectifierPhone" column="company_rectifier_phone" />
|
<result property="companyOrganizer" column="company_organizer" />
|
<result property="companyGroupCompanyName" column="company_group_company_name" />
|
<result property="companySecurityFunction" column="company_security_function" />
|
<result property="companyPostalCode" column="company_postal_code" />
|
<result property="companyIntroduction" column="company_introduction" />
|
<result property="companyOther" column="company_other" />
|
|
<association property="company" column="company_id" javaType="Company" resultMap="CompanyResult"/>
|
</resultMap>
|
|
<resultMap id="CompanyResult" type="Company">
|
<id property="companyId" column="company_id"/>
|
<result property="companyName" column="company_name"/>
|
<result property="companyPrincipal" column="company_principal"/>
|
<result property="companyAddress" column="company_address"/>
|
<result property="companyPhone" column="company_phone"/>
|
</resultMap>
|
|
<sql id="selectRegionVo">
|
SELECT d.region_id, d.parent_id, d.ancestors, d.region_name, d.order_num,
|
d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,
|
d.region_type,
|
d.company_unified_social_credit_code, d.company_business_license,
|
d.company_registered_address_of_business_license, d.company_scale, d.company_number_of_employees,
|
d.company_established, d.company_area, d.company_registered_capital, d.company_total_assets,
|
d.company_actual_income_of_the_previous_year, d.company_annual_profit, d.company_economic_type,
|
d.company_industry, d.company_legal_representative, d.company_corporate_position, d.company_legal_person_phone,
|
d.company_corporate_office_phone, d.company_person_in_charge_of_rectification, d.company_rectifier_phone,
|
d.company_organizer, d.company_group_company_name, d.company_security_function, d.company_postal_code,
|
d.company_introduction, d.company_other,
|
|
c.company_id,c.company_name
|
FROM tr_region d
|
LEFT JOIN sys_company AS c ON d.company_id = c.company_id
|
</sql>
|
|
<select id="selectRoleRegionTree" parameterType="Long" resultType="String">
|
select concat(d.region_id, d.region_name) as region_name
|
from tr_region d
|
left join sys_role_region rd on d.region_id = rd.region_id
|
where d.del_flag = '0' and rd.role_id = #{roleId}
|
<if test="companyId != null">
|
and d.company_id = #{companyId}
|
</if>
|
order by d.parent_id, d.order_num ,d.create_time DESC
|
</select>
|
|
<select id="selectRegionList" parameterType="Region" resultMap="RegionResult">
|
<include refid="selectRegionVo"/>
|
where d.del_flag = '0'
|
<if test="parentId != null and parentId != 0">
|
AND d.parent_id = #{parentId}
|
</if>
|
<if test="regionName != null and regionName != ''">
|
AND d.region_name like concat('%', #{regionName}, '%')
|
</if>
|
<if test="status != null and status != ''">
|
AND d.status = #{status}
|
</if>
|
<if test="companyId != null and companyId != 0">
|
AND c.company_id = #{companyId}
|
</if>
|
<!-- 数据范围过滤 -->
|
${params.dataScope}
|
order by d.parent_id, d.order_num ,d.create_time DESC
|
</select>
|
|
<select id="checkRegionExistUser" parameterType="Long" resultType="int">
|
select count(1) from sys_user where region_id = #{regionId} and del_flag = '0'
|
</select>
|
|
<select id="selectRegionCount" parameterType="Region" resultType="int">
|
select count(1) from tr_region
|
where del_flag = '0'
|
<if test="regionId != null and regionId != 0">and region_id = #{regionId}</if>
|
<if test="parentId != null and parentId != 0">and parent_id = #{parentId}</if>
|
<if test="companyId != null and companyId != 0">
|
AND company_id = #{companyId}
|
</if>
|
</select>
|
|
<select id="checkRegionNameUnique" resultMap="RegionResult">
|
<include refid="selectRegionVo"/>
|
where d.region_name=#{regionName} and d.parent_id = #{parentId}
|
<if test="companyId != null and companyId != 0">
|
AND c.company_id = #{companyId}
|
</if>
|
</select>
|
|
<select id="selectRegionById" parameterType="Long" resultMap="RegionResult">
|
select d.region_id, d.parent_id, d.ancestors, d.region_name, d.order_num,
|
d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,
|
d.company_unified_social_credit_code, d.company_business_license,
|
d.region_type,
|
d.company_registered_address_of_business_license, d.company_scale, d.company_number_of_employees,
|
d.company_established, d.company_area, d.company_registered_capital, d.company_total_assets,
|
d.company_actual_income_of_the_previous_year, d.company_annual_profit, d.company_economic_type,
|
d.company_industry, d.company_legal_representative, d.company_corporate_position, d.company_legal_person_phone,
|
d.company_corporate_office_phone, d.company_person_in_charge_of_rectification, d.company_rectifier_phone,
|
d.company_organizer, d.company_group_company_name, d.company_security_function, d.company_postal_code,
|
d.company_introduction, d.company_other,
|
c.company_id,c.company_name,(select region_name from tr_region where region_id = d.parent_id) parent_name
|
from tr_region d
|
LEFT JOIN sys_company AS c ON d.company_id = c.company_id
|
where d.region_id = #{regionId}
|
</select>
|
|
<select id="selectChildrenRegionById" parameterType="Long" resultMap="RegionResult">
|
SELECT region_id, parent_id, ancestors, region_name, order_num,
|
leader, phone, email, status, del_flag, create_by, create_time,
|
region_type,
|
company_unified_social_credit_code, company_business_license,
|
company_registered_address_of_business_license, company_scale, company_number_of_employees,
|
company_established, company_area, company_registered_capital, company_total_assets,
|
company_actual_income_of_the_previous_year, company_annual_profit, company_economic_type,
|
company_industry, company_legal_representative, company_corporate_position, company_legal_person_phone,
|
company_corporate_office_phone, company_person_in_charge_of_rectification, company_rectifier_phone,
|
company_organizer, company_group_company_name, company_security_function, company_postal_code,
|
company_introduction, company_other
|
from tr_region where find_in_set(#{regionId}, ancestors)
|
</select>
|
|
<insert id="insertRegion" parameterType="Region">
|
insert into tr_region(
|
<if test="regionId != null and regionId != 0">region_id,</if>
|
<if test="companyId != null and companyId != 0">company_id,</if>
|
<if test="parentId != null and parentId != 0">parent_id,</if>
|
<if test="regionName != null and regionName != ''">region_name,</if>
|
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
<if test="orderNum != null and orderNum != ''">order_num,</if>
|
<if test="leader != null and leader != ''">leader,</if>
|
<if test="phone != null and phone != ''">phone,</if>
|
<if test="email != null and email != ''">email,</if>
|
<if test="status != null">status,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
<if test="regionType != null ">region_type,</if>
|
|
<if test="companyUnifiedSocialCreditCode != null and companyUnifiedSocialCreditCode != ''">company_unified_social_credit_code,</if>
|
<if test="companyBusinessLicense != null and companyBusinessLicense != ''">company_business_license,</if>
|
<if test="companyRegisteredAddressOfBusinessLicense != null and companyRegisteredAddressOfBusinessLicense != ''">company_registered_address_of_business_license,</if>
|
<if test="companyScale != null and companyScale != ''">company_scale,</if>
|
<if test="companyNumberOfEmployees != null ">company_number_of_employees,</if>
|
<if test="companyEstablished != null ">company_established,</if>
|
<if test="companyArea != null ">company_area,</if>
|
<if test="companyRegisteredCapital != null ">company_registered_capital,</if>
|
<if test="companyTotalAssets != null ">company_total_assets,</if>
|
<if test="companyActualIncomeOfThePreviousYear != null ">company_actual_income_of_the_previous_year,</if>
|
<if test="companyAnnualProfit != null ">company_annual_profit,</if>
|
<if test="companyEconomicType != null and companyEconomicType != ''">company_economic_type,</if>
|
<if test="companyIndustry != null and companyIndustry != ''">company_industry,</if>
|
<if test="companyLegalRepresentative != null and companyLegalRepresentative != ''">company_legal_representative,</if>
|
<if test="companyCorporatePosition != null and companyCorporatePosition != ''">company_corporate_position,</if>
|
<if test="companyLegalPersonPhone != null and companyLegalPersonPhone != ''">company_legal_person_phone,</if>
|
<if test="companyCorporateOfficePhone != null and companyCorporateOfficePhone != ''">company_corporate_office_phone,</if>
|
<if test="companyPersonInChargeOfRectification != null and companyPersonInChargeOfRectification != ''">company_person_in_charge_of_rectification,</if>
|
<if test="companyRectifierPhone != null and companyRectifierPhone != ''">company_rectifier_phone,</if>
|
<if test="companyOrganizer != null and companyOrganizer != ''">company_organizer,</if>
|
<if test="companyGroupCompanyName != null and companyGroupCompanyName != ''">company_group_company_name,</if>
|
<if test="companySecurityFunction != null and companySecurityFunction != ''">company_security_function,</if>
|
<if test="companyPostalCode != null and companyPostalCode != ''">company_postal_code,</if>
|
<if test="companyIntroduction != null and companyIntroduction != ''">company_introduction,</if>
|
<if test="companyOther != null and companyOther != ''">company_other,</if>
|
create_time
|
)values(
|
<if test="regionId != null and regionId != 0">#{regionId},</if>
|
<if test="companyId != null and companyId != 0">#{companyId},</if>
|
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
<if test="regionName != null and regionName != ''">#{regionName},</if>
|
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
<if test="orderNum != null and orderNum != ''">#{orderNum},</if>
|
<if test="leader != null and leader != ''">#{leader},</if>
|
<if test="phone != null and phone != ''">#{phone},</if>
|
<if test="email != null and email != ''">#{email},</if>
|
<if test="status != null">#{status},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
<if test="regionType != null">#{regionType},</if>
|
|
<if test="companyUnifiedSocialCreditCode != null and companyUnifiedSocialCreditCode != ''">#{companyUnifiedSocialCreditCode},</if>
|
<if test="companyBusinessLicense != null and companyBusinessLicense != ''">#{companyBusinessLicense},</if>
|
<if test="companyRegisteredAddressOfBusinessLicense != null and companyRegisteredAddressOfBusinessLicense != ''">#{companyRegisteredAddressOfBusinessLicense},</if>
|
<if test="companyScale != null and companyScale != ''">#{companyScale},</if>
|
<if test="companyNumberOfEmployees != null ">#{companyNumberOfEmployees},</if>
|
<if test="companyEstablished != null ">#{companyEstablished},</if>
|
<if test="companyArea != null ">#{companyArea},</if>
|
<if test="companyRegisteredCapital != null ">#{companyRegisteredCapital},</if>
|
<if test="companyTotalAssets != null ">#{companyTotalAssets},</if>
|
<if test="companyActualIncomeOfThePreviousYear != null ">#{companyActualIncomeOfThePreviousYear},</if>
|
<if test="companyAnnualProfit != null ">#{companyAnnualProfit},</if>
|
<if test="companyEconomicType != null and companyEconomicType != ''">#{companyEconomicType},</if>
|
<if test="companyIndustry != null and companyIndustry != ''">#{companyIndustry},</if>
|
<if test="companyLegalRepresentative != null and companyLegalRepresentative != ''">#{companyLegalRepresentative},</if>
|
<if test="companyCorporatePosition != null and companyCorporatePosition != ''">#{companyCorporatePosition},</if>
|
<if test="companyLegalPersonPhone != null and companyLegalPersonPhone != ''">#{companyLegalPersonPhone},</if>
|
<if test="companyCorporateOfficePhone != null and companyCorporateOfficePhone != ''">#{companyCorporateOfficePhone},</if>
|
<if test="companyPersonInChargeOfRectification != null and companyPersonInChargeOfRectification != ''">#{companyPersonInChargeOfRectification},</if>
|
<if test="companyRectifierPhone != null and companyRectifierPhone != ''">#{companyRectifierPhone},</if>
|
<if test="companyOrganizer != null and companyOrganizer != ''">#{companyOrganizer},</if>
|
<if test="companyGroupCompanyName != null and companyGroupCompanyName != ''">#{companyGroupCompanyName},</if>
|
<if test="companySecurityFunction != null and companySecurityFunction != ''">#{companySecurityFunction},</if>
|
<if test="companyPostalCode != null and companyPostalCode != ''">#{companyPostalCode},</if>
|
<if test="companyIntroduction != null and companyIntroduction != ''">#{companyIntroduction},</if>
|
<if test="companyOther != null and companyOther != ''">#{companyOther},</if>
|
|
sysdate()
|
)
|
</insert>
|
|
<update id="updateRegion" parameterType="Region">
|
update tr_region
|
<set>
|
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
<if test="companyId != null and companyId != 0">company_id = #{companyId},</if>
|
<if test="regionName != null and regionName != ''">region_name = #{regionName},</if>
|
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
|
<if test="leader != null">leader = #{leader},</if>
|
<if test="phone != null">phone = #{phone},</if>
|
<if test="email != null">email = #{email},</if>
|
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
<if test="regionType != null ">region_type = #{regionType},</if>
|
|
<if test="companyUnifiedSocialCreditCode != null and companyUnifiedSocialCreditCode != ''">company_unified_social_credit_code = #{companyUnifiedSocialCreditCode},</if>
|
<if test="companyBusinessLicense != null and companyBusinessLicense != ''">company_business_license = #{companyBusinessLicense},</if>
|
<if test="companyRegisteredAddressOfBusinessLicense != null and companyRegisteredAddressOfBusinessLicense != ''">company_registered_address_of_business_license = #{companyRegisteredAddressOfBusinessLicense},</if>
|
<if test="companyScale != null and companyScale != ''">company_scale = #{companyScale},</if>
|
<if test="companyNumberOfEmployees != null ">company_number_of_employees = #{companyNumberOfEmployees},</if>
|
<if test="companyEstablished != null ">company_established = #{companyEstablished},</if>
|
<if test="companyArea != null ">company_area = #{companyArea},</if>
|
<if test="companyRegisteredCapital != null ">company_registered_capital = #{companyRegisteredCapital},</if>
|
<if test="companyTotalAssets != null ">company_total_assets = #{companyTotalAssets},</if>
|
<if test="companyActualIncomeOfThePreviousYear != null ">company_actual_income_of_the_previous_year = #{companyActualIncomeOfThePreviousYear},</if>
|
<if test="companyAnnualProfit != null ">company_annual_profit = #{companyAnnualProfit},</if>
|
<if test="companyEconomicType != null and companyEconomicType != ''">company_economic_type = #{companyEconomicType},</if>
|
<if test="companyIndustry != null and companyIndustry != ''">company_industry = #{companyIndustry},</if>
|
<if test="companyLegalRepresentative != null and companyLegalRepresentative != ''">company_legal_representative = #{companyLegalRepresentative},</if>
|
<if test="companyCorporatePosition != null and companyCorporatePosition != ''">company_corporate_position = #{companyCorporatePosition},</if>
|
<if test="companyLegalPersonPhone != null and companyLegalPersonPhone != ''">company_legal_person_phone = #{companyLegalPersonPhone},</if>
|
<if test="companyCorporateOfficePhone != null and companyCorporateOfficePhone != ''">company_corporate_office_phone = #{companyCorporateOfficePhone},</if>
|
<if test="companyPersonInChargeOfRectification != null and companyPersonInChargeOfRectification != ''">company_person_in_charge_of_rectification = #{companyPersonInChargeOfRectification},</if>
|
<if test="companyRectifierPhone != null and companyRectifierPhone != ''">company_rectifier_phone = #{companyRectifierPhone},</if>
|
<if test="companyOrganizer != null and companyOrganizer != ''">company_organizer = #{companyOrganizer},</if>
|
<if test="companyGroupCompanyName != null and companyGroupCompanyName != ''">company_group_company_name = #{companyGroupCompanyName},</if>
|
<if test="companySecurityFunction != null and companySecurityFunction != ''">company_security_function = #{companySecurityFunction},</if>
|
<if test="companyPostalCode != null and companyPostalCode != ''">company_postal_code = #{companyPostalCode},</if>
|
<if test="companyIntroduction != null and companyIntroduction != ''">company_introduction = #{companyIntroduction},</if>
|
<if test="companyOther != null and companyOther != ''">company_other = #{companyOther},</if>
|
|
update_time = sysdate()
|
</set>
|
where region_id = #{regionId}
|
</update>
|
|
<update id="updateRegionChildren" parameterType="java.util.List">
|
update tr_region set ancestors =
|
<foreach collection="regions" item="item" index="index"
|
separator=" " open="case region_id" close="end">
|
when #{item.regionId} then #{item.ancestors}
|
</foreach>
|
where region_id in
|
<foreach collection="regions" item="item" index="index"
|
separator="," open="(" close=")">
|
#{item.regionId}
|
</foreach>
|
</update>
|
|
<delete id="deleteRegionById" parameterType="Long">
|
update tr_region set del_flag = '2' where region_id = #{regionId}
|
</delete>
|
|
<update id="updateRegionStatus" parameterType="Region">
|
update tr_region
|
<set>
|
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
update_time = sysdate()
|
</set>
|
where region_id in (${ancestors})
|
</update>
|
|
</mapper>
|