修改大屏管理用户隔离逻辑删除,搜索,

配置证书,和连接证书服务器数据库
main
whb 7 months ago
parent 11117575b8
commit 69f13908ec

@ -1,17 +1,26 @@
package com.gccloud.dataroom.core.module.biz.component.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gccloud.common.exception.GlobalException;
import com.gccloud.common.permission.ApiPermission;
import com.gccloud.common.utils.BeanConvertUtils;
import com.gccloud.dataroom.core.module.biz.component.dao.DataRoomBizComponentDao;
import com.gccloud.dataroom.core.module.biz.component.dao.DataRoomBizUserDao;
import com.gccloud.dataroom.core.module.biz.component.dto.BizComponentDTO;
import com.gccloud.dataroom.core.module.biz.component.dto.BizComponentSearchDTO;
import com.gccloud.dataroom.core.module.biz.component.entity.BizComponentEntity;
import com.gccloud.dataroom.core.module.biz.component.entity.BizComponentUser;
import com.gccloud.dataroom.core.module.biz.component.service.IBizComponentService;
import com.gccloud.common.vo.PageVO;
import com.gccloud.common.vo.R;
import com.gccloud.dataroom.core.module.file.dao.DataRoomFileDao;
import com.gccloud.dataroom.core.module.file.entity.DataRoomFileEntity;
import com.gccloud.dataroom.core.permission.Permission;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -41,16 +50,38 @@ public class BizComponentController {
@ApiImplicitParam(name = "name", value = "名称模糊查询", paramType = "query", dataType = "string")
})
public R<PageVO<BizComponentEntity>> getPage(@ApiParam(name = "查询", value = "传入查询的业务条件", required = true) BizComponentSearchDTO searchDTO) {
if (!StringUtils.hasText(searchDTO.getUserId()))
{
throw new GlobalException("用户Id不能为空");
}
PageVO<BizComponentEntity> page = bizComponentService.getPage(searchDTO);
return R.success(page);
}
@Autowired
private DataRoomBizUserDao userDao;
@ApiPermission(permissions = {Permission.Component.ADD})
@PostMapping("/add")
@ApiOperation(value = "新增", notes = "新增", produces = MediaType.APPLICATION_JSON_VALUE)
public R<String> add(@ApiParam(name = "新增", value = "传入新增的业务条件", required = true) @RequestBody BizComponentDTO dto) {
if (!StringUtils.hasText(dto.getUserId()))
{
throw new GlobalException("用户Id不能为空");
}
BizComponentEntity entity = BeanConvertUtils.convert(dto, BizComponentEntity.class);
String code = bizComponentService.add(entity);
//将这个code加入用户的权限
BizComponentUser bizComponentUser = new BizComponentUser();
bizComponentUser.setCode(code);
bizComponentUser.setUserId(dto.getUserId());
userDao.insert(bizComponentUser);
return R.success(code);
}
@ -65,17 +96,39 @@ public class BizComponentController {
}
@ApiPermission(permissions = {Permission.Component.ADD})
@PostMapping("/copy/{code}")
@PostMapping("/copy")
@ApiOperation(value = "复制", notes = "复制", produces = MediaType.APPLICATION_JSON_VALUE)
public R<String> copy( @PathVariable String code) {
public R<String> copy( String code,String userId) {
if (!StringUtils.hasText(userId))
{
throw new GlobalException("用户Id不能为空");
}
String newCode = bizComponentService.copy(code);
//将这个code加入用户的权限
BizComponentUser bizComponentUser = new BizComponentUser();
bizComponentUser.setCode(code);
bizComponentUser.setUserId(userId);
userDao.insert(bizComponentUser);
return R.success(newCode);
}
@Autowired
private DataRoomBizComponentDao dataRoomBizComponentDao;
@ApiPermission(permissions = {Permission.Component.DELETE})
@PostMapping("/delete/{id}")
@ApiOperation(value = "删除", notes = "删除", produces = MediaType.APPLICATION_JSON_VALUE)
public R<Void> delete(@ApiParam(name = "删除", value = "传入删除的业务条件", required = true) @PathVariable String id) {
//判断type是否为1
BizComponentEntity bizComponentEntity = dataRoomBizComponentDao.selectById(id);
if ("1".equals(bizComponentEntity.getType())){
throw new GlobalException("系统文件,请勿删除!");
}
bizComponentService.delete(id);
return R.success();
}

@ -46,4 +46,7 @@ public class BizComponentDTO {
@ApiModelProperty(notes = "模块编码")
private String moduleCode;
@ApiModelProperty(notes = "用户ID")
private String userId;
}

@ -17,4 +17,7 @@ public class BizComponentSearchDTO extends SearchDTO {
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "用户ID")
private String userId;
}

