瀏覽代碼

Initial commit

jc 1 月之前
當前提交
5405a9eb19

+ 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/

+ 85 - 0
pom.xml

@@ -0,0 +1,85 @@
+<?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>com.zt</groupId>
+    <artifactId>xm-demo</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>xm-demo</name>
+    <description>xm-demo</description>
+    <properties>
+        <java.version>17</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <spring-boot.version>3.0.2</spring-boot.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <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-validation</artifactId>
+        </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>17</source>
+                    <target>17</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot.version}</version>
+                <configuration>
+                    <mainClass>com.zt.XmDemoApplication</mainClass>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>repackage</id>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 13 - 0
src/main/java/com/zt/XmDemoApplication.java

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

+ 40 - 0
src/main/java/com/zt/common/Shoop.java

@@ -0,0 +1,40 @@
+package com.zt.common;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import jakarta.validation.constraints.*;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @Date 2025/3/29 10:38
+ * @Author neko
+ **/
+@Data
+public class Shoop {
+    @NotBlank(message = "appId不能为空")
+    private String appId;
+    @NotBlank(message = "请求id不能为空")
+    private String reqId;
+    @NotBlank(message = "签名不能为空")
+    private String sign;
+    @NotNull(message = "时间不能为空")
+    private Long reqTime;
+    @NotNull(message = "商品id不能为空")
+    private Long goodsId;
+    @NotNull(message = "商品数量不能为空")
+    @Min(value = 1, message = "商品数量大于0")
+    private Long amount;
+    @NotNull(message = "价格不能为空")
+    @DecimalMin(value = "0", message = "价格大于0")
+    @DecimalMax(value = "9999", message = "价格小于9999")
+    private Double price;
+    @NotNull(message = "手机号不能为空")
+    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
+    private String mobile;
+    @NotNull(message = "日期格不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date NewDate;
+}

+ 41 - 0
src/main/java/com/zt/controller/Test1.java

@@ -0,0 +1,41 @@
+package com.zt.controller;
+
+import com.zt.common.Shoop;
+import jakarta.validation.Valid;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @Date 2025/3/29 10:37
+ * @Author neko
+ **/
+@RestController
+@RequestMapping("/test1")
+@Slf4j
+public class Test1 {
+    @RequestMapping("inter")
+    public String inter(@RequestHeader("redId") String redId, @Valid @RequestBody Shoop shoop){
+        System.out.println(redId);
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", "200");
+        map.put("msg", "操作成功");
+        map.put("data", shoop);
+
+        return map.toString();
+    }
+
+    @RequestMapping("inter2")
+    public String inter2(@RequestHeader("redId") String redId,Shoop shoop){
+        log.info("redId:{}",redId);
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", "200");
+        map.put("msg", "操作成功");
+        map.put("data", shoop);
+        return map.toString();
+    }
+
+}

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

@@ -0,0 +1,14 @@
+server:
+  port: 8088
+spring:
+  application:
+    name: xm-demo
+#  datasource:
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#    url: jdbc:mysql://localhost:3306/xue?characterEncoding=UTF-8&useSSL=false
+#    username: root
+#    password: 123456
+#    type: com.alibaba.druid.pool.DruidDataSource
+#mybatis-plus:
+#  configuration:
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 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>

+ 49 - 0
src/test/java/com/zt/Text.java

@@ -0,0 +1,49 @@
+package com.zt;
+
+import java.util.Deque;
+import java.util.LinkedList;
+
+/**
+ * @Date 2025/3/30 19:32
+ * @Author neko
+ **/
+public class Text {
+//    public int[] maxSlidingWindow(int[] nums, int k) {
+//        if (nums == null || k <= 0) {
+//            return new int[0];
+//        }
+//        int n = nums.length;
+//        int[] result = new int[n - k + 1];
+//        int resultIndex = 0;
+//        // 存储数组的索引
+//        Deque<Integer> deque = new LinkedList<>();
+//
+//        for (int i = 0; i < n; i++) {
+//            // 移除超出窗口范围的元素
+//            while (!deque.isEmpty() && deque.peekFirst() < i - k + 1) {
+//                deque.pollFirst();
+//            }
+//            // 移除队列中比当前元素小的元素
+//            while (!deque.isEmpty() && nums[deque.peekLast()] < nums[i]) {
+//                deque.pollLast();
+//            }
+//            // 将当前元素的索引加入队列
+//            deque.offerLast(i);
+//            // 当窗口大小达到 k 时,记录最大值
+//            if (i >= k - 1) {
+//                result[resultIndex++] = nums[deque.peekFirst()];
+//            }
+//        }
+//        return result;
+//    }
+//
+//    public static void main(String[] args) {
+//        SlidingWindowMaximum solution = new SlidingWindowMaximum();
+//        int[] nums = {1, 3, -1, -3, 5, 3, 6, 7};
+//        int k = 3;
+//        int[] result = solution.maxSlidingWindow(nums, k);
+//        for (int num : result) {
+//            System.out.print(num + " ");
+//        }
+//    }
+}

+ 25 - 0
src/test/java/com/zt/XmDemoApplicationTests.java

@@ -0,0 +1,25 @@
+package com.zt;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class XmDemoApplicationTests {
+    public static void main(String[] args) {
+        //给你一个字符串 s个字符串 t。返回 s中涵盖 t所有字符的最小子串。
+        // 如果 s中不存在涵盖 t所有字符的子串,则返回空字符串 “”
+        //对于 t中重复字符,我们寻找的子字符串中该字符数量必须不少于 t中该字符数量。
+        //如果 s中存在这样的子串,我们保证它是唯一的答案。
+        String s = "abcdefghjklmn";
+        String t = "abc";
+        boolean ss = s.contains(t);
+        if(ss==true){
+            System.out.println(t);
+        }else{
+            System.out.println("NULL");
+        }
+
+
+
+    }
+}