diff --git a/mall-ebtp-cloud-apollo-starter/pom.xml b/mall-ebtp-cloud-apollo-starter/pom.xml index 3ba6757..f4b48b1 100644 --- a/mall-ebtp-cloud-apollo-starter/pom.xml +++ b/mall-ebtp-cloud-apollo-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-apollo-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-apollo-stater @@ -25,5 +26,5 @@ mall-ebtp-cloud-mvc-starter - + diff --git a/mall-ebtp-cloud-attachment-sdk/bin/pom.xml b/mall-ebtp-cloud-attachment-sdk/bin/pom.xml deleted file mode 100644 index 3c48c2d..0000000 --- a/mall-ebtp-cloud-attachment-sdk/bin/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - - com.chinaunicom.ebtp - mall-ebtp-cloud-attachment-sdk - 0.0.1 - - - com.chinaunicom.ebtp - mall-ebtp-cloud-parent - 0.0.1 - ../mall-ebtp-cloud-parent - - - - - com.chinaunicom.ebtp - mall-ebtp-cloud-mvc-starter - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - io.github.openfeign - feign-okhttp - - - org.projectlombok - lombok - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - nexus-aliyun - Nexus aliyun - http://maven.aliyun.com/nexus/content/groups/public - - - - - - ettp-host-release - Install to ettp center - http://zentao.jlcucc.com:60000/repository/ettp-releases/ - - - - diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.class deleted file mode 100644 index 4a448ba..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.class deleted file mode 100644 index cdee3f0..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/FeignSupportConfig.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/FeignSupportConfig.class deleted file mode 100644 index 017c405..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/FeignSupportConfig.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/SDKAutoConfiguration.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/SDKAutoConfiguration.class deleted file mode 100644 index 4b0c2e1..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/SDKAutoConfiguration.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/FileConvertor.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/FileConvertor.class deleted file mode 100644 index 609f14d..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/FileConvertor.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/QueryServiceFallback.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/QueryServiceFallback.class deleted file mode 100644 index cc558e0..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/QueryServiceFallback.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentDetail.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentDetail.class deleted file mode 100644 index 6bb84c5..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentDetail.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentEntity.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentEntity.class deleted file mode 100644 index 0dc8dd4..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentEntity.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/FeedbackMessage.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/FeedbackMessage.class deleted file mode 100644 index 34a3fe4..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/FeedbackMessage.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/Snowflake.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/Snowflake.class deleted file mode 100644 index ebca6fc..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/Snowflake.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/UploadObject.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/UploadObject.class deleted file mode 100644 index fb762ac..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/UploadObject.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/param/QueryParameter.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/param/QueryParameter.class deleted file mode 100644 index 9974aa1..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/param/QueryParameter.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/QueryService.class b/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/QueryService.class deleted file mode 100644 index 1020dcc..0000000 Binary files a/mall-ebtp-cloud-attachment-sdk/bin/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/QueryService.class and /dev/null differ diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/resources/META-INF/spring.factories b/mall-ebtp-cloud-attachment-sdk/bin/src/main/resources/META-INF/spring.factories deleted file mode 100644 index f11530a..0000000 --- a/mall-ebtp-cloud-attachment-sdk/bin/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# AutoConfiguration -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.chinaunicom.ebtp.mall.cloud.attachment.sdk.config.SDKAutoConfiguration \ No newline at end of file diff --git a/mall-ebtp-cloud-attachment-sdk/bin/src/main/resources/attachment-sdk-cofiguration.properties b/mall-ebtp-cloud-attachment-sdk/bin/src/main/resources/attachment-sdk-cofiguration.properties deleted file mode 100644 index 580e33b..0000000 --- a/mall-ebtp-cloud-attachment-sdk/bin/src/main/resources/attachment-sdk-cofiguration.properties +++ /dev/null @@ -1,2 +0,0 @@ -ribbon.ReadTimeout=1800000 -ribbon.SocketTimeout=1800000 diff --git a/mall-ebtp-cloud-attachment-sdk/pom.xml b/mall-ebtp-cloud-attachment-sdk/pom.xml index 3c48c2d..6256e6f 100644 --- a/mall-ebtp-cloud-attachment-sdk/pom.xml +++ b/mall-ebtp-cloud-attachment-sdk/pom.xml @@ -5,17 +5,17 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - com.chinaunicom.ebtp - mall-ebtp-cloud-attachment-sdk - 0.0.1 - com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent + com.chinaunicom.ebtp + mall-ebtp-cloud-attachment-sdk + 0.0.1-SNAPSHOT + com.chinaunicom.ebtp @@ -25,14 +25,10 @@ org.springframework.cloud spring-cloud-starter-netflix-eureka-client - - org.springframework.cloud - spring-cloud-starter-openfeign - - - io.github.openfeign - feign-okhttp - + + org.springframework.cloud + spring-cloud-starter-openfeign + org.projectlombok lombok @@ -45,20 +41,4 @@ - - - nexus-aliyun - Nexus aliyun - http://maven.aliyun.com/nexus/content/groups/public - - - - - - ettp-host-release - Install to ettp center - http://zentao.jlcucc.com:60000/repository/ettp-releases/ - - - diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.java index 55acd69..633d83a 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.java @@ -52,6 +52,7 @@ public interface AttachmentClient { * @return */ Optional downloadFileByObjectId(String objectId); + /** * 上传资源文件 @@ -61,7 +62,7 @@ public interface AttachmentClient { * @return */ Optional upload(String businessId, File file); - Optional upload(Long businessId, File file); + /** @@ -72,6 +73,5 @@ public interface AttachmentClient { * @return */ Optional upload(String businessId, String filename, byte[] array); - Optional upload(Long businessId, String filename, byte[] array); } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java index 8258c35..a6582f0 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java @@ -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 findByBusinessId(List 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 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 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 findByBusinessId(List businessIdList) { - QueryParameter param = new QueryParameter(businessIdList); - AttachmentDetail attachemtnDetail = queryService.getAttachmentDetails(param); - - return Optional.ofNullable(attachemtnDetail); - } - - /** - * 文件下载 - * - * @param businessId 业务id - * @return - */ - @Override - public Optional downloadFilesByBusinessId(String businessId) { - return Optional.ofNullable(queryService.downloadByBid(businessId)); - } - - /** - * 文件下载 - * - * @param objectId 对象id + * @param objectId * @return */ @Override public Optional 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 downloadFilesByBusinessId(String businessId) { + Optional op = findByBusinessId(Arrays.asList(businessId)); + + if (op.isPresent()) { + List 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 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 upload(Long businessId, File file) { - return upload(businessId.toString(), file); - } - - /** - * 上传附件 - * - * @param businessId 业务ID - * @param filename 文件名称 - * @param array 文件字节组 - * @return - */ @Override public Optional 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 upload(Long businessId, String filename, byte[] array) { - return upload(businessId.toString(), filename, array); + return Optional.empty(); } } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/FeignSupportConfig.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/FeignSupportConfig.java deleted file mode 100644 index c44c3d9..0000000 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/FeignSupportConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.config; - -import org.springframework.context.annotation.Configuration; - -@Configuration -public class FeignSupportConfig { - -} \ No newline at end of file diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/SDKAutoConfiguration.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/SDKAutoConfiguration.java index d22aca1..52b6ee7 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/SDKAutoConfiguration.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/config/SDKAutoConfiguration.java @@ -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(); + } } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/FileConvertor.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/FileConvertor.java index 0d25bab..be41ae9 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/FileConvertor.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/FileConvertor.java @@ -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); + } + } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/ModelConvertor.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/ModelConvertor.java new file mode 100644 index 0000000..0ba21df --- /dev/null +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/convertor/ModelConvertor.java @@ -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 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 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 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(); + } + +} diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/DocumentCenterServiceFallback.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/DocumentCenterServiceFallback.java new file mode 100644 index 0000000..e207c3b --- /dev/null +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/DocumentCenterServiceFallback.java @@ -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 bids) { + return null; + } + + @Override + public String upload(String appCode, String objectId, MultipartFile multipartFiles) { + return null; + } + +} diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentDetail.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentDetail.java index c2b6799..8732134 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentDetail.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/model/AttachmentDetail.java @@ -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> { private static final long serialVersionUID = -6579549900874220624L; + /** + * 清单项入库操作 + * + * @param entity + */ + public void add(AttachmentEntity entity) { + String bid = entity.getBid(); + List list = containsKey(bid) ? get(bid) : new ArrayList<>(); + list.add(entity); + put(bid, list); + } + } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/DocumentCenterService.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/DocumentCenterService.java new file mode 100644 index 0000000..ad63675 --- /dev/null +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/DocumentCenterService.java @@ -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 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); + +} diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/QueryService.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/QueryService.java index caf06a4..b3eedb9 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/QueryService.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/QueryService.java @@ -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") diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/DownStream.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/DownStream.java new file mode 100644 index 0000000..df61c5b --- /dev/null +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/DownStream.java @@ -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; + +} diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/DownStreamData.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/DownStreamData.java new file mode 100644 index 0000000..2449d26 --- /dev/null +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/DownStreamData.java @@ -0,0 +1,10 @@ +package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.down; + +import lombok.Data; + +@Data +public class DownStreamData { + + private SysStorageVO sysStorageVO; + +} diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/SysStorageVO.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/SysStorageVO.java new file mode 100644 index 0000000..8b76485 --- /dev/null +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/down/SysStorageVO.java @@ -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; + +} diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/query/QueryData.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/query/QueryData.java new file mode 100644 index 0000000..29305e1 --- /dev/null +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/query/QueryData.java @@ -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; + +} diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/query/QueryResult.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/query/QueryResult.java new file mode 100644 index 0000000..08c549b --- /dev/null +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/query/QueryResult.java @@ -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 data; + +} diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/resources/attachment-sdk-cofiguration.properties b/mall-ebtp-cloud-attachment-sdk/src/main/resources/attachment-sdk-cofiguration.properties index 580e33b..89e51e3 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/resources/attachment-sdk-cofiguration.properties +++ b/mall-ebtp-cloud-attachment-sdk/src/main/resources/attachment-sdk-cofiguration.properties @@ -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/ \ No newline at end of file diff --git a/mall-ebtp-cloud-eureka-starter/pom.xml b/mall-ebtp-cloud-eureka-starter/pom.xml index f357e8f..ce93e07 100644 --- a/mall-ebtp-cloud-eureka-starter/pom.xml +++ b/mall-ebtp-cloud-eureka-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-eureka-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-eureka-starter @@ -25,5 +26,5 @@ mall-ebtp-cloud-mvc-starter - + diff --git a/mall-ebtp-cloud-eureka-starter/src/main/resources/eureka-cofiguration.properties b/mall-ebtp-cloud-eureka-starter/src/main/resources/eureka-cofiguration.properties index 9b3b66a..83b68ed 100644 --- a/mall-ebtp-cloud-eureka-starter/src/main/resources/eureka-cofiguration.properties +++ b/mall-ebtp-cloud-eureka-starter/src/main/resources/eureka-cofiguration.properties @@ -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} diff --git a/mall-ebtp-cloud-feign-starter/pom.xml b/mall-ebtp-cloud-feign-starter/pom.xml index 705a374..64b8386 100644 --- a/mall-ebtp-cloud-feign-starter/pom.xml +++ b/mall-ebtp-cloud-feign-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-feign-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-feign-starter diff --git a/mall-ebtp-cloud-feign-starter/src/main/resources/feign-configuration.properties b/mall-ebtp-cloud-feign-starter/src/main/resources/feign-configuration.properties index 9135922..f9ce372 100644 --- a/mall-ebtp-cloud-feign-starter/src/main/resources/feign-configuration.properties +++ b/mall-ebtp-cloud-feign-starter/src/main/resources/feign-configuration.properties @@ -1,4 +1,4 @@ # 默认开启熔断 feign.hystrix.enabled=true -feign.client.config.default.connectTimeout=5000 -feign.client.config.default.readTimeout=10000 \ No newline at end of file +feign.client.config.default.connectTimeout=50000 +feign.client.config.default.readTimeout=50000 \ No newline at end of file diff --git a/mall-ebtp-cloud-fileupload-starter/pom.xml b/mall-ebtp-cloud-fileupload-starter/pom.xml index 63df3a1..5cdfb4a 100644 --- a/mall-ebtp-cloud-fileupload-starter/pom.xml +++ b/mall-ebtp-cloud-fileupload-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-fileupload-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-fileupload-starter diff --git a/mall-ebtp-cloud-jpa-starter/pom.xml b/mall-ebtp-cloud-jpa-starter/pom.xml index 174d97c..028e252 100644 --- a/mall-ebtp-cloud-jpa-starter/pom.xml +++ b/mall-ebtp-cloud-jpa-starter/pom.xml @@ -4,26 +4,27 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-jpa-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-jpa-starter - + com.baomidou mybatis-plus-boot-starter - - com.alibaba - druid-spring-boot-starter - + + com.alibaba + druid-spring-boot-starter + - + diff --git a/mall-ebtp-cloud-kafka-starter/pom.xml b/mall-ebtp-cloud-kafka-starter/pom.xml index fa77eb8..84de136 100644 --- a/mall-ebtp-cloud-kafka-starter/pom.xml +++ b/mall-ebtp-cloud-kafka-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-kafka-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-kafka-starter diff --git a/mall-ebtp-cloud-log-starter/pom.xml b/mall-ebtp-cloud-log-starter/pom.xml index 289d880..8c41cae 100644 --- a/mall-ebtp-cloud-log-starter/pom.xml +++ b/mall-ebtp-cloud-log-starter/pom.xml @@ -4,17 +4,18 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-log-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-log-starter - + org.springframework.boot diff --git a/mall-ebtp-cloud-mvc-starter/pom.xml b/mall-ebtp-cloud-mvc-starter/pom.xml index 236f7c9..63d0646 100644 --- a/mall-ebtp-cloud-mvc-starter/pom.xml +++ b/mall-ebtp-cloud-mvc-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-mvc-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-mvc-starter diff --git a/mall-ebtp-cloud-office-starter/pom.xml b/mall-ebtp-cloud-office-starter/pom.xml index f20d8f9..30096c9 100644 --- a/mall-ebtp-cloud-office-starter/pom.xml +++ b/mall-ebtp-cloud-office-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-office-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-office-starter diff --git a/mall-ebtp-cloud-parent/pom.xml b/mall-ebtp-cloud-parent/pom.xml index a2fcca2..d525ae5 100644 --- a/mall-ebtp-cloud-parent/pom.xml +++ b/mall-ebtp-cloud-parent/pom.xml @@ -6,82 +6,81 @@ com.chinaunicom.ebtp mall-ebtp-cloud - 0.0.1 - .. + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + + 0.0.1-SNAPSHOT pom mall-ebtp-cloud-parent - http://maven.apache.org com.chinaunicom.ebtp mall-ebtp-cloud-mvc-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-eureka-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-apollo-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-security-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-jpa-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-office-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-swagger-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-fileupload-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-redis-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-kafka-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-feign-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-seata-starter - 0.0.1 + 0.0.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-attachment-sdk - 0.0.1 + 0.0.1-SNAPSHOT @@ -99,18 +98,6 @@ - - - repo_group_seal - Nexus Snapshot Repository - http://192.168.30.126:31233/repository/eshop-grouppath-45c07c6e-maven-group/ - - false - - - false - - aliyun-repos https://maven.aliyun.com/repository/public @@ -119,18 +106,5 @@ - - - - repo_group_seal - Nexus Snapshot Repository - http://192.168.30.126:31233/repository/eshop-grouppath-45c07c6e-maven-group/ - - true - - - true - - - + diff --git a/mall-ebtp-cloud-redis-starter/pom.xml b/mall-ebtp-cloud-redis-starter/pom.xml index f455206..32af5e3 100644 --- a/mall-ebtp-cloud-redis-starter/pom.xml +++ b/mall-ebtp-cloud-redis-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-redis-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-redis-starter diff --git a/mall-ebtp-cloud-seata-starter/pom.xml b/mall-ebtp-cloud-seata-starter/pom.xml index 4add5a8..5ac523e 100644 --- a/mall-ebtp-cloud-seata-starter/pom.xml +++ b/mall-ebtp-cloud-seata-starter/pom.xml @@ -4,21 +4,22 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-seata-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-seata-starter - + 1.3.0 - + com.chinaunicom.ebtp diff --git a/mall-ebtp-cloud-seata-starter/src/main/resources/file.conf b/mall-ebtp-cloud-seata-starter/src/main/resources/file.conf index a37e3e2..7de3b26 100644 --- a/mall-ebtp-cloud-seata-starter/src/main/resources/file.conf +++ b/mall-ebtp-cloud-seata-starter/src/main/resources/file.conf @@ -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 diff --git a/mall-ebtp-cloud-seata-starter/src/main/resources/registry.conf b/mall-ebtp-cloud-seata-starter/src/main/resources/registry.conf index d291bc7..0a4eb4c 100644 --- a/mall-ebtp-cloud-seata-starter/src/main/resources/registry.conf +++ b/mall-ebtp-cloud-seata-starter/src/main/resources/registry.conf @@ -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" } -} +} \ No newline at end of file diff --git a/mall-ebtp-cloud-security-starter/pom.xml b/mall-ebtp-cloud-security-starter/pom.xml index 84a46c7..931b060 100644 --- a/mall-ebtp-cloud-security-starter/pom.xml +++ b/mall-ebtp-cloud-security-starter/pom.xml @@ -8,13 +8,13 @@ com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-security-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-security-starter diff --git a/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/entity/AuthorityEntity.java b/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/entity/AuthorityEntity.java new file mode 100644 index 0000000..e7e36a6 --- /dev/null +++ b/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/entity/AuthorityEntity.java @@ -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 authorities; + +} diff --git a/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/entity/SecurityEntity.java b/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/entity/SecurityEntity.java new file mode 100644 index 0000000..499a4ee --- /dev/null +++ b/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/entity/SecurityEntity.java @@ -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 authorityList; + private String userid; + private List 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; + +} diff --git a/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/filter/TokenAuthenticationFilter.java b/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/filter/TokenAuthenticationFilter.java index 4fde9e3..d34dec0 100644 --- a/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/filter/TokenAuthenticationFilter.java +++ b/mall-ebtp-cloud-security-starter/src/main/java/com/chinaunicom/mall/ebtp/cloud/security/starter/filter/TokenAuthenticationFilter.java @@ -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 entity = restTemplate.getForEntity(createRequestUri(token), Map.class); - + ResponseEntity entity = restTemplate.getForEntity(createRequestUri(token), + SecurityEntity.class); + return new UsernamePasswordAuthenticationToken(entity.getBody(), token); } /** + * 生成山分认证中心请求接口地址 + * * @param token * @return */ diff --git a/mall-ebtp-cloud-security-starter/src/main/resources/security-configuration.properties b/mall-ebtp-cloud-security-starter/src/main/resources/security-configuration.properties index 11301af..d8b2a30 100644 --- a/mall-ebtp-cloud-security-starter/src/main/resources/security-configuration.properties +++ b/mall-ebtp-cloud-security-starter/src/main/resources/security-configuration.properties @@ -1 +1 @@ -user.auth.resource.token-info-uri=http://125.32.114.204:18091/oauth/check_token \ No newline at end of file +user.auth.resource.token-info-uri=http://10.242.31.158:8100/mall-auth/oauth/check_token \ No newline at end of file diff --git a/mall-ebtp-cloud-swagger-starter/pom.xml b/mall-ebtp-cloud-swagger-starter/pom.xml index 817c38e..2f3308b 100644 --- a/mall-ebtp-cloud-swagger-starter/pom.xml +++ b/mall-ebtp-cloud-swagger-starter/pom.xml @@ -4,15 +4,16 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 + com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-swagger-starter - 0.0.1 + 0.0.1-SNAPSHOT mall-ebtp-cloud-swagger-starter diff --git a/pom.xml b/pom.xml index 149aa9a..a2bc4ec 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 @@ -9,7 +11,7 @@ com.chinaunicom.ebtp mall-ebtp-cloud - 0.0.1 + 0.0.1-SNAPSHOT pom mall-ebtp-cloud @@ -24,7 +26,7 @@ UTF-8 Hoxton.SR7 2.2.3.RELEASE - 3.2.0 + 3.4.0 2.6.0-SNAPSHOT 1.5.21 1.3.3 @@ -348,17 +350,22 @@ - + META-INF/spring.handlers - + META-INF/spring.factories - + META-INF/spring.schemas - - + + ${start-class} @@ -387,27 +394,32 @@ mall-ebtp-cloud-seata-starter uboot-common uboot-core - mall-ebtp-cloud-attachment-sdk - - - - China Unicom - http://www.chinaunicom.com - - - - ajaxfan - ajaxfan@gmail.com - ChinaUnicom - - + mall-ebtp-cloud-attachment-sdk + + + + China Unicom + http://www.chinaunicom.com + + + + ajaxfan + ajaxfan@gmail.com + ChinaUnicom + + - ettp-host-release - Install to ettp center - http://zentao.jlcucc.com:60000/repository/ettp-releases/ + tianti-maven-release-local + user release resp + http://ccp.tianti.tg.unicom.local/artifactory/tianti-maven-release-local/ + + tianti-maven-snapshot-local + user snapshot + http://ccp.tianti.tg.unicom.local/artifactory/tianti-maven-snapshot-local/ + \ No newline at end of file diff --git a/uboot-common/pom.xml b/uboot-common/pom.xml index cc43ca1..196f29f 100644 --- a/uboot-common/pom.xml +++ b/uboot-common/pom.xml @@ -1,78 +1,88 @@ - 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"> + 4.0.0 - - com.chinaunicom.ebtp - mall-ebtp-cloud-parent - 0.0.1 - ../mall-ebtp-cloud-parent - + + com.chinaunicom.ebtp + mall-ebtp-cloud-parent + 0.0.1-SNAPSHOT + ../mall-ebtp-cloud-parent + + com.chinaunicom.mall.ebtp + uboot-common + 0.0.1-SNAPSHOT + uboot-common - com.chinaunicom.mall.ebtp - uboot-common - 0.0.1 - uboot-common + + + com.chinaunicom.ebtp + mall-ebtp-cloud-mvc-starter + - - - com.chinaunicom.ebtp - mall-ebtp-cloud-mvc-starter - + + com.chinaunicom.ebtp + mall-ebtp-cloud-jpa-starter + - - com.chinaunicom.ebtp - mall-ebtp-cloud-jpa-starter - + + com.chinaunicom.ebtp + mall-ebtp-cloud-eureka-starter + - - com.chinaunicom.ebtp - mall-ebtp-cloud-eureka-starter - + + com.chinaunicom.ebtp + mall-ebtp-cloud-feign-starter + - - com.chinaunicom.ebtp - mall-ebtp-cloud-feign-starter - + + com.chinaunicom.ebtp + mall-ebtp-cloud-swagger-starter + - - com.chinaunicom.ebtp - mall-ebtp-cloud-swagger-starter - + + com.chinaunicom.ebtp + mall-ebtp-cloud-redis-starter + - - com.chinaunicom.ebtp - mall-ebtp-cloud-redis-starter - - com.chinaunicom.ebtp mall-ebtp-cloud-security-starter - - org.apache.poi - poi-ooxml - - + + + + org.springframework.boot + spring-boot-starter-actuator + + + io.micrometer + micrometer-registry-prometheus + + + + org.apache.poi + poi-ooxml + + + - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - - src/main/resources - true - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + src/main/resources + true + + + diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/entity/BaseCacheUser.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/entity/BaseCacheUser.java index 6a8e5b8..03da1e6 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/entity/BaseCacheUser.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/entity/BaseCacheUser.java @@ -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 authorityList; + } diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/service/impl/BaseCacheUserServiceImpl.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/service/impl/BaseCacheUserServiceImpl.java index 9e5c847..3bee414 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/service/impl/BaseCacheUserServiceImpl.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/service/impl/BaseCacheUserServiceImpl.java @@ -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); - } - } } diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/config/FeignConfig.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/config/FeignConfig.java index ddef51d..ab0d973 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/config/FeignConfig.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/config/FeignConfig.java @@ -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)); } } } diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/config/WebConfig.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/config/WebConfig.java index f54f7fd..cbe40c1 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/config/WebConfig.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/config/WebConfig.java @@ -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 diff --git a/uboot-core/pom.xml b/uboot-core/pom.xml index 801f8e5..071b678 100644 --- a/uboot-core/pom.xml +++ b/uboot-core/pom.xml @@ -6,13 +6,13 @@ com.chinaunicom.ebtp mall-ebtp-cloud-parent - 0.0.1 + 0.0.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.mall.ebtp uboot-core - 0.0.1 + 0.0.1-SNAPSHOT uboot-core @@ -20,38 +20,12 @@ com.chinaunicom.mall.ebtp uboot-common - 0.0.1 - + 0.0.1-SNAPSHOT com.chinaunicom.ebtp - mall-ebtp-cloud-jpa-starter - - - - com.chinaunicom.ebtp - mall-ebtp-cloud-eureka-starter - - - - com.chinaunicom.ebtp - mall-ebtp-cloud-feign-starter - - - - com.chinaunicom.ebtp - mall-ebtp-cloud-swagger-starter - - - - com.chinaunicom.ebtp - mall-ebtp-cloud-redis-starter - - - - io.seata - seata-spring-boot-starter + mall-ebtp-cloud-seata-starter @@ -61,7 +35,6 @@ -