Selaa lähdekoodia

推送商品信息到芸众中台

chl 2 vuotta sitten
vanhempi
commit
e9808239d2

+ 2 - 35
huijie-center/pom.xml

@@ -21,50 +21,17 @@
     </description>
 
     <dependencies>
-        <!-- spring-boot-devtools -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-devtools</artifactId>
-            <optional>true</optional> <!-- 表示依赖不会传递 -->
-        </dependency>
-
-        <!-- swagger3-->
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-boot-starter</artifactId>
-        </dependency>
-
-        <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
-        <dependency>
-            <groupId>io.swagger</groupId>
-            <artifactId>swagger-models</artifactId>
-            <version>1.6.2</version>
-        </dependency>
-
-        <!-- Mysql驱动包 -->
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-
         <!-- 核心模块-->
         <dependency>
             <groupId>com.ruoyi</groupId>
             <artifactId>ruoyi-framework</artifactId>
         </dependency>
 
-        <!-- 定时任务-->
         <dependency>
-            <groupId>com.ruoyi</groupId>
-            <artifactId>ruoyi-quartz</artifactId>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
         </dependency>
 
-        <!-- 单元测试 -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
 </project>

+ 19 - 0
huijie-center/src/main/java/com/ruoyi/api/config/ContextConfig.java

@@ -0,0 +1,19 @@
+package com.ruoyi.api.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.SpringBootConfiguration;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootConfiguration
+public class ContextConfig {
+
+    @Autowired
+    private RestTemplateBuilder builder;
+
+    @Bean
+    public RestTemplate restTemplate() {
+        return builder.build();
+    }
+}

+ 1 - 1
huijie-center/src/main/java/com/ruoyi/api/constant/yz/ApiConstant.java

@@ -2,5 +2,5 @@ package com.ruoyi.api.constant.yz;
 
 public class ApiConstant {
     public static final String GET_TOKEN = "/app/application/getToken";
-
+    public static final String PUSH_PRODUCT = "/app/product/cloud/pushProduct";
 }

+ 80 - 0
huijie-center/src/main/java/com/ruoyi/api/fake/PushProductFake.java

