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