style: 移除部分方法中仅有单个非读操作的事务处理
This commit is contained in:
parent
55effa3658
commit
b85d69298d
@ -62,7 +62,6 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptRes
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Long add(DeptReq req) {
|
public Long add(DeptReq req) {
|
||||||
String name = req.getName();
|
String name = req.getName();
|
||||||
boolean isExists = this.isNameExists(name, req.getParentId(), null);
|
boolean isExists = this.isNameExists(name, req.getParentId(), null);
|
||||||
|
@ -23,7 +23,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import top.charles7c.continew.admin.common.constant.CacheConstants;
|
import top.charles7c.continew.admin.common.constant.CacheConstants;
|
||||||
import top.charles7c.continew.admin.common.model.resp.LabelValueResp;
|
import top.charles7c.continew.admin.common.model.resp.LabelValueResp;
|
||||||
@ -53,7 +52,6 @@ public class DictItemServiceImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(allEntries = true)
|
@CacheEvict(allEntries = true)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Long add(DictItemReq req) {
|
public Long add(DictItemReq req) {
|
||||||
String value = req.getValue();
|
String value = req.getValue();
|
||||||
CheckUtils.throwIf(this.isValueExists(value, null, req.getDictId()), "新增失败,字典值 [{}] 已存在", value);
|
CheckUtils.throwIf(this.isValueExists(value, null, req.getDictId()), "新增失败,字典值 [{}] 已存在", value);
|
||||||
@ -62,7 +60,6 @@ public class DictItemServiceImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(allEntries = true)
|
@CacheEvict(allEntries = true)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void update(DictItemReq req, Long id) {
|
public void update(DictItemReq req, Long id) {
|
||||||
String value = req.getValue();
|
String value = req.getValue();
|
||||||
CheckUtils.throwIf(this.isValueExists(value, id, req.getDictId()), "修改失败,字典值 [{}] 已存在", value);
|
CheckUtils.throwIf(this.isValueExists(value, id, req.getDictId()), "修改失败,字典值 [{}] 已存在", value);
|
||||||
|
@ -55,7 +55,6 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictRes
|
|||||||
private final DictItemService dictItemService;
|
private final DictItemService dictItemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Long add(DictReq req) {
|
public Long add(DictReq req) {
|
||||||
String name = req.getName();
|
String name = req.getName();
|
||||||
CheckUtils.throwIf(this.isNameExists(name, null), "新增失败,[{}] 已存在", name);
|
CheckUtils.throwIf(this.isNameExists(name, null), "新增失败,[{}] 已存在", name);
|
||||||
@ -65,7 +64,6 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void update(DictReq req, Long id) {
|
public void update(DictReq req, Long id) {
|
||||||
String name = req.getName();
|
String name = req.getName();
|
||||||
CheckUtils.throwIf(this.isNameExists(name, id), "修改失败,[{}] 已存在", name);
|
CheckUtils.throwIf(this.isNameExists(name, id), "修改失败,[{}] 已存在", name);
|
||||||
|
@ -53,7 +53,6 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuRes
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(allEntries = true)
|
@CacheEvict(allEntries = true)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Long add(MenuReq req) {
|
public Long add(MenuReq req) {
|
||||||
String title = req.getTitle();
|
String title = req.getTitle();
|
||||||
CheckUtils.throwIf(this.isNameExists(title, req.getParentId(), null), "新增失败,[{}] 已存在", title);
|
CheckUtils.throwIf(this.isNameExists(title, req.getParentId(), null), "新增失败,[{}] 已存在", title);
|
||||||
@ -63,7 +62,6 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuRes
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(allEntries = true)
|
@CacheEvict(allEntries = true)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void update(MenuReq req, Long id) {
|
public void update(MenuReq req, Long id) {
|
||||||
String title = req.getTitle();
|
String title = req.getTitle();
|
||||||
CheckUtils.throwIf(this.isNameExists(title, req.getParentId(), id), "修改失败,[{}] 已存在", title);
|
CheckUtils.throwIf(this.isNameExists(title, req.getParentId(), id), "修改失败,[{}] 已存在", title);
|
||||||
|
@ -189,7 +189,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateBasicInfo(UserBasicInfoUpdateReq updateReq, Long id) {
|
public void updateBasicInfo(UserBasicInfoUpdateReq updateReq, Long id) {
|
||||||
super.getById(id);
|
super.getById(id);
|
||||||
baseMapper.lambdaUpdate().set(UserDO::getNickname, updateReq.getNickname())
|
baseMapper.lambdaUpdate().set(UserDO::getNickname, updateReq.getNickname())
|
||||||
@ -197,7 +196,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updatePassword(String oldPassword, String newPassword, Long id) {
|
public void updatePassword(String oldPassword, String newPassword, Long id) {
|
||||||
CheckUtils.throwIfEqual(newPassword, oldPassword, "新密码不能与当前密码相同");
|
CheckUtils.throwIfEqual(newPassword, oldPassword, "新密码不能与当前密码相同");
|
||||||
UserDO user = super.getById(id);
|
UserDO user = super.getById(id);
|
||||||
@ -223,7 +221,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateEmail(String newEmail, String currentPassword, Long id) {
|
public void updateEmail(String newEmail, String currentPassword, Long id) {
|
||||||
UserDO user = super.getById(id);
|
UserDO user = super.getById(id);
|
||||||
CheckUtils.throwIfNotEqual(SecureUtils.md5Salt(currentPassword, id.toString()), user.getPassword(), "当前密码错误");
|
CheckUtils.throwIfNotEqual(SecureUtils.md5Salt(currentPassword, id.toString()), user.getPassword(), "当前密码错误");
|
||||||
@ -235,7 +232,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void resetPassword(Long id) {
|
public void resetPassword(Long id) {
|
||||||
UserDO user = super.getById(id);
|
UserDO user = super.getById(id);
|
||||||
user.setPassword(SecureUtils.md5Salt(SysConstants.DEFAULT_PASSWORD, id.toString()));
|
user.setPassword(SecureUtils.md5Salt(SysConstants.DEFAULT_PASSWORD, id.toString()));
|
||||||
|
@ -24,7 +24,6 @@ import java.util.stream.Collectors;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
|
||||||
@ -54,7 +53,6 @@ public class UserSocialServiceImpl implements UserSocialService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void saveOrUpdate(UserSocialDO userSocial) {
|
public void saveOrUpdate(UserSocialDO userSocial) {
|
||||||
if (null == userSocial.getCreateTime()) {
|
if (null == userSocial.getCreateTime()) {
|
||||||
baseMapper.insert(userSocial);
|
baseMapper.insert(userSocial);
|
||||||
|
Loading…
Reference in New Issue
Block a user