Browse Source

第一次提交

纵静芸 1 month ago
commit
ae59db3788
41 changed files with 851 additions and 0 deletions
  1. 8 0
      .idea/.gitignore
  2. 18 0
      .idea/compiler.xml
  3. 12 0
      .idea/dataSources.xml
  4. 7 0
      .idea/encodings.xml
  5. 20 0
      .idea/jarRepositories.xml
  6. 14 0
      .idea/misc.xml
  7. 86 0
      .idea/mybatisx/templates.xml
  8. 81 0
      pom.xml
  9. 20 0
      src/main/java/com/zhentao/ZongjingyunApplication.java
  10. 18 0
      src/main/java/com/zhentao/controller/GoodsController.java
  11. 77 0
      src/main/java/com/zhentao/controller/ProductController.java
  12. 18 0
      src/main/java/com/zhentao/mapper/GoodsMapper.java
  13. 18 0
      src/main/java/com/zhentao/mapper/TProductMapper.java
  14. 51 0
      src/main/java/com/zhentao/pojo/Goods.java
  15. 62 0
      src/main/java/com/zhentao/pojo/TProduct.java
  16. 14 0
      src/main/java/com/zhentao/service/GoodsService.java
  17. 14 0
      src/main/java/com/zhentao/service/TProductService.java
  18. 31 0
      src/main/java/com/zhentao/service/impl/GoodsServiceImpl.java
  19. 32 0
      src/main/java/com/zhentao/service/impl/TProductServiceImpl.java
  20. 66 0
      src/main/java/com/zhentao/util/SignUtil.java
  21. 36 0
      src/main/java/com/zhentao/vo/ResultVo.java
  22. 12 0
      src/main/resources/application.yml
  23. 20 0
      src/main/resources/mapper/GoodsMapper.xml
  24. 23 0
      src/main/resources/mapper/TProductMapper.xml
  25. 38 0
      src/test/java/com/zhentao/AppTest.java
  26. 12 0
      target/classes/application.yml
  27. BIN
      target/classes/com/zhentao/ZongjingyunApplication.class
  28. BIN
      target/classes/com/zhentao/controller/GoodsController.class
  29. BIN
      target/classes/com/zhentao/controller/ProductController.class
  30. BIN
      target/classes/com/zhentao/mapper/GoodsMapper.class
  31. BIN
      target/classes/com/zhentao/mapper/TProductMapper.class
  32. BIN
      target/classes/com/zhentao/pojo/Goods.class
  33. BIN
      target/classes/com/zhentao/pojo/TProduct.class
  34. BIN
      target/classes/com/zhentao/service/GoodsService.class
  35. BIN
      target/classes/com/zhentao/service/TProductService.class
  36. BIN
      target/classes/com/zhentao/service/impl/GoodsServiceImpl.class
  37. BIN
      target/classes/com/zhentao/service/impl/TProductServiceImpl.class
  38. BIN
      target/classes/com/zhentao/util/SignUtil.class
  39. BIN
      target/classes/com/zhentao/vo/ResultVo.class
  40. 20 0
      target/classes/mapper/GoodsMapper.xml
  41. 23 0
      target/classes/mapper/TProductMapper.xml

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 18 - 0
.idea/compiler.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <annotationProcessing>
+      <profile name="Maven default annotation processors profile" enabled="true">
+        <sourceOutputDir name="target/generated-sources/annotations" />
+        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
+        <outputRelativeToContentRoot value="true" />
+        <module name="zongjingyun-sale" />
+      </profile>
+    </annotationProcessing>
+  </component>
+  <component name="JavacSettings">
+    <option name="ADDITIONAL_OPTIONS_OVERRIDE">
+      <module name="zongjingyun-sale" options="-parameters" />
+    </option>
+  </component>
+</project>

+ 12 - 0
.idea/dataSources.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
+    <data-source source="LOCAL" name="2407zk2@localhost" uuid="9889c7cf-3166-45dd-a018-f251cb1f38fa">
+      <driver-ref>mysql.8</driver-ref>
+      <synchronize>true</synchronize>
+      <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
+      <jdbc-url>jdbc:mysql://localhost:3306/2407zk2</jdbc-url>
+      <working-dir>$ProjectFileDir$</working-dir>
+    </data-source>
+  </component>
+</project>

