2022-01-11 10:21:53 +08:00
|
|
|
<?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">
|
2022-04-21 10:22:28 +08:00
|
|
|
<mapper namespace="com.xhpc.activity.mapper.XhpcWorkDeptMapper">
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.xhpc.activity.domain.XhpcWorkDeptDomain">
|
2022-01-11 10:21:53 +08:00
|
|
|
<id column="work_dept_id" jdbcType="BIGINT" property="workDeptId" />
|
|
|
|
|
<result column="dept_name" jdbcType="VARCHAR" property="deptName" />
|
|
|
|
|
<result column="code" jdbcType="VARCHAR" property="code" />
|
|
|
|
|
<result column="sort" jdbcType="SMALLINT" property="sort" />
|
|
|
|
|
<result column="parent_dept_id" jdbcType="BIGINT" property="parentDeptId" />
|
|
|
|
|
<result column="status" jdbcType="SMALLINT" property="status" />
|
|
|
|
|
<result column="del_flag" jdbcType="SMALLINT" property="delFlag" />
|
|
|
|
|
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
|
|
|
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
|
|
|
|
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
|
|
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
|
|
|
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
<sql id="Base_Column_List">
|
2022-06-10 16:22:21 +08:00
|
|
|
work_dept_id, dept_name, code, sort, parent_dept_id, `status`, del_flag, tenant_id,
|
2022-01-11 10:21:53 +08:00
|
|
|
create_time, create_by, update_time, update_by
|
|
|
|
|
</sql>
|
2022-02-21 09:35:37 +08:00
|
|
|
|
2022-05-20 17:46:03 +08:00
|
|
|
|
2022-04-21 10:22:28 +08:00
|
|
|
<select id="selectListByParams" resultType="com.xhpc.activity.domain.XhpcWorkDeptDomain">
|
2022-02-21 09:35:37 +08:00
|
|
|
select
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
from xhpc_work_dept
|
|
|
|
|
where del_flag = 0 and status = 1
|
|
|
|
|
<if test="params.tenantId !=null and params.tenantId!=''">
|
|
|
|
|
and tenant_id=#{params.tenantId}
|
|
|
|
|
</if>
|
2022-05-26 17:04:01 +08:00
|
|
|
<if test="params.deptId !=null and params.deptId!=''">
|
|
|
|
|
and work_dept_id=#{params.deptId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="params.parentDeptId !=null and params.parentDeptId!=''">
|
|
|
|
|
and parent_dept_id=#{params.parentDeptId}
|
|
|
|
|
</if>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="params.parentDeptIds !=null and params.parentDeptIds!=''">
|
|
|
|
|
and find_in_set(parent_dept_id, #{params.parentDeptIds})
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
and parent_dept_id is null
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
2022-06-10 16:22:21 +08:00
|
|
|
order by sort desc
|
2022-02-21 09:35:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
2022-05-20 17:46:03 +08:00
|
|
|
|
2022-02-21 09:35:37 +08:00
|
|
|
<select id="selectMapListByParams" resultType="map">
|
|
|
|
|
select
|
2022-06-21 16:39:44 +08:00
|
|
|
concat('d_',work_dept_id) as 'id',
|
2022-02-21 09:35:37 +08:00
|
|
|
dept_name as 'name'
|
|
|
|
|
from xhpc_work_dept
|
|
|
|
|
where del_flag = 0 and status = 1
|
|
|
|
|
<if test="params.tenantId !=null and params.tenantId!=''">
|
|
|
|
|
and tenant_id=#{params.tenantId}
|
|
|
|
|
</if>
|
2022-05-24 17:35:09 +08:00
|
|
|
<choose>
|
|
|
|
|
<when test="params.parentDeptId !=null and params.parentDeptId!=''">
|
|
|
|
|
and parent_dept_id=#{params.parentDeptId}
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
and parent_dept_id is null
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
2022-06-10 16:22:21 +08:00
|
|
|
order by sort desc
|
2022-02-21 09:35:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
2022-05-20 17:46:03 +08:00
|
|
|
|
2022-01-11 10:21:53 +08:00
|
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
2022-06-10 16:22:21 +08:00
|
|
|
select
|
2022-01-11 10:21:53 +08:00
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
from xhpc_work_dept
|
|
|
|
|
where work_dept_id = #{workDeptId,jdbcType=BIGINT}
|
|
|
|
|
</select>
|
2022-05-20 17:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectDomainByNameAndTenant" resultType="com.xhpc.activity.domain.XhpcWorkDeptDomain">
|
|
|
|
|
select
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
from xhpc_work_dept
|
|
|
|
|
where del_flag = 0 and dept_name = #{deptName} and tenant_id=#{tenantId}
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="parentDeptId != null">
|
|
|
|
|
and parent_dept_id=#{parentDeptId}
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
and parent_dept_id is null
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<update id="deleteLogicByPrimaryKey" parameterType="java.lang.Long">
|
2022-01-11 10:21:53 +08:00
|
|
|
update xhpc_work_dept set del_flag=2
|
|
|
|
|
where work_dept_id = #{workDeptId,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
2022-05-20 17:46:03 +08:00
|
|
|
|
|
|
|
|
|
2022-04-21 10:22:28 +08:00
|
|
|
<insert id="insert" keyColumn="work_dept_id" keyProperty="workDeptId" parameterType="com.xhpc.activity.domain.XhpcWorkDeptDomain" useGeneratedKeys="true">
|
2022-06-10 16:22:21 +08:00
|
|
|
insert into xhpc_work_dept (dept_name, code, sort,
|
|
|
|
|
parent_dept_id, `status`, del_flag,
|
|
|
|
|
tenant_id, create_time, create_by,
|
2022-01-11 10:21:53 +08:00
|
|
|
update_time, update_by)
|
2022-06-10 16:22:21 +08:00
|
|
|
values (#{deptName,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{sort,jdbcType=SMALLINT},
|
2022-01-11 10:21:53 +08:00
|
|
|
#{parentDeptId,jdbcType=BIGINT}, #{status,jdbcType=SMALLINT}, 0,
|
|
|
|
|
#{tenantId,jdbcType=VARCHAR}, SYSDATE(), #{createBy,jdbcType=VARCHAR},
|
|
|
|
|
SYSDATE(), #{updateBy,jdbcType=VARCHAR})
|
|
|
|
|
</insert>
|
2022-05-20 17:46:03 +08:00
|
|
|
|
|
|
|
|
|
2022-04-21 10:22:28 +08:00
|
|
|
<update id="updateByPrimaryKey" parameterType="com.xhpc.activity.domain.XhpcWorkDeptDomain">
|
2022-01-11 10:21:53 +08:00
|
|
|
update xhpc_work_dept
|
|
|
|
|
set dept_name = #{deptName,jdbcType=VARCHAR},
|
|
|
|
|
code = #{code,jdbcType=VARCHAR},
|
|
|
|
|
sort = #{sort,jdbcType=SMALLINT},
|
|
|
|
|
parent_dept_id = #{parentDeptId,jdbcType=BIGINT},
|
|
|
|
|
`status` = #{status,jdbcType=SMALLINT},
|
|
|
|
|
update_time = SYSDATE(),
|
|
|
|
|
update_by = #{updateBy,jdbcType=VARCHAR}
|
|
|
|
|
where work_dept_id = #{workDeptId,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
2022-05-20 17:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateStatusByPrimaryKey" parameterType="com.xhpc.activity.domain.XhpcWorkDeptDomain">
|
|
|
|
|
update xhpc_work_dept
|
|
|
|
|
set `status` = #{status,jdbcType=SMALLINT},
|
|
|
|
|
update_time = SYSDATE(),
|
|
|
|
|
update_by = #{updateBy,jdbcType=VARCHAR}
|
|
|
|
|
where work_dept_id = #{workDeptId,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
|
|
|
|
|
2022-01-11 10:21:53 +08:00
|
|
|
</mapper>
|