chen il y a 1 mois
commit
067461e063
43 fichiers modifiés avec 676 ajouts et 0 suppressions
  1. 33 0
      .gitignore
  2. 8 0
      .idea/.gitignore
  3. 14 0
      .idea/compiler.xml
  4. 7 0
      .idea/encodings.xml
  5. 20 0
      .idea/jarRepositories.xml
  6. 12 0
      .idea/misc.xml
  7. 6 0
      .idea/vcs.xml
  8. 131 0
      .idea/workspace.xml
  9. 3 0
      .vscode/settings.json
  10. 19 0
      HELP.md
  11. 98 0
      pom.xml
  12. 13 0
      src/main/java/cn/zhentao/DemoApplication.java
  13. 31 0
      src/main/java/cn/zhentao/controller/DtoController.java
  14. 40 0
      src/main/java/cn/zhentao/pojo/Dto.java
  15. 25 0
      src/main/java/cn/zhentao/pojo/ResultVo.java
  16. 8 0
      src/main/java/cn/zhentao/service/DtoService.java
  17. 16 0
      src/main/java/cn/zhentao/service/Iml/DtoServiceIml.java
  18. 91 0
      src/main/java/cn/zhentao/test/DtoTest.java
  19. 17 0
      src/main/resources/META-INF/MANIFEST.MF
  20. 4 0
      src/main/resources/application.properties
  21. 6 0
      src/main/resources/static/index.html
  22. 13 0
      src/test/java/cn/zhentao/DemoApplicationTests.java
  23. 17 0
      target/classes/META-INF/MANIFEST.MF
  24. 4 0
      target/classes/application.properties
  25. BIN
      target/classes/cn/zhentao/DemoApplication.class
  26. BIN
      target/classes/cn/zhentao/controller/DtoController.class
  27. BIN
      target/classes/cn/zhentao/pojo/Dto.class
  28. BIN
      target/classes/cn/zhentao/pojo/ResultVo.class
  29. BIN
      target/classes/cn/zhentao/service/DtoService.class
  30. BIN
      target/classes/cn/zhentao/service/Iml/DtoServiceIml.class
  31. BIN
      target/classes/cn/zhentao/test/DtoTest.class
  32. 6 0
      target/classes/static/index.html
  33. BIN
      target/demo-0.0.1-SNAPSHOT.jar
  34. BIN
      target/demo-0.0.1-SNAPSHOT.jar.original
  35. 3 0
      target/maven-archiver/pom.properties
  36. 7 0
      target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
  37. 7 0
      target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
  38. 1 0
      target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
  39. 1 0
      target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
  40. 5 0
      target/surefire-reports/2025-03-31T10-05-59_676.dumpstream
  41. 6 0
      target/surefire-reports/TEST-cn.zhentao.DemoApplicationTests.xml
  42. 4 0
      target/surefire-reports/cn.zhentao.DemoApplicationTests.txt
  43. BIN
      target/test-classes/cn/zhentao/DemoApplicationTests.class

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 8 - 0
.idea/.gitignore

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

+ 14 - 0
.idea/compiler.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="true" />
+      <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="demo" />
+      </profile>
+    </annotationProcessing>
+  </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>

+ 12 - 0
.idea/misc.xml

@@ -0,0 +1,12 @@
+<?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_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 131 - 0
.idea/workspace.xml