@ -1,11 +1,14 @@
package com.gccloud.dataroom.core.module.biz.component.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gccloud.dataroom.core.config.DataRoomConfig;
import com.gccloud.dataroom.core.module.biz.component.dao.DataRoomBizComponentDao;
import com.gccloud.dataroom.core.module.biz.component.dao.DataRoomBizUserDao;
import com.gccloud.dataroom.core.module.biz.component.dto.BizComponentSearchDTO;
import com.gccloud.dataroom.core.module.biz.component.entity.BizComponentEntity;
import com.gccloud.dataroom.core.module.biz.component.entity.BizComponentUser;
import com.gccloud.dataroom.core.module.biz.component.service.IBizComponentService;
import com.gccloud.dataroom.core.module.file.entity.DataRoomFileEntity;
import com.gccloud.dataroom.core.module.file.service.IDataRoomOssService;
@ -17,12 +20,16 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.*;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author hongyang
@ -39,13 +46,46 @@ public class BizComponentServiceImpl extends ServiceImpl<DataRoomBizComponentDao
@Resource
private IDataRoomOssService ossService;
@Autowired
private DataRoomBizUserDao userDao;
@Override
public PageVO<BizComponentEntity> getPage(BizComponentSearchDTO searchDTO) {
final List<String> collect ;
LambdaQueryWrapper<BizComponentUser> userQueryWrapper = new LambdaQueryWrapper<>();
userQueryWrapper.select(BizComponentUser::getCode);
userQueryWrapper.eq(BizComponentUser::getUserId,searchDTO.getUserId());
List<BizComponentUser> bizComponentUserList = userDao.selectList(userQueryWrapper);
// 使用三元运算符处理空情况
collect = bizComponentUserList.isEmpty() ?
Collections.emptyList() :
bizComponentUserList.stream().map(BizComponentUser::getCode).collect(Collectors.toList());
LambdaQueryWrapper<BizComponentEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(searchDTO.getName()), BizComponentEntity::getName, searchDTO.getName());
queryWrapper.eq(StringUtils.isNotBlank(searchDTO.getType()), BizComponentEntity::getType, searchDTO.getType());
queryWrapper.orderByAsc(BizComponentEntity::getOrderNum);
// queryWrapper.in(BizComponentEntity::getCode,collect);
// 添加 AND 查询条件,既要 getCode 符合条件,又要 getType 为 "1"
// queryWrapper.and(wrapper ->
// wrapper.in(BizComponentEntity::getCode, collect)
// .eq(BizComponentEntity::getType, "1")
// );
// 添加 OR 查询条件,查询既符合 getCode 条件的数据,也符合 getType 为 "1" 的数据
queryWrapper.and(wrapper -> wrapper
.in(BizComponentEntity::getCode, collect)
.or()
.eq(BizComponentEntity::getType, "1")
);
queryWrapper.orderByDesc(BizComponentEntity::getCreateDate);
PageVO<BizComponentEntity> page = this.page(searchDTO, queryWrapper);
List<BizComponentEntity> list = page.getList();
String urlPrefix = bigScreenConfig.getFile().getBasePath();

