feat: 添加员工信息批量插入或更新Mapper方法
在CcdiEmployeeMapper中新增insertOrUpdateBatch方法: - 支持批量插入员工信息 - 使用ON DUPLICATE KEY UPDATE实现upsert功能 - 基于employee_id主键判断重复 - 插入时记录创建时间和创建人 - 更新时保留原创建信息,更新修改时间和修改人 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,8 @@ import com.ruoyi.ccdi.domain.dto.CcdiEmployeeQueryDTO;
|
|||||||
import com.ruoyi.ccdi.domain.vo.CcdiEmployeeVO;
|
import com.ruoyi.ccdi.domain.vo.CcdiEmployeeVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工信息 数据层
|
* 员工信息 数据层
|
||||||
*
|
*
|
||||||
@@ -32,4 +34,13 @@ public interface CcdiEmployeeMapper extends BaseMapper<CcdiEmployee> {
|
|||||||
* @return 员工VO
|
* @return 员工VO
|
||||||
*/
|
*/
|
||||||
CcdiEmployeeVO selectEmployeeWithRelatives(@Param("employeeId") Long employeeId);
|
CcdiEmployeeVO selectEmployeeWithRelatives(@Param("employeeId") Long employeeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入或更新员工信息
|
||||||
|
* 使用ON DUPLICATE KEY UPDATE语法
|
||||||
|
*
|
||||||
|
* @param list 员工信息列表
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int insertOrUpdateBatch(@Param("list") List<CcdiEmployee> list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,26 @@
|
|||||||
ORDER BY e.create_time DESC
|
ORDER BY e.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 批量插入或更新员工信息 -->
|
||||||
|
<insert id="insertOrUpdateBatch" parameterType="java.util.List">
|
||||||
|
INSERT INTO ccdi_employee
|
||||||
|
(employee_id, name, dept_id, id_card, phone, hire_date, status,
|
||||||
|
create_time, create_by, update_by, update_time, remark)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.employeeId}, #{item.name}, #{item.deptId}, #{item.idCard},
|
||||||
|
#{item.phone}, #{item.hireDate}, #{item.status}, NOW(),
|
||||||
|
#{item.createBy}, #{item.updateBy}, NOW(), #{item.remark})
|
||||||
|
</foreach>
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
name = VALUES(name),
|
||||||
|
dept_id = VALUES(dept_id),
|
||||||
|
phone = VALUES(phone),
|
||||||
|
hire_date = VALUES(hire_date),
|
||||||
|
status = VALUES(status),
|
||||||
|
update_by = VALUES(update_by),
|
||||||
|
update_time = NOW(),
|
||||||
|
remark = VALUES(remark)
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user