zbj//1.代码调整
This commit is contained in:
@@ -3,6 +3,7 @@ package com.njcn.device.pq.pojo.po;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -47,12 +48,14 @@ public class ResourceData {
|
|||||||
* 数据上传时间
|
* 数据上传时间
|
||||||
*/
|
*/
|
||||||
@TableField(value = "upload_time")
|
@TableField(value = "upload_time")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime uploadTime;
|
private LocalDateTime uploadTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据修改时间
|
* 数据修改时间
|
||||||
*/
|
*/
|
||||||
@TableField(value = "update_time")
|
@TableField(value = "update_time")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -55,12 +55,13 @@ public class ResourceController extends BaseController {
|
|||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/uploadFile")
|
@PostMapping("/uploadFile")
|
||||||
@ApiOperation("上传资源")
|
@ApiOperation("上传资源")
|
||||||
public HttpResult<Boolean> uploadFile(@ApiParam(value = "文件", required = true) @RequestPart("multipartFile") MultipartFile multipartFile,
|
public HttpResult<Boolean> uploadFile(@ApiParam(value = "文件", required = true) MultipartFile multipartFile,
|
||||||
@ApiParam(value = "文件", required = false) @RequestPart("picture") MultipartFile picture,
|
@ApiParam(value = "文件", required = false) MultipartFile picture,
|
||||||
@ApiParam(value = "资源名称", required = true) String name,
|
@ApiParam(value = "资源名称", required = true) String name,
|
||||||
|
@ApiParam(value = "资源状态", required = true) Integer state,
|
||||||
@ApiParam(value = "资源类型", required = true) Integer type) {
|
@ApiParam(value = "资源类型", required = true) Integer type) {
|
||||||
String methodDescribe = getMethodDescribe("uploadFile");
|
String methodDescribe = getMethodDescribe("uploadFile");
|
||||||
Boolean flag = iResourceAdministrationService.uploadFile(multipartFile, picture, name, type);
|
Boolean flag = iResourceAdministrationService.uploadFile(multipartFile, picture, name, state, type);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,10 +73,11 @@ public class ResourceController extends BaseController {
|
|||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/queryData")
|
@PostMapping("/queryData")
|
||||||
@ApiOperation("查询数据")
|
@ApiOperation("查询数据")
|
||||||
public HttpResult<List<ResourceData>> queryData(@RequestParam(value = "type", required = false) Integer type,
|
public HttpResult<List<ResourceData>> queryData(@ApiParam(value = "资源类型", required = false) Integer type,
|
||||||
@RequestParam(value = "state", required = false) Integer state) {
|
@ApiParam(value = "资源状态", required = false) Integer state,
|
||||||
|
@ApiParam(value = "搜索框数据", required = false) String searchValue) {
|
||||||
String methodDescribe = getMethodDescribe("queryData");
|
String methodDescribe = getMethodDescribe("queryData");
|
||||||
List<ResourceData> result = iResourceAdministrationService.queryData(type,state);
|
List<ResourceData> result = iResourceAdministrationService.queryData(type, state, searchValue);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface ResourceService extends IService<ResourceData> {
|
public interface ResourceService extends IService<ResourceData> {
|
||||||
|
|
||||||
Boolean uploadFile(MultipartFile multipartFile, MultipartFile picture, String name, Integer type);
|
Boolean uploadFile(MultipartFile multipartFile, MultipartFile picture, String name, Integer state, Integer type);
|
||||||
|
|
||||||
List<ResourceData> queryData(Integer type,Integer state);
|
List<ResourceData> queryData(Integer type,Integer state,String searchValue);
|
||||||
|
|
||||||
void previewFile(String id, HttpServletRequest request, HttpServletResponse response) throws IOException;
|
void previewFile(String id, HttpServletRequest request, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, ResourceDat
|
|||||||
//private final GeneralInfo generalInfo;
|
//private final GeneralInfo generalInfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean uploadFile(MultipartFile multipartFile, MultipartFile picture, String name, Integer type) {
|
public Boolean uploadFile(MultipartFile multipartFile, MultipartFile picture, String name,Integer state, Integer type) {
|
||||||
String resUrl = "";
|
String resUrl = "";
|
||||||
String picUrl = "";
|
String picUrl = "";
|
||||||
//通过封装好的文件工具类来传入文件和文件夹名称来获取文件路径
|
//通过封装好的文件工具类来传入文件和文件夹名称来获取文件路径
|
||||||
@@ -52,26 +52,35 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, ResourceDat
|
|||||||
resourceData.setResUrl(resUrl);
|
resourceData.setResUrl(resUrl);
|
||||||
resourceData.setPicUrl(picUrl);
|
resourceData.setPicUrl(picUrl);
|
||||||
resourceData.setUploadTime(LocalDateTime.now());
|
resourceData.setUploadTime(LocalDateTime.now());
|
||||||
resourceData.setState(1);
|
resourceData.setState(state);
|
||||||
resourceData.setType(type);
|
resourceData.setType(type);
|
||||||
resourceData.setFileName(multipartFile.getOriginalFilename());
|
resourceData.setFileName(multipartFile.getOriginalFilename());
|
||||||
return this.save(resourceData);
|
return this.save(resourceData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ResourceData> queryData(Integer type,Integer state) {
|
public List<ResourceData> queryData(Integer type, Integer state, String searchValue) {
|
||||||
List<ResourceData> list = null;
|
List<ResourceData> list = null;
|
||||||
if (null != type && null != state) {
|
if (null != type || null != state || StringUtils.isNotBlank(searchValue)) {
|
||||||
LambdaQueryWrapper<ResourceData> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<ResourceData> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (null != type) {
|
||||||
//type
|
//type
|
||||||
wrapper.eq(ResourceData::getType, type);
|
wrapper.eq(ResourceData::getType, type);
|
||||||
|
}
|
||||||
|
if (null != state) {
|
||||||
//state
|
//state
|
||||||
wrapper.eq(ResourceData::getState, state);
|
wrapper.eq(ResourceData::getState, state);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(searchValue)) {
|
||||||
|
//name
|
||||||
|
wrapper.like(ResourceData::getResourceName, searchValue);
|
||||||
|
}
|
||||||
list = resourceMapper.selectList(wrapper);
|
list = resourceMapper.selectList(wrapper);
|
||||||
} else {
|
} else {
|
||||||
list = this.list();
|
list = this.list();
|
||||||
}
|
}
|
||||||
for (ResourceData resourceData : list) {
|
for (
|
||||||
|
ResourceData resourceData : list) {
|
||||||
resourceData.setResUrl(fileStorageUtil.getFileUrl(resourceData.getResUrl()));
|
resourceData.setResUrl(fileStorageUtil.getFileUrl(resourceData.getResUrl()));
|
||||||
if (StringUtils.isNotBlank(resourceData.getPicUrl())) {
|
if (StringUtils.isNotBlank(resourceData.getPicUrl())) {
|
||||||
resourceData.setPicUrl(fileStorageUtil.getFileUrl(resourceData.getPicUrl()));
|
resourceData.setPicUrl(fileStorageUtil.getFileUrl(resourceData.getPicUrl()));
|
||||||
|
|||||||
Reference in New Issue
Block a user