事务由Controller迁移到Service

dep_wangsr
RuoYi 6 years ago committed by Limy
parent 64f20dbc6e
commit 3a029dbabc

@ -4,7 +4,6 @@ import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -78,7 +77,6 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:add")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult addSave(SysRole role)
{
@ -104,7 +102,6 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult editSave(SysRole role)
{
@ -129,7 +126,6 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/rule")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult ruleSave(SysRole role)
{

@ -4,7 +4,6 @@ import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -116,7 +115,6 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:add")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult addSave(SysUser user)
{
@ -148,7 +146,6 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult editSave(SysUser user)
{

@ -6,6 +6,7 @@ import org.quartz.CronTrigger;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.constant.ScheduleConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.quartz.domain.SysJob;
@ -80,6 +81,7 @@ public class SysJobServiceImpl implements ISysJobService
* @param job
*/
@Override
@Transactional
public int pauseJob(SysJob job)
{
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
@ -97,6 +99,7 @@ public class SysJobServiceImpl implements ISysJobService
* @param job
*/
@Override
@Transactional
public int resumeJob(SysJob job)
{
job.setStatus(ScheduleConstants.Status.NORMAL.getValue());
@ -114,6 +117,7 @@ public class SysJobServiceImpl implements ISysJobService
* @param job
*/
@Override
@Transactional
public int deleteJob(SysJob job)
{
int rows = jobMapper.deleteJobById(job.getJobId());
@ -131,6 +135,7 @@ public class SysJobServiceImpl implements ISysJobService
* @return
*/
@Override
@Transactional
public void deleteJobByIds(String ids)
{
Long[] jobIds = Convert.toLongArray(ids);
@ -147,6 +152,7 @@ public class SysJobServiceImpl implements ISysJobService
* @param job
*/
@Override
@Transactional
public int changeStatus(SysJob job)
{
int rows = 0;
@ -168,6 +174,7 @@ public class SysJobServiceImpl implements ISysJobService
* @param job
*/
@Override
@Transactional
public int run(SysJob job)
{
return ScheduleUtils.run(scheduler, selectJobById(job.getJobId()));
@ -179,6 +186,7 @@ public class SysJobServiceImpl implements ISysJobService
* @param job
*/
@Override
@Transactional
public int insertJobCron(SysJob job)
{
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
@ -196,6 +204,7 @@ public class SysJobServiceImpl implements ISysJobService
* @param job
*/
@Override
@Transactional
public int updateJobCron(SysJob job)
{
int rows = jobMapper.updateJob(job);

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.Ztree;
@ -184,6 +185,7 @@ public class SysDeptServiceImpl implements ISysDeptService
* @return
*/
@Override
@Transactional
public int updateDept(SysDept dept)
{
SysDept info = deptMapper.selectDeptById(dept.getParentId());

@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException;
@ -114,6 +115,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
* @return
*/
@Override
@Transactional
public int updateDictType(SysDictType dictType)
{
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId());

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert;
@ -163,6 +164,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @return
*/
@Override
@Transactional
public int insertRole(SysRole role)
{
// 新增角色信息
@ -177,6 +179,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @return
*/
@Override
@Transactional
public int updateRole(SysRole role)
{
// 修改角色信息
@ -193,6 +196,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @return
*/
@Override
@Transactional
public int updateRule(SysRole role)
{
// 修改角色信息

@ -6,6 +6,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert;
@ -158,6 +159,7 @@ public class SysUserServiceImpl implements ISysUserService
* @return
*/
@Override
@Transactional
public int insertUser(SysUser user)
{
// 新增用户信息
@ -176,6 +178,7 @@ public class SysUserServiceImpl implements ISysUserService
* @return
*/
@Override
@Transactional
public int updateUser(SysUser user)
{
Long userId = user.getUserId();

Loading…
Cancel
Save