chore: 清理冗余注释,保留字段/业务含义注释
This commit is contained in:
@@ -15,41 +15,33 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler({ErrorParameterException.class})
|
||||
public CommonResult errorParameterException(ErrorParameterException ex) {
|
||||
//code:400
|
||||
return CommonResult.error(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler({NotFindEntitiesException.class})
|
||||
public CommonResult notFindEntitiesException(NotFindEntitiesException ex) {
|
||||
//code:400
|
||||
return CommonResult.error(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler({AppException.class})
|
||||
public CommonResult AppException(AppException ex) {
|
||||
//code:500
|
||||
return CommonResult.serverError(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public CommonResult MyMethodArgumentNotValidException(MethodArgumentNotValidException ex) {
|
||||
BindingResult bindingResult = ex.getBindingResult();
|
||||
//code:400
|
||||
return CommonResult.error(bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(NotLoginException.class)
|
||||
public CommonResult handleNotLogin(NotLoginException e, HttpServletRequest req, HttpServletResponse res) {
|
||||
//code:401
|
||||
res.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
return new CommonResult<>(HttpStatus.UNAUTHORIZED.value(), "未登录,请重新登录", null);
|
||||
}
|
||||
@@ -57,8 +49,7 @@ public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(Exception.class)
|
||||
public CommonResult Exception(Exception ex) {
|
||||
log.error("系统异常", ex);
|
||||
//code:400
|
||||
return CommonResult.error(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@ import jakarta.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 全局数据验证分组
|
||||
* GlobalValidationGroup -> OpenGroups ->ops
|
||||
* @author guo
|
||||
*/
|
||||
public interface Ops {
|
||||
// 创建组
|
||||
interface CreateG extends Default {}
|
||||
interface CreateG extends Default {
|
||||
}
|
||||
|
||||
// 更新组
|
||||
interface UpdateG {}
|
||||
interface UpdateG {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,21 +10,16 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
*/
|
||||
@Configuration
|
||||
public class JacksonConfig {
|
||||
@Bean
|
||||
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||
ObjectMapper mapper = builder.build();
|
||||
|
||||
// 注册自定义序列化器
|
||||
SimpleModule module = new SimpleModule();
|
||||
module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer());
|
||||
mapper.registerModule(module);
|
||||
|
||||
// 关闭序列化为时间戳(使用字符串格式)
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
|
||||
return mapper;
|
||||
|
||||
@@ -13,9 +13,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Profile("dev")
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@@ -24,11 +21,9 @@ public class WebMvcDevConfig implements WebMvcConfigurer {
|
||||
|
||||
private final CorsProperties corsProperties;
|
||||
|
||||
// 注册拦截器
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new SaInterceptor(handle -> {
|
||||
// OPTIONS 请求直接放行
|
||||
if ("OPTIONS".equalsIgnoreCase(SaHolder.getRequest().getMethod())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,8 @@ public class WebMvcProdConfig implements WebMvcConfigurer {
|
||||
.allowCredentials(true);
|
||||
}
|
||||
|
||||
// 注册拦截器
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验。
|
||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns("/login");
|
||||
|
||||
-3
@@ -9,8 +9,6 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class LocalDateTimeSerializer extends StdSerializer<LocalDateTime> {
|
||||
|
||||
// 修改为ISO 8601格式,末尾带Z,表示UTC时区
|
||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
|
||||
public LocalDateTimeSerializer() {
|
||||
@@ -22,7 +20,6 @@ public class LocalDateTimeSerializer extends StdSerializer<LocalDateTime> {
|
||||
if (value == null) {
|
||||
gen.writeNull();
|
||||
} else {
|
||||
// 这里假设LocalDateTime是UTC时间,直接格式化并加Z
|
||||
String formattedDate = value.format(formatter);
|
||||
gen.writeString(formattedDate);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -2,9 +2,6 @@ package com.guo.learningprogresstracker.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
*/
|
||||
@Data
|
||||
public class TaskInfo {
|
||||
|
||||
|
||||
@@ -123,7 +123,6 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
||||
public void pausedStudySession(LocalDateTime endTime){
|
||||
if (this.getSessionState().equals(StudySessionStateEnum.PAUSED.name())) {
|
||||
log.warn("不应出现的情况:暂停了一个状态为【{}】的学习会话({})", this.getSessionState(), this.getSessionNum());
|
||||
//
|
||||
} else {
|
||||
this.setEndTime(ObjectUtils.isEmpty(endTime) ? LocalDateTime.now() : endTime);
|
||||
this.setActualTime(Duration.between(this.startTime, this.endTime).toSeconds());
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 复习模块 Service 实现(纯 MyBatis-Plus Java API)
|
||||
* 复习模块 Service 实现
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -33,7 +33,6 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
|
||||
@Override
|
||||
public List<ReviewFeedItem> getReviewFeed(int limit) {
|
||||
// created_by 条件由 TenantLineInnerInterceptor 自动注入
|
||||
List<StudyReportsEntity> reports = studyReportsMapper.selectList(
|
||||
Wrappers.<StudyReportsEntity>lambdaQuery()
|
||||
.orderByDesc(StudyReportsEntity::getCreatedTime)
|
||||
@@ -49,7 +48,6 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
|
||||
@Override
|
||||
public List<ReviewFeedItem> getTaskReview(String taskNum) {
|
||||
// 先查该任务下的所有 sessionNum
|
||||
List<String> sessionNums = studySessionsMapper.selectList(
|
||||
Wrappers.<StudySessionsEntity>lambdaQuery()
|
||||
.eq(StudySessionsEntity::getTaskNum, taskNum)
|
||||
@@ -77,14 +75,12 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
|
||||
@Override
|
||||
public StudyReportsEntity getReportDetail(int id) throws NotFindEntitiesException {
|
||||
// 拦截器自动校验归属
|
||||
return Optional.ofNullable(studyReportsMapper.selectById(id))
|
||||
.orElseThrow(() -> new NotFindEntitiesException("学习报告[" + id + "]不存在"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StudyReportFragmentsEntity getFragmentDetail(int id) throws NotFindEntitiesException {
|
||||
// 拦截器自动校验归属
|
||||
return Optional.ofNullable(studyReportFragmentsMapper.selectById(id))
|
||||
.orElseThrow(() -> new NotFindEntitiesException("学习残片[" + id + "]不存在"));
|
||||
}
|
||||
@@ -94,7 +90,6 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
*/
|
||||
private List<ReviewFeedItem> mergeAndConvert(List<StudyReportsEntity> reports,
|
||||
List<StudyReportFragmentsEntity> fragments) {
|
||||
// 收集所有 sessionNum,批量查询 session 和 task
|
||||
Set<String> allSessionNums = Stream.concat(
|
||||
reports.stream().map(StudyReportsEntity::getSessionNum),
|
||||
fragments.stream().map(StudyReportFragmentsEntity::getSessionNum)
|
||||
@@ -104,7 +99,6 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 批量查询 sessions,构建 sessionNum -> taskNum 映射
|
||||
Map<String, String> sessionToTaskMap = studySessionsMapper.selectList(
|
||||
Wrappers.<StudySessionsEntity>lambdaQuery()
|
||||
.in(StudySessionsEntity::getSessionNum, allSessionNums)
|
||||
@@ -115,7 +109,6 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
StudySessionsEntity::getTaskNum,
|
||||
(a, b) -> a));
|
||||
|
||||
// 批量查询 tasks,构建 taskNum -> taskName 映射
|
||||
Set<String> taskNums = new HashSet<>(sessionToTaskMap.values());
|
||||
Map<String, String> taskNameMap = tasksMapper.selectList(
|
||||
Wrappers.<TaskEntity>lambdaQuery()
|
||||
@@ -127,7 +120,6 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
TaskEntity::getTaskName,
|
||||
(a, b) -> a));
|
||||
|
||||
// 转换报告
|
||||
List<ReviewFeedItem> reportItems = reports.stream().map(r -> {
|
||||
ReviewFeedItem item = new ReviewFeedItem();
|
||||
item.setId(r.getId());
|
||||
@@ -141,7 +133,6 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
return item;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 转换残片
|
||||
List<ReviewFeedItem> fragmentItems = fragments.stream().map(f -> {
|
||||
ReviewFeedItem item = new ReviewFeedItem();
|
||||
item.setId(f.getId());
|
||||
@@ -155,7 +146,6 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
return item;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 合并并按创建时间倒序
|
||||
return Stream.concat(reportItems.stream(), fragmentItems.stream())
|
||||
.sorted(Comparator.comparing(ReviewFeedItem::getCreatedTime,
|
||||
Comparator.nullsLast(Comparator.reverseOrder())))
|
||||
|
||||
+2
-6
@@ -14,10 +14,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
* @description 针对表【study_report_fragments(记录学习过程中的学习内容报告残片)】的数据库操作Service实现
|
||||
* @createDate 2024-06-09 15:28:48
|
||||
*/
|
||||
* 针对表【study_report_fragments(记录学习过程中的学习内容报告残片)】的数据库操作Service实现
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StudyReportFragmentsServiceImpl extends ServiceImpl<StudyReportFragmentsMapper, StudyReportFragmentsEntity>
|
||||
@@ -28,14 +26,12 @@ public class StudyReportFragmentsServiceImpl extends ServiceImpl<StudyReportFrag
|
||||
@Override
|
||||
public void createFragments(CreateFragmentsRequest request) throws NotFindEntitiesException {
|
||||
StudyReportFragmentsEntity entity = FragmentsConvert.MAPPER.toFragmentsEntity(request);
|
||||
// 拦截器自动注入 created_by 条件,会话归属校验已内置
|
||||
StudySessionsEntity session = studySessionsMapper.selectOne(
|
||||
Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, entity.getSessionNum()));
|
||||
if (session == null) {
|
||||
throw new NotFindEntitiesException(String.format("未能找到学习会话sessionNum[%s]", entity.getSessionNum()));
|
||||
}
|
||||
// created_by 由 MetaObjectHandler 在 insert 时自动填充
|
||||
this.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-11
@@ -27,9 +27,7 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
* @description 针对表【study_sessions(记录每次学习会话的具体数据)】的数据库操作Service实现
|
||||
* @createDate 2024-06-09 15:28:48
|
||||
* 针对表【study_sessions(记录每次学习会话的具体数据)】的数据库操作Service实现
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -45,7 +43,6 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
private final StudyReportsMapper studyReportsMapper;
|
||||
|
||||
public StudySessionResponse startOrContinueStudySession(String taskNum) throws NotFindEntitiesException, ServiceException {
|
||||
// 拦截器已自动注入 created_by 条件,只有当前用户的 task 才能查到
|
||||
TaskEntity taskEntity = tasksServiceImpl.getOneOpt(
|
||||
Wrappers.lambdaQuery(TaskEntity.class).eq(TaskEntity::getTaskNum, taskNum))
|
||||
.orElseThrow(() -> new NotFindEntitiesException(String.format("[%s]不存在", taskNum)));
|
||||
@@ -82,7 +79,6 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
|
||||
@Override
|
||||
public void pauseStudySession(String sessionNum, LocalDateTime endTime) throws ErrorParameterException, ServiceException {
|
||||
// 拦截器自动校验归属,查不到即说明无权访问
|
||||
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在"));
|
||||
@@ -98,13 +94,11 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
|
||||
@Override
|
||||
public void endedStudySession(String sessionNum, String content) throws ErrorParameterException {
|
||||
// 拦截器自动校验归属
|
||||
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在"));
|
||||
studySessionsEntity.endedStudySession();
|
||||
this.updateById(studySessionsEntity);
|
||||
// 创建学习报告(created_by 由 MetaObjectHandler 自动填充)
|
||||
StudyReportsEntity studyReportsEntity = new StudyReportsEntity();
|
||||
studyReportsEntity.setSessionNum(sessionNum);
|
||||
studyReportsEntity.setContent(content);
|
||||
@@ -113,7 +107,6 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
|
||||
@Override
|
||||
public StudySessionResponse getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException {
|
||||
// 拦截器自动注入 created_by,task 归属校验已内置
|
||||
TaskEntity task = tasksServiceImpl.getOneOpt(Wrappers.lambdaQuery(TaskEntity.class)
|
||||
.eq(TaskEntity::getTaskNum, taskNum))
|
||||
.orElseThrow(() -> new ErrorParameterException("任务[" + taskNum + "]不存在"));
|
||||
@@ -124,7 +117,6 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getAllFragments(String sessionNum) throws ErrorParameterException {
|
||||
// 拦截器自动校验归属
|
||||
if (this.exists(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))) {
|
||||
return studyReportFragmentsMapper.selectList(Wrappers.lambdaQuery(StudyReportFragmentsEntity.class)
|
||||
@@ -137,7 +129,6 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
|
||||
@Override
|
||||
public void continueStudySession(String sessionNum) throws ErrorParameterException, ServiceException {
|
||||
// 拦截器自动校验归属
|
||||
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在"));
|
||||
@@ -153,7 +144,7 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 sessionNum 获取学习会话(归属由拦截器自动校验)
|
||||
* 通过 sessionNum 获取学习会话
|
||||
*/
|
||||
public StudySessionResponse getStudySessionBySessionNum(String sessionNum) throws ErrorParameterException {
|
||||
StudySessionsEntity session = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
|
||||
@@ -20,10 +20,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
* @description 针对表【tasks(存储学习任务的基本信息,包括优先级的多维度计算)】的数据库操作Service实现
|
||||
* @createDate 2024-06-09 15:28:48
|
||||
*/
|
||||
* 针对表【tasks(存储学习任务的基本信息,包括优先级的多维度计算)】的数据库操作Service实现
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@@ -34,7 +32,6 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
|
||||
@Override
|
||||
public Page<TaskInfo> taskList(Integer pageNum, Integer pageSize) {
|
||||
// 拦截器自动注入 created_by 条件,只返回当前用户的任务
|
||||
Page<TaskEntity> page = tasksMapper.selectPage(new Page<TaskEntity>(pageNum, pageSize),
|
||||
Wrappers.lambdaQuery(TaskEntity.class)
|
||||
.orderByDesc(TaskEntity::getCalculatedPriority));
|
||||
@@ -46,7 +43,6 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
public String addTask(TaskRequest taskRequest) throws ErrorParameterException {
|
||||
TaskEntity task = TaskConvert.MAPPER.taskRequestToTaskEntity(taskRequest);
|
||||
|
||||
// 拦截器自动注入 created_by,重复校验仅限当前用户
|
||||
if (this.exists(Wrappers.lambdaQuery(TaskEntity.class)
|
||||
.eq(TaskEntity::getTaskName, task.getTaskName()))) {
|
||||
throw new ErrorParameterException(String.format("任务名[%s]重复", task.getTaskName()));
|
||||
@@ -61,14 +57,12 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
|
||||
@Override
|
||||
public TaskInfoResponse getTask(String taskId) {
|
||||
// 拦截器自动校验归属,查到的一定是当前用户的任务
|
||||
TaskEntity taskEntity = this.getById(taskId);
|
||||
return TaskConvert.MAPPER.taskEntityToTaskInfoResponse(taskEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask(String taskId, TaskRequest updatedTask) {
|
||||
// getById 已被拦截器保护,其他用户的任务查不到
|
||||
TaskEntity existingTask = this.getById(taskId);
|
||||
if (existingTask == null) {
|
||||
throw new IllegalArgumentException("任务不存在: " + taskId);
|
||||
@@ -86,7 +80,6 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
|
||||
@Override
|
||||
public void deleteTask(String taskId) {
|
||||
// getById 已被拦截器保护,其他用户的任务查不到
|
||||
TaskEntity existingTask = this.getById(taskId);
|
||||
if (existingTask == null) {
|
||||
throw new IllegalArgumentException("任务不存在: " + taskId);
|
||||
|
||||
@@ -4,8 +4,6 @@ import com.guo.learningprogresstracker.dto.PriorityDto;
|
||||
|
||||
/**
|
||||
* 加权优先级计算工具
|
||||
*
|
||||
* @author guo
|
||||
*/
|
||||
public class CalculatedPriorityTool {
|
||||
|
||||
|
||||
@@ -7,16 +7,11 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用于生成编码的工具
|
||||
*
|
||||
* @author guo
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class GenerateNumTool {
|
||||
private static int getNextSequence() {
|
||||
// 获取当前时间的毫秒级时间戳
|
||||
long timestamp = System.currentTimeMillis();
|
||||
|
||||
// 使用时间戳的最后6位作为序列号
|
||||
return (int) (timestamp % 1_000_000);
|
||||
}
|
||||
|
||||
@@ -29,22 +24,14 @@ public class GenerateNumTool {
|
||||
*/
|
||||
public static String generateNum(String prefix, String separator) {
|
||||
String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
|
||||
// 唯一的后缀
|
||||
int sequence = getNextSequence();
|
||||
|
||||
// 返回完整的 taskNum
|
||||
return prefix + separator + currentDate + separator + sequence;
|
||||
}
|
||||
|
||||
public static String generateNum(String prefix) {
|
||||
String separator = "-";
|
||||
String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
|
||||
// 唯一的后缀
|
||||
int sequence = getNextSequence();
|
||||
|
||||
// 返回完整的 taskNum
|
||||
return prefix + separator + currentDate + separator + sequence;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user