refactor(service): 为服务类添加全局事务管理
- 在 GroupingServiceImpl、ImageServiceImpl、MarkdownFileServiceImpl、RegistrationCodeServiceImpl、SystemSettingServiceImpl、TrashServiceImpl 和 UserServiceImpl 类上添加了 @Transactional 注解- 移除了 GroupingServiceImpl 中的局部 @Transactional 注解 - 此修改确保了每个服务类
This commit is contained in:
@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class GroupingServiceImpl
|
||||
extends ServiceImpl<GroupingMapper, Grouping>
|
||||
implements GroupingService {
|
||||
@@ -52,7 +53,6 @@ public class GroupingServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteGrouping(Long id) {
|
||||
// 1. 使用 LambdaUpdateWrapper 软删除分组本身,确保 isDeleted 和 deletedAt 都被更新
|
||||
LambdaUpdateWrapper<Grouping> groupingUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.test.bijihoudaun.service.ImageService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -23,6 +24,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ImageServiceImpl
|
||||
extends ServiceImpl<ImageMapper, Image>
|
||||
implements ImageService {
|
||||
|
||||
@@ -16,11 +16,13 @@ import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class MarkdownFileServiceImpl
|
||||
extends ServiceImpl<MarkdownFileMapper, MarkdownFile>
|
||||
implements MarkdownFileService {
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class RegistrationCodeServiceImpl extends ServiceImpl<RegistrationCodeMapper, RegistrationCode> implements RegistrationCodeService {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,8 +5,10 @@ import com.test.bijihoudaun.entity.SystemSetting;
|
||||
import com.test.bijihoudaun.mapper.SystemSettingMapper;
|
||||
import com.test.bijihoudaun.service.SystemSettingService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class SystemSettingServiceImpl extends ServiceImpl<SystemSettingMapper, SystemSetting> implements SystemSettingService {
|
||||
|
||||
private static final String REGISTRATION_ENABLED_KEY = "registration.enabled";
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class TrashServiceImpl implements TrashService {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -17,12 +17,14 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService, UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user