提交代码

This commit is contained in:
huangzj
2023-08-30 15:55:45 +08:00
parent da374bcccf
commit e5967ef694
7 changed files with 117 additions and 3 deletions

View File

@@ -0,0 +1,85 @@
package com.njcn.system.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.FileUtil;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.LargeScreenParam;
import com.njcn.device.pq.pojo.vo.DataScaleVO;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.InputStreamResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;
import java.util.Objects;
/**
* Description:
* Date: 2023/8/30 11:08【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@Api(tags = "图片处理")
@RestController
@AllArgsConstructor
@RequestMapping("/image")
public class ImageToStreamController extends BaseController {
private final FileStorageUtil fileStorageUtil;
/**
* 数据规模
*/
@GetMapping("/toStream")
@ApiImplicitParam(name = "bgImage", value = "图片路径", required = true)
public void toStream(@RequestParam("bgImage") String bgImage,HttpServletResponse response) {
byte[] buffer = new byte[1024];
FileInputStream fis = null;
BufferedInputStream bis = null;
try {
//获取部分参数用于从minIO上将文件下载到tmp此步骤不是必须
InputStream fileStream = fileStorageUtil.getFileStream(bgImage);
response.setContentType("application/octet-stream");
response.setHeader("content-type", "image/png");
response.setHeader("Content-Disposition", "attachment;fileName=download" +System.currentTimeMillis() + "");// 设置文件名
//返回流处理
bis = new BufferedInputStream(fileStream);
OutputStream os = response.getOutputStream();
int i = bis.read(buffer);
while (i != -1) {
os.write(buffer, 0, i);
i = bis.read(buffer);
}
}catch (Exception e) {
}finally {
if (bis != null) {
try {
bis.close();
} catch (IOException ignored) {
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException ignored) {
}
}
}
}
}

View File

@@ -12,6 +12,7 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.system.pojo.po.UserLog;
import com.njcn.system.service.IUserLogService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import com.njcn.web.utils.RequestUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -63,7 +64,8 @@ public class UserLogController extends BaseController {
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
@PostMapping("/query")
@ApiOperation("查询审计日志(治理模块)")
public HttpResult<List<UserLog>> queryUserLog() {
@ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
public HttpResult<List<UserLog>> queryUserLog(@RequestBody BaseParam baseParam) {
String methodDescribe = getMethodDescribe("queryUserLog");
List<UserLog> list = userLogService.lambdaQuery().eq(UserLog::getLoginName, RequestUtil.getUsername()).
in(UserLog::getServiceName, Stream.of(ServerInfo.CS_DEVICE_BOOT,
@@ -71,7 +73,8 @@ public class UserLogController extends BaseController {
ServerInfo.CS_REPORT_BOOT,
ServerInfo.CS_EVENT_BOOT,
ServerInfo.CS_WARN_BOOT,
ServerInfo.CS_SYSTEM_BOOT).collect(Collectors.toList())).orderByDesc(UserLog::getCreateTime).last("limit 100").list();
ServerInfo.CS_SYSTEM_BOOT).collect(Collectors.toList())).between(UserLog::getCreateTime,baseParam.getSearchBeginTime(),baseParam.getSearchEndTime())
.orderByDesc(UserLog::getCreateTime).last("limit 100").list();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}