refactor: flatten dto entity and mapper packages
This commit is contained in:
30
src/main/java/com/label/mapper/AnnotationTaskMapper.java
Normal file
30
src/main/java/com/label/mapper/AnnotationTaskMapper.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.AnnotationTask;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* annotation_task 表 Mapper。
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnnotationTaskMapper extends BaseMapper<AnnotationTask> {
|
||||
|
||||
/**
|
||||
* 原子性领取任务:仅当任务为 UNCLAIMED 且属于当前租户时才更新。
|
||||
* 使用乐观 WHERE 条件实现并发安全(依赖数据库行级锁)。
|
||||
*
|
||||
* @param taskId 任务 ID
|
||||
* @param userId 领取用户 ID
|
||||
* @param companyId 当前租户
|
||||
* @return 影响行数(0 = 任务已被他人领取或不存在)
|
||||
*/
|
||||
@Update("UPDATE annotation_task " +
|
||||
"SET status = 'IN_PROGRESS', claimed_by = #{userId}, claimed_at = NOW(), updated_at = NOW() " +
|
||||
"WHERE id = #{taskId} AND status = 'UNCLAIMED' AND company_id = #{companyId}")
|
||||
int claimTask(@Param("taskId") Long taskId,
|
||||
@Param("userId") Long userId,
|
||||
@Param("companyId") Long companyId);
|
||||
}
|
||||
Reference in New Issue
Block a user