@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AutoImportSettings">
+    <option name="autoReloadType" value="SELECTIVE" />
+  </component>
+  <component name="ChangeListManager">
+    <list default="true" id="10b05465-08d5-4de9-8c1b-7ff9bbb70b98" name="更改" comment="">
+      <change beforePath="$PROJECT_DIR$/target/classes/META-INF/MANIFEST.MF" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/application.properties" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/cn/zhentao/DemoApplication.class" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/cn/zhentao/controller/DtoController.class" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/cn/zhentao/pojo/Dto.class" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/cn/zhentao/pojo/ResultVo.class" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/cn/zhentao/service/DtoService.class" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/cn/zhentao/service/Iml/DtoServiceIml.class" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/static/index.html" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/demo-0.0.1-SNAPSHOT.jar" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/demo-0.0.1-SNAPSHOT.jar.original" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/maven-archiver/pom.properties" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/surefire-reports/2025-03-30T20-04-20_770.dumpstream" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/surefire-reports/TEST-cn.zhentao.DemoApplicationTests.xml" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/surefire-reports/cn.zhentao.DemoApplicationTests.txt" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/test-classes/cn/zhentao/DemoApplicationTests.class" beforeDir="false" />
+    </list>
+    <option name="SHOW_DIALOG" value="false" />
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+    <option name="LAST_RESOLUTION" value="IGNORE" />
+  </component>
+  <component name="FileTemplateManagerImpl">
+    <option name="RECENT_TEMPLATES">
+      <list>
+        <option value="Class" />
+      </list>
+    </option>
+  </component>
+  <component name="Git.Settings">
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+  </component>
+  <component name="MarkdownSettingsMigration">
+    <option name="stateVersion" value="1" />
+  </component>
+  <component name="MavenImportPreferences">
+    <option name="generalSettings">
+      <MavenGeneralSettings>
+        <option name="localRepository" value="D:\ku" />
+        <option name="mavenHome" value="$PROJECT_DIR$/../../apache-maven-3.9.2" />
+        <option name="useMavenConfig" value="true" />
+        <option name="userSettingsFile" value="D:\apache-maven-3.9.2\conf\settings.xml" />
+      </MavenGeneralSettings>
+    </option>
+    <option name="importingSettings">
+      <MavenImportingSettings>
+        <option name="workspaceImportEnabled" value="true" />
+      </MavenImportingSettings>
+    </option>
+  </component>
+  <component name="ProjectId" id="2v3pZzMCqUpMuD99yjyVEc2wQTx" />
+  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
+  <component name="ProjectViewState">
+    <option name="hideEmptyMiddlePackages" value="true" />
+    <option name="showLibraryContents" value="true" />
+  </component>
+  <component name="PropertiesComponent"><![CDATA[{
+  "keyToString": {
+    "RequestMappingsPanelOrder0": "0",
+    "RequestMappingsPanelOrder1": "1",
+    "RequestMappingsPanelWidth0": "75",
+    "RequestMappingsPanelWidth1": "75",
+    "RunOnceActivity.OpenProjectViewOnStart": "true",
+    "RunOnceActivity.ShowReadmeOnStart": "true",
+    "WebServerToolWindowFactoryState": "false",
+    "last_opened_file_path": "D:/yun7/demo",
+    "node.js.detected.package.eslint": "true",
+    "node.js.detected.package.tslint": "true",
+    "node.js.selected.package.eslint": "(autodetect)",
+    "node.js.selected.package.tslint": "(autodetect)",
+    "settings.editor.selected.configurable": "preferences.pluginManager",
+    "spring.configuration.checksum": "fe01ce2a7fbac8fafaed7c982a04e229",
+    "vue.rearranger.settings.migration": "true"
+  }
+}]]></component>
+  <component name="RunManager" selected="应用程序.DtoTest">
+    <configuration name="DtoTest" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
+      <option name="MAIN_CLASS_NAME" value="cn.zhentao.test.DtoTest" />
+      <module name="demo" />
+      <extension name="coverage">
+        <pattern>
+          <option name="PATTERN" value="cn.zhentao.test.*" />
+          <option name="ENABLED" value="true" />
+        </pattern>
+      </extension>
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="DemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
+      <module name="demo" />
+      <option name="SPRING_BOOT_MAIN_CLASS" value="cn.zhentao.DemoApplication" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <recent_temporary>
+      <list>
+        <item itemvalue="应用程序.DtoTest" />
+      </list>
+    </recent_temporary>
+  </component>
+  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
+  <component name="TaskManager">
+    <task active="true" id="Default" summary="默认任务">
+      <changelist id="10b05465-08d5-4de9-8c1b-7ff9bbb70b98" name="更改" comment="" />
+      <created>1743383672367</created>
+      <option name="number" value="Default" />
+      <option name="presentableId" value="Default" />
+      <updated>1743383672367</updated>
+      <workItem from="1743383674052" duration="66000" />
+      <workItem from="1743383748480" duration="82000" />
+      <workItem from="1743383839024" duration="2819000" />
+    </task>
+    <servers />
+  </component>
+  <component name="TypeScriptGeneratedFilesManager">
+    <option name="version" value="3" />
+  </component>
+</project>

