fix: 后端代码格式化

This commit is contained in:
Tim
2025-09-18 14:42:25 +08:00
parent 70f7442f0c
commit 72b2b82e02
325 changed files with 15341 additions and 12370 deletions

View File

@@ -4,53 +4,53 @@ import com.openisle.exception.NotFoundException;
import com.openisle.model.*;
import com.openisle.repository.ActivityRepository;
import com.openisle.repository.UserRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class ActivityService {
private final ActivityRepository activityRepository;
private final UserRepository userRepository;
private final LevelService levelService;
private final NotificationService notificationService;
public List<Activity> list() {
return activityRepository.findAll();
}
private final ActivityRepository activityRepository;
private final UserRepository userRepository;
private final LevelService levelService;
private final NotificationService notificationService;
public Activity getByType(ActivityType type) {
Activity a = activityRepository.findByType(type);
if (a == null) throw new NotFoundException("Activity not found");
return a;
}
public List<Activity> list() {
return activityRepository.findAll();
}
public long countLevel1Users() {
int threshold = levelService.nextLevelExp(0);
return userRepository.countByExperienceGreaterThanEqual(threshold);
}
public Activity getByType(ActivityType type) {
Activity a = activityRepository.findByType(type);
if (a == null) throw new NotFoundException("Activity not found");
return a;
}
public void end(Activity activity) {
activity.setEnded(true);
activityRepository.save(activity);
}
public long countLevel1Users() {
int threshold = levelService.nextLevelExp(0);
return userRepository.countByExperienceGreaterThanEqual(threshold);
}
public long countParticipants(Activity activity) {
return activity.getParticipants().size();
}
public void end(Activity activity) {
activity.setEnded(true);
activityRepository.save(activity);
}
/**
* Redeem an activity for the given user.
*
* @return true if the user redeemed for the first time, false if the
* information was simply updated
*/
public boolean redeem(Activity activity, User user, String contact) {
notificationService.createActivityRedeemNotifications(user, contact);
boolean added = activity.getParticipants().add(user);
activityRepository.save(activity);
return added;
}
public long countParticipants(Activity activity) {
return activity.getParticipants().size();
}
/**
* Redeem an activity for the given user.
*
* @return true if the user redeemed for the first time, false if the
* information was simply updated
*/
public boolean redeem(Activity activity, User user, String contact) {
notificationService.createActivityRedeemNotifications(user, contact);
boolean added = activity.getParticipants().add(user);
activityRepository.save(activity);
return added;
}
}