+ 7 - 0
.idea/encodings.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
+  </component>
+</project>

+ 20 - 0
.idea/jarRepositories.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Central Repository" />
+      <option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+    </remote-repository>
+  </component>
+</project>

+ 14 - 0
.idea/misc.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
+  <component name="MavenProjectsManager">
+    <option name="originalFiles">
+      <list>
+        <option value="$PROJECT_DIR$/pom.xml" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 86 - 0
.idea/mybatisx/templates.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="TemplatesSettings">
+    <option name="templateConfigs">
+      <TemplateContext>
+        <option name="generateConfig">
+          <GenerateConfig>
+            <option name="annotationType" value="MYBATIS_PLUS3" />
+            <option name="basePackage" value="com.zhentao" />
+            <option name="basePath" value="src/main/java" />
+            <option name="classNameStrategy" value="camel" />
+            <option name="encoding" value="UTF-8" />
+            <option name="extraClassSuffix" value="" />
+            <option name="ignoreFieldPrefix" value="" />
+            <option name="ignoreFieldSuffix" value="" />
+            <option name="ignoreTablePrefix" value="" />
+            <option name="ignoreTableSuffix" value="" />
+            <option name="moduleName" value="zongjingyun-sale" />
+            <option name="modulePath" value="$PROJECT_DIR$" />
+            <option name="moduleUIInfoList">
+              <list>
+                <ModuleInfoGo>
+                  <option name="basePath" value="${domain.basePath}" />
+                  <option name="configFileName" value="serviceImpl.ftl" />
+                  <option name="configName" value="serviceImpl" />
+                  <option name="encoding" value="${domain.encoding}" />
+                  <option name="fileName" value="${domain.fileName}ServiceImpl" />
+                  <option name="fileNameWithSuffix" value="${domain.fileName}ServiceImpl.java" />
+                  <option name="modulePath" value="$PROJECT_DIR$" />
+                  <option name="packageName" value="${domain.basePackage}.service.impl" />
+                </ModuleInfoGo>
+                <ModuleInfoGo>
+                  <option name="basePath" value="${domain.basePath}" />
+                  <option name="configFileName" value="mapperInterface.ftl" />
+                  <option name="configName" value="mapperInterface" />
+                  <option name="encoding" value="${domain.encoding}" />
+                  <option name="fileName" value="${domain.fileName}Mapper" />
+                  <option name="fileNameWithSuffix" value="${domain.fileName}Mapper.java" />
+                  <option name="modulePath" value="$PROJECT_DIR$" />
+                  <option name="packageName" value="${domain.basePackage}.mapper" />
+                </ModuleInfoGo>
+                <ModuleInfoGo>
+                  <option name="basePath" value="${domain.basePath}" />
+                  <option name="configFileName" value="serviceInterface.ftl" />
+                  <option name="configName" value="serviceInterface" />
+                  <option name="encoding" value="${domain.encoding}" />
+                  <option name="fileName" value="${domain.fileName}Service" />
+                  <option name="fileNameWithSuffix" value="${domain.fileName}Service.java" />
+                  <option name="modulePath" value="$PROJECT_DIR$" />
+                  <option name="packageName" value="${domain.basePackage}.service" />
+                </ModuleInfoGo>
+                <ModuleInfoGo>
+                  <option name="basePath" value="src/main/resources" />
+                  <option name="configFileName" value="mapperXml.ftl" />
+                  <option name="configName" value="mapperXml" />
+                  <option name="encoding" value="${domain.encoding}" />
+                  <option name="fileName" value="${domain.fileName}Mapper" />
+                  <option name="fileNameWithSuffix" value="${domain.fileName}Mapper.xml" />
+                  <option name="modulePath" value="$PROJECT_DIR$" />
+                  <option name="packageName" value="mapper" />
+                </ModuleInfoGo>
+              </list>
+            </option>
+            <option name="needsComment" value="true" />
+            <option name="needsModel" value="true" />
+            <option name="relativePackage" value="pojo" />
+            <option name="superClass" value="" />
+            <option name="tableUIInfoList">
+              <list>
+                <TableUIInfo>
+                  <option name="className" value="Goods" />
+                  <option name="tableName" value="goods" />
+                </TableUIInfo>
+              </list>
+            </option>
+            <option name="templatesName" value="mybatis-plus3" />
+            <option name="useLombokPlugin" value="true" />
+          </GenerateConfig>
+        </option>
+        <option name="moduleName" value="zongjingyun-sale" />
+        <option name="projectPath" value="$PROJECT_DIR$" />
+        <option name="templateName" value="mybatis-plus3" />
+      </TemplateContext>
+    </option>
+  </component>
+</project>

