wlzboy
2025-11-22 fd047fa7234dc11643dab8ecbf38e8d7a8ba0854
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?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.system.mapper.SysDeptRegionMapper">
 
    <resultMap type="SysDeptRegion" id="SysDeptRegionResult">
        <id     property="regionId"     column="region_id"     />
        <result property="deptId"       column="dept_id"       />
        <result property="province"     column="province"      />
        <result property="city"         column="city"          />
        <result property="area"         column="area"          />
        <result property="address"      column="address"       />
        <result property="hospitalName" column="hospital_name" />
        <result property="regionType"   column="region_type"   />
        <result property="status"       column="status"        />
        <result property="remark"       column="remark"        />
        <result property="createBy"     column="create_by"     />
        <result property="createTime"   column="create_time"   />
        <result property="updateBy"     column="update_by"     />
        <result property="updateTime"   column="update_time"   />
    </resultMap>
 
    <sql id="selectDeptRegionVo">
        select region_id, dept_id, province, city, area, address, hospital_name, region_type, status, remark, create_by, create_time, update_by, update_time
        from sys_dept_region
    </sql>
 
    <select id="selectDeptRegionListByDeptId" parameterType="Long" resultMap="SysDeptRegionResult">
        <include refid="selectDeptRegionVo"/>
        where dept_id = #{deptId}
        and status = '0'
        order by region_id
    </select>
 
    <select id="selectDeptRegionListByDeptIds" resultMap="SysDeptRegionResult">
        <include refid="selectDeptRegionVo"/>
        where dept_id in
        <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
            #{deptId}
        </foreach>
        and status = '0'
        order by dept_id, region_id
    </select>
 
    <insert id="insertDeptRegion" parameterType="SysDeptRegion">
        insert into sys_dept_region(
            <if test="deptId != null">dept_id,</if>
            <if test="province != null and province != ''">province,</if>
            <if test="city != null and city != ''">city,</if>
            <if test="area != null and area != ''">area,</if>
            <if test="address != null and address != ''">address,</if>
            <if test="hospitalName != null and hospitalName != ''">hospital_name,</if>
            <if test="regionType != null and regionType != ''">region_type,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            create_time
        )values(
            <if test="deptId != null">#{deptId},</if>
            <if test="province != null and province != ''">#{province},</if>
            <if test="city != null and city != ''">#{city},</if>
            <if test="area != null and area != ''">#{area},</if>
            <if test="address != null and address != ''">#{address},</if>
            <if test="hospitalName != null and hospitalName != ''">#{hospitalName},</if>
            <if test="regionType != null and regionType != ''">#{regionType},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            sysdate()
        )
    </insert>
 
    <update id="updateDeptRegion" parameterType="SysDeptRegion">
        update sys_dept_region
        <set>
            <if test="province != null">province = #{province},</if>
            <if test="city != null">city = #{city},</if>
            <if test="area != null">area = #{area},</if>
            <if test="address != null">address = #{address},</if>
            <if test="hospitalName != null">hospital_name = #{hospitalName},</if>
            <if test="regionType != null and regionType != ''">region_type = #{regionType},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            update_time = sysdate()
        </set>
        where region_id = #{regionId}
    </update>
 
    <delete id="deleteDeptRegionById" parameterType="Long">
        delete from sys_dept_region where region_id = #{regionId}
    </delete>
 
    <delete id="deleteDeptRegionByDeptId" parameterType="Long">
        delete from sys_dept_region where dept_id = #{deptId}
    </delete>
 
</mapper>