123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639 |
- package com.fdkankan.manage.service.impl;
- import cn.dev33.satoken.stp.StpUtil;
- import cn.hutool.extra.servlet.ServletUtil;
- import cn.hutool.jwt.JWTUtil;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.fdkankan.common.util.JwtUtil;
- import com.fdkankan.manage.common.PageInfo;
- import com.fdkankan.manage.common.RedisKeyUtil;
- import com.fdkankan.manage.common.ResultCode;
- import com.fdkankan.manage.entity.*;
- import com.fdkankan.manage.exception.BusinessException;
- import com.fdkankan.manage.mapper.IJySceneUserAuthMapper;
- import com.fdkankan.manage.service.*;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.fdkankan.manage.util.AesUtil;
- import com.fdkankan.manage.vo.request.SceneParam;
- import com.fdkankan.manage.vo.response.CheckOtherVo;
- import com.fdkankan.manage.vo.response.ManageLoginResponse;
- import com.fdkankan.manage.vo.response.SceneAuthVo;
- import com.fdkankan.manage.vo.response.SceneUserAuthVo;
- import com.fdkankan.redis.util.RedisUtil;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.tomcat.util.security.Escape;
- import org.joda.time.DateTime;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.*;
- import java.util.concurrent.TimeUnit;
- import java.util.stream.Collectors;
- /**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author
- * @since 2023-08-24
- */
- @Service
- @Slf4j
- public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapper, JySceneUserAuth> implements IJySceneUserAuthService {
- @Autowired
- IJyUserService jyUserService;
- @Autowired
- IJySceneAuthService jySceneAuthService;
- @Autowired
- ISceneProService sceneProService;
- @Autowired
- IScenePlusService scenePlusService;
- @Autowired
- ISysUserService sysUserService;
- @Autowired
- ICaseService caseService;
- @Override
- public Object getAuthType(SceneParam param) {
- if(StringUtils.isBlank(param.getNum()) || param.getCaseId() == null){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- if(StringUtils.isNotBlank(param.getNum()) && param.getCaseId() !=null){
- param.setCaseId(null);
- }
- JySceneAuth jySceneAuth = null;
- if(StringUtils.isNotBlank(param.getNum())){
- caseService.checkNumInCase(param.getNum());
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
- if(plus == null){
- throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
- }
- jySceneAuth = jySceneAuthService.getByNum(param.getNum());
- if(jySceneAuth == null ){
- return new JySceneAuth(0);
- }
- }
- if(param.getCaseId() != null){
- Case caseEntity = caseService.getById(param.getCaseId());
- if(caseEntity == null){
- throw new BusinessException(ResultCode.CASE_NOT_EXIST);
- }
- jySceneAuth = jySceneAuthService.getByCaseId(param.getCaseId());
- if(jySceneAuth == null ){
- return new JySceneAuth(0);
- }
- }
- return jySceneAuth;
- }
- @Override
- public Object getAuthList(SceneParam param) {
- if(StringUtils.isBlank(param.getNum()) || param.getCaseId() == null){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- if(StringUtils.isNotBlank(param.getNum()) && param.getCaseId() !=null){
- param.setCaseId(null);
- }
- Long sceneUserId = null;
- JyUser loginUser = null;
- Long sysRoleId = null;
- if(StringUtils.isNotBlank(param.getNum())){
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
- if(plus == null){
- throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
- }
- caseService.checkNumInCase(param.getNum());
- sceneUserId = plus.getUserId();
- }
- if(param.getCaseId() != null){
- Case caseEntity = caseService.getById(param.getCaseId());
- if(caseEntity == null){
- throw new BusinessException(ResultCode.CASE_NOT_EXIST);
- }
- JyUser jyUser = jyUserService.getBySysId(caseEntity.getSysUserId());
- if(jyUser == null){
- throw new BusinessException(ResultCode.USER_NOT_EXIST);
- }
- sceneUserId = jyUser.getUserId();
- }
- if(StpUtil.isLogin()){
- loginUser = jyUserService.getBySysId(StpUtil.getLoginId());
- SysUser byId = sysUserService.getById(Long.valueOf(StpUtil.getLoginId().toString()));
- sysRoleId = byId.getRoleId();
- }else {
- if(StringUtils.isNotBlank(param.getRyId())){
- loginUser = jyUserService.getByRyId(param.getRyId());
- }
- if(StringUtils.isNotBlank(param.getRyNo())){
- loginUser = jyUserService.getByRyNo(param.getRyNo());
- }
- if(loginUser != null){
- SysUser byId = sysUserService.getById(loginUser.getSysUserId());
- sysRoleId = byId.getRoleId();
- }
- }
- if(loginUser == null){
- throw new BusinessException(ResultCode.USER_NOT_EXIST);
- }
- LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
- if(StringUtils.isNotBlank(param.getNum())){
- wrapper.eq(JySceneUserAuth::getNum,param.getNum());
- }
- if(param.getCaseId() != null){
- wrapper.eq(JySceneUserAuth::getCaseId,param.getCaseId());
- }
- wrapper.eq(JySceneUserAuth::getAuthType,param.getAuthType());
- if(!sceneUserId.equals(loginUser.getUserId()) && sysRoleId!=null && sysRoleId == 47L ){
- List<Integer> ids = new ArrayList<>();
- getSubAuthorIdsById(loginUser.getId(),param.getNum(),param.getCaseId(),ids);
- if(ids.size()<=0){
- return PageInfo.PageInfo(new Page(param.getPageNum(),param.getPageSize()));
- }
- wrapper.in(JySceneUserAuth::getAuthorId,ids);
- }
- wrapper.orderByDesc(JySceneUserAuth::getCreateTime);
- Page<JySceneUserAuth> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
- List<Integer> jyUserIds = page.getRecords().stream().map(JySceneUserAuth::getJyUserId).collect(Collectors.toList());
- HashMap<Integer, JyUser> map = jyUserService.getByIds(jyUserIds);
- for (JySceneUserAuth jySceneUserAuth : page.getRecords()) {
- JyUser jyUser = map.get(jySceneUserAuth.getJyUserId());
- if(jyUser != null){
- jySceneUserAuth.setRyId(jyUser.getRyId());
- jySceneUserAuth.setRyNickName(jyUser.getRyNickName());
- jySceneUserAuth.setRyNo(jyUser.getRyNo());
- }
- }
- return PageInfo.PageInfo(page);
- }
- private void getSubAuthorIdsById(Integer id,String num,Integer caseId,List<Integer> ids) {
- ids.add(id);
- LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
- if(StringUtils.isNotBlank(num)){
- wrapper.eq(JySceneUserAuth::getNum,num);
- }
- if(caseId != null){
- wrapper.eq(JySceneUserAuth::getCaseId,caseId);
- }
- wrapper.eq(JySceneUserAuth::getAuthorId,id);
- List<JySceneUserAuth> list = this.list(wrapper);
- if(list.size() >0){
- for (JySceneUserAuth auth : list) {
- ids.add(auth.getAuthorId());
- getSubAuthorIdsById(auth.getId(),num,caseId,ids);
- }
- }
- }
- @Override
- public void setAuthType(JySceneUserAuth param) {
- if(StringUtils.isBlank(param.getNum()) || param.getCaseId() == null || param.getAuthType() == null){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- if(StringUtils.isNotBlank(param.getNum()) && param.getCaseId() !=null){
- param.setCaseId(null);
- }
- if(StringUtils.isNotBlank(param.getNum())){
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
- if( plus == null){
- throw new BusinessException(ResultCode.SCENE_NOT_EXITS);
- }
- jySceneAuthService.updateAuthTypeByNum(param.getNum(),param.getAuthType());
- }
- if(param.getCaseId() != null){
- Case caseEntity = caseService.getById(param.getCaseId());
- if(caseEntity == null){
- throw new BusinessException(ResultCode.CASE_NOT_EXIST);
- }
- jySceneAuthService.updateAuthTypeByCaseId(param.getCaseId(),param.getAuthType());
- }
- }
- @Override
- public synchronized void addAuth(JySceneUserAuth param) {
- if(StringUtils.isBlank(param.getNum()) || param.getCaseId() == null ){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- JyUser jyUser = null;
- if(StringUtils.isNotBlank(param.getRyId()) ){
- jyUser = jyUserService.getByRyId(param.getRyId());
- if(jyUser == null){
- throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
- }
- }
- if(StringUtils.isNotBlank(param.getRyNo()) ){
- jyUser = jyUserService.getByRyNo(param.getRyNo());
- if(jyUser == null){
- throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
- }
- }
- if(jyUser == null){
- throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
- }
- Long sceneUserId = null;
- JySceneUserAuth jySceneUserAuth = null;
- if(StringUtils.isNotBlank(param.getNum())){
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
- if(plus == null){
- throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
- }
- caseService.checkNumInCase(param.getNum());
- sceneUserId = plus.getUserId();
- jySceneUserAuth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), param.getNum(),param.getAuthType());
- }
- if(param.getCaseId() != null){
- Case caseEntity = caseService.getById(param.getCaseId());
- if(caseEntity == null){
- throw new BusinessException(ResultCode.CASE_NOT_EXIST);
- }
- JyUser jyUser2 = jyUserService.getBySysId(caseEntity.getSysUserId());
- if(jyUser2 == null){
- throw new BusinessException(ResultCode.USER_NOT_EXIST);
- }
- sceneUserId = jyUser2.getUserId();
- jySceneUserAuth = jySceneUserAuthService.getByCaseIdAndJyUserId(jyUser.getId(), param.getCaseId(),param.getAuthType());
- }
- if(jySceneUserAuth != null && param.getCanDel() != 1){
- throw new BusinessException(ResultCode.SCENE_AUTH_EXITS);
- }
- if(jySceneUserAuth != null && param.getCanDel() == 1){
- param.setId(jySceneUserAuth.getId());
- }
- if(sceneUserId.equals(jyUser.getUserId())){
- throw new BusinessException(ResultCode.AUTH_ERROR);
- }
- JyUser sceneJyUser = null;
- if(StpUtil.isLogin()){
- sceneJyUser = jyUserService.getBySysId(StpUtil.getLoginId());
- }else {
- sceneJyUser = jyUserService.getByUserId(sceneUserId);
- }
- if(param.getCanEditLook() == 1 || param.getCanAuthLook() == 1){
- param.setIsAuthor(1);
- }
- if(param.getCanEditLook() == 1 ){
- param.setCanAuthLook(1);
- }
- if(param.getCanEditLook() == 0 && param.getCanAuthLook() == 0){
- param.setIsAuthor(0);
- }
- JySceneAuth jySceneAuth = null;
- if(StringUtils.isNotBlank(param.getNum())){
- jySceneAuth = jySceneAuthService.getByNum(param.getNum());
- }
- if(param.getCaseId() != null){
- jySceneAuth = jySceneAuthService.getByCaseId(param.getCaseId());
- }
- if(jySceneAuth == null){
- jySceneAuth = new JySceneAuth(param.getAuthType());
- if(StringUtils.isNotBlank(param.getNum())){
- jySceneAuth.setNum(param.getNum());
- }
- if(param.getCaseId() != null){
- jySceneAuth.setCaseId(param.getCaseId());
- }
- jySceneAuthService.save(jySceneAuth);
- }
- param.setJyUserId(jyUser.getId());
- param.setAuthorId(sceneJyUser.getId());
- this.saveOrUpdate(param);
- }
- @Override
- public void delAuth(JySceneUserAuth param) {
- if(param.getId() == null){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- this.removeById(param.getId());
- }
- @Override
- public JySceneUserAuth getByNumAndJyUserId(Integer jyUserId, String num,Integer authType) {
- LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(JySceneUserAuth::getJyUserId,jyUserId);
- wrapper.eq(JySceneUserAuth::getNum,num);
- wrapper.eq(JySceneUserAuth::getAuthType,authType);
- return this.getOne(wrapper);
- }
- @Override
- public JySceneUserAuth getByCaseIdAndJyUserId(Integer jyUserId, Integer caseId, Integer authType) {
- LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(JySceneUserAuth::getJyUserId,jyUserId);
- wrapper.eq(JySceneUserAuth::getCaseId,caseId);
- wrapper.eq(JySceneUserAuth::getAuthType,authType);
- return this.getOne(wrapper);
- }
- @Override
- public JySceneUserAuth getByNumAndRyId(String num, String ryId) {
- JyUser jyUser = jyUserService.getByRyId(ryId);
- if(jyUser == null){
- throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
- }
- JySceneAuth jySceneAuth = jySceneAuthService.getByNum(num);
- if(jySceneAuth == null){
- throw new BusinessException(ResultCode.DEL_AUTH_ERROR);
- }
- return this.getByNumAndJyUserId(jyUser.getId(),num,jySceneAuth.getAuthType());
- }
- @Override
- public JySceneUserAuth getByNumAndRyNo(String num, String ryNo) {
- JyUser jyUser = jyUserService.getByRyNo(ryNo);
- if(jyUser == null){
- throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
- }
- JySceneAuth jySceneAuth = jySceneAuthService.getByNum(num);
- if(jySceneAuth == null){
- throw new BusinessException(ResultCode.DEL_AUTH_ERROR);
- }
- return this.getByNumAndJyUserId(jyUser.getId(),num,jySceneAuth.getAuthType());
- }
- @Override
- public JySceneUserAuth getByCaseIdAndRyId(Integer caseId, String ryId) {
- JyUser jyUser = jyUserService.getByRyId(ryId);
- if(jyUser == null){
- throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
- }
- JySceneAuth jySceneAuth = jySceneAuthService.getByCaseId(caseId);
- if(jySceneAuth == null){
- throw new BusinessException(ResultCode.DEL_AUTH_ERROR);
- }
- return this.getByCaseIdAndJyUserId(jyUser.getId(),caseId,jySceneAuth.getAuthType());
- }
- @Override
- public JySceneUserAuth getByCaseIdAndRyNo(Integer caseId, String ryNo) {
- JyUser jyUser = jyUserService.getByRyNo(ryNo);
- if(jyUser == null){
- throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
- }
- JySceneAuth jySceneAuth = jySceneAuthService.getByCaseId(caseId);
- if(jySceneAuth == null){
- throw new BusinessException(ResultCode.DEL_AUTH_ERROR);
- }
- return this.getByCaseIdAndJyUserId(jyUser.getId(),caseId,jySceneAuth.getAuthType());
- }
- @Override
- public Object checkAuthOther(JySceneUserAuth param) {
- if(StringUtils.isBlank(param.getNum())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- ScenePro pro = sceneProService.getByNum(param.getNum());
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
- if(pro == null && plus == null){
- throw new BusinessException(ResultCode.SCENE_NOT_EXITS);
- }
- Long sceneUserId = pro == null ? plus.getUserId() :pro.getUserId();
- CheckOtherVo vo = new CheckOtherVo();
- SysUser byId = sysUserService.getById(Long.valueOf(StpUtil.getLoginId().toString()));
- JyUser jyUser = jyUserService.getBySysId(byId.getId());
- if( byId.getRoleId() != 47L || jyUser.getUserId().equals(sceneUserId)){
- vo.setIsAuthor(1);
- vo.setEditAuth(1);
- vo.setLookAuth(1);
- }else {
- JySceneUserAuth auth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), param.getNum(),param.getAuthType());
- if(auth !=null){
- if(auth.getCanAuthLook() == 1 ){
- vo.setLookAuth(auth.getLookAuth());
- vo.setLookEndTime(auth.getLookEndTime());
- }
- if(auth.getCanEditLook() == 1){
- vo.setEditAuth(auth.getEditAuth());
- vo.setEditEndTime(auth.getEditEndTime());
- }
- }
- }
- return vo;
- }
- @Autowired
- RedisUtil redisUtil;
- @Autowired
- IJySceneUserAuthService jySceneUserAuthService;
- @Autowired
- IJyUserShareService jyUserShareService;
- @Autowired
- ManageService manageService;
- @Autowired
- IJyUserPlatformService jyUserPlatformService;
- @Override
- public Object checkNumAuth(String num,String token,String clientIP,String userName,String password) {
- if(StringUtils.isBlank(num)){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- log.info("checkNumAuth-----------num:{},token:{},userName:{},password:{}",num,token,userName,password);
- ScenePro pro = sceneProService.getByNum(num);
- ScenePlus plus = scenePlusService.getByNum(num);
- if(pro == null && plus == null){
- throw new BusinessException(ResultCode.SCENE_NOT_EXITS);
- }
- Long sceneUserId = pro == null ? plus.getUserId():pro.getUserId();
- SceneAuthVo sceneAuthVo = new SceneAuthVo();
- JySceneAuth jySceneAuth = jySceneAuthService.getByNum(num);
- if(jySceneAuth!=null && jySceneAuth.getAuthType() == 1){
- sceneAuthVo.setViewAuth(true);
- }
- List<Case> caseList = caseService.getCaseByNum(num);
- for (Case aCase : caseList) {
- JySceneAuth jySceneAuth1 = jySceneAuthService.getByCaseId(aCase.getCaseId());
- if(jySceneAuth1!=null && jySceneAuth1.getAuthType() == 1){
- sceneAuthVo.setViewAuth(true);
- break;
- }
- }
- if(StringUtils.isBlank(token) && (StringUtils.isBlank(userName) || StringUtils.isBlank(password))){
- return sceneAuthVo;
- }
- Long sysUserId = null;
- if(StringUtils.isNotBlank(token)){
- String redisKey = String.format(RedisKeyUtil.loginToken,token);
- if( !redisUtil.hasKey(redisKey) ){
- return sceneAuthVo;
- }
- String userStr = redisUtil.get(redisKey);
- ManageLoginResponse result = JSONObject.parseObject(userStr,ManageLoginResponse.class);
- Long userId = result.getUserId();
- if(userId == null){
- redisUtil.del(redisKey);
- throw new BusinessException(ResultCode.USER_NOT_LOGIN);
- }else {
- redisUtil.expire(redisKey,2 * 60 * 60);
- }
- sysUserId = result.getId();
- }
- if(StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)){
- ManageLoginResponse login = manageService.login(clientIP, userName, password,true);
- sysUserId = login.getId();
- }
- if(sysUserId == null){
- return sceneAuthVo;
- }
- SysUser byId = sysUserService.getById(sysUserId);
- if(byId.getRoleId() == 1L ){
- sceneAuthVo.setViewAuth(true);
- sceneAuthVo.setEditAuth(true);
- return sceneAuthVo;
- }
- if(byId.getRoleId() == 45L || byId.getRoleId() == 48L){
- Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
- if(loginPlatformId != null){
- List<Long> byUserIdPlatform = jyUserService.getByUserIdPlatform(loginPlatformId);
- if(byUserIdPlatform.contains(sceneUserId)){
- sceneAuthVo.setViewAuth(true);
- sceneAuthVo.setEditAuth(true);
- return sceneAuthVo;
- }
- }
- }
- JyUser jyUser = jyUserService.getBySysId(byId.getId());
- //if(jySceneAuth != null && jySceneAuth.getAuthType() == 0){
- if(jySceneAuth != null ){
- JySceneUserAuth jySceneUserAuth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), num,jySceneAuth.getAuthType());
- setFlag(jySceneUserAuth,sceneAuthVo);
- }
- if(!caseList.isEmpty()){
- for (Case aCase : caseList) {
- JySceneUserAuth jySceneUserAuth = jySceneUserAuthService.getByCaseIdAndJyUserId(jyUser.getId(), aCase.getCaseId(),jySceneAuth.getAuthType());
- setFlag(jySceneUserAuth,sceneAuthVo);
- }
- }
- if(pro != null && jyUser.getUserId().equals(pro.getUserId())){
- sceneAuthVo.setViewAuth(true);
- sceneAuthVo.setEditAuth(true);
- sceneAuthVo.setIsAuthor(true);
- }
- if(plus != null && jyUser.getUserId().equals(plus.getUserId())){
- sceneAuthVo.setViewAuth(true);
- sceneAuthVo.setEditAuth(true);
- sceneAuthVo.setIsAuthor(true);
- }
- if(!sceneAuthVo.getViewAuth()){
- List<JyUserShare> jyUserShares = jyUserShareService.getByJyUserId(jyUser.getId());
- List<Integer> mainUserIds = jyUserShares.stream().map(JyUserShare::getMainJyUserId).collect(Collectors.toList());
- HashMap<Integer,Long> roleMap = new HashMap<>();
- if(!mainUserIds.isEmpty()){
- List<JyUser> jyUsers = jyUserService.listByIds(mainUserIds);
- Set<Long> sysIds = jyUsers.stream().map(JyUser::getSysUserId).collect(Collectors.toSet());
- HashMap<Long, SysUser> byIds = sysUserService.getByIds(sysIds);
- jyUsers.forEach( e-> roleMap.put(e.getId(),byIds.get(e.getSysUserId()).getRoleId()));
- for (JyUser user : jyUsers) {
- Long roleId = roleMap.get(user.getId());
- if(user.getPlatformId() != null && (roleId == 1L || roleId == 45L || roleId == 48L)){
- sceneAuthVo.setViewAuth(true);
- }else if(user.getUserId().equals(sceneUserId)){
- sceneAuthVo.setViewAuth(true);
- }
- }
- }
- }
- return sceneAuthVo;
- }
- private void setFlag(JySceneUserAuth jySceneUserAuth,SceneAuthVo sceneAuthVo){
- if(jySceneUserAuth != null){
- Date date = new Date();
- if(jySceneUserAuth.getLookAuth() == 1 ||
- ( jySceneUserAuth.getLookAuth() == 2 && jySceneUserAuth.getLookEndTime().getTime() >date.getTime())){
- sceneAuthVo.setViewAuth(true);
- }
- if(jySceneUserAuth.getEditAuth() == 1 ||
- (jySceneUserAuth.getEditAuth() == 2 && jySceneUserAuth.getEditEndTime().getTime() >date.getTime())){
- sceneAuthVo.setEditAuth(true);
- }
- }
- }
- @Override
- public List<JySceneUserAuth> getByJyUserId(Integer jyUserId) {
- LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(JySceneUserAuth::getJyUserId,jyUserId);
- return this.list(wrapper);
- }
- @Override
- public void delByJyUserId(Integer jyUserId) {
- LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(JySceneUserAuth::getJyUserId,jyUserId);
- this.remove(wrapper);
- }
- @Override
- public HashMap<String, List<JySceneUserAuth>> getByNumList(List<String> numList) {
- HashMap<String, List<JySceneUserAuth>> map = new HashMap<>();
- if(numList.isEmpty()){
- return map;
- }
- LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
- wrapper.in(JySceneUserAuth::getNum,numList);
- List<JySceneUserAuth> list = this.list(wrapper);
- for (JySceneUserAuth e : list) {
- String key = e.getNum() + "_"+ e.getAuthType();
- map.computeIfAbsent(key, k -> new ArrayList<>());
- map.get(key).add(e);
- }
- return map;
- }
- @Override
- public HashMap<String, List<JySceneUserAuth>> getByNumList(List<String> numList,Integer jyUserId) {
- HashMap<String, List<JySceneUserAuth>> map = new HashMap<>();
- if(numList.isEmpty()){
- return map;
- }
- LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
- wrapper.in(JySceneUserAuth::getNum,numList);
- wrapper.eq(JySceneUserAuth::getAuthorId,jyUserId);
- List<JySceneUserAuth> list = this.list(wrapper);
- for (JySceneUserAuth e : list) {
- String key = e.getNum() + "_"+ e.getAuthType();
- map.computeIfAbsent(key, k -> new ArrayList<>());
- map.get(key).add(e);
- }
- return map;
- }
- }
|