refactor: flatten dto entity and mapper packages
This commit is contained in:
36
src/main/java/com/label/mapper/AnnotationResultMapper.java
Normal file
36
src/main/java/com/label/mapper/AnnotationResultMapper.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.AnnotationResult;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
/**
|
||||
* annotation_result 表 Mapper。
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnnotationResultMapper extends BaseMapper<AnnotationResult> {
|
||||
|
||||
/**
|
||||
* 整体覆盖标注结果 JSON(JSONB 字段)。
|
||||
*
|
||||
* @param taskId 任务 ID
|
||||
* @param resultJson 新的 JSON 字符串(整体替换)
|
||||
* @param companyId 当前租户
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE annotation_result " +
|
||||
"SET result_json = #{resultJson}::jsonb, updated_at = NOW() " +
|
||||
"WHERE task_id = #{taskId} AND company_id = #{companyId}")
|
||||
int updateResultJson(@Param("taskId") Long taskId,
|
||||
@Param("resultJson") String resultJson,
|
||||
@Param("companyId") Long companyId);
|
||||
|
||||
/**
|
||||
* 按任务 ID 查询标注结果。
|
||||
*
|
||||
* @param taskId 任务 ID
|
||||
* @return 标注结果(不存在则返回 null)
|
||||
*/
|
||||
@Select("SELECT * FROM annotation_result WHERE task_id = #{taskId}")
|
||||
AnnotationResult selectByTaskId(@Param("taskId") Long taskId);
|
||||
}
|
||||
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);
|
||||
}
|
||||
31
src/main/java/com/label/mapper/ExportBatchMapper.java
Normal file
31
src/main/java/com/label/mapper/ExportBatchMapper.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.ExportBatch;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* export_batch 表 Mapper。
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExportBatchMapper extends BaseMapper<ExportBatch> {
|
||||
|
||||
/**
|
||||
* 更新微调任务信息(glm_job_id + finetune_status)。
|
||||
*
|
||||
* @param id 批次 ID
|
||||
* @param glmJobId GLM fine-tune 任务 ID
|
||||
* @param finetuneStatus 新状态
|
||||
* @param companyId 当前租户
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE export_batch SET glm_job_id = #{glmJobId}, " +
|
||||
"finetune_status = #{finetuneStatus}, updated_at = NOW() " +
|
||||
"WHERE id = #{id} AND company_id = #{companyId}")
|
||||
int updateFinetuneInfo(@Param("id") Long id,
|
||||
@Param("glmJobId") String glmJobId,
|
||||
@Param("finetuneStatus") String finetuneStatus,
|
||||
@Param("companyId") Long companyId);
|
||||
}
|
||||
28
src/main/java/com/label/mapper/SourceDataMapper.java
Normal file
28
src/main/java/com/label/mapper/SourceDataMapper.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.SourceData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* source_data 表 Mapper。
|
||||
*/
|
||||
@Mapper
|
||||
public interface SourceDataMapper extends BaseMapper<SourceData> {
|
||||
|
||||
/**
|
||||
* 按 ID 更新资料状态(带 company_id 租户隔离)。
|
||||
*
|
||||
* @param id 资料 ID
|
||||
* @param status 新状态
|
||||
* @param companyId 当前租户
|
||||
* @return 影响行数(0 表示记录不存在或不属于当前租户)
|
||||
*/
|
||||
@Update("UPDATE source_data SET status = #{status}, updated_at = NOW() " +
|
||||
"WHERE id = #{id} AND company_id = #{companyId}")
|
||||
int updateStatus(@Param("id") Long id,
|
||||
@Param("status") String status,
|
||||
@Param("companyId") Long companyId);
|
||||
}
|
||||
23
src/main/java/com/label/mapper/SysCompanyMapper.java
Normal file
23
src/main/java/com/label/mapper/SysCompanyMapper.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.SysCompany;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* sys_company 表 Mapper。
|
||||
* 继承 BaseMapper 获得标准 CRUD;自定义方法用注解 SQL。
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysCompanyMapper extends BaseMapper<SysCompany> {
|
||||
|
||||
/**
|
||||
* 按公司代码查询公司(忽略多租户过滤,sys_company 无 company_id 字段)。
|
||||
*
|
||||
* @param companyCode 公司代码
|
||||
* @return 公司实体,不存在则返回 null
|
||||
*/
|
||||
@Select("SELECT * FROM sys_company WHERE company_code = #{companyCode}")
|
||||
SysCompany selectByCompanyCode(String companyCode);
|
||||
}
|
||||
36
src/main/java/com/label/mapper/SysConfigMapper.java
Normal file
36
src/main/java/com/label/mapper/SysConfigMapper.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.SysConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* sys_config 表 Mapper。
|
||||
*
|
||||
* 注意:sys_config 已加入 MybatisPlusConfig.IGNORED_TABLES,不走多租户过滤器,
|
||||
* 需手动传入 companyId 进行过滤。
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysConfigMapper extends BaseMapper<SysConfig> {
|
||||
|
||||
/** 查询指定公司的配置(租户专属,优先级高) */
|
||||
@Select("SELECT * FROM sys_config WHERE company_id = #{companyId} AND config_key = #{configKey}")
|
||||
SysConfig selectByCompanyAndKey(@Param("companyId") Long companyId,
|
||||
@Param("configKey") String configKey);
|
||||
|
||||
/** 查询全局默认配置(company_id IS NULL) */
|
||||
@Select("SELECT * FROM sys_config WHERE company_id IS NULL AND config_key = #{configKey}")
|
||||
SysConfig selectGlobalByKey(@Param("configKey") String configKey);
|
||||
|
||||
/**
|
||||
* 查询指定公司所有可见配置(公司专属 + 全局默认),
|
||||
* 按 company_id DESC NULLS LAST 排序(公司专属优先于全局默认)。
|
||||
*/
|
||||
@Select("SELECT * FROM sys_config WHERE company_id = #{companyId} OR company_id IS NULL " +
|
||||
"ORDER BY company_id DESC NULLS LAST")
|
||||
List<SysConfig> selectAllForCompany(@Param("companyId") Long companyId);
|
||||
}
|
||||
34
src/main/java/com/label/mapper/SysUserMapper.java
Normal file
34
src/main/java/com/label/mapper/SysUserMapper.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* sys_user 表 Mapper。
|
||||
* 继承 BaseMapper 获得标准 CRUD;自定义登录查询方法绕过多租户过滤器,
|
||||
* 由调用方显式传入 companyId。
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
/**
|
||||
* 按公司 ID + 用户名查询用户(登录场景使用)。
|
||||
* <p>
|
||||
* 使用 @InterceptorIgnore 绕过 TenantLineInnerInterceptor,
|
||||
* 由参数 companyId 显式限定租户,防止登录时 CompanyContext 尚未注入
|
||||
* 导致查询条件变为 {@code company_id = NULL}。
|
||||
* </p>
|
||||
*
|
||||
* @param companyId 公司 ID
|
||||
* @param username 用户名
|
||||
* @return 用户实体(含 passwordHash),不存在则返回 null
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
@Select("SELECT * FROM sys_user WHERE company_id = #{companyId} AND username = #{username} AND status = 'ACTIVE'")
|
||||
SysUser selectByCompanyAndUsername(@Param("companyId") Long companyId,
|
||||
@Param("username") String username);
|
||||
}
|
||||
14
src/main/java/com/label/mapper/TaskHistoryMapper.java
Normal file
14
src/main/java/com/label/mapper/TaskHistoryMapper.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.AnnotationTaskHistory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* annotation_task_history 表 Mapper(仅追加,禁止 UPDATE/DELETE)。
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskHistoryMapper extends BaseMapper<AnnotationTaskHistory> {
|
||||
// 继承 BaseMapper 的 insert 用于追加历史记录
|
||||
// 严禁调用 update/delete 相关方法
|
||||
}
|
||||
36
src/main/java/com/label/mapper/TrainingDatasetMapper.java
Normal file
36
src/main/java/com/label/mapper/TrainingDatasetMapper.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.TrainingDataset;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
|
||||
/**
|
||||
* training_dataset 表 Mapper。
|
||||
*/
|
||||
@Mapper
|
||||
public interface TrainingDatasetMapper extends BaseMapper<TrainingDataset> {
|
||||
|
||||
/**
|
||||
* 按任务 ID 将训练样本状态改为 APPROVED。
|
||||
*
|
||||
* @param taskId 任务 ID
|
||||
* @param companyId 当前租户
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE training_dataset SET status = 'APPROVED', updated_at = NOW() " +
|
||||
"WHERE task_id = #{taskId} AND company_id = #{companyId}")
|
||||
int approveByTaskId(@Param("taskId") Long taskId, @Param("companyId") Long companyId);
|
||||
|
||||
/**
|
||||
* 按任务 ID 删除训练样本(驳回时清除候选数据)。
|
||||
*
|
||||
* @param taskId 任务 ID
|
||||
* @param companyId 当前租户
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Delete("DELETE FROM training_dataset WHERE task_id = #{taskId} AND company_id = #{companyId}")
|
||||
int deleteByTaskId(@Param("taskId") Long taskId, @Param("companyId") Long companyId);
|
||||
}
|
||||
12
src/main/java/com/label/mapper/VideoProcessJobMapper.java
Normal file
12
src/main/java/com/label/mapper/VideoProcessJobMapper.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.label.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.label.entity.VideoProcessJob;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* video_process_job 表 Mapper。
|
||||
*/
|
||||
@Mapper
|
||||
public interface VideoProcessJobMapper extends BaseMapper<VideoProcessJob> {
|
||||
}
|
||||
Reference in New Issue
Block a user