@@ -0,0 +1,80 @@
+package com.ruoyi.api.fake;
+
+import com.ruoyi.api.pojo.bo.ProductsBO;
+import com.ruoyi.common.utils.uuid.IdUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class PushProductFake {
+
+    /**
+     * 推送商品Fake数据
+     * @return
+     */
+    public static ProductsBO productsBO() {
+        ProductsBO productsBO = new ProductsBO();
+        productsBO.setTitle("测试商品" + IdUtils.fastUUID().toString());
+        productsBO.setDetailImages("<figure class=\"image\"><img src=\"https://img.yunzhonghe.com/image/1570588776975JFmOBwQXph.jpg\"></figure>");
+        productsBO.setCategory1Id(4L);
+        productsBO.setCategory2Id(6L);
+        productsBO.setCategory3Id(7L);
+        productsBO.setStock(10000L);
+        productsBO.setPrice(6666L);
+        productsBO.setGuidePrice(7777L);
+        productsBO.setOriginPrice(8000L);
+        productsBO.setCostPrice(5555L);
+        productsBO.setFreight(0L);
+        productsBO.setFreightTemplateId(0L);
+        productsBO.setFreightType(2);
+        productsBO.setUnit("个");
+        productsBO.setImageUrl("http://img.limofang.cn//2021/2/1570869704680QazgQpvuHF.jpg");
+
+        // 组图
+        List<ProductsBO.ProductsGalleryBO> gallery = new ArrayList<>();
+        List<String> srcList = Arrays.asList("http://img.limofang.cn//2021/2/1570869704669UWFHzwIMIn.jpg", "http://img.limofang.cn//2021/2/1570869704688uYGRoXrfAH.jpg", "http://img.limofang.cn//2021/2/1570869704680QazgQpvuHF.jpg", "http://img.limofang.cn//2021/2/1570869706317wpCRqaHaNw.jpg", "http://img.limofang.cn//2021/2/1570869706339pKSzOYmWaS.jpg");
+        for (String src : srcList) {
+            ProductsBO.ProductsGalleryBO productsGalleryBO = productsBO.new ProductsGalleryBO();
+            productsGalleryBO.setType(1);
+            productsGalleryBO.setSrc(src);
+            gallery.add(productsGalleryBO);
+        }
+        productsBO.setGallery(gallery);
+
+        // 属性
+        List<ProductsBO.ProductsAttrsBO> attrList = new ArrayList<>();
+        ProductsBO.ProductsAttrsBO productsAttrsBO = productsBO.new ProductsAttrsBO();
+        productsAttrsBO.setName("颜色");
+        productsAttrsBO.setValue("白");
+        attrList.add(productsAttrsBO);
+        productsBO.setAttrs(attrList);
+
+        // 规格
+        ArrayList<ProductsBO.ProductsSkusBO> skuList = new ArrayList<>();
+        ProductsBO.ProductsSkusBO productsSkusBO = productsBO.new ProductsSkusBO();
+        productsSkusBO.setTitle("新款+超辣");
+        productsSkusBO.setCostPrice(1L);
+        productsSkusBO.setOriginPrice(3L);
+        productsSkusBO.setGuidePrice(3L);
+        productsSkusBO.setActivityPrice(0L);
+        productsSkusBO.setStock(99L);
+        // 规格详情
+        List<ProductsBO.ProductsSkusBO.SkusOptions> optionList = new ArrayList<>();
+        ProductsBO.ProductsSkusBO.SkusOptions skusOptions = productsSkusBO.new SkusOptions();
+        skusOptions.setSpecName("规格");
+        skusOptions.setSpecItemName("默认");
+        optionList.add(skusOptions);
+        productsSkusBO.setOptions(optionList);
+        productsSkusBO.setPrice(1L);
+        productsSkusBO.setWeight(500L);
+        productsSkusBO.setCode("");
+        productsSkusBO.setSn("0001");
+        skuList.add(productsSkusBO);
+        productsBO.setSkus(skuList);
+
+        productsBO.setSingleOption(1);
+        productsBO.setCode("");
+        return productsBO;
+    }
+}

+ 179 - 0
huijie-center/src/main/java/com/ruoyi/api/pojo/bo/ProductsBO.java

@@ -0,0 +1,179 @@
+package com.ruoyi.api.pojo.bo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProductsBO {
+
+    /**
+     * 标题
+     */
+    private String title;
+    /**
+     * 详情图json数组
+     */
+    private String detailImages;
+    private Long category1Id;
+    private Long category2Id;
+    private Long category3Id;
+    /**
+     * 库存数量
+     */
+    private Long stock;
+    /**
+     * 供货价(单位:分)
+     */
+    private Long price;
+    /**
+     * 供货价(单位:分)
+     */
+    private Long guidePrice;
+    /**
+     * 市场价(单位:分)
+     */
+    private Long originPrice;
+    /**
+     * 成本价(单位:分)
+     */
+    private Long costPrice;
+    /**
+     * 运费(分)
+     */
+    private Long freight;
+    /**
+     * 配送模板id
+     */
+    private Long freightTemplateId;
+    /**
+     * 运费类型(0统一,1模板, 2第三方运费,3包邮)
+     */
+    private Integer freightType;
+    /**
+     * 单位(件,个)
+     */
+    private String unit;
+    /**
+     * 图片url
+     */
+    private String imageUrl;
+    /**
+     * 相册图json数组
+     */
+    private List<ProductsGalleryBO> gallery;
+    /**
+     * 属性
+     */
+    private List<ProductsAttrsBO> attrs;
+    /**
+     * 规格
+     */
+    private List<ProductsSkusBO> skus;
+    /**
+     * 单规格(1是0否)
+     */
+    private Integer singleOption;
+    /**
+     * 自定义编码
+     */
+    private String code;
+
+    /**
+     * 属性值
+     */
+    @Data
+    public class ProductsAttrsBO {
+        /**
+         * 属性名称
+         */
+        private String name;
+        /**
+         * 属性值
+         */
+        private String value;
+    }
+
+    /**
+     * 组图
+     */
+    @Data
+    public class ProductsGalleryBO {
+        /**
+         * type
+         */
+        private Integer type;
+        /**
+         * 路径
+         */
+        private String src;
+    }
+
+    /**
+     *
+     */
+    @Data
+    public class ProductsSkusBO {
+        /**
+         * 规格属性名称
+         */
+        private String title;
+        /**
+         * 成本价格(分)
+         */
+        private Long costPrice;
+        /**
+         * 市场价(分)
+         */
+        private Long originPrice;
+        /**
+         * 指导价(分)
+         */
+        private Long guidePrice;
+        /**
+         * 营销价格(分)
+         */
+        private Long activityPrice;
+        /**
+         * 库存
+         */
+        private Long stock;
+        /**
+         * 规格详情
+         */
+        private List<SkusOptions> options;
+        /**
+         * 供货价(分)
+         */
+        private Long price;
+        /**
+         * 重量
+         */
+        private Long weight;
+        /**
+         * 条码
+         */
+        private String sn;
+        /**
+         * 自定义编码
+         */
+        private String code;
+
+        @Data
+        public class SkusOptions {
+            /**
+             * 规格名称
+             */
+            private String specName;
+            /**
+             * 规格名称
+             */
+            private String specItemName;
+        }
+    }
+
+}