@ -1,6 +1,8 @@
package com.gccloud.dataroom.core.module.file.controller;
import com.gccloud.common.exception.GlobalException;
import com.gccloud.common.permission.ApiPermission;
import com.gccloud.dataroom.core.module.file.dao.DataRoomFileDao;
import com.gccloud.dataroom.core.module.file.dto.FileSearchDTO;
import com.gccloud.dataroom.core.module.file.entity.DataRoomFileEntity;
import com.gccloud.dataroom.core.module.file.service.IDataRoomFileService;
@ -38,6 +40,9 @@ public class DataRoomFileController extends SuperController {
@Resource
private IDataRoomFileService fileService;
@Resource
private DataRoomFileDao dataRoomFileDao;
@ApiPermission(permissions = {Permission.File.VIEW})
@GetMapping(value = {"", "/"})
@ApiOperation(value = "列表", position = 10, notes = "分页查询文件", produces = MediaType.APPLICATION_JSON_VALUE)
@ -47,6 +52,12 @@ public class DataRoomFileController extends SuperController {
@ApiImplicitParam(name = "searchKey", value = "查询条件", paramType = "query", dataType = "string")
})
public R<PageVO<DataRoomFileVO>> getPage(@ApiParam(name = "查询", value = "传入查询的业务条件", required = true) FileSearchDTO searchDTO) {
if (!org.springframework.util.StringUtils.hasText(searchDTO.getUserId()))
{
throw new GlobalException("用户Id不能为空");
}
PageVO<DataRoomFileEntity> page = fileService.getPage(searchDTO);
PageVO<DataRoomFileVO> pageVO = BeanConvertUtils.convertPage(page, DataRoomFileVO.class);
return R.success(pageVO);
@ -88,6 +99,11 @@ public class DataRoomFileController extends SuperController {
@PostMapping("/delete/{id}")
@ApiOperation(value = "删除", notes = "删除", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public R<Boolean> delete(@PathVariable("id") String id) {
//删除之前判断是否为内置
DataRoomFileEntity dataRoomFileEntity = dataRoomFileDao.selectById(id);
if ("999999999".equals(dataRoomFileEntity.getUserName())){
throw new GlobalException("系统文件,请勿删除!");
}
sysOssService.delete(id);
return R.success(true);
}

@ -24,5 +24,7 @@ public class FileSearchDTO extends SearchDTO {
*/
private List<String> extensionList;
private String userId;
}

@ -31,9 +31,15 @@ public class DataRoomFileServiceImpl extends ServiceImpl<DataRoomFileDao, DataRo
LambdaQueryWrapper<DataRoomFileEntity> queryWrapper = QueryWrapperUtils.wrapperLike(new LambdaQueryWrapper(), searchDTO.getSearchKey(), DataRoomFileEntity::getOriginalName);
queryWrapper.eq(StringUtils.isNotBlank(searchDTO.getModule()), DataRoomFileEntity::getModule, searchDTO.getModule());
queryWrapper.eq(StringUtils.isNotBlank(searchDTO.getExtension()), DataRoomFileEntity::getExtension, searchDTO.getExtension());
queryWrapper.eq(DataRoomFileEntity::getUserName, searchDTO.getUserId()).or(query->query.eq(DataRoomFileEntity::getUserName,"999999999"));
if (searchDTO.getExtensionList() != null && searchDTO.getExtensionList().size() > 0) {
queryWrapper.in(DataRoomFileEntity::getExtension, searchDTO.getExtensionList());
}
if (org.springframework.util.StringUtils.hasText(searchDTO.getSearchKey())) {
queryWrapper.like(DataRoomFileEntity::getOriginalName, searchDTO.getSearchKey());
}
queryWrapper.orderByDesc(DataRoomFileEntity::getCreateDate);
return page(searchDTO, queryWrapper);
}

@ -125,14 +125,30 @@ public class DataRoomPageController {
}
@ApiPermission(permissions = {Permission.DataRoom.ADD})
@PostMapping("/copy/{code}")
@PostMapping("/copy")
@ApiOperation(value = "复制大屏/组件", position = 50, produces = MediaType.APPLICATION_JSON_VALUE)
public R<String> copy(@PathVariable String code) {
public R<String> copy(String code,String userId) {
if (!StringUtils.hasText(userId))
{
throw new GlobalException("用户Id不能为空");
}
PageEntity bigScreenPage = bigScreenPageService.getByCode(code);
if (bigScreenPage == null) {
throw new GlobalException("大屏页不存在");
}
String newCode = bigScreenPageService.copy(bigScreenPage);
//将这个code加入用户的权限
BizComponentUser bizComponentUser = new BizComponentUser();
bizComponentUser.setCode(newCode);
bizComponentUser.setUserId(userId);
bizComponentUser.setType(bigScreenPage.getType());
userDao.insert(bizComponentUser);
return R.success(newCode);
}

@ -440,6 +440,7 @@ public class DataRoomPageServiceImpl extends ServiceImpl<DataRoomPageDao, PageEn
screenEntity.setCoverPicture(copyUrl);
}
this.save(screenEntity);
dataRoomExtendClient.afterAdd(screenEntity.getCode());
return screenEntity.getCode();
}

@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -130,7 +131,10 @@ public class TypeServiceImpl extends ServiceImpl<DataRoomTypeDao, TypeEntity> im
//获取所有code
LambdaQueryWrapper<BizComponentUser> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
userLambdaQueryWrapper.eq(BizComponentUser::getUserId,userId);
userLambdaQueryWrapper.eq(BizComponentUser::getType,type);
ArrayList<String> stringArrayList = new ArrayList<>(1024);
stringArrayList.add("bizComponentCatalog");
stringArrayList.add(type);
userLambdaQueryWrapper.in(BizComponentUser::getType,stringArrayList);
List<BizComponentUser> bizComponentUserList = userDao.selectList(userLambdaQueryWrapper);
List<String> codeList = bizComponentUserList.stream().map(code -> code.getCode()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(codeList))

@ -3,6 +3,12 @@ server:
port: 8081
servlet:
context-path: /bigScreenServer
ssl:
key-store: classpath:szyx.sztzjy.com.pfx
key-store-password: u15a19un
key-store-type: PKCS12
enabled: true
client-auth: none
# spring环境配置
spring:
@ -36,9 +42,9 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.p6spy.engine.spy.P6SpyDriver
url: jdbc:p6spy:mysql://118.31.7.2:3306/dashboard?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
url: jdbc:p6spy:mysql://120.79.54.255:3306/dashboard?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
username: root
password: sztzjy2017
password: Sztzjy506
mybatis-plus:
# mybatis plus xml配置文件扫描多个通过分号隔开
@ -53,6 +59,6 @@ gc:
starter:
file:
basePath: /usr/local/tianzeProject/largeScreen/uploadFile/img
img: http://118.31.7.2:96/file
img: http://120.79.54.255:96/file

Loading…
Cancel
Save