+ 3 - 0
.vscode/settings.json

@@ -0,0 +1,3 @@
+{
+    "java.configuration.updateBuildConfiguration": "interactive"
+}

+ 19 - 0
HELP.md

@@ -0,0 +1,19 @@
+# Getting Started
+
+### Reference Documentation
+
+For further reference, please consider the following sections:
+
+* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
+* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.6.13/maven-plugin/reference/html/)
+* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.6.13/maven-plugin/reference/html/#build-image)
+* [Spring Web](https://docs.spring.io/spring-boot/docs/2.6.13/reference/htmlsingle/#web)
+
+### Guides
+
+The following guides illustrate how to use some features concretely:
+
+* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
+* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
+* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
+

+ 98 - 0
pom.xml

@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>cn.zhentao</groupId>
+    <artifactId>demo</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>demo</name>
+    <description>demo</description>
+    <properties>
+        <java.version>1.8</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <spring-boot.version>2.6.13</spring-boot.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.13.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.83</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.8.20</version>
+        </dependency>
+    </dependencies>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring-boot.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.6.13</version>
+                <configuration>
+                    <mainClass>cn.zhentao.DemoApplication</mainClass>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>repackage</id>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+
+        </plugins>
+
+    </build>
+
+</project>

+ 13 - 0
src/main/java/cn/zhentao/DemoApplication.java

@@ -0,0 +1,13 @@
+package cn.zhentao;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DemoApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(DemoApplication.class, args);
+    }
+
+}

+ 31 - 0
src/main/java/cn/zhentao/controller/DtoController.java

@@ -0,0 +1,31 @@
+package cn.zhentao.controller;
+
+import cn.zhentao.pojo.Dto;
+import cn.zhentao.pojo.ResultVo;
+import cn.zhentao.service.DtoService;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("dto")
+@Slf4j
+public class DtoController {
+    @Autowired
+    DtoService dtoService;
+
+    @PostMapping("/add1")
+    public ResultVo<Dto> add(@Validated @RequestBody Dto dto, @RequestHeader("reqId") String reqId){
+        log.info(JSONObject.toJSONString(dto));
+        return dtoService.add(dto,reqId);
+    }
+
+    @GetMapping("/add2")
+    public ResultVo<Dto> addv2( Dto dto, @RequestHeader("reqId") String reqId){
+        log.info(JSONObject.toJSONString(dto));
+        return dtoService.add(dto,reqId);
+    }
+
+}

+ 40 - 0
src/main/java/cn/zhentao/pojo/Dto.java

@@ -0,0 +1,40 @@
+package cn.zhentao.pojo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.*;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class Dto {
+    @NotBlank(message="应用不能为空")
+    private String appId;
+    @NotBlank(message="签名不能为空")
+    private String sign;
+    @NotNull(message="时间戳不能为空")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private String reqTime;
+
+    @NotNull(message="goodsld不能为空")
+    @JsonFormat(shape=JsonFormat.Shape.STRING)
+    private String goodsId;
+    @NotNull(message="数里不能为空")
+    @DecimalMin(value="1",message="最小值1")
+    private Integer amount;
+    @NotNull(message="价格不能为空")
+    @DecimalMin(value ="@",message="最小值@")
+    @DecimalMax(value="9999",message="最大值9999")
+    private BigDecimal price;
+    @NotBlank(message="手机号不能为空")
+    @Pattern(regexp="^((13[0-9])|(14[0-9])|(15([8-9]))|(166)|(17[0-9])|(18[8-9])|(19[0-9]))\\d{8}$",message ="手机号码格式错误")
+    private String mobile;//手然号
+    @NotNull(message="日期不能为空")@DateTimeFormat(pattern ="yyyy-MM-dd HH:mm:ss")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone ="GMT+8")
+    private Date nowDate;//日期格式
+
+    private String reqId;
+}

