修改了版本号和天梯仓库路径
This commit is contained in:
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-apollo-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-apollo-stater</name>
|
||||
|
||||
<dependencies>
|
||||
@ -25,5 +26,5 @@
|
||||
<artifactId>mall-ebtp-cloud-mvc-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-attachment-sdk</artifactId>
|
||||
<version>0.0.1</version>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-mvc-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nexus-aliyun</id>
|
||||
<name>Nexus aliyun</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>ettp-host-release</id>
|
||||
<name>Install to ettp center</name>
|
||||
<url>http://zentao.jlcucc.com:60000/repository/ettp-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
# AutoConfiguration
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.chinaunicom.ebtp.mall.cloud.attachment.sdk.config.SDKAutoConfiguration
|
@ -1,2 +0,0 @@
|
||||
ribbon.ReadTimeout=1800000
|
||||
ribbon.SocketTimeout=1800000
|
@ -5,17 +5,17 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-attachment-sdk</artifactId>
|
||||
<version>0.0.1</version>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-attachment-sdk</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
@ -25,14 +25,10 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
@ -45,20 +41,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nexus-aliyun</id>
|
||||
<name>Nexus aliyun</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>ettp-host-release</id>
|
||||
<name>Install to ettp center</name>
|
||||
<url>http://zentao.jlcucc.com:60000/repository/ettp-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
||||
|
@ -52,6 +52,7 @@ public interface AttachmentClient {
|
||||
* @return
|
||||
*/
|
||||
Optional<byte[]> downloadFileByObjectId(String objectId);
|
||||
|
||||
|
||||
/**
|
||||
* 上传资源文件
|
||||
@ -61,7 +62,7 @@ public interface AttachmentClient {
|
||||
* @return
|
||||
*/
|
||||
Optional<UploadObject> upload(String businessId, File file);
|
||||
Optional<UploadObject> upload(Long businessId, File file);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -72,6 +73,5 @@ public interface AttachmentClient {
|
||||
* @return
|
||||
*/
|
||||
Optional<UploadObject> upload(String businessId, String filename, byte[] array);
|
||||
Optional<UploadObject> upload(Long businessId, String filename, byte[] array);
|
||||
|
||||
}
|
||||
|
@ -1,22 +1,27 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.api;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.FileConvertor;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentDetail;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.FeedbackMessage;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.Snowflake;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.UploadObject;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.param.QueryParameter;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.service.QueryService;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.service.DocumentCenterService;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 附件工具客户端默认实现
|
||||
@ -25,22 +30,50 @@ import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.service.QueryService;
|
||||
*/
|
||||
@Primary
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DefaultAttachmentClient implements AttachmentClient {
|
||||
|
||||
/* 附件工具类服务 */
|
||||
private @Autowired QueryService queryService;
|
||||
private @Autowired DocumentCenterService documentCenterService;
|
||||
|
||||
/* 模型转换器 */
|
||||
private @Autowired ModelConvertor modelConvertor;
|
||||
|
||||
/* 文件转换器 */
|
||||
private @Autowired FileConvertor fileConvertor;
|
||||
|
||||
/**
|
||||
* 获取业务ID
|
||||
* 根据业务id列表查询详单
|
||||
*
|
||||
* @param businessIdList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<AttachmentDetail> findByBusinessId(List<String> businessIdList) {
|
||||
log.debug("query bids: {}", businessIdList);
|
||||
String json = documentCenterService.fetchDetails(businessIdList);
|
||||
log.debug("fetch content: {}", json);
|
||||
|
||||
AttachmentDetail detail = new AttachmentDetail();
|
||||
|
||||
// 组织数据存储
|
||||
modelConvertor.toQueryResult(json).ifPresent(result -> {
|
||||
result.getData().stream().forEach(data -> {
|
||||
detail.add(new AttachmentEntity().setBid(data.getObjectId()).setId(data.getFileId())
|
||||
.setFilename(data.getOriginalName()));
|
||||
});
|
||||
});
|
||||
return Optional.ofNullable(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成业务id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<String> getBusinessId() {
|
||||
Snowflake snowflake = queryService.getSnokflakId();
|
||||
|
||||
if (Objects.isNull(snowflake)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(snowflake.getId());
|
||||
return Optional.of(String.format("{\"id\":\"%s\"}", IdUtil.getSnowflake(23, 16).nextIdStr()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,90 +84,83 @@ public class DefaultAttachmentClient implements AttachmentClient {
|
||||
*/
|
||||
@Override
|
||||
public Optional<AttachmentEntity> findByObjectId(String objectId) {
|
||||
AttachmentEntity entity = queryService.getObjectDetail(objectId);
|
||||
return Optional.ofNullable(entity);
|
||||
return modelConvertor.toAttachmentEntity(documentCenterService.getObjectDetail(objectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过业务ID查找附件信息
|
||||
* 通过对象id下载附件
|
||||
*
|
||||
* @param businessIdList 业务ID列表
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<AttachmentDetail> findByBusinessId(List<String> businessIdList) {
|
||||
QueryParameter param = new QueryParameter(businessIdList);
|
||||
AttachmentDetail attachemtnDetail = queryService.getAttachmentDetails(param);
|
||||
|
||||
return Optional.ofNullable(attachemtnDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
*
|
||||
* @param businessId 业务id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<byte[]> downloadFilesByBusinessId(String businessId) {
|
||||
return Optional.ofNullable(queryService.downloadByBid(businessId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
*
|
||||
* @param objectId 对象id
|
||||
* @param objectId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<byte[]> downloadFileByObjectId(String objectId) {
|
||||
return Optional.ofNullable(queryService.downloadByOid(objectId));
|
||||
return modelConvertor.toByteArray(documentCenterService.getObjectDetail(objectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件
|
||||
* 根据业务id下载文件
|
||||
*
|
||||
* @param businessId 业务id
|
||||
* @param file 文件
|
||||
* @param businessId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<byte[]> downloadFilesByBusinessId(String businessId) {
|
||||
Optional<AttachmentDetail> op = findByBusinessId(Arrays.asList(businessId));
|
||||
|
||||
if (op.isPresent()) {
|
||||
List<AttachmentEntity> list = op.get().get(businessId);
|
||||
|
||||
// 如果业务id下只包含单独一个文件,则直接返回该文件数据
|
||||
if (list.size() == 1) {
|
||||
return downloadFileByObjectId(list.get(0).getId());
|
||||
}
|
||||
// 如果大于1个则下载返回压缩包数据流
|
||||
else if (list.size() > 1) {
|
||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
try (ZipOutputStream zout = new ZipOutputStream(out)) {
|
||||
list.stream().forEach(data -> {
|
||||
try {
|
||||
zout.putNextEntry(new ZipEntry(data.getId() + data.getFilename()));// 文件项名称
|
||||
zout.write(downloadFileByObjectId(data.getId()).get());// 文件数据流
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
return Optional.ofNullable(out.toByteArray());
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param businessId
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<UploadObject> upload(String businessId, File file) {
|
||||
Objects.requireNonNull(businessId);
|
||||
Objects.requireNonNull(file);
|
||||
String res = documentCenterService.upload("ebtp-mall-cloud", businessId, fileConvertor.toMultipartFile(file));
|
||||
|
||||
FeedbackMessage feedback = queryService.handleFileUpload(businessId, FileConvertor.toMultipartFile(file));
|
||||
log.debug(res);
|
||||
|
||||
return Optional.ofNullable(new UploadObject().setId(feedback.getOid()));
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UploadObject> upload(Long businessId, File file) {
|
||||
return upload(businessId.toString(), file);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件
|
||||
*
|
||||
* @param businessId 业务ID
|
||||
* @param filename 文件名称
|
||||
* @param array 文件字节组
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<UploadObject> upload(String businessId, String filename, byte[] array) {
|
||||
Objects.requireNonNull(businessId);
|
||||
Objects.requireNonNull(array);
|
||||
String res = documentCenterService.upload("ebtp-mall-cloud", businessId,
|
||||
fileConvertor.toMultipartFile(filename, array));
|
||||
|
||||
FeedbackMessage feedback = queryService.handleFileUpload(businessId,
|
||||
FileConvertor.toMultipartFile(filename, array));
|
||||
log.debug(res);
|
||||
|
||||
return Optional.ofNullable(new UploadObject().setId(feedback.getOid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UploadObject> upload(Long businessId, String filename, byte[] array) {
|
||||
return upload(businessId.toString(), filename, array);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class FeignSupportConfig {
|
||||
|
||||
}
|
@ -1,14 +1,34 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.config;
|
||||
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.FileConvertor;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor;
|
||||
|
||||
@Configuration
|
||||
@EnableFeignClients(basePackages = "com.chinaunicom.ebtp.mall.cloud.attachment.sdk")
|
||||
@ComponentScan(basePackages = "com.chinaunicom.ebtp.mall.cloud.attachment.sdk")
|
||||
@PropertySource("classpath:attachment-sdk-cofiguration.properties")
|
||||
public class SDKAutoConfiguration {
|
||||
|
||||
/**
|
||||
* @return 数据模型转换器
|
||||
*/
|
||||
@Bean
|
||||
public ModelConvertor modelConvertor() {
|
||||
return new ModelConvertor();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 文件转换器
|
||||
*/
|
||||
@Bean
|
||||
public FileConvertor fileConvertor() {
|
||||
return new FileConvertor();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,23 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.FileItemFactory;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 文件转换器
|
||||
*
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
@Slf4j
|
||||
public final class FileConvertor {
|
||||
|
||||
/**
|
||||
@ -24,21 +26,13 @@ public final class FileConvertor {
|
||||
* @param file 原始文件对象
|
||||
* @return
|
||||
*/
|
||||
public static MultipartFile toMultipartFile(File file) {
|
||||
FileItemFactory factory = new DiskFileItemFactory(16, null);
|
||||
FileItem item = factory.createItem("file", "text/plain", true, file.getName());
|
||||
public MultipartFile toMultipartFile(File file) {
|
||||
FileItem item = createFileItem(file.getName());
|
||||
|
||||
int bytesRead = 0;
|
||||
byte[] buffer = new byte[8192];
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
try (OutputStream os = item.getOutputStream()) {
|
||||
while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
|
||||
os.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
try {
|
||||
FileUtils.copyFile(file, item.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return new CommonsMultipartFile(item);
|
||||
}
|
||||
@ -50,16 +44,26 @@ public final class FileConvertor {
|
||||
* @param array 文件字节组
|
||||
* @return
|
||||
*/
|
||||
public static MultipartFile toMultipartFile(String filename, byte[] array) {
|
||||
FileItemFactory factory = new DiskFileItemFactory(16, null);
|
||||
FileItem item = factory.createItem("file", "text/plain", true, filename);
|
||||
public MultipartFile toMultipartFile(String filename, byte[] array) {
|
||||
FileItem item = createFileItem(filename);
|
||||
|
||||
try (OutputStream os = item.getOutputStream()) {
|
||||
os.write(array);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return new CommonsMultipartFile(item);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////// private
|
||||
/////////////////////////////////////////////////////////////////////////// Method
|
||||
|
||||
/**
|
||||
* @param filename
|
||||
* @return
|
||||
*/
|
||||
private FileItem createFileItem(String filename) {
|
||||
return new DiskFileItemFactory(16, null).createItem("file", "text/plain", true, filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.down.DownStream;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.down.SysStorageVO;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.query.QueryResult;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 山分数据模型转换为吉林数据模型
|
||||
*
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
@Slf4j
|
||||
public class ModelConvertor {
|
||||
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
public ModelConvertor() {
|
||||
objectMapper = new ObjectMapper();
|
||||
/** 实体中存在未定义的属性是不报出错误 */
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 山分接口返回的json数据包转换为吉林实体模型
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
public Optional<AttachmentEntity> toAttachmentEntity(String json) {
|
||||
AttachmentEntity entity = null;
|
||||
|
||||
try {
|
||||
SysStorageVO vo = toSysStorageVO(json);
|
||||
log.debug("convert to model: {}", vo);
|
||||
|
||||
entity = new AttachmentEntity();
|
||||
entity.setId(vo.getFileId()).setFilename(vo.getOriginalName()).setBid(vo.getObjectId());
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return Optional.ofNullable(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
public Optional<QueryResult> toQueryResult(String json) {
|
||||
QueryResult result = null;
|
||||
try {
|
||||
result = objectMapper.readValue(json, QueryResult.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return Optional.ofNullable(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
public Optional<byte[]> toByteArray(String json) {
|
||||
byte[] array = null;
|
||||
|
||||
try {
|
||||
array = toSysStorageVO(json).getFileStream();
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return Optional.ofNullable(array);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////// private
|
||||
/////////////////////////////////////////////////////////////////////////// method
|
||||
/**
|
||||
* Json转换为业务实体
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
* @throws JsonMappingException
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
private SysStorageVO toSysStorageVO(String json) throws JsonMappingException, JsonProcessingException {
|
||||
log.debug("current convertor json is: {}", json);
|
||||
return objectMapper.readValue(json, DownStream.class).getData().getSysStorageVO();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.fallback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.service.DocumentCenterService;
|
||||
|
||||
@Component
|
||||
public class DocumentCenterServiceFallback implements DocumentCenterService {
|
||||
|
||||
@Override
|
||||
public String getObjectDetail(String fileId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fetchDetails(List<String> bids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upload(String appCode, String objectId, MultipartFile multipartFiles) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
@ -11,4 +12,16 @@ import java.util.List;
|
||||
public class AttachmentDetail extends Hashtable<String, List<AttachmentEntity>> {
|
||||
private static final long serialVersionUID = -6579549900874220624L;
|
||||
|
||||
/**
|
||||
* 清单项入库操作
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
public void add(AttachmentEntity entity) {
|
||||
String bid = entity.getBid();
|
||||
List<AttachmentEntity> list = containsKey(bid) ? get(bid) : new ArrayList<>();
|
||||
list.add(entity);
|
||||
put(bid, list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.fallback.DocumentCenterServiceFallback;
|
||||
|
||||
/**
|
||||
* 连接山分的文档中心服务
|
||||
*
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
@FeignClient(name = "DocumentCenterService", url = "${document.center.ip-address}", fallback = DocumentCenterServiceFallback.class)
|
||||
public interface DocumentCenterService {
|
||||
|
||||
/**
|
||||
* 通过附件id查询明细
|
||||
*
|
||||
* @param fileId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST, value = "v1.0/files/downloadAllStream")
|
||||
String getObjectDetail(@RequestParam("fileId") String fileId);
|
||||
|
||||
/**
|
||||
* 通过业务id列表获取明细
|
||||
*
|
||||
* @param bids
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST, value = "v1.0/files/queryReturn")
|
||||
String fetchDetails(@RequestBody List<String> bids);
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/v1.0/files/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
String upload(@RequestPart("appCode") String appCode, @RequestPart("objectId") String objectId,
|
||||
@RequestPart("multipartFiles") MultipartFile multipartFiles);
|
||||
|
||||
}
|
@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.config.FeignSupportConfig;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.fallback.QueryServiceFallback;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentDetail;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
|
||||
@ -18,7 +17,7 @@ import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.FeedbackMessage;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.Snowflake;
|
||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.param.QueryParameter;
|
||||
|
||||
@FeignClient(value = "core-service-ebtp-updownload", configuration = FeignSupportConfig.class, fallback = QueryServiceFallback.class)
|
||||
@FeignClient(value = "core-service-ebtp-updownload", fallback = QueryServiceFallback.class)
|
||||
public interface QueryService {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "v1/business/id")
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.down;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DownStream {
|
||||
|
||||
private Integer code;
|
||||
private Boolean success;
|
||||
private String message;
|
||||
private DownStreamData data;
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.down;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DownStreamData {
|
||||
|
||||
private SysStorageVO sysStorageVO;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.down;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysStorageVO {
|
||||
|
||||
/* 文件原始名称 */
|
||||
private String originalName;
|
||||
|
||||
/* 附件id */
|
||||
private String fileId;
|
||||
|
||||
/* 业务id */
|
||||
private String objectId;
|
||||
|
||||
/* 文件流 */
|
||||
private byte[] fileStream;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryData {
|
||||
|
||||
private String fileId;
|
||||
private String objectId;
|
||||
private String originalName;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryResult {
|
||||
|
||||
private List<QueryData> data;
|
||||
|
||||
}
|
@ -1,2 +1,6 @@
|
||||
ribbon.ReadTimeout=1800000
|
||||
ribbon.SocketTimeout=1800000
|
||||
|
||||
# document center id
|
||||
document.center.service.id=core-service-document-center
|
||||
document.center.ip-address=http://10.242.31.158:8801/
|
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-eureka-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-eureka-starter</name>
|
||||
|
||||
<dependencies>
|
||||
@ -25,5 +26,5 @@
|
||||
<artifactId>mall-ebtp-cloud-mvc-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -1,5 +1,4 @@
|
||||
# 胜智云eureka 统一配置
|
||||
# eureka.client.service-url.defaultZone=http://192.168.40.17:12093/eureka/,http://192.168.40.17:18126/eureka/,http://192.168.40.17:28641/eureka/
|
||||
eureka.client.service-url.defaultZone=http://192.168.1.103:8761/eureka/
|
||||
eureka.client.service-url.defaultZone=http://10.242.31.158:5001/eureka,http://10.242.31.158:5002/eureka,http://10.242.31.158:5003/eureka
|
||||
eureka.instance.prefer-ip-address=true
|
||||
eureka.instance.instance-id=${spring.cloud.client.ip-address}:${server.port}
|
||||
|
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-feign-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-feign-starter</name>
|
||||
|
||||
<dependencies>
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 默认开启熔断
|
||||
feign.hystrix.enabled=true
|
||||
feign.client.config.default.connectTimeout=5000
|
||||
feign.client.config.default.readTimeout=10000
|
||||
feign.client.config.default.connectTimeout=50000
|
||||
feign.client.config.default.readTimeout=50000
|
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-fileupload-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-fileupload-starter</name>
|
||||
|
||||
<dependencies>
|
||||
|
@ -4,26 +4,27 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-jpa-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-jpa-starter</name>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-kafka-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-kafka-starter</name>
|
||||
|
||||
<dependencies>
|
||||
|
@ -4,17 +4,18 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-log-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-log-starter</name>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-mvc-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-mvc-starter</name>
|
||||
|
||||
<dependencies>
|
||||
|
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-office-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-office-starter</name>
|
||||
|
||||
<dependencies>
|
||||
|
@ -6,82 +6,81 @@
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<relativePath>..</relativePath>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>mall-ebtp-cloud-parent</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-mvc-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-eureka-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-apollo-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-security-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-jpa-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-office-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-swagger-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-fileupload-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-redis-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-kafka-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-feign-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-seata-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-attachment-sdk</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
@ -99,18 +98,6 @@
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<!-- 配置nexus远程仓库 -->
|
||||
<repository>
|
||||
<id>repo_group_seal</id>
|
||||
<name>Nexus Snapshot Repository</name>
|
||||
<url>http://192.168.30.126:31233/repository/eshop-grouppath-45c07c6e-maven-group/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aliyun-repos</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
@ -119,18 +106,5 @@
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<!-- 配置从哪个仓库中下载构件,即jar包 -->
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>repo_group_seal</id>
|
||||
<name>Nexus Snapshot Repository</name>
|
||||
<url>http://192.168.30.126:31233/repository/eshop-grouppath-45c07c6e-maven-group/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
|
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-redis-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-redis-starter</name>
|
||||
|
||||
<properties>
|
||||
|
@ -4,21 +4,22 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-seata-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-seata-starter</name>
|
||||
|
||||
|
||||
<properties>
|
||||
<seata.version>1.3.0</seata.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
|
@ -28,11 +28,12 @@ transport {
|
||||
serialization = "seata"
|
||||
compressor = "none"
|
||||
}
|
||||
|
||||
service {
|
||||
#transaction service group mapping
|
||||
vgroupMapping.test_tx_group = "default"
|
||||
vgroupMapping.biz-service-ebtp-archive-fescar-service-group = "default"
|
||||
#only support when registry.type=file, please don't set multiple addresses
|
||||
default.grouplist = "127.0.0.1:8091"
|
||||
default.grouplist = "10.242.31.158:18035"
|
||||
#degrade, current not support
|
||||
enableDegrade = false
|
||||
#disable seata
|
||||
|
@ -1,17 +1,15 @@
|
||||
registry {
|
||||
type = "eureka"
|
||||
|
||||
eureka {
|
||||
serviceUrl = "http://192.168.1.103:8761/eureka/"
|
||||
application = "default"
|
||||
weight = "1"
|
||||
type = "file"
|
||||
|
||||
file {
|
||||
name = "file.conf"
|
||||
}
|
||||
}
|
||||
|
||||
config {
|
||||
type = "file"
|
||||
|
||||
|
||||
file {
|
||||
name = "file.conf"
|
||||
}
|
||||
}
|
||||
}
|
@ -8,13 +8,13 @@
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-security-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-security-starter</name>
|
||||
|
||||
<dependencies>
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.security.starter.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AuthorityEntity {
|
||||
|
||||
private String roleName;
|
||||
private String roleCode;
|
||||
private List<String> authorities;
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.security.starter.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SecurityEntity {
|
||||
|
||||
private String city;
|
||||
private String ou;
|
||||
private String staffType;
|
||||
private List<AuthorityEntity> authorityList;
|
||||
private String userid;
|
||||
private List<String> authorities;
|
||||
private String orgId;
|
||||
private String ouName;
|
||||
private String province;
|
||||
private String staffOrgId;
|
||||
private String staffName;
|
||||
private String tenantId;
|
||||
private String staffId;
|
||||
private String username;
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.security.starter.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
@ -20,12 +19,16 @@ import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.common.Constants;
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 请求Token拦截
|
||||
*
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
@Slf4j
|
||||
public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
private @Autowired RestTemplate restTemplate;
|
||||
@ -41,31 +44,42 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
@Override
|
||||
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
|
||||
final FilterChain filterChain) throws ServletException, IOException {
|
||||
// 清空上下文中的缓存信息, 防止二次请求时数据异常 (如此, 每次有新的请求进入,都会进行token的验证)
|
||||
SecurityContextHolder.getContext().setAuthentication(null);
|
||||
|
||||
// 提取request头信息
|
||||
final String header = request.getHeader(Constants.AUTHORIZATION_HEADER);
|
||||
|
||||
// 检查请求头是否包含 Bearer 前缀
|
||||
if (StringUtils.startsWith(header, Constants.TOKEN_PREFIX)) {
|
||||
// 提取 token 信息
|
||||
// 移除header的前缀,提取出token字串
|
||||
String authToken = RegExUtils.replaceAll(header, Constants.TOKEN_PREFIX, "");
|
||||
|
||||
// 通过token读取用户信息
|
||||
SecurityContextHolder.getContext().setAuthentication(getAuthentication(authToken));
|
||||
try {// 通过token读取用户信息
|
||||
SecurityContextHolder.getContext().setAuthentication(getAuthentication(authToken));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用山分的认证中心接口,获取该token的绑定信息
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
private Authentication getAuthentication(String token) {
|
||||
ResponseEntity<Map> entity = restTemplate.getForEntity(createRequestUri(token), Map.class);
|
||||
|
||||
ResponseEntity<SecurityEntity> entity = restTemplate.getForEntity(createRequestUri(token),
|
||||
SecurityEntity.class);
|
||||
|
||||
return new UsernamePasswordAuthenticationToken(entity.getBody(), token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成山分认证中心请求接口地址
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
user.auth.resource.token-info-uri=http://125.32.114.204:18091/oauth/check_token
|
||||
user.auth.resource.token-info-uri=http://10.242.31.158:8100/mall-auth/oauth/check_token
|
@ -4,15 +4,16 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-swagger-starter</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-ebtp-cloud-swagger-starter</name>
|
||||
|
||||
<dependencies>
|
||||
|
62
pom.xml
62
pom.xml
@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
@ -9,7 +11,7 @@
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>mall-ebtp-cloud</name>
|
||||
|
||||
@ -24,7 +26,7 @@
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring.cloud.version>Hoxton.SR7</spring.cloud.version>
|
||||
<com.alibaba.cloud.version>2.2.3.RELEASE</com.alibaba.cloud.version>
|
||||
<mybatis-plus.version>3.2.0</mybatis-plus.version>
|
||||
<mybatis-plus.version>3.4.0</mybatis-plus.version>
|
||||
<unifast.version>2.6.0-SNAPSHOT</unifast.version>
|
||||
<swagger.version>1.5.21</swagger.version>
|
||||
<swagger2markup.version>1.3.3</swagger2markup.version>
|
||||
@ -348,17 +350,22 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/spring.handlers</resource>
|
||||
</transformer>
|
||||
<transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
|
||||
<transformer
|
||||
implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
|
||||
<resource>META-INF/spring.factories</resource>
|
||||
</transformer>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
||||
<resource>META-INF/spring.schemas</resource>
|
||||
</transformer>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>${start-class}</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
@ -387,27 +394,32 @@
|
||||
<module>mall-ebtp-cloud-seata-starter</module>
|
||||
<module>uboot-common</module>
|
||||
<module>uboot-core</module>
|
||||
<module>mall-ebtp-cloud-attachment-sdk</module>
|
||||
</modules>
|
||||
|
||||
<organization>
|
||||
<name>China Unicom</name>
|
||||
<url>http://www.chinaunicom.com</url>
|
||||
</organization>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>ajaxfan</name>
|
||||
<email>ajaxfan@gmail.com</email>
|
||||
<organization>ChinaUnicom</organization>
|
||||
</developer>
|
||||
</developers>
|
||||
<module>mall-ebtp-cloud-attachment-sdk</module>
|
||||
</modules>
|
||||
|
||||
<organization>
|
||||
<name>China Unicom</name>
|
||||
<url>http://www.chinaunicom.com</url>
|
||||
</organization>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>ajaxfan</name>
|
||||
<email>ajaxfan@gmail.com</email>
|
||||
<organization>ChinaUnicom</organization>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>ettp-host-release</id>
|
||||
<name>Install to ettp center</name>
|
||||
<url>http://zentao.jlcucc.com:60000/repository/ettp-releases/</url>
|
||||
<id>tianti-maven-release-local</id>
|
||||
<name>user release resp</name>
|
||||
<url>http://ccp.tianti.tg.unicom.local/artifactory/tianti-maven-release-local/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>tianti-maven-snapshot-local</id>
|
||||
<name>user snapshot</name>
|
||||
<url>http://ccp.tianti.tg.unicom.local/artifactory/tianti-maven-snapshot-local/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
@ -1,78 +1,88 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
<groupId>com.chinaunicom.mall.ebtp</groupId>
|
||||
<artifactId>uboot-common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>uboot-common</name>
|
||||
|
||||
<groupId>com.chinaunicom.mall.ebtp</groupId>
|
||||
<artifactId>uboot-common</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<name>uboot-common</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-mvc-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-mvc-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-jpa-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-jpa-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-eureka-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-eureka-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-feign-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-feign-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-swagger-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-swagger-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-redis-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-redis-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-security-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!--普罗米修斯 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.chinaunicom.mall.ebtp.common.base.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.AuthorityEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 缓存用户实体映射类
|
||||
*
|
||||
@ -143,4 +146,9 @@ public class BaseCacheUser {
|
||||
*/
|
||||
private Integer positionId;
|
||||
|
||||
/**
|
||||
* 用户角色列表
|
||||
*/
|
||||
private List<AuthorityEntity> authorityList;
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
|
||||
|
||||
@ -29,14 +30,17 @@ public class BaseCacheUserServiceImpl implements IBaseCacheUserService {
|
||||
|
||||
@Override
|
||||
public BaseCacheUser getCacheUser() {
|
||||
Map map = (Map) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
try {
|
||||
SecurityEntity securityEntity = (SecurityEntity) SecurityContextHolder.getContext().getAuthentication()
|
||||
.getPrincipal();
|
||||
|
||||
log.debug("Current user principal: " + map);
|
||||
log.debug("Current user principal: " + securityEntity);
|
||||
|
||||
return new BaseCacheUser().setUserId(getUserId((String) map.get("staffId")))
|
||||
.setFullName((String) map.get("staffName")).setLoginName((String) map.get("username"))
|
||||
.setRoleIds((String) map.get("staffId")).setOrganizationId((String) map.get("ou"))
|
||||
.setOrganizationName((String) map.get("ouName"));
|
||||
return convertToBusinessModel(securityEntity);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return new BaseCacheUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,54 +48,31 @@ public class BaseCacheUserServiceImpl implements IBaseCacheUserService {
|
||||
return USERS.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建用户对象模型
|
||||
*
|
||||
* @param rawObject
|
||||
* @return
|
||||
*/
|
||||
private BaseCacheUser convertToBusinessModel(SecurityEntity raw) {
|
||||
return new BaseCacheUser().setUserId(getUserId(raw.getStaffId())).setFullName(raw.getStaffName())
|
||||
.setLastName(raw.getUsername()).setRoleIds(raw.getStaffId()).setOrganizationId(raw.getOu())
|
||||
.setOrganizationName(raw.getOuName()).setAuthorityList(raw.getAuthorityList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
// TODO: 山东框架使用未使用雪花ID存放字符串,暂时使用该方法进行id转换
|
||||
private Long getUserId(String rawUid) {
|
||||
private String getUserId(String rawUid) {
|
||||
long id = ID_SEED;
|
||||
byte[] bytes = rawUid.getBytes();
|
||||
|
||||
for (byte b : bytes) {
|
||||
id += b;
|
||||
}
|
||||
return id;
|
||||
return String.valueOf(id);
|
||||
}
|
||||
|
||||
static {
|
||||
BaseCacheUser user = new BaseCacheUser().setUserId(1L).setFullName("采购经理").setLoginName("caigou")
|
||||
.setRoleIds("caigou").setOrganizationId("100").setOrganizationName("中国联通吉林分公司");
|
||||
USERS.put(String.valueOf(user.getUserId()), user);
|
||||
|
||||
BaseCacheUser user0 = new BaseCacheUser().setUserId(2L).setFullName("代理机构管理员").setLoginName("daili-admin")
|
||||
.setRoleIds("daili-admin").setOrganizationId("100100").setOrganizationName("中兴代理公司");
|
||||
USERS.put(String.valueOf(user0.getUserId()), user0);
|
||||
|
||||
BaseCacheUser user1 = new BaseCacheUser().setUserId(3L).setFullName("代理机构子管理员").setLoginName("daili-subadmin")
|
||||
.setRoleIds("daili-subadmin").setOrganizationId("100100").setOrganizationName("中兴代理公司");
|
||||
USERS.put(String.valueOf(user1.getUserId()), user1);
|
||||
|
||||
BaseCacheUser user2 = new BaseCacheUser().setUserId(4L).setFullName("项目经理1").setLoginName("daili1")
|
||||
.setRoleIds("daili").setOrganizationId("100100").setOrganizationName("中兴代理公司");
|
||||
USERS.put(String.valueOf(user2.getUserId()), user2);
|
||||
|
||||
BaseCacheUser user3 = new BaseCacheUser().setUserId(5L).setFullName("项目经理2").setLoginName("daili2")
|
||||
.setRoleIds("daili").setOrganizationId("100100").setOrganizationName("中兴代理公司");
|
||||
USERS.put(String.valueOf(user3.getUserId()), user3);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
BaseCacheUser user4 = new BaseCacheUser().setUserId(6L + i).setFullName("专家" + (i + 1))
|
||||
.setLoginName("1300000000" + (i + 1)).setRoleIds("zhuanjia").setOrganizationId("666")
|
||||
.setOrganizationName("专家公司");
|
||||
USERS.put(String.valueOf(user4.getUserId()), user4);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
BaseCacheUser user4 = new BaseCacheUser().setUserId(11L + i).setFullName("供应商" + (i + 1))
|
||||
.setLoginName("gys" + (i + 1)).setRoleIds("gys").setOrganizationId("200" + (i + 1))
|
||||
.setOrganizationName("供应商公司" + (i + 1));
|
||||
USERS.put(String.valueOf(user4.getUserId()), user4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,14 @@ import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
|
||||
/**
|
||||
* fegin调用时 header中添加JwtToken
|
||||
* 通过拦截器来为header注入token
|
||||
*/
|
||||
@Configuration
|
||||
public class FeignConfig implements RequestInterceptor {
|
||||
|
||||
/**
|
||||
* @param template
|
||||
*/
|
||||
@Override
|
||||
public void apply(RequestTemplate template) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
@ -29,7 +32,7 @@ public class FeignConfig implements RequestInterceptor {
|
||||
if (StringUtils.startsWith(header, TOKEN_PREFIX)) {
|
||||
String authToken = RegExUtils.replaceAll(header, TOKEN_PREFIX, "");// 提取 token 信息
|
||||
|
||||
template.header(AUTHORIZATION_HEADER, String.format("%s %s", TOKEN_PREFIX, authToken));
|
||||
template.header(AUTHORIZATION_HEADER, String.format("%s%s", TOKEN_PREFIX, authToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.chinaunicom.mall.ebtp.common.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.ResourceHttpMessageConverter;
|
||||
@ -13,7 +11,9 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
|
||||
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
/**
|
||||
* @author dino
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-parent</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../mall-ebtp-cloud-parent</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>com.chinaunicom.mall.ebtp</groupId>
|
||||
<artifactId>uboot-core</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>uboot-core</name>
|
||||
|
||||
<dependencies>
|
||||
@ -20,38 +20,12 @@
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.mall.ebtp</groupId>
|
||||
<artifactId>uboot-common</artifactId>
|
||||
<version>0.0.1</version>
|
||||
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-jpa-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-eureka-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-feign-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-swagger-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-redis-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.seata</groupId>
|
||||
<artifactId>seata-spring-boot-starter</artifactId>
|
||||
<artifactId>mall-ebtp-cloud-seata-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -61,7 +35,6 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
Reference in New Issue
Block a user