|
|
|
@ -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();
|
|
|
|
|
}
|
|
|
|
|