ff4f1ba1 by 荆蔚杰

案卷附件查询接口.删除接口.

1 parent e16a5805
......@@ -39,7 +39,7 @@ public class DgArchivesCatalogDO implements Serializable {
* 序号
*/
@TableField("XH")
private String xh;
private Integer xh;
/**
* 材料编码
......
......@@ -32,7 +32,7 @@ public class AddDgArchivesCatalogRequest implements Serializable {
* 序号
*/
@ApiModelProperty(name = "xh", value = "序号")
private String xh;
private Integer xh;
/**
* 材料编码
......
......@@ -37,7 +37,7 @@ public class DgArchivesCatalogDetailVO implements Serializable {
* 序号
*/
@ApiModelProperty(name = "xh", value = "序号")
private String xh;
private Integer xh;
/**
* 材料编码
......
......@@ -38,7 +38,7 @@ public class DgArchivesCatalogListVO implements Serializable {
* 序号
*/
@ApiModelProperty(name = "xh", value = "序号")
private String xh;
private Integer xh;
/**
* 材料编码
......
......@@ -39,7 +39,7 @@ public class DgArchivesCatalogSearchRequest extends PageInfo implements Serializ
* 序号
*/
@ApiModelProperty(name = "xh", value = "序号")
private String xh;
private Integer xh;
/**
* 材料编码
......
......@@ -37,7 +37,7 @@ public class UpdateDgArchivesCatalogRequest implements Serializable {
* 序号
*/
@ApiModelProperty(name = "xh", value = "序号")
private String xh;
private Integer xh;
/**
* 材料编码
......
package com.pashanhoo.common.util;
package com.pashanhoo.common.util.fileupload;
import polaris.fileattachment.AttachmentService;
import polaris.fileattachment.models.FileUrl;
......
package com.pashanhoo.common.util.fileupload;
import com.pashanhoo.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* 文件上传
*/
@Api(tags = "文件控制器")
@RequestMapping("/file")
@RestController
public class FileController {
@Autowired
MinioUtil minioUtil;
@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ApiOperation("上传单个文件")
public Result upload(@RequestPart("file") MultipartFile file, HttpServletResponse response) {
try {
return Result.ok(minioUtil.upload(file));
} catch (Exception e) {
return Result.exception(e.getMessage());
}
}
@RequestMapping(value = "/batchUpload", method = RequestMethod.POST,headers = "content-type=multipart/form-data")
@ApiOperation("上传多个文件")
public Result upload(@RequestPart("file") MultipartFile[] files, HttpServletResponse response) {
try {
return Result.ok(minioUtil.batchUpload(files));
} catch (Exception e) {
return Result.exception(e.getMessage());
}
}
}
package com.pashanhoo.common.util;
package com.pashanhoo.common.util.fileupload;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
......
package com.pashanhoo.common.util;
package com.pashanhoo.common.util.fileupload;
import io.minio.MinioClient;
import io.minio.errors.*;
......@@ -17,6 +17,7 @@ import java.util.*;
*/
@Component
public class MinioUtil {
private MinioClient minioClient;
@Autowired
MinioConfig minioConfig;
......@@ -34,7 +35,7 @@ public class MinioUtil {
* 文件上传
*
* @param file
* @return
* @return minio文件路径
* @throws IOException
*/
public String upload(MultipartFile file) throws IOException {
......@@ -53,14 +54,14 @@ public class MinioUtil {
// 下载地址
String saveUrl = savePath + "/" + originalFilename;
// 浏览器直接预览地址,针对图片
String pUrl = minioConfig.getType() + minioConfig.getEndpoint() + "/file/" + savePath + "/" + originalFilename;
String pUrl = minioConfig.getType() + minioConfig.getEndpoint() + "/file/" + saveUrl;
try {
minioClient.putObject(minioConfig.getBucket(), saveUrl, file.getInputStream(), contentType);
} catch (Exception e) {
e.printStackTrace();
}
return pUrl;
return saveUrl;
}
/**
......@@ -74,8 +75,8 @@ public class MinioUtil {
Assert.notNull(files, "上传文件为空");
List<String> list = new ArrayList<>();
for (MultipartFile file : files) {
String pUrl = this.upload(file);
list.add(pUrl);
String saveUrl = this.upload(file);
list.add(saveUrl);
}
return list;
}
......@@ -91,6 +92,15 @@ public class MinioUtil {
minioClient.removeObject(bucketName, objectName);
}
/**
* 根据存储路径组装下载预览路径
* @param saveUrl
* @return
*/
public String getPreviewUrl(String saveUrl) {
return minioConfig.getType() + minioConfig.getEndpoint() + "/file/" + saveUrl;
}
private static final Map<String, String> contentTypeMap = new HashMap<>() {
{
put("323", "text/h323");
......
......@@ -3,6 +3,7 @@ package com.pashanhoo.file.controller;
import com.pashanhoo.common.Result;
import com.pashanhoo.file.entity.vo.AddDgFileRequest;
import com.pashanhoo.file.entity.vo.DgFileListVO;
import com.pashanhoo.file.entity.vo.UpdateDgFileRequest;
import com.pashanhoo.file.entity.vo.DgFileSearchRequest;
import com.pashanhoo.file.service.DgFileService;
......@@ -64,9 +65,8 @@ public class DgFileController {
@PostMapping("search")
@ApiOperation(value = "根据条件进行列表查询")
public Result searchDgFileList(@RequestBody DgFileSearchRequest request) {
//TODO 默认排序条件设置
request.defaultFillPageProp("","");
public Result<List<DgFileListVO>> searchDgFileList(@RequestBody DgFileSearchRequest request) {
return Result.ok(dgfileService.searchDgFileList(request));
}
}
......
......@@ -2,6 +2,9 @@ package com.pashanhoo.file.entity.vo;
import java.util.Date;
import java.io.Serializable;
import java.util.List;
import com.pashanhoo.catalog.entity.vo.DgArchivesCatalogListVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -18,7 +21,6 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="档案文件信息列表VO")
//TODO 该类属性暂时是完整的全部属性,需进行个性化的增删
public class DgFileListVO implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -65,5 +67,16 @@ public class DgFileListVO implements Serializable {
@ApiModelProperty(name = "fjsize", value = "附件大小")
private String fjsize;
/**
* 文件名称
*/
@ApiModelProperty(name = "wjmc", value = "档案目录信息")
private String wjmc;
/**
* 序号
*/
@ApiModelProperty(name = "xh", value = "序号")
private Integer xh;
}
......
......@@ -19,7 +19,6 @@ import com.pashanhoo.common.PageInfo;
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="档案文件信息列表查询请求实体")
//TODO 初始查询条件是全部,需要根据情况自行删减
public class DgFileSearchRequest extends PageInfo implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -66,5 +65,9 @@ public class DgFileSearchRequest extends PageInfo implements Serializable {
@ApiModelProperty(name = "fjsize", value = "附件大小")
private String fjsize;
/**
* 档案标识码
*/
@ApiModelProperty(name = "bsmArchives", value = "档案标识码")
private String bsmArchives;
}
......
......@@ -3,6 +3,11 @@ package com.pashanhoo.file.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pashanhoo.file.entity.DgFileDO;
import com.pashanhoo.file.entity.vo.DgFileListVO;
import com.pashanhoo.file.entity.vo.DgFileSearchRequest;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
......@@ -14,4 +19,10 @@ import com.pashanhoo.file.entity.DgFileDO;
*/
public interface DgFileMapper extends BaseMapper<DgFileDO> {
/**
* 查询附件以及名称和排序
* @param request
* @return
*/
List<DgFileListVO> selectFileWithNameAndSort(@Param("request") DgFileSearchRequest request);
}
......
package com.pashanhoo.file.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pashanhoo.file.entity.DgFileDO;
import com.pashanhoo.file.entity.vo.AddDgFileRequest;
import com.pashanhoo.file.entity.vo.DgFileDetailVO;
import com.pashanhoo.file.entity.vo.UpdateDgFileRequest;
import com.pashanhoo.file.entity.vo.DgFileSearchRequest;
import com.pashanhoo.file.entity.vo.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
/**
* <p>
* 档案文件信息 服务类
......@@ -43,5 +43,5 @@ public interface DgFileService extends IService<DgFileDO> {
* @param request
* @return
*/
Page searchDgFileList(DgFileSearchRequest request);
List<DgFileListVO> searchDgFileList(DgFileSearchRequest request);
}
......
package com.pashanhoo.file.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pashanhoo.common.util.fileupload.MinioUtil;
import com.pashanhoo.file.entity.DgFileConverter;
import com.pashanhoo.file.entity.DgFileDO;
import com.pashanhoo.file.entity.vo.AddDgFileRequest;
import com.pashanhoo.file.entity.vo.DgFileDetailVO;
import com.pashanhoo.file.entity.vo.UpdateDgFileRequest;
import com.pashanhoo.file.entity.vo.DgFileSearchRequest;
import com.pashanhoo.file.entity.vo.*;
import com.pashanhoo.file.mapper.DgFileMapper;
import com.pashanhoo.file.service.DgFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;
/**
* <p>
* 档案文件信息 服务实现类
......@@ -32,6 +31,9 @@ public class DgFileServiceImpl extends ServiceImpl<DgFileMapper, DgFileDO> imple
@Autowired
private DgFileMapper dgfileMapper;
@Autowired
MinioUtil minioUtil;
/**
* 新增记录
* @param request
......@@ -71,17 +73,19 @@ public class DgFileServiceImpl extends ServiceImpl<DgFileMapper, DgFileDO> imple
* @return
*/
@Override
public Page searchDgFileList(DgFileSearchRequest request) {
Page<DgFileDO> pageParam = new Page<DgFileDO>(request.getCurrentPage(), request.getPageSize());
public List<DgFileListVO> searchDgFileList(DgFileSearchRequest request) {
QueryWrapper<DgFileDO> wrapper = new QueryWrapper<>();
//设置默认排序
wrapper = "desc".equals(request.getSortOrder()) ? wrapper.orderByDesc(request.getSortField()) : wrapper.orderByAsc(request.getSortField());
//TODO 根据当前情况设置wrapper条件
List<DgFileListVO> fileListVOS = dgfileMapper.selectFileWithNameAndSort(request);
Page page = this.page(pageParam, wrapper);
//将查询出来的DO List转为 ListVO List并重新设置到page对象中,并返回page对象
return page.setRecords(dgfileConverter.doList2ListVOList(page.getRecords()));
for (DgFileListVO fileListVO : fileListVOS) {
if (fileListVO.getFjurl() != null) {
String previewUrl = minioUtil.getPreviewUrl(fileListVO.getFjurl());
fileListVO.setFjurl(previewUrl);
}
}
return fileListVOS;
}
}
......
......@@ -68,7 +68,7 @@ minio:
params:
type: http://
bucket: archive
host: 192.168.2.218
endpoint: 192.168.2.218
port: 8989
user: minioadmin
password: minioadmin
accessKeyId: minioadmin
accessKeySecret: minioadmin
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pashanhoo.file.mapper.DgFileMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.pashanhoo.file.entity.DgFileDO">
<id column="BSM_FILE" property="bsmFile" />
<result column="BSM_CATALOG" property="bsmCatalog" />
<result column="KZM" property="kzm" />
<result column="SCRQ" property="scrq" />
<result column="SCR" property="scr" />
<result column="FJURL" property="fjurl" />
<result column="FJSIZE" property="fjsize" />
<id column="BSM_FILE" property="bsmFile"/>
<result column="BSM_CATALOG" property="bsmCatalog"/>
<result column="KZM" property="kzm"/>
<result column="SCRQ" property="scrq"/>
<result column="SCR" property="scr"/>
<result column="FJURL" property="fjurl"/>
<result column="FJSIZE" property="fjsize"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
BSM_FILE, BSM_CATALOG, KZM, SCRQ, SCR, FJURL, FJSIZE
BSM_FILE,
BSM_CATALOG,
KZM,
SCRQ,
SCR,
FJURL,
FJSIZE
</sql>
<select id="selectFileWithNameAndSort" resultType="com.pashanhoo.file.entity.vo.DgFileListVO">
select DF.*, DAC.WJMC, DAC.XH
from DG_FILE DF
left join DG_ARCHIVES_CATALOG DAC on DAC.BSM_CATALOG =
DF.BSM_CATALOG
<where>
<if test="request.bsmArchives != null and request.bsmArchives != ''">
BSM_ARCHIVES = #{request.bsmArchives,jdbcType=VARCHAR}
</if>
</where>
order by XH;
</select>
</mapper>
......