【fix sonar】OnlAuthPageServiceImpl文件

This commit is contained in:
梁琦涛
2023-03-13 14:07:29 +08:00
parent 1332e91290
commit 71be16d307
@@ -1,14 +1,9 @@
package com.jero.generater.modules.online.auth.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.generater.modules.online.auth.entity.OnlAuthPage;
import com.jero.generater.modules.online.auth.entity.OnlAuthRelation;
@@ -22,41 +17,47 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@Service("OnlAuthPageServiceImpl")
@Service("onlAuthPageServiceImpl")
public class OnlAuthPageServiceImpl extends ServiceImpl<OnlAuthPageMapper, OnlAuthPage> implements IOnlAuthPageService {
@Autowired
private OnlAuthRelationMapper onlAuthRelationMapper;
@Override
public void disableAuthColumn(AuthColumnVO authColumnVO) {
LambdaUpdateWrapper<OnlAuthPage> lambdaUpdateWrapper = new LambdaUpdateWrapper();
LambdaUpdateWrapper<OnlAuthPage> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(OnlAuthPage::getCgformId, authColumnVO.getCgformId())
.eq(OnlAuthPage::getCode, authColumnVO.getCode())
.eq(OnlAuthPage::getType, Integer.valueOf(1))
.set(OnlAuthPage::getStatus, Integer.valueOf(0));
update((Wrapper) lambdaUpdateWrapper);
.eq(OnlAuthPage::getType, 1)
.set(OnlAuthPage::getStatus, 0);
update(lambdaUpdateWrapper);
}
@Transactional
@Override
@Transactional(rollbackFor = JeroBootException.class)
public void enableAuthColumn(AuthColumnVO authColumnVO) {
String cgformId = authColumnVO.getCgformId();
String code = authColumnVO.getCode();
LambdaQueryWrapper<OnlAuthPage> lambdaQueryWrapper = new LambdaQueryWrapper();
LambdaQueryWrapper<OnlAuthPage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(OnlAuthPage::getCgformId, cgformId)
.eq(OnlAuthPage::getCode, code)
.eq(OnlAuthPage::getType, Integer.valueOf(1));
List<OnlAuthPage> list = list((Wrapper) lambdaQueryWrapper);
if (list != null && list.size() > 0) {
LambdaUpdateWrapper<OnlAuthPage> lambdaUpdateWrapper = new LambdaUpdateWrapper();
.eq(OnlAuthPage::getType, 1);
List<OnlAuthPage> list = list(lambdaQueryWrapper);
if (list != null && !list.isEmpty()) {
LambdaUpdateWrapper<OnlAuthPage> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(OnlAuthPage::getCgformId, cgformId)
.eq(OnlAuthPage::getCode, code)
.eq(OnlAuthPage::getType, Integer.valueOf(1))
.set(OnlAuthPage::getStatus, Integer.valueOf(1));
update((Wrapper) lambdaUpdateWrapper);
.eq(OnlAuthPage::getType, 1)
.set(OnlAuthPage::getStatus, 1);
update(lambdaUpdateWrapper);
} else {
list = new ArrayList();
list = new ArrayList<>();
list.add(new OnlAuthPage(cgformId, code, 3, 5));
list.add(new OnlAuthPage(cgformId, code, 5, 5));
list.add(new OnlAuthPage(cgformId, code, 5, 3));
@@ -65,6 +66,8 @@ public class OnlAuthPageServiceImpl extends ServiceImpl<OnlAuthPageMapper, OnlAu
}
@Override
@Transactional(rollbackFor = JeroBootException.class)
public void switchAuthColumn(AuthColumnVO authColumnVO) {
String str1 = authColumnVO.getCgformId();
String str2 = authColumnVO.getCode();
@@ -79,120 +82,134 @@ public class OnlAuthPageServiceImpl extends ServiceImpl<OnlAuthPageMapper, OnlAu
}
@Transactional
@Override
@Transactional(rollbackFor = JeroBootException.class)
public void switchFormShow(String cgformId, String code, boolean flag) {
a(cgformId, code, 5, 5, flag);
}
@Transactional
@Override
@Transactional(rollbackFor = JeroBootException.class)
public void switchFormEditable(String cgformId, String code, boolean flag) {
a(cgformId, code, 3, 5, flag);
}
@Transactional
@Override
@Transactional(rollbackFor = JeroBootException.class)
public void switchListShow(String cgformId, String code, boolean flag) {
a(cgformId, code, 5, 3, flag);
}
@Override
public List<AuthPageVO> queryRoleAuthByFormId(String roleId, String cgformId, int type) {
return ((OnlAuthPageMapper) this.baseMapper).queryRoleAuthByFormId(roleId, cgformId, type);
return this.baseMapper.queryRoleAuthByFormId(roleId, cgformId, type);
}
@Override
public List<AuthPageVO> queryRoleDataAuth(String roleId, String cgformId) {
return ((OnlAuthPageMapper) this.baseMapper).queryRoleDataAuth(roleId, cgformId);
return this.baseMapper.queryRoleDataAuth(roleId, cgformId);
}
@Override
public List<AuthPageVO> queryAuthByFormId(String cgformId, int type) {
if (type == 1) {
return ((OnlAuthPageMapper) this.baseMapper).queryAuthColumnByFormId(cgformId);
return this.baseMapper.queryAuthColumnByFormId(cgformId);
}
return ((OnlAuthPageMapper) this.baseMapper).queryAuthButtonByFormId(cgformId);
return this.baseMapper.queryAuthButtonByFormId(cgformId);
}
@Override
public List<String> queryRoleNoAuthCode(String cgformId, Integer control, Integer page) {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String str = loginUser.getId();
return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(str, cgformId, control, page, null);
return this.baseMapper.queryRoleNoAuthCode(str, cgformId, control, page, null);
}
@Override
public List<String> queryFormDisabledCode(String cgformId) {
return queryRoleNoAuthCode(cgformId, Integer.valueOf(3), Integer.valueOf(5));
return queryRoleNoAuthCode(cgformId, 3, 5);
}
@Override
public List<String> queryHideCode(String userId, String cgformId, boolean isList) {
return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(isList ? 3 : 5), null);
return this.baseMapper.queryRoleNoAuthCode(userId, cgformId, 5, isList ? 3 : 5, null);
}
@Override
public List<String> queryListHideColumn(String userId, String cgformId) {
return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(3), Integer.valueOf(1));
return this.baseMapper.queryRoleNoAuthCode(userId, cgformId, 5, 3, 1);
}
@Override
public List<String> queryFormHideColumn(String userId, String cgformId) {
return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(5), Integer.valueOf(1));
return this.baseMapper.queryRoleNoAuthCode(userId, cgformId, 5, 5, 1);
}
@Override
public List<String> queryFormHideButton(String userId, String cgformId) {
return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(5), Integer.valueOf(2));
return this.baseMapper.queryRoleNoAuthCode(userId, cgformId, 5, 5, 2);
}
@Override
public List<String> queryHideCode(String cgformId, boolean isList) {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String str = loginUser.getId();
return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(str, cgformId, Integer.valueOf(5), Integer.valueOf(isList ? 3 : 5), null);
return this.baseMapper.queryRoleNoAuthCode(str, cgformId, 5, isList ? 3 : 5, null);
}
@Override
public List<String> queryListHideButton(String userId, String cgformId) {
if (userId == null) {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
userId = loginUser.getId();
}
return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(3), Integer.valueOf(2));
return this.baseMapper.queryRoleNoAuthCode(userId, cgformId, 5, 3, 2);
}
private void a(String paramString1, String paramString2, int paramInt1, int paramInt2, boolean paramBoolean) {
LambdaQueryWrapper<OnlAuthPage> lambdaQueryWrapper = new LambdaQueryWrapper();
LambdaQueryWrapper<OnlAuthPage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(OnlAuthPage::getCgformId, paramString1)
.eq(OnlAuthPage::getCode, paramString2)
.eq(OnlAuthPage::getControl, Integer.valueOf(paramInt1))
.eq(OnlAuthPage::getPage, Integer.valueOf(paramInt2))
.eq(OnlAuthPage::getType, Integer.valueOf(1));
.eq(OnlAuthPage::getControl, paramInt1)
.eq(OnlAuthPage::getPage, paramInt2)
.eq(OnlAuthPage::getType, 1);
OnlAuthPage onlAuthPage = (OnlAuthPage) ((OnlAuthPageMapper) this.baseMapper).selectOne((Wrapper) lambdaQueryWrapper);
OnlAuthPage onlAuthPage = this.baseMapper.selectOne(lambdaQueryWrapper);
if (paramBoolean) {
if (onlAuthPage == null) {
OnlAuthPage onlAuthPage1 = new OnlAuthPage();
onlAuthPage1.setCgformId(paramString1);
onlAuthPage1.setCode(paramString2);
onlAuthPage1.setControl(Integer.valueOf(paramInt1));
onlAuthPage1.setPage(Integer.valueOf(paramInt2));
onlAuthPage1.setType(Integer.valueOf(1));
onlAuthPage1.setStatus(Integer.valueOf(1));
((OnlAuthPageMapper) this.baseMapper).insert(onlAuthPage1);
onlAuthPage1.setControl(paramInt1);
onlAuthPage1.setPage(paramInt2);
onlAuthPage1.setType(1);
onlAuthPage1.setStatus(1);
this.baseMapper.insert(onlAuthPage1);
} else if (onlAuthPage.getStatus().intValue() == 0) {
onlAuthPage.setStatus(Integer.valueOf(1));
((OnlAuthPageMapper) this.baseMapper).updateById(onlAuthPage);
} else if (onlAuthPage.getStatus() == 0) {
onlAuthPage.setStatus(1);
this.baseMapper.updateById(onlAuthPage);
}
} else if (!paramBoolean && onlAuthPage != null) {
} else if (onlAuthPage != null) {
String str = onlAuthPage.getId();
((OnlAuthPageMapper) this.baseMapper).deleteById(str);
this.onlAuthRelationMapper.delete((Wrapper) (new LambdaQueryWrapper<OnlAuthRelation>()).eq(OnlAuthRelation::getAuthId, str));
this.baseMapper.deleteById(str);
this.onlAuthRelationMapper.delete(new LambdaQueryWrapper<OnlAuthRelation>().eq(OnlAuthRelation::getAuthId, str));
}
}
}