배치이력 생성 작업
This commit is contained in:
34
admin/src/main/resources/mappers/batchLog/BatchLogMapper.xml
Normal file
34
admin/src/main/resources/mappers/batchLog/BatchLogMapper.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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="app.module.admin.usecase.batchLog.adapters.persistence.BatchLogMapper">
|
||||
<!-- 실행 중인지 확인 -->
|
||||
<select id="exists" resultType="boolean">
|
||||
SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM batch_log
|
||||
WHERE type = #{type}
|
||||
AND status = 'RUNNING'
|
||||
AND start_at::date = CURRENT_DATE
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 실행 로그 insert -->
|
||||
<insert id="create">
|
||||
<selectKey keyProperty="id" resultType="long" order="BEFORE">
|
||||
SELECT nextval('batch_log_id_seq')
|
||||
</selectKey>
|
||||
|
||||
INSERT INTO batch_log (id, type, status, start_at, created_at)
|
||||
VALUES (#{id}, #{type}, #{status}, #{startAt}, now())
|
||||
</insert>
|
||||
|
||||
<!-- 상태 업데이트 -->
|
||||
<update id="update">
|
||||
UPDATE batch_log
|
||||
SET status = #{status},
|
||||
error_message = #{errorMessage},
|
||||
end_at = now()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user