zbj//1.大屏获取暂降事件最新50条数据sql更改 2.资源管理 删除资源/下载资源/修改资源
This commit is contained in:
@@ -16,6 +16,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -39,10 +42,10 @@ public class ResourceAdministrationController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/uploadFile")
|
||||
@ApiOperation("上传资源")
|
||||
public HttpResult<Boolean> uploadFile(@ApiParam(value = "文件", required = true)@RequestPart("multipartFile") MultipartFile multipartFile,
|
||||
@ApiParam(value = "资源名称", required = true)String name,
|
||||
public HttpResult<Boolean> uploadFile(@ApiParam(value = "文件", required = true) @RequestPart("multipartFile") MultipartFile multipartFile,
|
||||
@ApiParam(value = "资源名称", required = true) String name,
|
||||
@ApiParam(value = "资源类型", required = true) String type,
|
||||
@ApiParam(value = "资源描述", required = false)String describe,
|
||||
@ApiParam(value = "资源描述", required = false) String describe,
|
||||
@ApiParam(value = "系统类型Guid", required = true) String systemType) {
|
||||
String methodDescribe = getMethodDescribe("uploadFile");
|
||||
Boolean flag = iResourceAdministrationService.uploadFile(multipartFile, name, type, describe, systemType);
|
||||
@@ -55,10 +58,65 @@ public class ResourceAdministrationController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryData")
|
||||
@ApiOperation("查询数据")
|
||||
@ApiImplicitParam(name = "baseParam",value = "查询数据",required = true)
|
||||
@ApiImplicitParam(name = "baseParam", value = "查询数据", required = true)
|
||||
public HttpResult<List<Resinformation>> queryData(@RequestBody @Validated BaseParam baseParam) {
|
||||
String methodDescribe = getMethodDescribe("queryData");
|
||||
List<Resinformation> result = iResourceAdministrationService.queryData(baseParam);
|
||||
List<Resinformation> result = iResourceAdministrationService.queryData(baseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改资源
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateFile")
|
||||
@ApiOperation("修改资源")
|
||||
public HttpResult<Boolean> updateFile(@ApiParam(value = "文件", required = true) @RequestPart("multipartFile") MultipartFile multipartFile,
|
||||
@ApiParam(value = "id", required = true) String id,
|
||||
@ApiParam(value = "资源名称", required = true) String name,
|
||||
@ApiParam(value = "资源类型", required = true) String type,
|
||||
@ApiParam(value = "资源描述", required = false) String describe,
|
||||
@ApiParam(value = "系统类型Guid", required = true) String systemType) {
|
||||
String methodDescribe = getMethodDescribe("updateFile");
|
||||
Boolean flag = iResourceAdministrationService.updateFile(multipartFile, id, name, type, describe, systemType);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除资源
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/deleteFile")
|
||||
@ApiOperation("删除资源")
|
||||
@ApiImplicitParam(name = "id",value = "id",required = true)
|
||||
public HttpResult<Boolean> deleteFile(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("deleteFile");
|
||||
Boolean flag = iResourceAdministrationService.deleteFile(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载资源
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/downloadFile")
|
||||
@ApiOperation("下载资源")
|
||||
@ApiImplicitParam(name = "id",value = "id",required = true)
|
||||
public HttpResult<Object> downloadFile(@RequestParam("id")String id,HttpServletResponse response) throws IOException {
|
||||
String methodDescribe = getMethodDescribe("downloadFile");
|
||||
iResourceAdministrationService.downloadFile(id,response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "下载成功", methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*/
|
||||
/*@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/exportData")
|
||||
@ApiOperation("导出数据")
|
||||
public HttpResult<Object> exportData() {
|
||||
String methodDescribe = getMethodDescribe("exportData");
|
||||
iResourceAdministrationService.exportData();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "成功", methodDescribe);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.system.pojo.po.Resinformation;
|
||||
import com.njcn.system.pojo.po.ResinformationParam;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: zbj
|
||||
@@ -12,4 +15,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@Mapper
|
||||
public interface ResourceAdministrationMapper extends BaseMapper<Resinformation> {
|
||||
List<ResinformationParam> listAll();
|
||||
}
|
||||
|
||||
@@ -2,4 +2,9 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.system.mapper.ResourceAdministrationMapper">
|
||||
|
||||
<select id="listAll" resultType="com.njcn.system.pojo.po.ResinformationParam">
|
||||
SELECT pr.`NAME` "name", sdd.`Name` "type", pr.DESCRIPTION "description", pr.UPDATETIME "time"
|
||||
FROM pqs_resinformation pr
|
||||
left join sys_dict_data sdd on sdd.Id = pr.TYPE
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.njcn.system.pojo.po.Resinformation;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -15,7 +18,15 @@ import java.util.List;
|
||||
*/
|
||||
public interface IResourceAdministrationService extends IService<Resinformation> {
|
||||
|
||||
Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe,String systemType);
|
||||
Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe, String systemType);
|
||||
|
||||
List<Resinformation> queryData(BaseParam baseParam);
|
||||
|
||||
Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String describe, String systemType);
|
||||
|
||||
Boolean deleteFile(String id);
|
||||
|
||||
void downloadFile(String id,HttpServletResponse response) throws IOException;
|
||||
|
||||
void exportData();
|
||||
}
|
||||
|
||||
@@ -3,11 +3,15 @@ package com.njcn.system.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.system.mapper.ResourceAdministrationMapper;
|
||||
import com.njcn.system.pojo.po.Resinformation;
|
||||
import com.njcn.system.pojo.po.ResinformationParam;
|
||||
import com.njcn.system.service.IResourceAdministrationService;
|
||||
import com.njcn.user.pojo.dto.excel.UserExcel;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -16,6 +20,10 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -34,6 +42,8 @@ public class ResourceAdministrationServiceImpl extends ServiceImpl<ResourceAdmin
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
//private final GeneralInfo generalInfo;
|
||||
|
||||
@Override
|
||||
public Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe, String systemType) {
|
||||
//通过封装好的文件工具类来传入文件和文件夹名称来获取文件路径
|
||||
@@ -41,7 +51,7 @@ public class ResourceAdministrationServiceImpl extends ServiceImpl<ResourceAdmin
|
||||
//创建对象
|
||||
Resinformation resinformation = new Resinformation();
|
||||
resinformation.setName(name);
|
||||
if (Objects.nonNull(describe)) {
|
||||
if (StringUtils.isNotBlank(describe)) {
|
||||
resinformation.setDescription(describe);
|
||||
}
|
||||
resinformation.setUrl(url);
|
||||
@@ -66,4 +76,55 @@ public class ResourceAdministrationServiceImpl extends ServiceImpl<ResourceAdmin
|
||||
return this.page(new Page<>(baseParam.getPageNum(), baseParam.getPageSize())).getRecords();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String describe, String systemType) {
|
||||
Resinformation resinformation = resourceAdministrationMapper.selectById(id);
|
||||
//删除文件
|
||||
fileStorageUtil.deleteFile(resinformation.getUrl());
|
||||
//获取路径
|
||||
String url = fileStorageUtil.uploadMultipart(multipartFile, OssPath.RESOURCEADMINISTRATION);
|
||||
resinformation.setUrl(url);
|
||||
resinformation.setName(name);
|
||||
if (StringUtils.isNotBlank(describe)) {
|
||||
resinformation.setDescription(describe);
|
||||
}
|
||||
//获取用户id
|
||||
//String userIndex = RequestUtil.getUserIndex();
|
||||
String userIndex = "123456";
|
||||
resinformation.setUpdateUser(userIndex);
|
||||
resinformation.setUpdateTime(LocalDateTime.now());
|
||||
resinformation.setState(1);
|
||||
resinformation.setSystemType(systemType);
|
||||
resinformation.setType(type);
|
||||
int i = resourceAdministrationMapper.updateById(resinformation);
|
||||
return i > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteFile(String id) {
|
||||
Resinformation resinformation = resourceAdministrationMapper.selectById(id);
|
||||
//删除文件
|
||||
fileStorageUtil.deleteFile(resinformation.getUrl());
|
||||
//删除数据
|
||||
int i = resourceAdministrationMapper.deleteById(id);
|
||||
return i > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadFile(String id,HttpServletResponse response) throws IOException {
|
||||
Resinformation resinformation = resourceAdministrationMapper.selectById(id);
|
||||
//下载文件
|
||||
fileStorageUtil.downloadStream(response,resinformation.getUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportData() {
|
||||
String fileName = "资源列表.csv";
|
||||
//String targetDir = generalInfo.getBusinessTempPath() + File.separator + RequestUtil.getUserIndex();
|
||||
String targetDir = "C:\\Users\\User\\Desktop\\1";
|
||||
File excel = new File(targetDir, fileName);
|
||||
List<ResinformationParam> list = resourceAdministrationMapper.listAll();
|
||||
ExcelUtil.exportExcelWithTargetFile(excel, ResinformationParam.class, list);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user