+ 484 - 0
huijie-center/src/main/java/com/ruoyi/api/pojo/entity/Products.java

@@ -0,0 +1,484 @@
+package com.ruoyi.api.pojo.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @TableName products
+ */
+@Data
+@ApiModel(value = "商品对象", description = "商品表")
+public class Products implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("ID")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+    /**
+     * 删除时间
+     */
+    @ApiModelProperty("删除时间")
+    private Date deletedAt;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty("创建时间")
+    private Date createdAt;
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty("更新时间")
+    private Date updatedAt;
+    /**
+     * 标题
+     */
+    @Size(max = 255, message = "编码长度不能超过255")
+    @ApiModelProperty("标题")
+    @Length(max = 255, message = "编码长度不能超过255")
+    private String title;
+    /**
+     * 市场价(单位:分)
+     */
+    @ApiModelProperty("市场价(单位:分)")
+    private Long originPrice;
+    /**
+     * 供货价(单位:分)
+     */
+    @ApiModelProperty("供货价(单位:分)")
+    private Long guidePrice;
+    /**
+     * 供货价(单位:分)
+     */
+    @ApiModelProperty("供货价(单位:分)")
+    private Long price;
+    /**
+     * 成本价(单位:分)
+     */
+    @ApiModelProperty("成本价(单位:分)")
+    private Long costPrice;
+    /**
+     * 营销价(单位:分)
+     */
+    @ApiModelProperty("营销价(单位:分)")
+    private Long activityPrice;
+    /**
+     * 库存数量
+     */
+    @ApiModelProperty("库存数量")
+    private Long stock;
+    /**
+     * 销量
+     */
+    @ApiModelProperty("销量")
+    private Long sales;
+    /**
+     * 好评率
+     */
+    @ApiModelProperty("好评率")
+    private Long feedbackRate;
+    /**
+     * 产品编号
+     */
+    @Size(max = -1, message = "编码长度不能超过-1")
+    @ApiModelProperty("产品编号")
+    @Length(max = -1, message = "编码长度不能超过-1")
+    private String sn;
+    /**
+     * 自定义编码
+     */
+    @Size(max = 255, message = "编码长度不能超过255")
+    @ApiModelProperty("自定义编码")
+    @Length(max = 255, message = "编码长度不能超过255")
+    private String code;
+    /**
+     * 新品(1是0否)
+     */
+    @ApiModelProperty("新品(1是0否)")
+    private Integer isNew;
+    /**
+     * 推荐(1是0否)
+     */
+    @ApiModelProperty("推荐(1是0否)")
+    private Integer isRecommend;
+    /**
+     * 热销(1是0否)
+     */
+    @ApiModelProperty("热销(1是0否)")
+    private Integer isHot;
+    /**
+     * 促销(1是0否)
+     */
+    @ApiModelProperty("促销(1是0否)")
+    private Integer isPromotion;
+    /**
+     * 上架(1是0否)
+     */
+    @ApiModelProperty("上架(1是0否)")
+    private Integer isDisplay;
+    /**
+     * 锁定(1是0否)
+     */
+    @ApiModelProperty("锁定(1是0否)")
+    private Integer statusLock;
+    /**
+     * 单规格(1是0否)
+     */
+    @ApiModelProperty("单规格(1是0否)")
+    private Integer singleOption;
+    /**
+     * 简介
+     */
+    @Size(max = 200, message = "编码长度不能超过200")
+    @ApiModelProperty("简介")
+    @Length(max = 200, message = "编码长度不能超过200")
+    private String desc;
+    /**
+     * 图片url
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("图片url")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String imageUrl;
+    /**
+     * 视频url
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("视频url")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String videoUrl;
+    /**
+     * 单位(件,个)
+     */
+    @Size(max = 255, message = "编码长度不能超过255")
+    @ApiModelProperty("单位(件,个)")
+    @Length(max = 255, message = "编码长度不能超过255")
+    private String unit;
+
+    /**
+     * 条形码
+     */
+    @Size(max = 255, message = "编码长度不能超过255")
+    @ApiModelProperty("条形码")
+    @Length(max = 255, message = "编码长度不能超过255")
+    private String barcode;
+    /**
+     * 长(单位:毫米)
+     */
+    @ApiModelProperty("长(单位:毫米)")
+    @TableField("long")
+    private Long length;
+    /**
+     * 宽(单位:毫米)
+     */
+    @ApiModelProperty("宽(单位:毫米)")
+    private Long wide;
+    /**
+     * 高(单位:毫米)
+     */
+    @ApiModelProperty("高(单位:毫米)")
+    private Long high;
+    /**
+     * 体积(单位:立方毫米)
+     */
+    @ApiModelProperty("体积(单位:立方毫米)")
+    private Long volume;
+    /**
+     * 运费(分)
+     */
+    @ApiModelProperty("运费(分)")
+    private Long freight;
+    /**
+     * 运费类型(0统一,1模板, 2第三方运费,3包邮)
+     */
+    @ApiModelProperty("运费类型(0统一,1模板, 2第三方运费,3包邮)")
+    private Integer freightType;
+    /**
+     * 最高价(单位:分)
+     */
+    @ApiModelProperty("最高价(单位:分)")
+    private Long maxPrice;
+    /**
+     * 最低价(单位:分)
+     */
+    @ApiModelProperty("最低价(单位:分)")
+    private Long minPrice;
+    /**
+     * 相册图json数组
+     */
+    @Size(max = -1, message = "编码长度不能超过-1")
+    @ApiModelProperty("相册图json数组")
+    @Length(max = -1, message = "编码长度不能超过-1")
+    private String gallery;
+    /**
+     * 资质json数组
+     */
+    @Size(max = -1, message = "编码长度不能超过-1")
+    @ApiModelProperty("资质json数组")
+    @Length(max = -1, message = "编码长度不能超过-1")
+    private String qualifications;
+    /**
+     * 详情图json数组
+     */
+    @Size(max = -1, message = "编码长度不能超过-1")
+    @ApiModelProperty("详情图json数组")
+    @Length(max = -1, message = "编码长度不能超过-1")
+    private String detailImages;
+    /**
+     * 属性json列表(冗余信息)
+     */
+    @Size(max = -1, message = "编码长度不能超过-1")
+    @ApiModelProperty("属性json列表(冗余信息)")
+    @Length(max = -1, message = "编码长度不能超过-1")
+    private String attrs;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long brandId;
+    /**
+     * 供应商id
+     */
+    @ApiModelProperty("供应商id")
+    private Long supplierId;
+    /**
+     * 供应链id
+     */
+    @ApiModelProperty("供应链id")
+    private Long gatherSupplyId;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long category1Id;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long category2Id;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long category3Id;
+    /**
+     * 配送模板id
+     */
+    @ApiModelProperty("配送模板id")
+    private Long freightTemplateId;
+    /**
+     * 商品来源
+     */
+    @ApiModelProperty("商品来源")
+    private Long source;
+    /**
+     * 商品排序
+     */
+    @ApiModelProperty("商品排序")
+    private Long sort;
+    /**
+     * 商品来源ID
+     */
+    @ApiModelProperty("商品来源ID")
+    private Long sourceGoodsId;
+    /**
+     * 是否冻结
+     */
+    @ApiModelProperty("是否冻结")
+    private Long freeze;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Integer shopLevel;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Integer desLevel;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Integer expressLevel;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Integer level;
+    /**
+     * 简称
+     */
+    @Size(max = 255, message = "编码长度不能超过255")
+    @ApiModelProperty("简称")
+    @Length(max = 255, message = "编码长度不能超过255")
+    private String childTitle;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long billPosition;
+    /**
+     *
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String taxCode;
+    /**
+     *
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String taxShortName;
+    /**
+     *
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String taxOption;
+    /**
+     *
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String taxUnit;
+    /**
+     *
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String favorablePolicy;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long isFavorablePolicy;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long freeOfTax;
+    /**
+     *
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String shortCode;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long taxMeasurePrice;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long taxRate;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long isTaxLogo;
+    /**
+     *
+     */
+    @Size(max = 255, message = "编码长度不能超过255")
+    @ApiModelProperty("")
+    @Length(max = 255, message = "编码长度不能超过255")
+    private String md5;
+    /**
+     * 站点ID
+     */
+    @ApiModelProperty("站点ID")
+    private Long locationId;
+    /**
+     * 最小起订量
+     */
+    @ApiModelProperty("最小起订量")
+    private Long minBuyQty;
+    /**
+     *
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String taxProductName;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long isPlugin;
+    /**
+     * 利润率
+     */
+    @ApiModelProperty("利润率")
+    private Double costRate;
+    /**
+     * 营销利润率
+     */
+    @ApiModelProperty("营销利润率")
+    private Double activityRate;
+    /**
+     *
+     */
+    @ApiModelProperty("排序")
+    private Long isSingleOrder;
+    /**
+     *
+     */
+    @ApiModelProperty("插件id")
+    private Long pluginId;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long isBill;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long supplierSourceId;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private BigDecimal profitRate;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long supplierSourceCategoryId;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long isSupplyLine;
+    /**
+     *
+     */
+    @ApiModelProperty("")
+    private Long jushuitanBind;
+    /**
+     *
+     */
+    @Size(max = 191, message = "编码长度不能超过191")
+    @ApiModelProperty("")
+    @Length(max = 191, message = "编码长度不能超过191")
+    private String supplyLine;
+
+}

