Files
ccdi/ccdi-info-collection/src/main/resources/mapper/info/collection/CcdiBaseStaffMapper.xml
wkc 621579f39f refactor: 重命名 ruoyi-info-collection 模块为 ccdi-info-collection
- 重命名模块目录 ruoyi-info-collection -> ccdi-info-collection
- 更新所有 pom.xml 中的模块引用
- 更新 IDEA 配置文件 (compiler.xml, encodings.xml)
- Java 包名保持不变 (com.ruoyi.info.collection)
- 编译测试通过
2026-02-26 10:43:10 +08:00

102 lines
4.2 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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.ruoyi.info.collection.mapper.CcdiBaseStaffMapper">
<!-- 员工基本信息ResultMap用于列表查询不包含亲属 -->
<resultMap type="com.ruoyi.info.collection.domain.vo.CcdiBaseStaffVO" id="CcdiBaseStaffVOResult">
<id property="staffId" column="staff_id"/>
<result property="name" column="name"/>
<result property="deptId" column="dept_id"/>
<result property="deptName" column="dept_name"/>
<result property="idCard" column="id_card"/>
<result property="phone" column="phone"/>
<result property="hireDate" column="hire_date"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
</resultMap>
<select id="selectBaseStaffPageWithDept" resultMap="CcdiBaseStaffVOResult">
SELECT
e.staff_id, e.name, e.dept_id, e.id_card, e.phone, e.hire_date, e.status, e.create_time,
d.dept_name
FROM ccdi_base_staff e
LEFT JOIN sys_dept d ON e.dept_id = d.dept_id
<where>
<if test="query.name != null and query.name != ''">
AND e.name LIKE CONCAT('%', #{query.name}, '%')
</if>
<if test="query.staffId != null">
AND e.staff_id = #{query.staffId}
</if>
<if test="query.deptId != null">
AND e.dept_id = #{query.deptId}
</if>
<if test="query.idCard != null and query.idCard != ''">
AND e.id_card LIKE CONCAT('%', #{query.idCard}, '%')
</if>
<if test="query.status != null and query.status != ''">
AND e.status = #{query.status}
</if>
</where>
ORDER BY e.create_time DESC
</select>
<!-- 批量插入或更新员工信息只更新非null字段 -->
<insert id="insertOrUpdateBatch" parameterType="java.util.List">
INSERT INTO ccdi_base_staff
(staff_id, name, dept_id, id_card, phone, hire_date, status,
create_time, create_by, update_by, update_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.staffId}, #{item.name}, #{item.deptId}, #{item.idCard},
#{item.phone}, #{item.hireDate}, #{item.status}, NOW(),
#{item.createBy}, #{item.updateBy}, NOW())
</foreach>
ON DUPLICATE KEY UPDATE
name = COALESCE(VALUES(name), name),
dept_id = COALESCE(VALUES(dept_id), dept_id),
phone = COALESCE(VALUES(phone), phone),
hire_date = COALESCE(VALUES(hire_date), hire_date),
status = COALESCE(VALUES(status), status),
update_by = COALESCE(VALUES(update_by), update_by),
update_time = NOW()
</insert>
<!-- 批量插入员工信息 -->
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO ccdi_base_staff
(staff_id, name, dept_id, id_card, phone, hire_date, status,
create_time, create_by, update_by, update_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.staffId}, #{item.name}, #{item.deptId}, #{item.idCard},
#{item.phone}, #{item.hireDate}, #{item.status}, NOW(),
#{item.createBy}, #{item.updateBy}, NOW())
</foreach>
</insert>
<!-- 查询员工选项(用于下拉选择框) -->
<!-- 支持按员工ID或姓名模糊搜索只返回在职员工 -->
<select id="selectStaffOptions" resultType="com.ruoyi.info.collection.domain.vo.CcdiBaseStaffOptionVO">
SELECT
e.staff_id,
e.name,
e.dept_id,
d.dept_name
FROM ccdi_base_staff e
LEFT JOIN sys_dept d ON e.dept_id = d.dept_id
<where>
e.status = '0'
<if test="query != null and query != ''">
AND (CAST(e.staff_id AS CHAR) LIKE CONCAT('%', #{query}, '%')
OR e.name LIKE CONCAT('%', #{query}, '%'))
</if>
</where>
ORDER BY e.staff_id
LIMIT 100
</select>
</mapper>