+ 81 - 0
pom.xml

@@ -0,0 +1,81 @@
+<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>
+
+  <groupId>com.zhentao</groupId>
+  <artifactId>zongjingyun-sale</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>zongjingyun1</name>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <parent>
+    <groupId>org.springframework.boot</groupId>
+    <artifactId>spring-boot-starter-parent</artifactId>
+    <version>2.3.2.RELEASE</version>
+    <relativePath/>
+  </parent>
+  <!--引入项目的依赖-->
+  <dependencies>
+
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <!--        <dependency>-->
+    <!--            <groupId>org.springframework.boot</groupId>-->
+    <!--            <artifactId>spring-boot-starter-web</artifactId>-->
+    <!--        </dependency>-->
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-configuration-processor</artifactId>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.7.1</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.projectlombok</groupId>
+      <artifactId>lombok</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.alibaba.fastjson2</groupId>
+      <artifactId>fastjson2</artifactId>
+      <version>2.0.39</version>
+    </dependency>
+
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-web</artifactId>
+    </dependency>
+    <!--        mybatis-plus依赖-->
+    <dependency>
+      <groupId>com.baomidou</groupId>
+      <artifactId>mybatis-plus-boot-starter</artifactId>
+      <version>3.5.4</version>
+    </dependency>
+    <!--        mysql依赖-->
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+    </dependency>
+    <!--        lombok依赖-->
+    <dependency>
+      <groupId>org.projectlombok</groupId>
+      <artifactId>lombok</artifactId>
+    </dependency>
+  </dependencies>
+
+
+</project>

+ 20 - 0
src/main/java/com/zhentao/ZongjingyunApplication.java

@@ -0,0 +1,20 @@
+package com.zhentao;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Hello world!
+ *
+ */
+
+@SpringBootApplication
+@MapperScan("com.zhentao.mapper")
+public class ZongjingyunApplication {
+    public static void main( String[] args ) {
+        SpringApplication.run(ZongjingyunApplication.class, args);
+        System.err.println("zjy");
+
+    }
+}

+ 18 - 0
src/main/java/com/zhentao/controller/GoodsController.java

@@ -0,0 +1,18 @@
+package com.zhentao.controller;
+
+import com.zhentao.service.GoodsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("goods")
+public class GoodsController {
+    @Autowired
+    GoodsService goodsService;
+    @RequestMapping("addGoods")
+    public String addGoods(String goodsName){
+        goodsService.addGoods(goodsName);
+        return "添加成功";
+    }
+}

+ 77 - 0
src/main/java/com/zhentao/controller/ProductController.java

@@ -0,0 +1,77 @@
+package com.zhentao.controller;
+
+import com.zhentao.pojo.TProduct;
+import com.zhentao.service.TProductService;
+import com.zhentao.util.SignUtil;
+import com.zhentao.vo.ResultVo;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/product")
+public class ProductController {
+
+    private static final String APP_SECRET = "123";
+    private static final String SUCCESS_CODE = "200";
+    private static final String FAILURE_CODE = "1002";
+
+    private final TProductService productService;
+
+    public ProductController(TProductService productService) {
+        this.productService = productService;
+    }
+
+    @GetMapping("/info")
+    public ResultVo<String> getProductInfo(@RequestParam("goodsId") Long goodsId,
+                                           HttpServletRequest request) {
+        // 验签逻辑
+        String reqId = request.getHeader("reqId");
+        String reqTimeStr = request.getHeader("reqTime");
+        String appId = request.getHeader("appId");
+        String sign = request.getHeader("sign");
+
+        // 参数校验
+        if (goodsId == null || reqId == null || reqTimeStr == null || appId == null || sign == null) {
+            return new ResultVo<>(FAILURE_CODE, "参数缺失", null);
+        }
+
+        long reqTime;
+        try {
+            reqTime = Long.parseLong(reqTimeStr);
+        } catch (NumberFormatException e) {
+            return new ResultVo<>(FAILURE_CODE, "时间戳格式错误", null);
+        }
+
+        // 验证时间戳有效性
+        long currentTime = System.currentTimeMillis();
+        if (Math.abs(currentTime - reqTime) > 30*1000) {
+            return new ResultVo<>(FAILURE_CODE, "请求已过期", null);
+        }
+
+        // 构建待签名参数
+        Map<String, String> params = new HashMap<>();
+        params.put("goodsId", goodsId.toString());
+        params.put("reqId", reqId);
+        params.put("reqTime", reqTimeStr);
+        params.put("appId", appId);
+
+        // 验签
+        if (!SignUtil.verifySign(params, sign, APP_SECRET)) {
+            return new ResultVo<>(FAILURE_CODE, "签名验证失败", null);
+        }
+
+        // 获取商品信息
+        TProduct product = productService.getProductById(goodsId);
+        if (product == null) {
+            return new ResultVo<>(FAILURE_CODE, "商品不存在", null);
+        }
+
+        return new ResultVo<>(SUCCESS_CODE, "成功", product.getName());
+    }
+}

+ 18 - 0
src/main/java/com/zhentao/mapper/GoodsMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.mapper;
+
+import com.zhentao.pojo.Goods;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author 芸
+* @description 针对表【goods】的数据库操作Mapper
+* @createDate 2025-05-16 10:18:08
+* @Entity com.zhentao.pojo.Goods
+*/
+public interface GoodsMapper extends BaseMapper<Goods> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/zhentao/mapper/TProductMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.mapper;
+
+import com.zhentao.pojo.TProduct;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author 芸
+* @description 针对表【t_product(商品表)】的数据库操作Mapper
+* @createDate 2025-05-15 16:08:06
+* @Entity com.zhentao.pojo.TProduct
+*/
+public interface TProductMapper extends BaseMapper<TProduct> {
+
+}
+
+
+
+

+ 51 - 0
src/main/java/com/zhentao/pojo/Goods.java