+ 17 - 0
huijie-center/src/main/java/com/ruoyi/api/service/IProductService.java

@@ -0,0 +1,17 @@
+package com.ruoyi.api.service;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.ruoyi.api.downstream.YzResult;
+
+/**
+ * 商品服务
+ *
+ * @author chl
+ */
+public interface IProductService {
+    /**
+     * 获取token
+     * @return
+     */
+    public YzResult pushProduct() throws JsonProcessingException;
+}

+ 36 - 0
huijie-center/src/main/java/com/ruoyi/api/service/impl/ProductServiceImpl.java

@@ -0,0 +1,36 @@
+package com.ruoyi.api.service.impl;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ruoyi.api.constant.yz.ApiConstant;
+import com.ruoyi.api.downstream.YzResult;
+import com.ruoyi.api.fake.PushProductFake;
+import com.ruoyi.api.pojo.bo.ProductsBO;
+import com.ruoyi.api.service.IProductService;
+import com.ruoyi.api.utils.HttpUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ProductServiceImpl implements IProductService {
+    @Value("${downstream.url}")
+    private String url;
+
+    private final ObjectMapper objectMapper = new ObjectMapper();
+
+    @Override
+    public YzResult pushProduct() throws JsonProcessingException {
+        String realUrl = url + ApiConstant.PUSH_PRODUCT;
+
+        // TODO:没有第三方供应链,伪造测试数据
+        ProductsBO productsBO = PushProductFake.productsBO();
+        objectMapper.setPropertyNamingStrategy(com.fasterxml.jackson.databind.PropertyNamingStrategy.SNAKE_CASE);
+
+        String data = objectMapper.writeValueAsString(productsBO);
+        System.out.println("data: " + data);
+
+        ResponseEntity<String> responseEntity = HttpUtils.sendPostWithHeaders(realUrl, data);
+        return objectMapper.readValue(responseEntity.getBody(), YzResult.class);
+    }
+}

+ 63 - 0
huijie-center/src/main/java/com/ruoyi/api/utils/HttpUtils.java

@@ -0,0 +1,63 @@
+package com.ruoyi.api.utils;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.ruoyi.api.service.ITokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * Http工具包
+ */
+@Component
+public final class HttpUtils {
+    private static RestTemplate restTemplate;
+    private static ITokenService tokenService;
+
+    @Autowired
+    public void setRestTemplate(RestTemplate restTemplate) {
+        HttpUtils.restTemplate = restTemplate;
+    }
+
+    @Autowired
+    public void setTokenService(ITokenService tokenService) {
+        HttpUtils.tokenService = tokenService;
+    }
+
+    /**
+     * 发送post请求:带请求头
+     *
+     * @param data
+     * @param url
+     * @return
+     */
+    public static ResponseEntity<String> sendPostWithHeaders(String url, String data) {
+        HttpHeaders headers = getDefaultHeaders();
+        JSONObject jsonObject = JSONObject.parseObject(data);
+        HttpEntity<JSONObject> httpEntity = new HttpEntity<>(jsonObject, headers);
+        return restTemplate.postForEntity(url, httpEntity, String.class);
+    }
+
+    /**
+     * 获取默认请求头
+     *
+     * @return
+     */
+    private static HttpHeaders getDefaultHeaders() {
+        String token = null;
+        try {
+            token = tokenService.getToken();
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Content-Type", "application/json;charset=UTF-8");
+        headers.set("x-token", token);
+        return headers;
+    }
+}

+ 34 - 4
pom.xml

@@ -2,8 +2,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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	
+    <modelVersion>4.0.0</modelVersion>
+
     <groupId>com.ruoyi</groupId>
     <artifactId>ruoyi</artifactId>
     <version>3.8.5</version>
@@ -11,7 +11,7 @@
     <name>ruoyi</name>
     <url>http://www.ruoyi.vip</url>
     <description>若依管理系统</description>
-    
+
     <properties>
         <ruoyi.version>3.8.5</ruoyi.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -30,8 +30,10 @@
         <poi.version>4.1.2</poi.version>
         <velocity.version>2.3</velocity.version>
         <jwt.version>0.9.1</jwt.version>
+        <mybatis-plus.version>3.4.1</mybatis-plus.version>
+        <hutool.version>5.5.8</hutool.version>
     </properties>
-	
+
     <!-- 依赖声明 -->
     <dependencyManagement>
         <dependencies>
@@ -170,6 +172,34 @@
                 <version>${ruoyi.version}</version>
             </dependency>
 
+            <!--mybatis-plus-->
+            <dependency>
+                <groupId>com.baomidou</groupId>
+                <artifactId>mybatis-plus-boot-starter</artifactId>
+                <version>${mybatis-plus.version}</version>
+            </dependency>
+
+            <!--mybatis-plus 代码生成器-->
+            <dependency>
+                <groupId>com.baomidou</groupId>
+                <artifactId>mybatis-plus-generator</artifactId>
+                <version>${mybatis-plus.version}</version>
+            </dependency>
+
+            <!-- Mybatis Plus 代码生成器模板引擎,  -->
+            <dependency>
+                <groupId>org.apache.velocity</groupId>
+                <artifactId>velocity-engine-core</artifactId>
+                <version>${velocity.version}</version>
+            </dependency>
+
+            <!-- hutool工具包 -->
+            <dependency>
+                <groupId>cn.hutool</groupId>
+                <artifactId>hutool-all</artifactId>
+                <version>${hutool.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 

+ 0 - 32
ruoyi-admin/pom.xml

@@ -24,25 +24,6 @@
             <optional>true</optional> <!-- 表示依赖不会传递 -->
         </dependency>
 
-        <!-- swagger3-->
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-boot-starter</artifactId>
-        </dependency>
-
-        <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
-        <dependency>
-            <groupId>io.swagger</groupId>
-            <artifactId>swagger-models</artifactId>
-            <version>1.6.2</version>
-        </dependency>
-
-         <!-- Mysql驱动包 -->
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-
         <!-- 核心模块-->
         <dependency>
             <groupId>com.ruoyi</groupId>
@@ -61,24 +42,11 @@
             <artifactId>ruoyi-generator</artifactId>
         </dependency>
 
-        <!-- 单元测试 -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-
         <!-- 中台模块 -->
         <dependency>
             <groupId>com.ruoyi</groupId>
             <artifactId>huijie-center</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.ruoyi</groupId>
-            <artifactId>huijie-center</artifactId>
-            <version>3.8.5</version>
-            <scope>test</scope>
-        </dependency>
 
     </dependencies>
 

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java

@@ -21,7 +21,7 @@ public class RuoYiApplication
         // System.setProperty("spring.devtools.restart.enabled", "false");
         ConfigurableApplicationContext context = SpringApplication.run(RuoYiApplication.class, args);
         ConfigurableEnvironment environment = context.getEnvironment();
-        String port = environment.getProperty("spring.port");
+        String port = environment.getProperty("server.port");
         String active = environment.getProperty("spring.profiles.active");
         String timeZone = TimeZone.getDefault().getID();
         System.out.println(

+ 24 - 0
ruoyi-admin/src/test/java/com/ruoyi/api/ProductsTests.java

@@ -0,0 +1,24 @@
+package com.ruoyi.api;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.ruoyi.api.downstream.YzResult;
+import com.ruoyi.api.service.IProductService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class ProductsTests {
+    @Resource
+    private IProductService productService;
+
+    @Test
+    public void testPushProduct() throws JsonProcessingException {
+        YzResult yzResult = productService.pushProduct();
+        System.out.println(yzResult);
+    }
+}

+ 0 - 5
ruoyi-admin/src/test/java/com/ruoyi/api/TokenTests.java

@@ -1,17 +1,12 @@
 package com.ruoyi.api;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
-import com.ruoyi.api.constant.yz.HttpConstant;
-import com.ruoyi.api.downstream.YzResult;
-import com.ruoyi.api.exception.BusinessException;
-import com.ruoyi.api.result.ResponseEnum;
 import com.ruoyi.api.service.ITokenService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.util.ObjectUtils;
 
 @SpringBootTest
 @RunWith(SpringRunner.class)

+ 56 - 7
ruoyi-common/pom.xml

@@ -52,19 +52,19 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
-  
+
         <!-- JSON工具类 -->
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
         </dependency>
-        
+
         <!-- 动态数据源 -->
-		<dependency>
-			<groupId>com.baomidou</groupId>
-			<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
-			<version>3.5.2</version>
-		</dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
+            <version>3.5.2</version>
+        </dependency>
 
         <!-- 阿里JSON解析器 -->
         <dependency>
@@ -126,6 +126,55 @@
             <artifactId>javax.servlet-api</artifactId>
         </dependency>
 
+        <!--lombok用来简化实体类:需要安装lombok插件-->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+        <!--hutool工具包-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+        </dependency>
+
+        <!--mybatis-plus-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
+
+        <!--mybatis-plus 代码生成器-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+        </dependency>
+
+        <!-- Mybatis Plus 代码生成器模板引擎,  -->
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity-engine-core</artifactId>
+        </dependency>
+
+        <!-- swagger3-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-boot-starter</artifactId>
+        </dependency>
+
+        <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
+        <dependency>
+            <groupId>io.swagger</groupId>
+            <artifactId>swagger-models</artifactId>
+            <version>1.6.2</version>
+        </dependency>
+
+        <!-- Mysql驱动包 -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 0 - 1
ruoyi-system/pom.xml

@@ -16,7 +16,6 @@
     </description>
 
     <dependencies>
-
         <!-- 通用工具-->
         <dependency>
             <groupId>com.ruoyi</groupId>