|
@@ -10,6 +10,9 @@ import com.boman.web.core.api.RemoteObjService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
@@ -41,6 +44,7 @@ public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
|
|
|
* @return int
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
|
|
|
public int saveList(List<RoleMenuDto> dtos) {
|
|
|
int effective = 0;
|
|
|
for (RoleMenuDto dto : dtos) {
|
|
@@ -59,8 +63,13 @@ public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
|
|
|
childList = buildBtnByHead(head, childList);
|
|
|
List<SysRoleMenu> roleMenuList = buildRoleMenu(roleId, map(childList, SysMenu::getId));
|
|
|
// 先删除,再添加,防止联合索引报错
|
|
|
- deleteByRoleIdList(Collections.singletonList(roleId));
|
|
|
- effective += batchRoleMenu(roleMenuList);
|
|
|
+ try {
|
|
|
+ deleteByRoleIdList(Collections.singletonList(roleId));
|
|
|
+ effective += batchRoleMenu(roleMenuList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return effective;
|