165 lines
6.0 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.xhpc.activity.mapper.XhpcWorkDeptMapper">
<resultMap id="BaseResultMap" type="com.xhpc.activity.domain.XhpcWorkDeptDomain">
<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>
<select id="selectListByParams" resultType="com.xhpc.activity.domain.XhpcWorkDeptDomain">
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>
<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>
</select>
<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>
<update id="deleteByPrimaryKey" parameterType="java.lang.Long">
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">
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>
<insert id="insertSelective" keyColumn="work_dept_id" keyProperty="workDeptId" parameterType="com.xhpc.activity.domain.XhpcWorkDeptDomain" useGeneratedKeys="true">
insert into xhpc_work_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptName != null">
dept_name,
</if>
<if test="code != null">
code,
</if>
<if test="sort != null">
sort,
</if>
<if test="parentDeptId != null">
parent_dept_id,
</if>
<if test="status != null">
`status`,
</if>
del_flag,
<if test="tenantId != null">
tenant_id,
</if>
create_time,
<if test="createBy != null">
create_by,
</if>
update_time,
<if test="updateBy != null">
update_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptName != null">
#{deptName,jdbcType=VARCHAR},
</if>
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="sort != null">
#{sort,jdbcType=SMALLINT},
</if>
<if test="parentDeptId != null">
#{parentDeptId,jdbcType=BIGINT},
</if>
<if test="status != null">
#{status,jdbcType=SMALLINT},
</if>
0,
<if test="tenantId != null">
#{tenantId,jdbcType=VARCHAR},
</if>
SYSDATE(),
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
SYSDATE(),
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.activity.domain.XhpcWorkDeptDomain">
update xhpc_work_dept
<set>
<if test="deptName != null">
dept_name = #{deptName,jdbcType=VARCHAR},
</if>
<if test="code != null">
code = #{code,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=SMALLINT},
</if>
<if test="parentDeptId != null">
parent_dept_id = #{parentDeptId,jdbcType=BIGINT},
</if>
<if test="status != null">
`status` = #{status,jdbcType=SMALLINT},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=VARCHAR},
</if>
update_time = SYSDATE(),
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
</set>
where work_dept_id = #{workDeptId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.activity.domain.XhpcWorkDeptDomain">
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},
tenant_id = #{tenantId,jdbcType=VARCHAR},
update_time = SYSDATE(),
update_by = #{updateBy,jdbcType=VARCHAR}
where work_dept_id = #{workDeptId,jdbcType=BIGINT}
</update>
</mapper>