You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
power/power-dao/src/main/resources/mapper/Power_Sys_DictMapper.xml

917 lines
31 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.manage.dao.Power_Sys_DictMapper">
<resultMap id="BaseResultMap" type="com.manage.entity.Power_Sys_Dict">
<id column="dict_id" jdbcType="INTEGER" property="dictId"/>
<result column="dept_id" jdbcType="INTEGER" property="deptId"/>
<result column="hospital_name" jdbcType="VARCHAR" property="hospitalName"/>
<result column="sys_flag" jdbcType="VARCHAR" property="sysFlag"/>
<result column="sys_name" jdbcType="VARCHAR" property="sysName"/>
<result column="dict_area" jdbcType="VARCHAR" property="dictArea"/>
<result column="hospital_tel" jdbcType="VARCHAR" property="hospitalTel"/>
<result column="parent_id" jdbcType="INTEGER" property="parentId"/>
<result column="sys_type" jdbcType="VARCHAR" property="sysType"/>
<result column="sort" jdbcType="INTEGER" property="sort"/>
<result column="dict_status" jdbcType="INTEGER" property="dictStatus"/>
<result column="dict_edit" jdbcType="INTEGER" property="dictEdit"/>
<result column="create_date" jdbcType="CHAR" property="createDate"/>
<result column="creater" jdbcType="VARCHAR" property="creater"/>
<result column="update_date" jdbcType="CHAR" property="updateDate"/>
<result column="updater" jdbcType="VARCHAR" property="updater"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
</resultMap>
<resultMap id="BaseResultMapVo" type="com.manage.vo.Power_Sys_DictVo">
<result column="sys_name" jdbcType="VARCHAR" property="sysName"/>
<result column="dict_status" jdbcType="INTEGER" property="dictStatus"/>
<result column="dept_name" jdbcType="INTEGER" property="deptName"/>
<result column="userName" jdbcType="VARCHAR" property="userName"/>
</resultMap>
<sql id="Base_Column_List">
dict_id, dept_id, hospital_name, sys_flag, sys_name, dict_area, hospital_tel, parent_id,
sys_type, sort, dict_status, dict_edit, create_date, creater, update_date, updater,
remark
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMapVo">
SELECT
power_sys_dict.dict_id,
power_sys_dict.dept_id,
power_sys_dict.sys_flag,
power_sys_dict.sys_name,
power_sys_dict.parent_id,
power_sys_dict.sys_type,
power_sys_dict.sort,
power_sys_dict.dict_status,
power_sys_dict.dict_edit,
power_sys_dict.create_date,
power_sys_dict.creater,
power_sys_dict.update_date,
power_sys_dict.updater,
power_sys_dict.remark,
if(power_sys_dict1.hospital_name != '',power_sys_dict1.hospital_name,power_sys_dict.hospital_name) hospital_name,
if(power_sys_dict1.hospital_tel != '',power_sys_dict1.hospital_tel,power_sys_dict.hospital_tel) hospital_tel,
if(power_sys_dict1.dict_area != '',power_sys_dict1.dict_area,power_sys_dict.dict_area) dict_area,
if(power_sys_dict.parent_id != 0,power_sys_dict.parent_id,power_sys_dict.dict_id) hospitalId
FROM
power_sys_dict
LEFT JOIN power_sys_dict power_sys_dict1 ON power_sys_dict.parent_id = power_sys_dict1.dict_id
WHERE power_sys_dict.dict_id = #{dictId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from power_sys_dict
where dict_id = #{dictId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.manage.entity.Power_Sys_Dict">
insert into power_sys_dict (dict_id, dept_id, hospital_name,
sys_flag, sys_name, dict_area,
hospital_tel, parent_id, sys_type,
sort, dict_status, dict_edit,
create_date, creater, update_date,
updater, remark)
values (#{dictId,jdbcType=INTEGER}, #{deptId,jdbcType=INTEGER}, #{hospitalName,jdbcType=VARCHAR},
#{sysFlag,jdbcType=VARCHAR}, #{sysName,jdbcType=VARCHAR}, #{dictArea,jdbcType=VARCHAR},
#{hospitalTel,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{sysType,jdbcType=VARCHAR},
#{sort,jdbcType=INTEGER}, #{dictStatus,jdbcType=INTEGER}, #{dictEdit,jdbcType=INTEGER},
#{createDate,jdbcType=CHAR}, #{creater,jdbcType=VARCHAR}, #{updateDate,jdbcType=CHAR},
#{updater,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.manage.entity.Power_Sys_Dict" useGeneratedKeys="true"
keyProperty="dictId">
insert into power_sys_dict
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dictId != null">
dict_id,
</if>
<if test="deptId != null">
dept_id,
</if>
<if test="hospitalName != null">
hospital_name,
</if>
<if test="sysFlag != null">
sys_flag,
</if>
<if test="sysName != null">
sys_name,
</if>
<if test="dictArea != null">
dict_area,
</if>
<if test="hospitalTel != null">
hospital_tel,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="sysType != null">
sys_type,
</if>
<if test="sort != null">
sort,
</if>
<if test="dictStatus != null">
dict_status,
</if>
<if test="dictEdit != null">
dict_edit,
</if>
<if test="createDate != null">
create_date,
</if>
<if test="creater != null">
creater,
</if>
<if test="updateDate != null">
update_date,
</if>
<if test="updater != null">
updater,
</if>
<if test="remark != null">
remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dictId != null">
#{dictId,jdbcType=INTEGER},
</if>
<if test="deptId != null">
#{deptId,jdbcType=INTEGER},
</if>
<if test="hospitalName != null">
#{hospitalName,jdbcType=VARCHAR},
</if>
<if test="sysFlag != null">
#{sysFlag,jdbcType=VARCHAR},
</if>
<if test="sysName != null">
#{sysName,jdbcType=VARCHAR},
</if>
<if test="dictArea != null">
#{dictArea,jdbcType=VARCHAR},
</if>
<if test="hospitalTel != null">
#{hospitalTel,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=INTEGER},
</if>
<if test="sysType != null">
#{sysType,jdbcType=VARCHAR},
</if>
<if test="sort != null">
#{sort,jdbcType=INTEGER},
</if>
<if test="dictStatus != null">
#{dictStatus,jdbcType=INTEGER},
</if>
<if test="dictEdit != null">
#{dictEdit,jdbcType=INTEGER},
</if>
<if test="createDate != null">
#{createDate,jdbcType=CHAR},
</if>
<if test="creater != null">
#{creater,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
#{updateDate,jdbcType=CHAR},
</if>
<if test="updater != null">
#{updater,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.manage.entity.Power_Sys_Dict">
update power_sys_dict
<set>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="hospitalName != null">
hospital_name = #{hospitalName,jdbcType=VARCHAR},
</if>
<if test="sysFlag != null">
sys_flag = #{sysFlag,jdbcType=VARCHAR},
</if>
<if test="sysName != null">
sys_name = #{sysName,jdbcType=VARCHAR},
</if>
<if test="dictArea != null">
dict_area = #{dictArea,jdbcType=VARCHAR},
</if>
<if test="hospitalTel != null">
hospital_tel = #{hospitalTel,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="sysType != null">
sys_type = #{sysType,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="dictStatus != null">
dict_status = #{dictStatus,jdbcType=INTEGER},
</if>
<if test="dictEdit != null">
dict_edit = #{dictEdit,jdbcType=INTEGER},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=CHAR},
</if>
<if test="creater != null">
creater = #{creater,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
update_date = #{updateDate,jdbcType=CHAR},
</if>
<if test="updater != null">
updater = #{updater,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
</set>
where dict_id = #{dictId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.manage.entity.Power_Sys_Dict">
update power_sys_dict
set dept_id = #{deptId,jdbcType=INTEGER},
hospital_name = #{hospitalName,jdbcType=VARCHAR},
sys_flag = #{sysFlag,jdbcType=VARCHAR},
sys_name = #{sysName,jdbcType=VARCHAR},
dict_area = #{dictArea,jdbcType=VARCHAR},
hospital_tel = #{hospitalTel,jdbcType=VARCHAR},
parent_id = #{parentId,jdbcType=INTEGER},
sys_type = #{sysType,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
dict_status = #{dictStatus,jdbcType=INTEGER},
dict_edit = #{dictEdit,jdbcType=INTEGER},
create_date = #{createDate,jdbcType=CHAR},
creater = #{creater,jdbcType=VARCHAR},
update_date = #{updateDate,jdbcType=CHAR},
updater = #{updater,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR}
where dict_id = #{dictId,jdbcType=INTEGER}
</update>
<!--2019-4-22 ly -->
<select id="findSomeByMore" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from power_sys_dict where 1 = 1
<if test="deptId!=null and deptId!=''">
and dept_id=#{deptId}
</if>
<if test="dictId!=null and dictId!=''">
and dict_id=#{dictId}
</if>
<if test="hospitalName!=null and hospitalName!=''">
and hospital_name=#{hospitalName}
</if>
<if test="sysFlag!=null and sysFlag!=''">
and sys_flag=#{sysFlag}
</if>
<if test="sysName!=null and sysName!=''">
and sys_name=#{sysName}
</if>
<if test="parentId!=null and parentId!=''">
and parent_id=#{parentId}
</if>
<if test="dictStatus!=null and dictStatus!=''">
and dict_status=#{dictStatus}
</if>
LIMIT #{offset},#{limit}
</select>
<select id="getTotal" resultType="int">
SELECT count(1) FROM power_sys_dict WHERE 1 = 1
<if test="deptId!=null and deptId!=''">
and dept_id=#{deptId}
</if>
<if test="dictId!=null and dictId!=''">
and dict_id=#{dictId}
</if>
<if test="hospitalName!=null and hospitalName!=''">
and hospital_name=#{hospitalName}
</if>
<if test="sysFlag!=null and sysFlag!=''">
and sys_flag=#{sysFlag}
</if>
<if test="sysName!=null and sysName!=''">
and sys_name=#{sysName}
</if>
<if test="parentId!=null and parentId!=''">
and parent_id=#{parentId}
</if>
<if test="dictStatus!=null and dictStatus!=''">
and dict_status=#{dictStatus}
</if>
</select>
<select id="selectList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from power_sys_dict ORDER BY parent_id asc
</select>
<select id="selectHosList" resultMap="BaseResultMap">
SELECT
dict.*
FROM
power_sys_dict dict
<if test="userId != null">
LEFT JOIN power_user_dict ON dict.dict_id = power_user_dict.dict_id
</if>
WHERE
dict.hospital_name != ''
AND
dict.hospital_name IS NOT NULL
AND
dict_status = 1
<if test="userId != null">
AND power_user_dict.user_id = ${userId}
</if>
</select>
<select id="selectSysType" resultMap="BaseResultMapVo">
SELECT
DISTINCT sys_type
FROM
power_sys_dict
WHERE
dict_status = 1 AND sys_name IS NOT NULL
</select>
<!--查询全部-->
<select id="selectAll" resultMap="BaseResultMapVo">
SELECT
dict.dict_id dictId,
dict.parent_id parentId,
dict.dept_id dictDeptId,
dept.dept_id deptId,
dict.hospital_name hospitalName,
dict.sys_name sysName,
dict.sys_flag sysFlag,
dict.sys_type sysType,
dept.dept_name deptName,
dict.hospital_tel,
dict.dict_area
FROM
power_sys_dict dict
LEFT JOIN power_dept dept ON dict.dict_id = dept.dict_id
AND dict.dict_status = 1 AND dept.effective = 1
</select>
<!--查询全部-->
<select id="selectAllByAdmin" resultMap="BaseResultMapVo">
SELECT
dict.dict_id dictId,
dict.parent_id parentId,
dict.dept_id dictDeptId,
dept.dept_id deptIds,
dict.hospital_name hospitalName,
dict.sys_name sysName,
dict.sys_flag sysFlag,
dict.sys_type sysType,
dept.dept_name deptName,
dict.hospital_tel,
dict.dict_area,
dept.creater username
FROM
power_sys_dict dict
LEFT JOIN power_dept dept ON dict.dict_id = dept.dict_id
AND dict.dict_status = 1 AND dept.effective = 1
union all
select
null as dictId,
power_user.role_id,
power_user.user_id dictDeptId,
power_user.dept_id deptIds,
null as hospitalName,
power_user.user_id as sysName,
null as sysFlag,
power_role.role_name sysType,
null as deptName,
power_user.user_tel hospital_tel,
power_user.user_name as dict_area,
power_user.name as username
from power_user
LEFT JOIN (SELECT
dict.dict_id dictId,
dict.parent_id parentId,
dict.dept_id dictDeptId,
dept.dept_id deptIds,
dict.hospital_name hospitalName,
dict.sys_name sysName,
dict.sys_flag sysFlag,
dict.sys_type sysType,
dept.dept_name deptName,
dict.hospital_tel,
dict.dict_area,
dept.creater username
FROM
power_sys_dict dict
LEFT JOIN power_dept dept ON dict.dict_id = dept.dict_id
AND dict.dict_status = 1 AND dept.effective = 1) dict
on FIND_IN_SET(dict.deptIds,power_user.dept_id)
inner join power_role on power_role.role_id = power_user.role_id and power_role.effective = 1 and power_role.role_id != 0 and power_role.role_id != -100
where dict.deptIds is not null and power_user.effective = 1
</select>
<!--查询全部系统-->
<select id="selectAllSys" resultMap="BaseResultMapVo">
SELECT
power_sys_dict.dict_id,power_sys_dict.sys_flag,power_sys_dict.sys_name,power_sys_dict1.hospital_name
FROM
power_sys_dict
LEFT JOIN
power_sys_dict power_sys_dict1
ON power_sys_dict.parent_id = power_sys_dict1.dict_id
WHERE
power_sys_dict.dict_status = 1 AND power_sys_dict.sys_name is not null
GROUP BY power_sys_dict.sys_flag
</select>
<!--根据用户id查询全部-->
<select id="selectAllByUserId" resultMap="BaseResultMapVo" parameterType="java.lang.Integer">
SELECT DISTINCT
dict.dict_id dictId,
dict.parent_id parentId,
dict.dept_id dictDeptId,
dept.dept_id deptId,
dict.hospital_name hospitalName,
dict.sys_name sysName,
dict.sys_flag sysFlag,
dict.sys_type sysType,
dept.dept_name deptName,
dict.hospital_tel,
dict.dict_area
FROM
(
SELECT
dict_id,
parent_id,
dept_id,
hospital_name,
sys_name,
sys_flag,
hospital_tel,
dict_area,
sys_type
FROM
power_sys_dict
WHERE
FIND_IN_SET(
dept_id,
(
SELECT
dept_id
FROM
power_user
WHERE
user_id = ${userId}
)
)
UNION ALL
SELECT
dict_id,
parent_id,
dept_id,
hospital_name,
sys_name,
sys_flag,
hospital_tel,
dict_area,
sys_type
FROM
power_sys_dict
WHERE
dict_id IN (
SELECT
parent_id
FROM
power_sys_dict
WHERE
FIND_IN_SET(
dept_id,
(
SELECT
dept_id
FROM
power_user
WHERE
user_id = ${userId}
)
)
)
UNION ALL
SELECT
power_sys_dict1.dict_id,
power_sys_dict1.parent_id,
power_sys_dict1.dept_id,
NULL AS hospital_name,
power_sys_dict1.sys_name,
power_sys_dict1.sys_flag,
NULL AS hospital_tel,
NULL AS dict_area,
power_sys_dict1.sys_type
FROM
power_sys_dict
LEFT JOIN power_sys_dict power_sys_dict1 ON power_sys_dict.dict_id = power_sys_dict1.parent_id
AND power_sys_dict1.sys_type = '权限系统'
WHERE
power_sys_dict.dict_id = (
SELECT
dict_id
FROM
power_sys_dict
WHERE
dict_id IN (
SELECT
parent_id
FROM
power_sys_dict
WHERE
FIND_IN_SET(
dept_id,
(
SELECT
dept_id
FROM
power_user
WHERE
user_id = ${userId}
)
)
)
)
) dict
LEFT JOIN power_dept dept ON dict.dept_id = dept.dept_id
</select>
<!--查询角色id为-100的为该医院所有系统-->
<select id="selectAllByHosRoleId" resultMap="BaseResultMapVo" parameterType="java.lang.Integer">
SELECT DISTINCT
dict.dict_id dictId,
dict.parent_id parentId,
dict.dept_id dictDeptId,
dept.dept_id deptIds,
dict.hospital_name hospitalName,
dict.sys_name sysName,
dict.sys_flag sysFlag,
dict.sys_type sysType,
dept.dept_name deptName,
dict.hospital_tel,
dict.dict_area,
dept.creater username
FROM
(
SELECT
dict_id,
parent_id,
dept_id,
hospital_name,
sys_name,
sys_flag,
hospital_tel,
dict_area,
sys_type
FROM
power_sys_dict
WHERE
dict_id = (
SELECT
dict_id
FROM
power_user_dict
WHERE
user_id = #{userId}
)
OR parent_id = (
SELECT
dict_id
FROM
power_user_dict
WHERE
user_id = #{userId}
)
UNION ALL
SELECT
power_sys_dict.dict_id,
power_dept.dict_id parent_id,
power_dept.dept_id,
power_sys_dict.hospital_name,
power_sys_dict.sys_name,
power_sys_dict.sys_flag,
power_sys_dict.hospital_tel,
power_sys_dict.dict_area,
power_sys_dict.sys_type
FROM
power_dept
LEFT JOIN power_sys_dict ON power_dept.dept_id = power_sys_dict.dept_id
WHERE
power_dept.dict_id = (
SELECT
dict_id
FROM
power_user_dict
WHERE
user_id = #{userId}
)
) dict
LEFT JOIN power_dept dept ON dict.dept_id = dept.dept_id
union all
select
null as dictId,
power_user.role_id,
power_user.user_id dictDeptId,
power_user.dept_id deptIds,
null as hospitalName,
power_user.user_id as sysName,
null as sysFlag,
power_role.role_name sysType,
null as deptName,
power_user.user_tel hospital_tel,
power_user.user_name as dict_area,
power_user.name as username
from power_user
left join (SELECT DISTINCT
dict.dict_id dictId,
dict.parent_id parentId,
dict.dept_id dictDeptId,
dept.dept_id deptIds,
dict.hospital_name hospitalName,
dict.sys_name sysName,
dict.sys_flag sysFlag,
dict.sys_type sysType,
dept.dept_name deptName,
dict.hospital_tel,
dict.dict_area
FROM
(
SELECT
dict_id,
parent_id,
dept_id,
hospital_name,
sys_name,
sys_flag,
hospital_tel,
dict_area,
sys_type
FROM
power_sys_dict
WHERE
dict_id = (
SELECT
dict_id
FROM
power_user_dict
WHERE
user_id = #{userId}
)
OR parent_id = (
SELECT
dict_id
FROM
power_user_dict
WHERE
user_id = #{userId}
)
UNION ALL
SELECT
power_sys_dict.dict_id,
power_dept.dict_id parent_id,
power_dept.dept_id,
power_sys_dict.hospital_name,
power_sys_dict.sys_name,
power_sys_dict.sys_flag,
power_sys_dict.hospital_tel,
power_sys_dict.dict_area,
power_sys_dict.sys_type
FROM
power_dept
LEFT JOIN power_sys_dict ON power_dept.dept_id = power_sys_dict.dept_id
WHERE
power_dept.dict_id = (
SELECT
dict_id
FROM
power_user_dict
WHERE
user_id = #{userId}
)
) dict
LEFT JOIN power_dept dept ON dict.dept_id = dept.dept_id
) dict on FIND_IN_SET(dict.deptIds,power_user.dept_id)
inner join power_role on power_role.role_id = power_user.role_id and power_role.effective = 1 and
power_role.role_id != 0 and power_role.role_id != -100
where dict.deptIds is not null and power_user.effective = 1
<if test="userId != null">
AND power_user.user_id != #{userId}
</if>
<if test="roleId != null">
AND power_user.role_id != #{roleId}
</if>
</select>
<!--根据系统标识查询科室id-->
<select id="selectDeptIdBySysFlag" resultType="com.manage.vo.Power_Sys_DictVo">
SELECT
dept_id
FROM
power_sys_dict
WHERE
sys_flag = #{sysFlag}
</select>
<!--验证医院名称是否重复-->
<select id="checkHospitalName" resultType="com.manage.vo.Power_Sys_DictVo">
SELECT
dict_id
FROM
power_sys_dict
WHERE
hospital_name = #{hospitalName}
</select>
<!--根据父节点查询医院-->
<select id="getHospitalByParentId" resultType="com.manage.vo.Power_Sys_DictVo">
SELECT
dict_id,
hospital_name,
hospital_tel,
dict_area
FROM
power_sys_dict
WHERE
parent_id = ${parentId}
<if test="sysType != null and sysType != ''">
AND sys_type = #{sysType}
</if>
</select>
<!--根据科室id验证系统标识或系统名称是否重复(添加)-->
<select id="checkSysFlagOrSysNameByDeptIds" resultMap="BaseResultMap">
SELECT
dict_id,
dept_id,
sys_flag,
sys_name,
parent_id
FROM
power_sys_dict
WHERE
<if test="sysFlag != '' or sysName != ''">
(sys_flag = #{sysFlag} OR sys_name = #{sysName})
</if>
<if test="deptIds != null and deptIds != ''">
AND dept_id IN (${deptIds})
</if>
</select>
<!--根据科室id验证系统标识或系统名称是否重复(修改)-->
<select id="checkSysFlagOrSysNameByDeptId" resultMap="BaseResultMap">
SELECT
dict_id,
dept_id,
sys_flag,
sys_name,
parent_id
FROM
power_sys_dict
WHERE
<if test="sysFlag != '' or sysName != ''">
(sys_flag = #{sysFlag} OR sys_name = #{sysName})
</if>
<if test="deptIds != null and deptIds != ''">
AND dept_id IN (${deptIds})
</if>
</select>
<!--用于系统管理员全查权限系统标识-->
<select id="selectSysFlagByAdmin" resultMap="BaseResultMap">
SELECT
sys_flag,
sys_name
FROM
power_sys_dict
WHERE
sys_flag IS NOT NULL
GROUP BY
sys_flag,
sys_name
</select>
<!--通过通知类别id查询对应系统的系统类别-->
<select id="selectSysTypeByNoticeId" resultMap="BaseResultMap">
SELECT
power_sys_dict.sys_type,
power_sys_dict.parent_id
FROM
power_notice
LEFT JOIN power_sys_dict ON power_notice.notice_type_flag = power_sys_dict.sys_flag
WHERE
notice_id = ${noticeId}
</select>
<!--通过系统标识和系统名称查询集合-->
<select id="selectAllBySysFlagAndSysName" resultMap="BaseResultMap">
SELECT
power_sys_dict.dict_id
FROM
power_sys_dict
WHERE
sys_flag = #{sysFlag}
AND
sys_name = #{sysName}
</select>
<!--通过系统标识查询医院id集合-->
<select id="selectHospitalIdBySysFlag" resultMap="BaseResultMap">
SELECT
parent_id
FROM
power_sys_dict
WHERE
sys_flag = #{sysFlag}
</select>
<!--通过用户id查询系统标识集合-->
<select id="selectSysFlagsByUserId" resultMap="BaseResultMap">
SELECT
sys_flag,sort
FROM
power_sys_dict
WHERE
sys_flag = 'power'
AND
dict_status = 1
GROUP BY
sys_flag
UNION ALL
SELECT
sys_flag,sort
FROM
power_sys_dict
WHERE
sys_flag != ''
AND sys_flag != 'power'
<if test="userId != null and roleId != -100">AND instr((SELECT dept_id FROM power_user WHERE user_id =
#{userId}),dept_id)
</if>
<if test="
userId != null and roleId == -100">
AND parent_id = (
SELECT
dict_id
FROM
power_user_dict
WHERE
user_id = #{userId}
)
</if>
AND
dict_status = 1
GROUP BY
sys_flag
</select>
<insert id="simpleInsertDict" parameterType="java.util.List">
INSERT INTO power_sys_dict(
dict_id,
dept_id,
hospital_name,
sys_flag,
sys_name,
dict_area,
hospital_tel,
parent_id,
sys_type,
sort,
dict_status,
dict_edit,
create_date,
creater,
update_date,
updater,
remark)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.dictId,jdbcType=INTEGER},
#{item.deptId,jdbcType=INTEGER},
#{item.hospitalName,jdbcType=VARCHAR},
#{item.sysFlag,jdbcType=VARCHAR},
#{item.sysName,jdbcType=VARCHAR},
#{item.dictArea,jdbcType=VARCHAR},
#{item.hospitalTel,jdbcType=VARCHAR},
#{item.parentId,jdbcType=INTEGER},
#{item.sysType,jdbcType=VARCHAR},
#{item.sort,jdbcType=INTEGER},
#{item.dictStatus,jdbcType=INTEGER},
#{item.dictEdit,jdbcType=INTEGER},
#{item.createDate,jdbcType=CHAR},
#{item.creater,jdbcType=VARCHAR},
#{item.updateDate,jdbcType=CHAR},
#{item.updater,jdbcType=VARCHAR},
#{item.remark,jdbcType=VARCHAR}
)
</foreach>
</insert>
<select id="selectDeptIdByParentIdAndSysFlag" resultMap="BaseResultMap">
SELECT dept_id FROM power_sys_dict WHERE parent_id = #{parentId} AND sys_flag = #{sysFlag}
<if test="deptIds != null and deptIds != ''">
AND dept_id in (${deptIds})
</if>
</select>
<select id="selectLastDict" resultType="java.lang.Integer">
SELECT max(dict_id) FROM power_sys_dict
</select>
</mapper>