日常任务改版1

This commit is contained in:
2025-08-26 10:59:02 +08:00
parent a565d0803d
commit fd62c2a88d
2 changed files with 11 additions and 9 deletions

View File

@@ -1,7 +1,6 @@
package com.accompany.business.service.dailytask;
import com.accompany.business.service.dailytask.annotation.DailyTaskHandlerType;
import com.accompany.business.constant.dailytask.DailyTaskTypeEnum;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@@ -11,18 +10,18 @@ import java.util.Map;
@Component
public class DailyTaskHandlerRegistry {
private final Map<DailyTaskTypeEnum, DailyTaskHandler> handlerMap = new HashMap<>();
private final Map<String, DailyTaskHandler> handlerMap = new HashMap<>();
public DailyTaskHandlerRegistry(List<DailyTaskHandler> handlers) {
for (DailyTaskHandler handler : handlers) {
DailyTaskHandlerType annotation = handler.getClass().getAnnotation(DailyTaskHandlerType.class);
if (annotation != null) {
handlerMap.put(annotation.value(), handler);
handlerMap.put(annotation.value().getHandlerType(), handler);
}
}
}
public DailyTaskHandler getHandler(DailyTaskTypeEnum taskType) {
return handlerMap.get(taskType);
public DailyTaskHandler getHandler(String handlerType) {
return handlerMap.get(handlerType);
}
}

View File

@@ -18,6 +18,7 @@ import com.accompany.common.result.BusiResult;
import com.accompany.common.status.BusiStatus;
import com.accompany.common.utils.StringUtils;
import com.accompany.core.exception.ServiceException;
import com.accompany.core.model.Users;
import com.accompany.payment.service.RechargeUserService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
@@ -57,7 +58,7 @@ public class DailyTaskService {
private UsersService usersService;
public DailyTaskVo executeDailyTask(DailyTaskVo dailyTaskVo, Long uid, Integer partitionId) {
DailyTaskHandler handler = taskHandlerRegistry.getHandler(dailyTaskVo.getTaskType());
DailyTaskHandler handler = taskHandlerRegistry.getHandler(dailyTaskVo.getTaskType().getHandlerType());
DailyTaskContext dailyTaskContext = new DailyTaskContext(uid, dailyTaskVo, partitionId);
return handler.handle(dailyTaskContext);
}
@@ -69,7 +70,7 @@ public class DailyTaskService {
* @param dailyProgressContext
*/
public void executeProgress(DailyTaskTypeEnum taskType, DailyProgressContext dailyProgressContext) {
DailyTaskHandler handler = taskHandlerRegistry.getHandler(taskType);
DailyTaskHandler handler = taskHandlerRegistry.getHandler(taskType.getHandlerType());
handler.executeProgress(dailyProgressContext);
}
@@ -83,7 +84,7 @@ public class DailyTaskService {
public BusiResult executeReceive(Integer taskConfigId, Long uid, String todayDate) {
DailyTaskVo dailyTaskVo = this.taskVo(taskConfigId, uid);
DailyTaskTypeEnum taskType = dailyTaskVo.getTaskType();
DailyTaskHandler handler = taskHandlerRegistry.getHandler(taskType);
DailyTaskHandler handler = taskHandlerRegistry.getHandler(taskType.getHandlerType());
if (handler == null || StringUtils.isEmpty(todayDate) || uid == null) {
throw new ServiceException(BusiStatus.PARAMERROR);
}
@@ -107,7 +108,9 @@ public class DailyTaskService {
taskRole.add(GuildConstant.RoleType.MANAGER);
}
});
Integer partitionId = guildMember.getPartitionId();
Users users = usersService.getUsersByUid(uid);
Integer partitionId = users.getPartitionId();
List<DailyTaskVo> dailyTaskVos = this.taskVoList(partitionId, taskTabType, taskRole, uid);
if (CollectionUtils.isEmpty(dailyTaskVos)) {