+ 25 - 0
src/main/java/cn/zhentao/pojo/ResultVo.java

@@ -0,0 +1,25 @@
+package cn.zhentao.pojo;
+
+import lombok.Data;
+
+@Data
+public class ResultVo<T> {
+    private Integer code;
+    private String message;
+    private T data;
+
+    public static <T> ResultVo<T> success(T data) {
+        ResultVo<T> result = new ResultVo<>();
+        result.setCode(200);
+        result.setMessage("success");
+        result.setData(data);
+        return result;
+    }
+
+    public static <T> ResultVo<T> error(String message) {
+        ResultVo<T> result = new ResultVo<>();
+        result.setCode(500);
+        result.setMessage(message);
+        return result;
+    }
+} 

+ 8 - 0
src/main/java/cn/zhentao/service/DtoService.java

@@ -0,0 +1,8 @@
+package cn.zhentao.service;
+
+import cn.zhentao.pojo.Dto;
+import cn.zhentao.pojo.ResultVo;
+
+public interface DtoService {
+    ResultVo<Dto> add(Dto dto, String reqId);
+}

+ 16 - 0
src/main/java/cn/zhentao/service/Iml/DtoServiceIml.java

@@ -0,0 +1,16 @@
+package cn.zhentao.service.Iml;
+
+import cn.zhentao.pojo.Dto;
+import cn.zhentao.pojo.ResultVo;
+import cn.zhentao.service.DtoService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DtoServiceIml implements DtoService {
+    @Override
+    public ResultVo<Dto> add(Dto dto, String reqId) {
+        System.err.println(dto);
+        System.err.println(reqId);
+        return ResultVo.success(dto);
+    }
+}

+ 91 - 0
src/main/java/cn/zhentao/test/DtoTest.java

@@ -0,0 +1,91 @@
+package cn.zhentao.test;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import cn.hutool.json.JSONObject;
+import cn.zhentao.pojo.Dto;
+import cn.zhentao.pojo.ResultVo;
+import com.alibaba.fastjson.JSON;
+import lombok.extern.slf4j.Slf4j;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+public class DtoTest {
+    private static final String APP_ID = "test_app_id";
+    private static final String APP_KEY = "test_app_key";
+    private static final String BASE_URL = "http://localhost:8080/dto";
+    private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+    public static void main(String[] args) {
+        // 准备测试数据
+        String reqId = "test_req_" + System.currentTimeMillis();
+        String reqTime = LocalDateTime.now().format(DATE_TIME_FORMATTER);
+        
+        // 创建DTO对象
+        Dto dto = new Dto();
+        dto.setAppId(APP_ID);
+        dto.setGoodsId("test_goods_001");
+        dto.setReqId(reqId);
+        dto.setReqTime(reqTime);
+        
+        // 生成签名
+        String sign = generateSign(dto);
+        dto.setSign(sign);
+        
+        // 测试接口1
+        testAdd1(dto, reqId);
+        
+        // 测试接口2
+        testAdd2(dto, reqId);
+    }
+    
+    private static String generateSign(Dto dto) {
+        String content = String.format("%s%s%s%s%s",
+                dto.getAppId(),
+                dto.getGoodsId(),
+                dto.getReqId(),
+                dto.getReqTime(),
+                APP_KEY);
+        return cn.hutool.crypto.SecureUtil.md5(content);
+    }
+    
+    private static void testAdd1(Dto dto, String reqId) {
+        try {
+            HttpResponse response = HttpRequest.post(BASE_URL + "/add1")
+                    .header("reqId", reqId)
+                    .body(JSON.toJSONString(dto))
+                    .execute();
+            
+            ResultVo<Dto> result = JSON.parseObject(response.body(), ResultVo.class);
+            log.info("接口1返回结果:{}", JSON.toJSONString(result));
+        } catch (Exception e) {
+            log.error("接口1调用异常", e);
+        }
+    }
+    
+    private static void testAdd2(Dto dto, String reqId) {
+        try {
+            Map<String, Object> params = new HashMap<>();
+            params.put("appId", dto.getAppId());
+            params.put("goodsId", dto.getGoodsId());
+            params.put("reqId", dto.getReqId());
+            params.put("reqTime", dto.getReqTime());
+            params.put("sign", dto.getSign());
+            
+            HttpResponse response = HttpRequest.get(BASE_URL + "/add2")
+                    .header("reqId", reqId)
+                    .form(params)
+                    .execute();
+            
+            ResultVo<Dto> result = JSON.parseObject(response.body(), ResultVo.class);
+            log.info("接口2返回结果:{}", JSON.toJSONString(result));
+        } catch (Exception e) {
+            log.error("接口2调用异常", e);
+        }
+    }
+} 

