feat[文件模块]:任务编号生成文件数据
This commit is contained in:
+12
-1
@@ -1,8 +1,8 @@
|
||||
package com.central.file.controller;
|
||||
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.file.model.FileInfo;
|
||||
import com.central.file.service.IFileService;
|
||||
import com.central.file.utils.HexToJpeg;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -81,6 +81,11 @@ public class FileController {
|
||||
return fileService.getViewUrl(id);
|
||||
}
|
||||
|
||||
@GetMapping("/files/name")
|
||||
public String getViewUrlByName(@RequestParam String name) {
|
||||
return fileService.getViewUrlByName(name);
|
||||
}
|
||||
|
||||
@GetMapping("/type/{id}")
|
||||
public String getFileInfo(@PathVariable String id) {
|
||||
FileInfo fileInfo = fileService.getFileInfo(id);
|
||||
@@ -101,6 +106,12 @@ public class FileController {
|
||||
map.put("filePath", fileInfo.getPath());
|
||||
return Result.succeed(map);
|
||||
}
|
||||
|
||||
@PostMapping("/path")
|
||||
FileInfo creatFileInfo(@RequestBody String path){
|
||||
return fileService.createFile(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取access_token
|
||||
* @return
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.central.file.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.db.mapper.SuperMapper;
|
||||
import com.central.file.model.FileInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.central.file.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.file.model.FileInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -27,5 +27,9 @@ public interface IFileService extends IService<FileInfo> {
|
||||
|
||||
String getViewUrl(String id);
|
||||
|
||||
String getViewUrlByName(String name);
|
||||
|
||||
FileInfo getFileInfo(String id);
|
||||
|
||||
FileInfo createFile(String path);
|
||||
}
|
||||
|
||||
+3
-1
@@ -2,9 +2,9 @@ package com.central.file.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.file.mapper.FileMapper;
|
||||
import com.central.file.model.FileInfo;
|
||||
import com.central.file.service.IFileService;
|
||||
import com.central.file.utils.FileUtil;
|
||||
import com.central.oss.model.ObjectInfo;
|
||||
@@ -108,4 +108,6 @@ public abstract class AbstractIFileService extends ServiceImpl<FileMapper, FileI
|
||||
List<FileInfo> list = baseMapper.findList(page, params);
|
||||
return PageResult.<FileInfo>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||
}
|
||||
|
||||
public abstract String getViewUrlByName(String name);
|
||||
}
|
||||
|
||||
+11
-1
@@ -2,7 +2,7 @@ package com.central.file.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.central.common.constant.CommonConstant;
|
||||
import com.central.file.model.FileInfo;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.oss.model.ObjectInfo;
|
||||
import com.central.oss.properties.FileServerProperties;
|
||||
import com.central.oss.template.CosTemplate;
|
||||
@@ -49,6 +49,11 @@ public class CosService extends AbstractIFileService {
|
||||
cosTemplate.delete(cosObject.getBucketName(), cosObject.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByName(String name) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void out(String id, OutputStream os) {
|
||||
FileInfo fileInfo = baseMapper.selectById(id);
|
||||
@@ -72,6 +77,11 @@ public class CosService extends AbstractIFileService {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo createFile(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private COSObject parsePath(String path) {
|
||||
COSObject cosObject = new COSObject();
|
||||
if (StrUtil.isNotEmpty(path)) {
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
package com.central.file.service.impl;
|
||||
|
||||
import com.central.file.model.FileInfo;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.oss.model.ObjectInfo;
|
||||
import com.central.oss.properties.FileServerProperties;
|
||||
import com.central.oss.template.FdfsTemplate;
|
||||
@@ -45,6 +45,11 @@ public class FastdfsService extends AbstractIFileService {
|
||||
fdfsTemplate.delete(objectPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByName(String name) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void out(String id, OutputStream os) {
|
||||
}
|
||||
@@ -58,4 +63,9 @@ public class FastdfsService extends AbstractIFileService {
|
||||
public FileInfo getFileInfo(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo createFile(String path) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+37
-2
@@ -1,9 +1,10 @@
|
||||
package com.central.file.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aliyun.oss.model.OSSObject;
|
||||
import com.central.common.constant.CommonConstant;
|
||||
import com.central.file.model.FileInfo;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.oss.model.ObjectInfo;
|
||||
import com.central.oss.properties.FileServerProperties;
|
||||
import com.central.oss.template.OssTemplate;
|
||||
@@ -25,12 +26,17 @@ import java.io.OutputStream;
|
||||
@ConditionalOnProperty(prefix = FileServerProperties.PREFIX, name = "type", havingValue = FileServerProperties.TYPE_OSS)
|
||||
public class OssService extends AbstractIFileService {
|
||||
|
||||
private static final String PATH_SPLIT = "/";
|
||||
|
||||
@Resource
|
||||
private OssTemplate ossTemplate;
|
||||
|
||||
@Resource
|
||||
private FileServerProperties fileServerProperties;
|
||||
|
||||
@Override
|
||||
protected String fileType() {
|
||||
return FileServerProperties.TYPE_COS;
|
||||
return FileServerProperties.TYPE_OSS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,11 +73,40 @@ public class OssService extends AbstractIFileService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByName(String name) {
|
||||
|
||||
return ossTemplate.getViewUrl(name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo getFileInfo(String id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo createFile(String path) {
|
||||
OSSObject ossObject = parsePath(path);
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.setPath(path);
|
||||
fileInfo.setId(IdUtil.fastSimpleUUID());
|
||||
fileInfo.setName(ossObject.getKey());
|
||||
fileInfo.setSize(ossObject.getObjectMetadata().getContentLength());
|
||||
fileInfo.setUrl(fileServerProperties.getOss().getEndpoint() +PATH_SPLIT+ path);
|
||||
fileInfo.setSource(fileType());
|
||||
fileInfo.setIsImg(ossObject.getKey().endsWith(".jpeg") || ossObject.getKey().endsWith(".png") || ossObject.getKey().endsWith(".gif"));
|
||||
if (fileInfo.getIsImg()) {
|
||||
fileInfo.setContentType("image/jpeg");
|
||||
}
|
||||
|
||||
int res = baseMapper.insert(fileInfo);
|
||||
if (res > 0) {
|
||||
return fileInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private OSSObject parsePath(String path) {
|
||||
OSSObject ossObject = new OSSObject();
|
||||
if (StrUtil.isNotEmpty(path)) {
|
||||
|
||||
+11
-1
@@ -2,7 +2,7 @@ package com.central.file.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.central.common.constant.CommonConstant;
|
||||
import com.central.file.model.FileInfo;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.oss.model.ObjectInfo;
|
||||
import com.central.oss.properties.FileServerProperties;
|
||||
import com.central.oss.template.S3Template;
|
||||
@@ -50,6 +50,11 @@ public class S3Service extends AbstractIFileService {
|
||||
s3Template.delete(s3Object.bucketName, s3Object.objectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewUrlByName(String name) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void out(String id, OutputStream os) {
|
||||
FileInfo fileInfo = baseMapper.selectById(id);
|
||||
@@ -69,6 +74,11 @@ public class S3Service extends AbstractIFileService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo createFile(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private class S3Object {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.central.file.utils;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.central.file.model.FileInfo;
|
||||
import com.central.common.model.FileInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="findList" resultType="com.central.file.model.FileInfo">
|
||||
<select id="findList" resultType="com.central.common.model.FileInfo">
|
||||
select * from file_info t
|
||||
<include refid="where" />
|
||||
order by t.create_time desc
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
待开发功能:
|
||||
1. 景区管理
|
||||
2. 套餐管理
|
||||
3. 素材管理
|
||||
+26
-2
@@ -1,13 +1,15 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.context.LoginUserContextHolder;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.LoginAppUser;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.feign.FileCenterService;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.service.IOrderFileService;
|
||||
import com.central.order.service.ITourismService;
|
||||
import com.central.order.service.IOrderService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
@@ -42,7 +44,7 @@ public class OrderFileController {
|
||||
private FileCenterService fileCenterService;
|
||||
|
||||
@Autowired
|
||||
private ITourismService tourismService;
|
||||
private IOrderService orderService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -122,4 +124,26 @@ public class OrderFileController {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Operation(summary = "设备回传照片path记录创建")
|
||||
@PostMapping("/path")
|
||||
public void createOrderFileForPath(@RequestBody OrderFile orderFile) {
|
||||
|
||||
if (orderFile != null && orderFile.getOrderNo() != null) {
|
||||
Order order = orderService.getOrderByNumber(orderFile.getOrderNo());
|
||||
orderFile.setOrderNo(order.getOrderNo());
|
||||
orderFile.setUserId(order.getUserId());
|
||||
if (orderFile.getFilePath() != null) {
|
||||
|
||||
FileInfo fileInfo = fileCenterService.creatFileInfo(orderFile.getFilePath());
|
||||
orderFile.setFileId(fileInfo.get);
|
||||
orderFile.setFilePath(fileInfo.getPath());
|
||||
orderFile.setFileType(fileInfo.getContentType());
|
||||
orderFile.setTourismId(order.getTourismId());
|
||||
}
|
||||
orderFileService.save(orderFile);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.central.order.feign;
|
||||
|
||||
import com.central.common.constant.ServiceNameConstants;
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.feign.fallback.FileCenterServiceFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -34,4 +37,7 @@ public interface FileCenterService {
|
||||
|
||||
@GetMapping("/qrcode/{codeId}")
|
||||
Result<Map> uploadQrCodeFile(@PathVariable("codeId") String codeId) throws Exception;
|
||||
|
||||
@PostMapping("/path")
|
||||
FileInfo creatFileInfo(@RequestBody String path);
|
||||
}
|
||||
|
||||
+6
@@ -1,5 +1,6 @@
|
||||
package com.central.order.feign.fallback;
|
||||
|
||||
import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.feign.FileCenterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -39,6 +40,11 @@ public class FileCenterServiceFallbackFactory implements FallbackFactory<FileCen
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInfo creatFileInfo(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: order-center
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 119.45.169.13
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# ip: 119.45.169.13
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
|
||||
@@ -47,6 +47,6 @@
|
||||
|
||||
<!-- 根据订单编号查询订单信息 -->
|
||||
<select id="getOrderByNumber" resultMap="OrderResultMap">
|
||||
SELECT * FROM orders WHERE order_number = #{orderNumber}
|
||||
SELECT * FROM orders WHERE order_no = #{orderNumber}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.central.file.model;
|
||||
package com.central.common.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class OssTemplate implements InitializingBean {
|
||||
|
||||
ObjectInfo obj = new ObjectInfo();
|
||||
obj.setObjectPath(bucketName + PATH_SPLIT + objectName);
|
||||
obj.setObjectUrl(fileProperties.getCos().getEndpoint() + PATH_SPLIT + obj.getObjectPath());
|
||||
obj.setObjectUrl(fileProperties.getOss().getEndpoint() + PATH_SPLIT + obj.getObjectPath());
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,8 @@ zlt:
|
||||
/login.html,
|
||||
/user/login, /oauth/authorize,
|
||||
/api-uaa/tokens/key,
|
||||
/*/v3/api-docs/**
|
||||
/*/v3/api-docs/**,
|
||||
/api-order/files/path
|
||||
auth:
|
||||
urlPermission:
|
||||
#是否开启url级别权限
|
||||
|
||||
Reference in New Issue
Block a user