From 4b46caec39e5390ae9d907d4bc8b38fbad83e1e1 Mon Sep 17 00:00:00 2001 From: zer0Black Date: Fri, 12 Mar 2021 11:01:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=B7=BB=E5=8A=A0=E3=80=91service?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/service/IOnlAuthDataService.java | 8 + .../auth/service/IOnlAuthPageService.java | 44 ++++ .../auth/service/IOnlAuthRelationService.java | 10 + .../service/impl/onlAuthDataServiceImpl.java | 26 +++ .../service/impl/onlAuthPageServiceImpl.java | 198 ++++++++++++++++++ .../impl/onlAuthRelationServiceImpl.java | 45 ++++ 6 files changed, 331 insertions(+) create mode 100644 jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthDataService.java create mode 100644 jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthPageService.java create mode 100644 jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthRelationService.java create mode 100644 jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthDataServiceImpl.java create mode 100644 jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthPageServiceImpl.java create mode 100644 jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthRelationServiceImpl.java diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthDataService.java b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthDataService.java new file mode 100644 index 00000000..3c4bafc8 --- /dev/null +++ b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthDataService.java @@ -0,0 +1,8 @@ +package com.jero.generater.modules.online.auth.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.jero.generater.modules.online.auth.entity.OnlAuthData; + +public interface IOnlAuthDataService extends IService { + void deleteOne(String str); +} diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthPageService.java b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthPageService.java new file mode 100644 index 00000000..c97d76b9 --- /dev/null +++ b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthPageService.java @@ -0,0 +1,44 @@ +package com.jero.generater.modules.online.auth.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + +import com.jero.generater.modules.online.auth.entity.OnlAuthPage; +import com.jero.generater.modules.online.auth.vo.AuthColumnVO; +import com.jero.generater.modules.online.auth.vo.AuthPageVO; + +public interface IOnlAuthPageService extends IService { + void disableAuthColumn(AuthColumnVO authColumnVO); + + void enableAuthColumn(AuthColumnVO authColumnVO); + + List queryAuthByFormId(String str, int i); + + List queryFormDisabledCode(String str); + + List queryFormHideButton(String str, String str2); + + List queryFormHideColumn(String str, String str2); + + List queryHideCode(String str, String str2, boolean z); + + List queryHideCode(String str, boolean z); + + List queryListHideButton(String str, String str2); + + List queryListHideColumn(String str, String str2); + + List queryRoleAuthByFormId(String str, String str2, int i); + + List queryRoleDataAuth(String str, String str2); + + List queryRoleNoAuthCode(String str, Integer num, Integer num2); + + void switchAuthColumn(AuthColumnVO authColumnVO); + + void switchFormEditable(String str, String str2, boolean z); + + void switchFormShow(String str, String str2, boolean z); + + void switchListShow(String str, String str2, boolean z); +} diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthRelationService.java b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthRelationService.java new file mode 100644 index 00000000..3833afb7 --- /dev/null +++ b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/IOnlAuthRelationService.java @@ -0,0 +1,10 @@ +package com.jero.generater.modules.online.auth.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + +import com.jero.generater.modules.online.auth.entity.OnlAuthRelation; + +public interface IOnlAuthRelationService extends IService { + void saveRoleAuth(String str, String str2, int i, List list); +} diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthDataServiceImpl.java b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthDataServiceImpl.java new file mode 100644 index 00000000..e52030a5 --- /dev/null +++ b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthDataServiceImpl.java @@ -0,0 +1,26 @@ +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.extension.service.impl.ServiceImpl; +import com.jero.generater.modules.online.auth.entity.OnlAuthData; +import com.jero.generater.modules.online.auth.entity.OnlAuthRelation; +import com.jero.generater.modules.online.auth.mapper.OnlAuthDataMapper; +import com.jero.generater.modules.online.auth.mapper.OnlAuthRelationMapper; +import com.jero.generater.modules.online.auth.service.IOnlAuthDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service("onlAuthDataServiceImpl") +public class onlAuthDataServiceImpl extends ServiceImpl implements IOnlAuthDataService +{ +@Autowired +private OnlAuthRelationMapper onlAuthRelationMapper; + +public void deleteOne(String id) { + removeById(id); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); + this.onlAuthRelationMapper.delete((Wrapper)lambdaQueryWrapper.eq(OnlAuthRelation::getAuthId, id)); +} +} + diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthPageServiceImpl.java b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthPageServiceImpl.java new file mode 100644 index 00000000..5a2fc0af --- /dev/null +++ b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthPageServiceImpl.java @@ -0,0 +1,198 @@ +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.system.vo.LoginUser; +import com.jero.generater.modules.online.auth.entity.OnlAuthPage; +import com.jero.generater.modules.online.auth.entity.OnlAuthRelation; +import com.jero.generater.modules.online.auth.mapper.OnlAuthPageMapper; +import com.jero.generater.modules.online.auth.mapper.OnlAuthRelationMapper; +import com.jero.generater.modules.online.auth.service.IOnlAuthPageService; +import com.jero.generater.modules.online.auth.vo.AuthColumnVO; +import com.jero.generater.modules.online.auth.vo.AuthPageVO; +import org.apache.shiro.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +@Service("onlAuthPageServiceImpl") +public class onlAuthPageServiceImpl extends ServiceImpl implements IOnlAuthPageService { + @Autowired + private OnlAuthRelationMapper onlAuthRelationMapper; + + public void disableAuthColumn(AuthColumnVO authColumnVO) { + LambdaUpdateWrapper 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); + } + + + @Transactional + public void enableAuthColumn(AuthColumnVO authColumnVO) { + String cgformId = authColumnVO.getCgformId(); + String code = authColumnVO.getCode(); + + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); + lambdaQueryWrapper.eq(OnlAuthPage::getCgformId, cgformId) + .eq(OnlAuthPage::getCode, code) + .eq(OnlAuthPage::getType, Integer.valueOf(1)); + List list = list((Wrapper) lambdaQueryWrapper); + if (list != null && list.size() > 0) { + LambdaUpdateWrapper 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); + } else { + 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)); + saveBatch(list); + } + } + + + public void switchAuthColumn(AuthColumnVO authColumnVO) { + String str1 = authColumnVO.getCgformId(); + String str2 = authColumnVO.getCode(); + int i = authColumnVO.getSwitchFlag(); + if (i == 1) { + switchListShow(str1, str2, authColumnVO.isListShow()); + } else if (i == 2) { + switchFormShow(str1, str2, authColumnVO.isFormShow()); + } else if (i == 3) { + switchFormEditable(str1, str2, authColumnVO.isFormEditable()); + } + } + + + @Transactional + public void switchFormShow(String cgformId, String code, boolean flag) { + a(cgformId, code, 5, 5, flag); + } + + + @Transactional + public void switchFormEditable(String cgformId, String code, boolean flag) { + a(cgformId, code, 3, 5, flag); + } + + + @Transactional + public void switchListShow(String cgformId, String code, boolean flag) { + a(cgformId, code, 5, 3, flag); + } + + + public List queryRoleAuthByFormId(String roleId, String cgformId, int type) { + return ((OnlAuthPageMapper) this.baseMapper).queryRoleAuthByFormId(roleId, cgformId, type); + } + + + public List queryRoleDataAuth(String roleId, String cgformId) { + return ((OnlAuthPageMapper) this.baseMapper).queryRoleDataAuth(roleId, cgformId); + } + + + public List queryAuthByFormId(String cgformId, int type) { + if (type == 1) { + return ((OnlAuthPageMapper) this.baseMapper).queryAuthColumnByFormId(cgformId); + } + return ((OnlAuthPageMapper) this.baseMapper).queryAuthButtonByFormId(cgformId); + } + + + public List 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); + } + + + public List queryFormDisabledCode(String cgformId) { + return queryRoleNoAuthCode(cgformId, Integer.valueOf(3), Integer.valueOf(5)); + } + + + public List queryHideCode(String userId, String cgformId, boolean isList) { + return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(isList ? 3 : 5), null); + } + + + public List queryListHideColumn(String userId, String cgformId) { + return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(3), Integer.valueOf(1)); + } + + + public List queryFormHideColumn(String userId, String cgformId) { + return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(5), Integer.valueOf(1)); + } + + + public List queryFormHideButton(String userId, String cgformId) { + return ((OnlAuthPageMapper) this.baseMapper).queryRoleNoAuthCode(userId, cgformId, Integer.valueOf(5), Integer.valueOf(5), Integer.valueOf(2)); + } + + + public List 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); + } + + + public List 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)); + } + + private void a(String paramString1, String paramString2, int paramInt1, int paramInt2, boolean paramBoolean) { + LambdaQueryWrapper 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)); + + OnlAuthPage onlAuthPage = (OnlAuthPage) ((OnlAuthPageMapper) this.baseMapper).selectOne((Wrapper) 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); + + } else if (onlAuthPage.getStatus().intValue() == 0) { + onlAuthPage.setStatus(Integer.valueOf(1)); + ((OnlAuthPageMapper) this.baseMapper).updateById(onlAuthPage); + } + + } else if (!paramBoolean && onlAuthPage != null) { + + String str = onlAuthPage.getId(); + ((OnlAuthPageMapper) this.baseMapper).deleteById(str); + this.onlAuthRelationMapper.delete((Wrapper) (new LambdaQueryWrapper()).eq(OnlAuthRelation::getAuthId, str)); + } + } +} diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthRelationServiceImpl.java b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthRelationServiceImpl.java new file mode 100644 index 00000000..1f252fd4 --- /dev/null +++ b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/auth/service/impl/onlAuthRelationServiceImpl.java @@ -0,0 +1,45 @@ +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 java.util.ArrayList; +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.jero.generater.modules.online.auth.entity.OnlAuthRelation; +import com.jero.generater.modules.online.auth.mapper.OnlAuthRelationMapper; +import com.jero.generater.modules.online.auth.service.IOnlAuthRelationService; +import org.springframework.stereotype.Service; + + + + + + + + + +@Service("onlAuthRelationServiceImpl") +public class onlAuthRelationServiceImpl extends ServiceImpl implements IOnlAuthRelationService { + public void saveRoleAuth(String roleId, String cgformId, int type, List authIds) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); + lambdaQueryWrapper.eq(OnlAuthRelation::getCgformId, cgformId) + .eq(OnlAuthRelation::getType, Integer.valueOf(type)) + .eq(OnlAuthRelation::getRoleId, roleId); + + this.baseMapper.delete((Wrapper)lambdaQueryWrapper); + + ArrayList arrayList = new ArrayList(); + for (String str : authIds) { + OnlAuthRelation onlAuthRelation = new OnlAuthRelation(); + onlAuthRelation.setAuthId(str); + onlAuthRelation.setCgformId(cgformId); + onlAuthRelation.setRoleId(roleId); + onlAuthRelation.setType(Integer.valueOf(type)); + arrayList.add(onlAuthRelation); + } + + saveBatch(arrayList); + } +} +