Blame view

parking-module-system/src/main/resources/mybatis/smapper/SysOrgAreaSmapper.xml 2.56 KB
55f68655   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  <?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.zteits.sys.mapper.smapper.SysOrgAreaSmapper" >
    <resultMap id="BaseResultMap" type="com.zteits.sys.domain.SysOrgArea" >
      <id column="id" property="id" jdbcType="BIGINT" />
      <result column="org_id" property="orgId" jdbcType="BIGINT" />
      <result column="area_id" property="areaId" jdbcType="BIGINT" />
      <result column="area_type" property="areaType" jdbcType="INTEGER" />
      <result column="org_area_type" property="orgAreaType" jdbcType="INTEGER" />
    </resultMap>
    <sql id="Base_Column_List" >
      id, org_id, area_id, area_type, org_area_type
    </sql>
   
     <!--批量保存组织与区域关系-->
    <insert id="batchSaveOrgAreaRelation" parameterType="com.zteits.clouds.api.dto.sys.param.SysOrgAreaRelationSaveRequest" >
  	    <selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER" >
  	      SELECT LAST_INSERT_ID()
  	    </selectKey>
  	    insert into sys_org_area (org_id, area_id, area_type, 
  	      org_area_type)
  	    values 
          <foreach collection="areaBlockIds" item="blockId" index="index" separator=",">
             (#{orgId,jdbcType=BIGINT}, #{blockId.areaId,jdbcType=BIGINT}, #{blockId.areaType,jdbcType=INTEGER}, 
              #{blockId.orgAreaType,jdbcType=INTEGER})
          </foreach>
    </insert>
     <!--通过组织id删除组织区域关系表 -->
     <delete id="deleteOrgAreaRelationByOrgId" parameterType="java.lang.Long" >
      delete from sys_org_area
      where org_id = #{orgId,jdbcType=BIGINT}
    </delete>
    <!--通过区域id删除组织区域关系表 -->
     <delete id="deleteOrgAreaRelationByAreaId" parameterType="java.lang.Long" >
      delete from sys_org_area
      where area_id = #{areaId,jdbcType=BIGINT}
    </delete>
    <!-- 通过组织id查询已关联的区域list -->
    <select id="queryAreaIdsByorgId" resultType="java.lang.Long" parameterType="com.zteits.clouds.api.dto.sys.param.SysOrgAreaRelationSaveRequest">
       select 
          area_id
       from sys_org_area a 
       where org_id = #{orgId,jdbcType=BIGINT}
    </select>
    <!--通过组织ids查询组织对应的区域-->
    <select id="queryAreaListByOrgIds" resultMap="BaseResultMap" parameterType="com.zteits.clouds.api.dto.sys.param.AreaListByOrgIdRequest">
       select 
  	   a.area_id,
  	   a.area_type,
  	   a.org_area_type
  	from sys_org_area a 
      where 1=1
        and  a.org_id in 
        <foreach collection="orgIds" item="orgId" open="(" close=")" separator=",">
           #{orgId}
        </foreach>
    </select>
   
    
    
  </mapper>