设置 事务 rollback 属性
parent
cd854d0ee1
commit
2dd87e0414
|
@ -41,7 +41,7 @@ public class InfJobServiceImpl implements InfJobService {
|
|||
private SchedulerManager schedulerManager;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createJob(InfJobCreateReqVO createReqVO) throws SchedulerException {
|
||||
validateCronExpression(createReqVO.getCronExpression());
|
||||
// 校验唯一性
|
||||
|
@ -66,7 +66,7 @@ public class InfJobServiceImpl implements InfJobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateJob(InfJobUpdateReqVO updateReqVO) throws SchedulerException {
|
||||
validateCronExpression(updateReqVO.getCronExpression());
|
||||
// 校验存在
|
||||
|
@ -86,7 +86,7 @@ public class InfJobServiceImpl implements InfJobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateJobStatus(Long id, Integer status) throws SchedulerException {
|
||||
// 校验 status
|
||||
if (!containsAny(status, InfJobStatusEnum.NORMAL.getStatus(), InfJobStatusEnum.STOP.getStatus())) {
|
||||
|
@ -120,7 +120,7 @@ public class InfJobServiceImpl implements InfJobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteJob(Long id) throws SchedulerException {
|
||||
// 校验存在
|
||||
InfJobDO job = this.validateJobExists(id);
|
||||
|
|
|
@ -88,7 +88,7 @@ public class SysUserProfileController {
|
|||
* @param file 头像文件
|
||||
* @return 上传结果
|
||||
*/
|
||||
@PostMapping("/uploadAvatar")
|
||||
@PostMapping("/upload-avatar")
|
||||
@ApiOperation("上传用户个人头像")
|
||||
public CommonResult<Boolean> uploadAvatar(@RequestParam("avatarFile") MultipartFile file) {
|
||||
if (!file.isEmpty()) {
|
||||
|
|
|
@ -206,7 +206,7 @@ public class SysMenuServiceImpl implements SysMenuService {
|
|||
*
|
||||
* @param menuId 菜单编号
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteMenu(Long menuId) {
|
||||
// 校验更新的菜单是否存在
|
||||
if (menuMapper.selectById(menuId) == null) {
|
||||
|
|
|
@ -176,7 +176,7 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void assignRoleMenu(Long roleId, Set<Long> menuIds) {
|
||||
// 获得角色拥有菜单编号
|
||||
Set<Long> dbMenuIds = CollectionUtils.convertSet(roleMenuMapper.selectListByRoleId(roleId),
|
||||
|
|
|
@ -174,7 +174,7 @@ public class SysRoleServiceImpl implements SysRoleService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteRole(Long id) {
|
||||
// 校验是否可以更新
|
||||
this.checkUpdateRole(id);
|
||||
|
|
|
@ -2,7 +2,7 @@ package cn.iocoder.dashboard.modules.system.service.user;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.dashboard.common.exception.ServiceException;
|
||||
|
@ -68,19 +68,6 @@ public class SysUserServiceImpl implements SysUserService {
|
|||
@Resource
|
||||
private InfFileService fileService;
|
||||
|
||||
// /**
|
||||
// * 根据条件分页查询用户列表
|
||||
// *
|
||||
// * @param user 用户信息
|
||||
// * @return 用户信息集合信息
|
||||
// */
|
||||
// @Override
|
||||
// @DataScope(deptAlias = "d", userAlias = "u")
|
||||
// public List<SysUser> selectUserList(SysUser user)
|
||||
// {
|
||||
// return userMapper.selectUserList(user);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public SysUserDO getUserByUserName(String username) {
|
||||
return userMapper.selectByUsername(username);
|
||||
|
@ -322,7 +309,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||
* @param id 用户 id
|
||||
* @param oldPassword 旧密码
|
||||
* @param newPassword 新密码
|
||||
* @return
|
||||
* @return 校验结果
|
||||
*/
|
||||
private boolean checkOldPassword(Long id, String oldPassword, String newPassword) {
|
||||
if (id == null || StrUtil.isBlank(oldPassword) || StrUtil.isBlank(newPassword)) {
|
||||
|
@ -340,7 +327,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional // 添加事务,异常则回滚所有导入
|
||||
@Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
||||
public SysUserImportRespVO importUsers(List<SysUserImportExcelVO> importUsers, boolean isUpdateSupport) {
|
||||
if (CollUtil.isEmpty(importUsers)) {
|
||||
throw ServiceExceptionUtil.exception(USER_IMPORT_LIST_IS_EMPTY);
|
||||
|
@ -381,8 +368,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||
public int updateAvatar(Long id, InputStream avatarFile) {
|
||||
this.checkUserExists(id);
|
||||
// 存储文件
|
||||
String avatar;
|
||||
avatar = fileService.createFile(UUID.fastUUID().toString(), IoUtil.readBytes(avatarFile));
|
||||
String avatar = fileService.createFile(IdUtil.fastUUID(), IoUtil.readBytes(avatarFile));
|
||||
// 更新路径
|
||||
SysUserDO sysUserDO = new SysUserDO();
|
||||
sysUserDO.setId(id);
|
||||
|
|
|
@ -109,7 +109,7 @@ public class ToolCodegenServiceImpl implements ToolCodegenService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<Long> createCodegenListFromDB(List<String> tableNames) {
|
||||
List<Long> ids = new ArrayList<>(tableNames.size());
|
||||
// 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量
|
||||
|
@ -118,7 +118,7 @@ public class ToolCodegenServiceImpl implements ToolCodegenService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCodegen(ToolCodegenUpdateReqVO updateReqVO) {
|
||||
// 校验是否已经存在
|
||||
if (codegenTableMapper.selectById(updateReqVO.getTable().getId()) == null) {
|
||||
|
@ -134,7 +134,7 @@ public class ToolCodegenServiceImpl implements ToolCodegenService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncCodegenFromDB(Long tableId) {
|
||||
// 校验是否已经存在
|
||||
ToolCodegenTableDO table = codegenTableMapper.selectById(tableId);
|
||||
|
@ -149,7 +149,7 @@ public class ToolCodegenServiceImpl implements ToolCodegenService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncCodegenFromSQL(Long tableId, String sql) {
|
||||
// 校验是否已经存在
|
||||
ToolCodegenTableDO table = codegenTableMapper.selectById(tableId);
|
||||
|
@ -201,7 +201,7 @@ public class ToolCodegenServiceImpl implements ToolCodegenService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteCodegen(Long tableId) {
|
||||
// 校验是否已经存在
|
||||
if (codegenTableMapper.selectById(tableId) == null) {
|
||||
|
|
Loading…
Reference in New Issue