+ 17 - 0
src/main/resources/META-INF/MANIFEST.MF

@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Main-Class: cn.zhentao.DemoApplication
+Class-Path: jakarta.annotation-api-1.3.5.jar tomcat-embed-el-9.0.68.jar 
+ logback-core-1.2.11.jar spring-web-5.3.23.jar spring-core-5.3.23.jar sl
+ f4j-api-1.7.36.jar spring-aop-5.3.23.jar lombok-1.18.24.jar spring-boot
+ -2.6.13.jar jackson-datatype-jsr310-2.13.4.jar spring-expression-5.3.23
+ .jar jackson-core-2.13.4.jar spring-boot-starter-2.6.13.jar tomcat-embe
+ d-core-9.0.68.jar spring-boot-starter-json-2.6.13.jar logback-classic-1
+ .2.11.jar spring-webmvc-5.3.23.jar spring-boot-autoconfigure-2.6.13.jar
+  validation-api-2.0.1.Final.jar jackson-databind-2.13.4.2.jar jackson-m
+ odule-parameter-names-2.13.4.jar spring-jcl-5.3.23.jar fastjson-1.2.83.
+ jar spring-boot-starter-web-2.6.13.jar log4j-api-2.17.2.jar log4j-to-sl
+ f4j-2.17.2.jar spring-boot-starter-logging-2.6.13.jar jackson-annotatio
+ ns-2.13.4.jar snakeyaml-1.29.jar spring-boot-starter-tomcat-2.6.13.jar 
+ jackson-datatype-jdk8-2.13.4.jar jul-to-slf4j-1.7.36.jar tomcat-embed-w
+ ebsocket-9.0.68.jar spring-beans-5.3.23.jar spring-context-5.3.23.jar
+

+ 4 - 0
src/main/resources/application.properties

@@ -0,0 +1,4 @@
+# 应用服务 WEB 访问端口
+server.port=8080
+
+

+ 6 - 0
src/main/resources/static/index.html

@@ -0,0 +1,6 @@
+<html>
+<body>
+<h1>hello word!!!</h1>
+<p>this is a html page</p>
+</body>
+</html>

+ 13 - 0
src/test/java/cn/zhentao/DemoApplicationTests.java

@@ -0,0 +1,13 @@
+package cn.zhentao;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class DemoApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}

+ 17 - 0
target/classes/META-INF/MANIFEST.MF

@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Main-Class: cn.zhentao.DemoApplication
+Class-Path: jakarta.annotation-api-1.3.5.jar tomcat-embed-el-9.0.68.jar 
+ logback-core-1.2.11.jar spring-web-5.3.23.jar spring-core-5.3.23.jar sl
+ f4j-api-1.7.36.jar spring-aop-5.3.23.jar lombok-1.18.24.jar spring-boot
+ -2.6.13.jar jackson-datatype-jsr310-2.13.4.jar spring-expression-5.3.23
+ .jar jackson-core-2.13.4.jar spring-boot-starter-2.6.13.jar tomcat-embe
+ d-core-9.0.68.jar spring-boot-starter-json-2.6.13.jar logback-classic-1
+ .2.11.jar spring-webmvc-5.3.23.jar spring-boot-autoconfigure-2.6.13.jar
+  validation-api-2.0.1.Final.jar jackson-databind-2.13.4.2.jar jackson-m
+ odule-parameter-names-2.13.4.jar spring-jcl-5.3.23.jar fastjson-1.2.83.
+ jar spring-boot-starter-web-2.6.13.jar log4j-api-2.17.2.jar log4j-to-sl
+ f4j-2.17.2.jar spring-boot-starter-logging-2.6.13.jar jackson-annotatio
+ ns-2.13.4.jar snakeyaml-1.29.jar spring-boot-starter-tomcat-2.6.13.jar 
+ jackson-datatype-jdk8-2.13.4.jar jul-to-slf4j-1.7.36.jar tomcat-embed-w
+ ebsocket-9.0.68.jar spring-beans-5.3.23.jar spring-context-5.3.23.jar
+