@@ -0,0 +1,51 @@
+package com.zhentao.pojo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 
+ * @TableName goods
+ */
+@TableName(value ="goods")
+@Data
+public class Goods implements Serializable {
+    /**
+     * 
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 
+     */
+    private String goodsName;
+
+    /**
+     * 
+     */
+    private String descriptions;
+
+    /**
+     * 
+     */
+    private String goodsImg;
+
+    /**
+     * 
+     */
+    private String content;
+
+    /**
+     * 
+     */
+    private Date createdTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 62 - 0
src/main/java/com/zhentao/pojo/TProduct.java

@@ -0,0 +1,62 @@
+package com.zhentao.pojo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 商品表
+ * @TableName t_product
+ */
+@TableName(value ="t_product")
+@Data
+public class TProduct implements Serializable {
+    /**
+     * 商品ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+
+    /**
+     * 价格
+     */
+    private BigDecimal price;
+
+    /**
+     * 商品描述
+     */
+    private String description;
+
+    /**
+     * 库存
+     */
+    private Integer stock;
+
+    /**
+     * 状态:0-下架,1-上架
+     */
+    private Integer status;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 14 - 0
src/main/java/com/zhentao/service/GoodsService.java

@@ -0,0 +1,14 @@
+package com.zhentao.service;
+
+import com.zhentao.pojo.Goods;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author 芸
+* @description 针对表【goods】的数据库操作Service
+* @createDate 2025-05-16 10:18:08
+*/
+public interface GoodsService extends IService<Goods> {
+
+    void addGoods(String goodsName);
+}

+ 14 - 0
src/main/java/com/zhentao/service/TProductService.java

@@ -0,0 +1,14 @@
+package com.zhentao.service;
+
+import com.zhentao.pojo.TProduct;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author 芸
+* @description 针对表【t_product(商品表)】的数据库操作Service
+* @createDate 2025-05-15 16:08:06
+*/
+public interface TProductService extends IService<TProduct> {
+
+    TProduct getProductById(Long goodsId);
+}

+ 31 - 0
src/main/java/com/zhentao/service/impl/GoodsServiceImpl.java

@@ -0,0 +1,31 @@
+package com.zhentao.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.pojo.Goods;
+import com.zhentao.service.GoodsService;
+import com.zhentao.mapper.GoodsMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+* @author 芸
+* @description 针对表【goods】的数据库操作Service实现
+* @createDate 2025-05-16 10:18:08
+*/
+@Service
+public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods>
+    implements GoodsService{
+
+    @Autowired
+    GoodsMapper goodsMapper;
+    @Override
+    public void addGoods(String goodsName) {
+        Goods goods = new Goods();
+        goods.setGoodsName(goodsName);
+        goodsMapper.insert(goods);
+    }
+}
+
+
+
+

+ 32 - 0
src/main/java/com/zhentao/service/impl/TProductServiceImpl.java

@@ -0,0 +1,32 @@
+package com.zhentao.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.pojo.TProduct;
+import com.zhentao.service.TProductService;
+import com.zhentao.mapper.TProductMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author 芸
+* @description 针对表【t_product(商品表)】的数据库操作Service实现
+* @createDate 2025-05-15 16:08:06
+*/
+@Service
+public class TProductServiceImpl extends ServiceImpl<TProductMapper, TProduct>
+    implements TProductService{
+
+    @Override
+    public TProduct getProductById(Long goodsId) {
+        TProduct product = new TProduct();
+        product.setId(goodsId);
+        product.setName("商品纵静芸");
+        product.setPrice(new java.math.BigDecimal("9999.00"));
+        product.setStock(100);
+        product.setStatus(1);
+        return product;
+    }
+}
+
+
+
+

+ 66 - 0
src/main/java/com/zhentao/util/SignUtil.java

@@ -0,0 +1,66 @@
+package com.zhentao.util;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class SignUtil {
+
+    /**
+     * 生成签名
+     * @param params 请求参数
+     * @param secret 密钥
+     * @return 签名
+     */
+    public static String generateSign(Map<String, String> params, String secret) {
+        // 1. 按ASCII码排序参数
+        List<String> keys = new ArrayList<>(params.keySet());
+        Collections.sort(keys);
+
+        // 2. 拼接key=value&字符串
+        StringBuilder paramStr = new StringBuilder();
+        for (String key : keys) {
+            paramStr.append(key).append("=").append(params.get(key)).append("&");
+        }
+
+        // 3. 拼接secret
+        paramStr.append("key=").append(secret);
+
+        // 4. MD5加密
+        return md5(paramStr.toString());
+    }
+
+    /**
+     * 验证签名
+     * @param params 请求参数
+     * @param sign 签名
+     * @param secret 密钥
+     * @return 是否验证通过
+     */
+    public static boolean verifySign(Map<String, String> params, String sign, String secret) {
+        String generatedSign = generateSign(params, secret);
+        return generatedSign.equals(sign);
+    }
+
+    /**
+     * MD5加密
+     * @param input 输入字符串
+     * @return 加密后的字符串
+     */
+    private static String md5(String input) {
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            byte[] digest = md.digest(input.getBytes());
+            StringBuilder sb = new StringBuilder();
+            for (byte b : digest) {
+                sb.append(String.format("%02x", b & 0xff));
+            }
+            return sb.toString();
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("MD5算法不可用", e);
+        }
+    }
+}

+ 36 - 0
src/main/java/com/zhentao/vo/ResultVo.java

@@ -0,0 +1,36 @@
+package com.zhentao.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ResultVo<T> implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private String code;
+    private String msg;
+    private T data;
+
+    // 成功返回方法
+    public static <T> ResultVo<T> success(T data) {
+        return new ResultVo<>("200", "成功", data);
+    }
+
+    public static <T> ResultVo<T> success(String msg, T data) {
+        return new ResultVo<>("200", msg, data);
+    }
+
+    // 失败返回方法
+    public static <T> ResultVo<T> failure(String code, String msg) {
+        return new ResultVo<>(code, msg, null);
+    }
+
+    public static <T> ResultVo<T> failure(String msg) {
+        return new ResultVo<>("1002", msg, null);
+    }
+}

+ 12 - 0
src/main/resources/application.yml

