weaver-hrm-salary/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml

251 lines
8.2 KiB
XML
Raw Normal View History

2022-03-02 09:54:55 +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.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail">
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="employee_id" property="employeeId"/>
<result column="field_code" property="fieldCode"/>
<result column="field_value" property="fieldValue"/>
<result column="id" property="id"/>
<result column="tax_declaration_id" property="taxDeclarationId"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
create_time
, t.creator
, t.delete_type
, t.employee_id
, t.field_code
, t.field_value
, t.id
, t.tax_declaration_id
, t.tenant_key
, t.update_time
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration_detail t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration_detail t
WHERE id = #{id} AND delete_type = 0
</select>
2022-04-18 18:56:17 +08:00
<select id="countEmployeeId" resultType="int">
SELECT count(DISTINCT employee_id)
FROM hrsa_tax_declaration_detail
WHERE delete_type = 0
AND tax_declaration_id = #{taxDeclarationId}
</select>
<select id="listEmployeeId" resultType="long">
SELECT DISTINCT employee_id
FROM hrsa_tax_declaration_detail
WHERE delete_type = 0
AND tax_declaration_id = #{taxDeclarationId}
</select>
<select id="listByTaxDeclarationIdAndEmployeeIds"
resultType="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO">
</select>
2022-03-02 09:54:55 +08:00
<!-- 插入全部字段 -->
<insert id="insert" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_tax_declaration_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
create_time,
creator,
delete_type,
employee_id,
field_code,
field_value,
id,
tax_declaration_id,
tenant_key,
update_time,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{createTime},
#{creator},
#{deleteType},
#{employeeId},
#{fieldCode},
#{fieldValue},
#{id},
#{taxDeclarationId},
#{tenantKey},
#{updateTime},
</trim>
</insert>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_tax_declaration_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="createTime != null">
create_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="fieldCode != null">
field_code,
</if>
<if test="fieldValue != null">
field_value,
</if>
<if test="id != null">
id,
</if>
<if test="taxDeclarationId != null">
tax_declaration_id,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="createTime != null">
#{createTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="fieldCode != null">
#{fieldCode},
</if>
<if test="fieldValue != null">
#{fieldValue},
</if>
<if test="id != null">
#{id},
</if>
<if test="taxDeclarationId != null">
#{taxDeclarationId},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
</trim>
</insert>
2022-04-16 15:33:51 +08:00
<insert id="batchInsert">
INSERT INTO hrsa_tax_declaration_detail
(id, tax_declaration_id, employee_id, field_code, field_value, creator,
create_time, update_time, delete_type, tenant_key)
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.id},
#{item.taxDeclarationId},
#{item.employeeId},
#{item.fieldCode},
#{item.fieldValue},
#{item.creator},
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey}
)
</foreach>
</insert>
2022-03-02 09:54:55 +08:00
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail">
UPDATE hrsa_tax_declaration_detail
<set>
create_time=#{createTime},
creator=#{creator},
delete_type=#{deleteType},
employee_id=#{employeeId},
field_code=#{fieldCode},
field_value=#{fieldValue},
tax_declaration_id=#{taxDeclarationId},
tenant_key=#{tenantKey},
update_time=#{updateTime},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail">
UPDATE hrsa_tax_declaration_detail
<set>
<if test="createTime != null">
create_time=#{createTime},
</if>
<if test="creator != null">
creator=#{creator},
</if>
<if test="deleteType != null">
delete_type=#{deleteType},
</if>
<if test="employeeId != null">
employee_id=#{employeeId},
</if>
<if test="fieldCode != null">
field_code=#{fieldCode},
</if>
<if test="fieldValue != null">
field_value=#{fieldValue},
</if>
<if test="taxDeclarationId != null">
tax_declaration_id=#{taxDeclarationId},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete" parameterType="com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail">
UPDATE hrsa_tax_declaration_detail
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
</mapper>