+ 4 - 0
target/classes/application.properties

@@ -0,0 +1,4 @@
+# 应用服务 WEB 访问端口
+server.port=8080
+
+

BIN
target/classes/cn/zhentao/DemoApplication.class


BIN
target/classes/cn/zhentao/controller/DtoController.class


BIN
target/classes/cn/zhentao/pojo/Dto.class


BIN
target/classes/cn/zhentao/pojo/ResultVo.class


BIN
target/classes/cn/zhentao/service/DtoService.class


BIN
target/classes/cn/zhentao/service/Iml/DtoServiceIml.class


BIN
target/classes/cn/zhentao/test/DtoTest.class


+ 6 - 0
target/classes/static/index.html

@@ -0,0 +1,6 @@
+<html>
+<body>
+<h1>hello word!!!</h1>
+<p>this is a html page</p>
+</body>
+</html>

BIN
target/demo-0.0.1-SNAPSHOT.jar


BIN
target/demo-0.0.1-SNAPSHOT.jar.original


+ 3 - 0
target/maven-archiver/pom.properties

@@ -0,0 +1,3 @@
+artifactId=demo
+groupId=cn.zhentao
+version=0.0.1-SNAPSHOT

+ 7 - 0
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

@@ -0,0 +1,7 @@
+cn\zhentao\pojo\ResultVo.class
+cn\zhentao\DemoApplication.class
+cn\zhentao\service\Iml\DtoServiceIml.class
+cn\zhentao\service\DtoService.class
+cn\zhentao\controller\DtoController.class
+cn\zhentao\test\DtoTest.class
+cn\zhentao\pojo\Dto.class

+ 7 - 0
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

@@ -0,0 +1,7 @@
+D:\yun7\demo\src\main\java\cn\zhentao\service\DtoService.java
+D:\yun7\demo\src\main\java\cn\zhentao\service\Iml\DtoServiceIml.java
+D:\yun7\demo\src\main\java\cn\zhentao\test\DtoTest.java
+D:\yun7\demo\src\main\java\cn\zhentao\controller\DtoController.java
+D:\yun7\demo\src\main\java\cn\zhentao\pojo\ResultVo.java
+D:\yun7\demo\src\main\java\cn\zhentao\DemoApplication.java
+D:\yun7\demo\src\main\java\cn\zhentao\pojo\Dto.java

+ 1 - 0
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst

@@ -0,0 +1 @@
+cn\zhentao\DemoApplicationTests.class

+ 1 - 0
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst

@@ -0,0 +1 @@
+D:\yun7\demo\src\test\java\cn\zhentao\DemoApplicationTests.java

+ 5 - 0
target/surefire-reports/2025-03-31T10-05-59_676.dumpstream

@@ -0,0 +1,5 @@
+# Created at 2025-03-31T10:05:59.809
+Boot Manifest-JAR contains absolute paths in classpath 'D:\ku\org\apache\maven\surefire\surefire-booter\3.0.0\surefire-booter-3.0.0.jar'
+Hint: <argLine>-Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
+'other' has different root
+

Fichier diff supprimé car celui-ci est trop grand
+ 6 - 0
target/surefire-reports/TEST-cn.zhentao.DemoApplicationTests.xml


+ 4 - 0
target/surefire-reports/cn.zhentao.DemoApplicationTests.txt

@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: cn.zhentao.DemoApplicationTests
+-------------------------------------------------------------------------------
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.131 s - in cn.zhentao.DemoApplicationTests

BIN
target/test-classes/cn/zhentao/DemoApplicationTests.class


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff