118 lines
4.5 KiB
XML
Raw Normal View History

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">
<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">
work_dept_id, dept_name, code, sort, parent_dept_id, `status`, del_flag, tenant_id,
create_time, create_by, update_time, update_by
</sql>
2022-02-21 09:35:37 +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>
</select>
2022-02-21 09:35:37 +08:00
<select id="selectMapListByParams" resultType="map">
select
work_dept_id as 'id',
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-02-21 09:35:37 +08:00
</select>
2022-01-11 10:21:53 +08:00
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xhpc_work_dept
where work_dept_id = #{workDeptId,jdbcType=BIGINT}
</select>
<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>
<insert id="insert" keyColumn="work_dept_id" keyProperty="workDeptId" parameterType="com.xhpc.activity.domain.XhpcWorkDeptDomain" useGeneratedKeys="true">
2022-01-11 10:21:53 +08:00
insert into xhpc_work_dept (dept_name, code, sort,
parent_dept_id, `status`, del_flag,
tenant_id, create_time, create_by,
update_time, update_by)
values (#{deptName,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{sort,jdbcType=SMALLINT},
#{parentDeptId,jdbcType=BIGINT}, #{status,jdbcType=SMALLINT}, 0,
#{tenantId,jdbcType=VARCHAR}, SYSDATE(), #{createBy,jdbcType=VARCHAR},
SYSDATE(), #{updateBy,jdbcType=VARCHAR})
</insert>
<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>
<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>