|
|
@@ -0,0 +1,113 @@
|
|
|
+package com.fdkankan.manage.service.impl;
|
|
|
+
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.manage.common.ResultCode;
|
|
|
+import com.fdkankan.manage.entity.AuthPage;
|
|
|
+import com.fdkankan.manage.entity.JyPlatform;
|
|
|
+import com.fdkankan.manage.entity.JyUser;
|
|
|
+import com.fdkankan.manage.exception.BusinessException;
|
|
|
+import com.fdkankan.manage.mapper.IAuthPageMapper;
|
|
|
+import com.fdkankan.manage.service.IAuthPageService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.manage.service.IJyPlatformService;
|
|
|
+import com.fdkankan.manage.service.IJyUserService;
|
|
|
+import com.fdkankan.manage.service.ISysRoleService;
|
|
|
+import com.fdkankan.manage.vo.AuthPageVo;
|
|
|
+import com.fdkankan.manage.vo.request.PageDataAuth;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2025-12-11
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage> implements IAuthPageService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IJyUserService jyUserService;
|
|
|
+ @Autowired
|
|
|
+ IJyPlatformService platformService;
|
|
|
+ @Autowired
|
|
|
+ ISysRoleService sysRoleService;
|
|
|
+ @Override
|
|
|
+ public void setAuth(PageDataAuth param) {
|
|
|
+ if(param.getJyId() == null ){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ JyUser jyUser = jyUserService.getById(param.getJyId());
|
|
|
+ if(jyUser == null || jyUser.getStatus() == 0){
|
|
|
+ throw new BusinessException(ResultCode.USERNAME_ERROR);
|
|
|
+ }
|
|
|
+ JyUser loginUser = jyUserService.getLoginUser();
|
|
|
+
|
|
|
+ AuthPage authPage = new AuthPage();
|
|
|
+ authPage.setJyId(param.getJyId() );
|
|
|
+ authPage.setPageAuth(param.getPageAuth());
|
|
|
+ authPage.setCreaterId(loginUser.getId());
|
|
|
+ authPage.setCreaterPlatformId(loginUser.getPlatformId());
|
|
|
+ this.save(authPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delAuth(AuthPageVo param) {
|
|
|
+ if(param.getId() == null){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ this.removeById(param.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AuthPageVo> pageList(PageDataAuth param) {
|
|
|
+
|
|
|
+ JyUser loginUser = jyUserService.getLoginUser();
|
|
|
+ param.setPlatformId(loginUser.getPlatformId());
|
|
|
+
|
|
|
+ return this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<JyPlatform> platformList() {
|
|
|
+ JyUser loginUser = jyUserService.getLoginUser();
|
|
|
+ if(sysRoleService.isSuperAdmin()){
|
|
|
+ List<JyPlatform> list = platformService.list();
|
|
|
+ for (JyPlatform jyPlatform : list) {
|
|
|
+ jyPlatform.setPageAuth("admin");
|
|
|
+ }
|
|
|
+ return list ;
|
|
|
+ }
|
|
|
+ List<AuthPage> authPages = this.getByJyUserId(loginUser.getId());
|
|
|
+ List<Integer> platformIds = authPages.stream().map(AuthPage::getCreaterPlatformId).collect(Collectors.toList());
|
|
|
+ if(loginUser.getPlatformId() != null){
|
|
|
+ platformIds.add(loginUser.getPlatformId());
|
|
|
+ }
|
|
|
+ if(platformIds!= null && !platformIds.isEmpty()){
|
|
|
+ List<JyPlatform> jyPlatforms = platformService.listByIds(platformIds);
|
|
|
+ for (JyPlatform jyPlatform : jyPlatforms) {
|
|
|
+ if(platformIds.contains(jyPlatform.getId())){
|
|
|
+ jyPlatform.setPageAuth("admin");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return jyPlatforms;
|
|
|
+ }
|
|
|
+
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<AuthPage> getByJyUserId(Integer jyId) {
|
|
|
+ LambdaQueryWrapper<AuthPage> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(AuthPage::getJyId,jyId);
|
|
|
+ return this.list(wrapper);
|
|
|
+ }
|
|
|
+}
|