feat: add missing @Transaction to service (#255)
This commit is contained in:
parent
e5dc581e48
commit
4df8f9b93e
|
@ -71,7 +71,6 @@ public class DatabaseTypeService {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void update(DatabaseTypeUpdateRequest request) {
|
||||
databaseTypeUpdateValidator.validRequestRequiredParams(request);
|
||||
databaseTypeDao.selectOptionalById(request.getId()).ifPresent(data -> {
|
||||
|
@ -111,6 +110,7 @@ public class DatabaseTypeService {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteById(Integer id) {
|
||||
databaseTypeDao.selectOptionalById(id).ifPresent(data -> {
|
||||
if (DatabaseTypes.has(data.getDatabaseType())) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -39,6 +40,7 @@ public class DocumentDiscussionService {
|
|||
|
||||
private final EventPublisher eventPublisher;
|
||||
|
||||
@Transactional
|
||||
public void deleteById(Integer groupId,
|
||||
Integer projectId,
|
||||
Integer discussionId) {
|
||||
|
@ -73,6 +75,7 @@ public class DocumentDiscussionService {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void create(Integer groupId, Integer projectId, Integer userId, DiscussionCreateRequest request) {
|
||||
if (projectDao.exists(groupId, projectId)) {
|
||||
DocumentDiscussion pojo = new DocumentDiscussion();
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.databasir.dao.tables.pojos.DocumentTemplateProperty;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -40,6 +41,7 @@ public class DocumentTemplateService {
|
|||
.build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateByType(DocumentTemplatePropertiesUpdateRequest request) {
|
||||
List<DocumentTemplateProperty> pojoList = documentTemplatePropertiesUpdateRequestConverter.toPojo(request);
|
||||
documentTemplatePropertyDao.batchInsertOnDuplicateKeyUpdateValue(pojoList);
|
||||
|
|
|
@ -84,6 +84,7 @@ public class GroupService {
|
|||
eventPublisher.publish(new GroupUpdated(request.getId(), request.getName(), request.getDescription()));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void delete(Integer groupId) {
|
||||
groupDao.deleteById(groupId);
|
||||
userRoleDao.deleteByGroupId(groupId);
|
||||
|
@ -130,10 +131,12 @@ public class GroupService {
|
|||
return groupResponseConverter.toResponse(group, users);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void removeMember(Integer groupId, Integer userId) {
|
||||
userRoleDao.deleteByUserIdAndGroupId(userId, groupId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addMember(Integer groupId, GroupMemberCreateRequest request) {
|
||||
if (userRoleDao.hasRole(request.getUserId(), groupId)) {
|
||||
throw DomainErrors.USER_ROLE_DUPLICATE.exception();
|
||||
|
@ -145,6 +148,7 @@ public class GroupService {
|
|||
userRoleDao.insertAndReturnId(pojo);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void changeMemberRole(Integer groupId, Integer userId, String role) {
|
||||
if (!userRoleDao.hasRole(userId, groupId, role)) {
|
||||
// TODO 最多 20 个组长
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.databasir.dao.tables.pojos.UserRole;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -38,6 +39,8 @@ public class LoginService {
|
|||
|
||||
private final JwtTokens jwtTokens;
|
||||
|
||||
@Transactional
|
||||
|
||||
public AccessTokenRefreshResponse refreshAccessTokens(AccessTokenRefreshRequest request) {
|
||||
Login login = loginDao.selectByRefreshToken(request.getRefreshToken())
|
||||
.orElseThrow(DomainErrors.INVALID_REFRESH_TOKEN_OPERATION::exception);
|
||||
|
@ -71,6 +74,8 @@ public class LoginService {
|
|||
return new AccessTokenRefreshResponse(accessToken, accessTokenExpireAtMilli);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
public LoginKeyResponse generate(Integer userId) {
|
||||
User user = userDao.selectById(userId);
|
||||
String accessToken = jwtTokens.accessToken(user.getEmail());
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.databasir.dao.tables.pojos.TableColumnDocument;
|
|||
import com.databasir.dao.tables.pojos.TableDocument;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
@ -41,6 +42,8 @@ public class MockDataService {
|
|||
|
||||
private final MockDataValidator mockDataValidator;
|
||||
|
||||
@Transactional
|
||||
|
||||
public String generateMockInsertSql(Integer projectId, MockDataGenerateCondition condition) {
|
||||
mockDataValidator.validProject(projectId);
|
||||
DatabaseDocument databaseDoc =
|
||||
|
@ -50,6 +53,8 @@ public class MockDataService {
|
|||
return mockDataGenerator.createInsertSql(projectId, databaseDoc.getId(), tableDoc.getName());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
public void saveMockRules(Integer projectId,
|
||||
Integer tableId,
|
||||
List<ColumnMockRuleSaveRequest> rules) {
|
||||
|
|
|
@ -236,6 +236,8 @@ public class ProjectService {
|
|||
return projectSimpleTaskResponseConverter.of(tasks);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
public void cancelTask(Integer projectId, Integer taskId) {
|
||||
if (!projectDao.existsById(projectId)) {
|
||||
throw DomainErrors.PROJECT_NOT_FOUND.exception();
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.databasir.dao.impl.SysMailDao;
|
|||
import com.databasir.dao.tables.pojos.SysMail;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -40,6 +41,8 @@ public class SystemService {
|
|||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
public void updateEmailSetting(SystemEmailUpdateRequest request) {
|
||||
SysMail sysMail = new SysMail();
|
||||
sysMail.setSmtpHost(request.getSmtpHost());
|
||||
|
|
|
@ -76,6 +76,8 @@ public class UserProjectService {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
public void removeFavorites(Integer projectId, Integer userId) {
|
||||
if (userFavoriteProjectDao.exists(userId, projectId)) {
|
||||
userFavoriteProjectDao.delete(userId, projectId);
|
||||
|
|
|
@ -143,12 +143,15 @@ public class UserService {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void removeSysOwnerFrom(Integer userId) {
|
||||
if (userRoleDao.hasRole(userId, SYS_OWNER)) {
|
||||
userRoleDao.deleteRole(userId, SYS_OWNER);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
public void addSysOwnerTo(Integer userId) {
|
||||
if (!userRoleDao.hasRole(userId, SYS_OWNER)) {
|
||||
UserRole role = new UserRole();
|
||||
|
@ -158,6 +161,7 @@ public class UserService {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updatePassword(Integer userId, UserPasswordUpdateRequest request) {
|
||||
if (!Objects.equals(request.getNewPassword(), request.getConfirmNewPassword())) {
|
||||
throw DomainErrors.UPDATE_PASSWORD_CONFIRM_FAILED.exception();
|
||||
|
@ -171,6 +175,7 @@ public class UserService {
|
|||
loginDao.deleteByUserId(userId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateNickname(Integer userId, UserNicknameUpdateRequest request) {
|
||||
User user = userDao.selectById(userId);
|
||||
user.setNickname(request.getNickname());
|
||||
|
|
Loading…
Reference in New Issue