123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- ~
- ~ Copyright (c) 2018-2025, hnqz All rights reserved.
- ~
- ~ Redistribution and use in source and binary forms, with or without
- ~ modification, are permitted provided that the following conditions are met:
- ~
- ~ Redistributions of source code must retain the above copyright notice,
- ~ this list of conditions and the following disclaimer.
- ~ Redistributions in binary form must reproduce the above copyright
- ~ notice, this list of conditions and the following disclaimer in the
- ~ documentation and/or other materials provided with the distribution.
- ~ Neither the name of the pig4cloud.com developer nor the names of its
- ~ contributors may be used to endorse or promote products derived from
- ~ this software without specific prior written permission.
- ~ Author: hnqz
- ~
- -->
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.qunzhixinxi.hnqz.admin.mapper.SysDeptMapper">
- <resultMap id="sysDeptMap" type="com.qunzhixinxi.hnqz.admin.api.entity.SysDept">
- <id property="deptId" column="dept_id"/>
- <result property="name" column="name"/>
- <result property="sort" column="sort"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="delFlag" column="del_flag"/>
- <result property="parentId" column="parent_id"/>
- <result property="tenantId" column="tenant_id"/>
- <result property="deptCode" column="dept_code"/>
- <result property="level" column="level"/>
- <result property="level1Name" column="level1_name"/>
- <result property="level1Id" column="level1_id"/>
- <result property="level2Name" column="level2_name"/>
- <result property="level2Id" column="level2_id"/>
- <result property="level3Name" column="level3_name"/>
- <result property="level3Id" column="level3_id"/>
- <result property="appId" column="app_id"/>
- <result property="appSecret" column="app_secret"/>
- <result property="rsaPublicKey" column="rsa_public_key"/>
- <result property="queryUrl" column="query_url"/>
- <result property="subjectName" column="subject_name"/>
- <result property="subjectType" column="subject_type"/>
- <result property="taxCode" column="tax_code"/>
- </resultMap>
- <resultMap id="sysEntRelMap" type="com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseRelationVO">
- <id property="relId" column="rel_id"/>
- <result property="entId" column="ent_id"/>
- <result property="entName" column="ent_name"/>
- <result property="rootId" column="root_id"/>
- <result property="rootName" column="root_name"/>
- <result property="entType" column="ent_type"/>
- <result property="productLine" column="product_line"/>
- <result property="entLevel" column="ent_level"/>
- <collection property="serviceCharges" ofType="com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseServiceChargeVO"
- select="com.qunzhixinxi.hnqz.admin.mapper.SysDeptSubMapper.listSysEnterpriseServiceCharge"
- column="ent_id"/>
- </resultMap>
- <select id="selectDistinctDeptId" resultMap="sysDeptMap">
- SELECT DISTINCT dept_id,
- level
- FROM sys_dept
- WHERE dept_id = #{query.deptId,jdbcType=INTEGER}
- ORDER BY level
- LIMIT 1
- </select>
- <select id="selectDeptList" resultMap="sysDeptMap">
- SELECT dept_id,
- sort,
- name
- FROM sys_dept
- </select>
- <select id="selectDeptByIds" resultMap="sysDeptMap">
- SELECT *
- FROM sys_dept
- WHERE dept_id = #{query.deptId,jdbcType=INTEGER}
- </select>
- <select id="selectDeptByName" resultMap="sysDeptMap">
- SELECT dept_id,
- name
- FROM sys_dept
- WHERE dept_id = #{query.deptId,jdbcType=INTEGER}
- </select>
- <select id="selectDept" resultMap="sysDeptMap">
- SELECT *
- FROM sys_dept
- WHERE dept_id = #{deptId,jdbcType=INTEGER}
- </select>
- <select id="selectListByDept" resultMap="sysDeptMap">
- SELECT dept_id,
- name
- FROM sys_dept
- WHERE del_flag = 0
- </select>
- <select id="selectDeptById" resultType="java.util.HashMap">
- SELECT d.dept_id AS deptid,
- d.name,
- d.level,
- CASE WHEN a.zj_number IS NULL THEN e.entcode ELSE a.zj_number END entcode
- FROM sys_dept d
- LEFT JOIN wm_da_agent a ON d.dept_id = a.dept_id
- LEFT JOIN wm_da_drug_ent e ON d.dept_id = e.dept_id
- WHERE d.dept_id = #{query.deptId,jdbcType=INTEGER}
- </select>
- <select id="getAllParentDept" resultMap="sysDeptMap">
- SELECT DISTINCT dept_id,
- `name`,
- `level`
- FROM sys_dept
- WHERE dept_id IN
- (SELECT d.dept_id
- FROM sys_dept d
- WHERE d.dept_id = #{query.deptId}
- UNION
- SELECT r.up_id
- FROM sys_dept d
- LEFT JOIN wm_relation r ON d.dept_id = r.down_id
- WHERE d.dept_id = #{query.deptId}
- UNION
- SELECT r2.up_id
- FROM sys_dept d
- LEFT JOIN wm_relation r ON d.dept_id = r.down_id
- LEFT JOIN wm_relation r2 ON r.up_id = r2.down_id
- WHERE d.dept_id = #{query.deptId}
- )
- AND del_flag = 0
- AND dept_id NOT IN (1)
- </select>
- <select id="selectByName" resultMap="sysDeptMap">
- SELECT *
- FROM sys_dept
- WHERE name = #{name,jdbcType=VARCHAR}
- </select>
- <select id="selectEntCodeByLevelId" resultType="string">
- <choose>
- <when test="level = 1">
- SELECT `entcode` FROM `wm_da_drug_ent`
- </when>
- <otherwise>
- SELECT `zj_number` FROM `wm_da_agent`
- </otherwise>
- </choose>
- WHERE `id` = #{levelId}
- </select>
- <update id="updateByPrimaryKeySelective" parameterType="com.qunzhixinxi.hnqz.admin.api.entity.SysDept">
- update sys_dept
- <set>
- <if test="delFlag != null">
- del_flag = #{delFlag,jdbcType=VARCHAR},
- </if>
- <if test="name != null">
- name = #{name,jdbcType=VARCHAR},
- </if>
- <if test="subjectType != null">
- subject_type = #{subjectType,jdbcType=VARCHAR},
- </if>
- <if test="taxCode != null">
- tax_code = #{taxCode,jdbcType=VARCHAR},
- </if>
- <if test="deptPermissions != null and deptPermissions != ''">
- dept_permissions = #{deptPermissions, jdbcType=VARCHAR}
- </if>
- </set>
- where dept_id = #{deptId,jdbcType=BIGINT}
- </update>
- <select id="getParentDept" resultType="map">
- SELECT DISTINCT dept_id deptid,
- `name`
- FROM sys_dept
- WHERE dept_id IN
- (
- SELECT r.up_id
- FROM sys_dept d
- LEFT JOIN wm_relation r ON d.dept_id = r.down_id
- WHERE d.dept_id = #{query.deptId}
- UNION
- SELECT r2.up_id
- FROM sys_dept d
- LEFT JOIN wm_relation r ON d.dept_id = r.down_id
- LEFT JOIN wm_relation r2 ON r.up_id = r2.down_id
- WHERE d.dept_id = #{query.deptId}
- )
- AND del_flag = 0
- AND dept_id NOT IN (1)
- </select>
- <select id="getChildDept" resultType="map">
- SELECT DISTINCT dept_id deptid,
- `name`
- FROM sys_dept
- WHERE dept_id IN
- (
- SELECT r.down_id
- FROM sys_dept d
- LEFT JOIN wm_relation r ON d.dept_id = r.up_id
- WHERE d.dept_id = #{query.deptId}
- UNION
- SELECT r2.down_id
- FROM sys_dept d
- LEFT JOIN wm_relation r ON d.dept_id = r.up_id
- LEFT JOIN wm_relation r2 ON r.down_id = r2.up_id
- WHERE d.dept_id = #{query.deptId}
- )
- AND del_flag = 0
- AND dept_id NOT IN (1)
- </select>
- <select id="getDeptConvertToName" resultType="map">
- SELECT dept_id deptid, `name`
- FROM sys_dept
- </select>
- <!-- 查询所有dept -->
- <select id="listAllDept" resultMap="sysDeptMap">
- SELECT *
- FROM sys_dept
- </select>
- <!-- 根据id批量查询 -->
- <select id="selectByIds" resultMap="sysDeptMap">
- select * from sys_dept where dept_id in
- <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </select>
- <select id="pageEntRels" resultMap="sysEntRelMap">
- SELECT el.rel_id,
- d.dept_id AS `ent_id`,
- d.name AS `ent_name`,
- d1.dept_id AS `root_id`,
- d1.name AS `root_name`,
- el.e_type AS `ent_type`,
- el.pro_line AS `product_line`,
- el.e_level AS `ent_level`
- FROM sys_dept d
- LEFT JOIN sys_ent_rel el ON el.ent_id = d.dept_id
- LEFT JOIN sys_dept d1 ON el.root_id = d1.dept_id
- <where>
- d.del_flag = 0
- <if test="entName != null and entName != ''">
- AND d.name like CONCAT('%', #{entName},'%')
- </if>
- </where>
- </select>
- </mapper>
|