@@ -0,0 +1,12 @@
+server:
+  port: 8000
+
+spring:
+  datasource:
+    url: jdbc:mysql://localhost:3306/2407zk2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
+    username: root
+    password: root
+    driver-class-name: com.mysql.cj.jdbc.Driver
+mybatis-plus:
+  mapper-locations: classpath:mapper/*.xml
+  type-aliases-package: com.zhentao.pojo

+ 20 - 0
src/main/resources/mapper/GoodsMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.mapper.GoodsMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.pojo.Goods">
+            <id property="id" column="id" jdbcType="INTEGER"/>
+            <result property="goodsName" column="goods_name" jdbcType="VARCHAR"/>
+            <result property="descriptions" column="descriptions" jdbcType="VARCHAR"/>
+            <result property="goodsImg" column="goods_img" jdbcType="VARCHAR"/>
+            <result property="content" column="content" jdbcType="VARCHAR"/>
+            <result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,goods_name,descriptions,
+        goods_img,content,created_time
+    </sql>
+</mapper>

+ 23 - 0
src/main/resources/mapper/TProductMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.mapper.TProductMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.pojo.TProduct">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="name" column="name" jdbcType="VARCHAR"/>
+            <result property="price" column="price" jdbcType="DECIMAL"/>
+            <result property="description" column="description" jdbcType="VARCHAR"/>
+            <result property="stock" column="stock" jdbcType="INTEGER"/>
+            <result property="status" column="status" jdbcType="TINYINT"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,name,price,
+        description,stock,status,
+        create_time,update_time
+    </sql>
+</mapper>

+ 38 - 0
src/test/java/com/zhentao/AppTest.java

@@ -0,0 +1,38 @@
+package com.zhentao;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}

+ 12 - 0
target/classes/application.yml

@@ -0,0 +1,12 @@
+server:
+  port: 8000
+
+spring:
+  datasource:
+    url: jdbc:mysql://localhost:3306/2407zk2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
+    username: root
+    password: root
+    driver-class-name: com.mysql.cj.jdbc.Driver
+mybatis-plus:
+  mapper-locations: classpath:mapper/*.xml
+  type-aliases-package: com.zhentao.pojo

BIN
target/classes/com/zhentao/ZongjingyunApplication.class


BIN
target/classes/com/zhentao/controller/GoodsController.class


BIN
target/classes/com/zhentao/controller/ProductController.class


BIN
target/classes/com/zhentao/mapper/GoodsMapper.class


BIN
target/classes/com/zhentao/mapper/TProductMapper.class


BIN
target/classes/com/zhentao/pojo/Goods.class


BIN
target/classes/com/zhentao/pojo/TProduct.class


BIN
target/classes/com/zhentao/service/GoodsService.class


BIN
target/classes/com/zhentao/service/TProductService.class


BIN
target/classes/com/zhentao/service/impl/GoodsServiceImpl.class


BIN
target/classes/com/zhentao/service/impl/TProductServiceImpl.class


BIN
target/classes/com/zhentao/util/SignUtil.class


BIN
target/classes/com/zhentao/vo/ResultVo.class


+ 20 - 0
target/classes/mapper/GoodsMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.mapper.GoodsMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.pojo.Goods">
+            <id property="id" column="id" jdbcType="INTEGER"/>
+            <result property="goodsName" column="goods_name" jdbcType="VARCHAR"/>
+            <result property="descriptions" column="descriptions" jdbcType="VARCHAR"/>
+            <result property="goodsImg" column="goods_img" jdbcType="VARCHAR"/>
+            <result property="content" column="content" jdbcType="VARCHAR"/>
+            <result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,goods_name,descriptions,
+        goods_img,content,created_time
+    </sql>
+</mapper>

+ 23 - 0
target/classes/mapper/TProductMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.mapper.TProductMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.pojo.TProduct">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="name" column="name" jdbcType="VARCHAR"/>
+            <result property="price" column="price" jdbcType="DECIMAL"/>
+            <result property="description" column="description" jdbcType="VARCHAR"/>
+            <result property="stock" column="stock" jdbcType="INTEGER"/>
+            <result property="status" column="status" jdbcType="TINYINT"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,name,price,
+        description,stock,status,
+        create_time,update_time
+    </sql>
+</mapper>