parent
b020c1fc55
commit
93abbf2170
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/zw_test01.iml" filepath="$PROJECT_DIR$/.idea/zw_test01.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -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/
|
@ -0,0 +1,126 @@
|
||||
<?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.zw</groupId>
|
||||
<artifactId>ZwDemoSpringBoot</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>ZwDemoSpringBoot</name>
|
||||
<description>ZwDemoSpringBoot</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-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</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>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>3.5.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot-autoconfigure</artifactId>
|
||||
<version>3.5.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<scope>compile</scope>
|
||||
</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>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.zw.zwdemospringboot.ZwDemoSpringBootApplication</mainClass>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,14 @@
|
||||
package com.zw.zwdemospringboot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ZwDemoSpringBootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ZwDemoSpringBootApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zw.zwdemospringboot.controller;
|
||||
|
||||
import com.zw.zwdemospringboot.entity.User;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
||||
*/
|
||||
@Controller
|
||||
public class BasicController {
|
||||
|
||||
// http://127.0.0.1:8080/hello?name=lisi
|
||||
@RequestMapping("/hello")
|
||||
@ResponseBody
|
||||
public String hello(@RequestParam(name = "name", defaultValue = "unknown user") String name) {
|
||||
return "Hello " + name;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/user
|
||||
@RequestMapping("/user")
|
||||
@ResponseBody
|
||||
public User user() {
|
||||
User user = new User();
|
||||
user.setName("theonefx");
|
||||
user.setAge(666);
|
||||
return user;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/save_user?name=newName&age=11
|
||||
@RequestMapping("/save_user")
|
||||
@ResponseBody
|
||||
public String saveUser(User u) {
|
||||
return "user will save: name=" + u.getName() + ", age=" + u.getAge();
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/html
|
||||
@RequestMapping("/html")
|
||||
public String html(){
|
||||
return "index.html";
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public void parseUser(@RequestParam(name = "name", defaultValue = "unknown user") String name
|
||||
, @RequestParam(name = "age", defaultValue = "12") Integer age, User user) {
|
||||
user.setName("zhangsan");
|
||||
user.setAge(18);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zw.zwdemospringboot.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
||||
*/
|
||||
@Controller
|
||||
public class PathVariableController {
|
||||
|
||||
// http://127.0.0.1:8080/user/123/roles/222
|
||||
@RequestMapping(value = "/user/{userId}/roles/{roleId}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String getLogin(@PathVariable("userId") String userId, @PathVariable("roleId") String roleId) {
|
||||
return "User Id : " + userId + " Role Id : " + roleId;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/javabeat/somewords
|
||||
@RequestMapping(value = "/javabeat/{regexp1:[a-z-]+}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String getRegExp(@PathVariable("regexp1") String regexp1) {
|
||||
return "URI Part : " + regexp1;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.zw.zwdemospringboot.controller;
|
||||
|
||||
import com.zw.zwdemospringboot.service.Person;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class StreamTest1 {
|
||||
public static void main(String[] args) {
|
||||
List<String> list1 = Arrays.asList("aaa", "abc", "avvc", "adddd", "edw", "dswe", "sdf", "sd");
|
||||
List<String> list2 = Arrays.asList("bdd", "sfdsf", "efv", "yttb", "gdf", "jmh", "cvb", "dfg");
|
||||
|
||||
Stream<String> s1 = list1.stream().filter(s -> {
|
||||
return s.length() == 3;
|
||||
}).limit(3);
|
||||
Stream<String> s2 = list2.stream().filter(s -> s.startsWith("d")).skip(2);
|
||||
|
||||
//Stream.concat(s1,s2).map(n -> new Person(n)).forEach(System.out::println);
|
||||
//Stream.concat(s1,s2).map(Person::new).forEach(System.out::println);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.zw.zwdemospringboot.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class StreamTest2 {
|
||||
public static void main(String[] args) {
|
||||
// List<String> c1 = Stream.of("aa", "bb", "cc").collect(Collectors.toList());
|
||||
// System.out.println(c1);
|
||||
//
|
||||
// Set<String> c2 = Stream.of("cc", "dd", "ee","cc").collect(Collectors.toSet());
|
||||
// System.out.println(c2);
|
||||
//
|
||||
// ArrayList<String> c3 = Stream.of("cc", "dd", "ee", "cc")
|
||||
// //.collect(Collectors.toCollection(() -> new ArrayList<>()));
|
||||
// .collect(Collectors.toCollection(ArrayList::new));
|
||||
// System.out.println(c3);
|
||||
//
|
||||
// HashSet<String> s4 = Stream.of("cc", "dd", "ee", "cc").collect(Collectors.toCollection(HashSet::new));
|
||||
// System.out.println(s4);
|
||||
|
||||
Object[] s5 = Stream.of("cc", "dd", "ee", "cc")
|
||||
.toArray();
|
||||
System.out.println(s5);
|
||||
|
||||
|
||||
Stream.of("11", "22", "22", "33").mapToInt(Integer::parseInt).toArray();
|
||||
|
||||
// Integer[] array1 = Stream.of("11", "22", "22", "33").toArray(Integer[]::new);
|
||||
// System.out.println(array1);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.zw.zwdemospringboot.controller;
|
||||
|
||||
import com.zw.zwdemospringboot.entity.ZwUser;
|
||||
import com.zw.zwdemospringboot.service.ZwUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
@Autowired
|
||||
private ZwUserService zwUserService;
|
||||
|
||||
@GetMapping("/getId")
|
||||
public ZwUser hello(@RequestParam(name = "id") Integer id) {
|
||||
return zwUserService.getComboById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.zw.zwdemospringboot.controller;
|
||||
|
||||
import com.zw.zwdemospringboot.service.*;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ZwTestController {
|
||||
|
||||
public static void main(String arg[]){
|
||||
/*pringString(s-> System.out.println(s));
|
||||
|
||||
pringString(System.out::println);
|
||||
|
||||
PrintStream out = System.out;
|
||||
pringString(out::print);*/
|
||||
|
||||
// int n = method(-10, a -> Math.abs(a));
|
||||
// System.out.println(n);
|
||||
//
|
||||
// int num = method(-20, Math::abs);
|
||||
// System.out.println(num);
|
||||
//构造器引用
|
||||
// printName("aaa", name->new Person(name));
|
||||
//
|
||||
// printName("bbb", Person::new);
|
||||
|
||||
//普通方法引用
|
||||
/*pringString(s->{
|
||||
Method method = new Method();
|
||||
method.printUpp(s);
|
||||
} );
|
||||
|
||||
Method method = new Method();
|
||||
pringString(method::printUpp);*/
|
||||
|
||||
|
||||
// Stream<String> stream = Stream.of("1", "2", "3", "4");
|
||||
// stream.map(s -> Integer.parseInt(s)).forEach(System.out::println);
|
||||
//
|
||||
// ArrayList<String> list = new ArrayList<>();
|
||||
// list.add("aaa");
|
||||
// list.add("avd");
|
||||
// list.add("addd");
|
||||
// list.add("fdsf");
|
||||
// list.add("fdsss");
|
||||
//
|
||||
// List<String> a = list.stream().filter(s -> s.startsWith("a")).collect(Collectors.toList());
|
||||
// System.out.println(a);
|
||||
//
|
||||
// HashSet<Integer> hs = new HashSet<>();
|
||||
// hs.add(10);
|
||||
// hs.add(20);
|
||||
// hs.add(30);
|
||||
// hs.add(40);
|
||||
// hs.add(50);
|
||||
//
|
||||
// Stream<Integer> integerStream = hs.stream().filter(age -> age > 25);
|
||||
// Set<Integer> ages = integerStream.collect(Collectors.toSet());
|
||||
// for (Integer i : ages) {
|
||||
// System.out.println(i);
|
||||
// }
|
||||
//
|
||||
// String[] strArray = {"aaa,30", "bbb,40", "ccc,50", "ddd,60"};
|
||||
// Stream<String> stream1 = Stream.of(strArray)
|
||||
// .filter(s -> Integer.parseInt(s.split(",")[1]) > 28);
|
||||
// Map<String, Integer> map = stream1.collect(Collectors.toMap(
|
||||
// s -> s.split(",")[0],
|
||||
// s -> Integer.parseInt(s.split(",")[1])
|
||||
// ));
|
||||
//
|
||||
// Set<String> keySet = map.keySet();
|
||||
// for (String s:keySet){
|
||||
// System.out.println(s+","+map.get(s));
|
||||
// }
|
||||
|
||||
|
||||
Integer[] arr ={1,2,3,4,5};
|
||||
Stream<Integer> stream = Arrays.stream(arr);
|
||||
List<Integer> list = Arrays.asList(arr);
|
||||
//Stream.of(arr).filter(s->s>0).forEach(System.out::println);
|
||||
|
||||
Stream.of(arr).mapToInt(Integer::intValue).filter(i->i>3).forEach(System.out::println);
|
||||
|
||||
Stream<String> stream1 = Stream.of("a","b","c");
|
||||
Stream<String> stream2 = Stream.of("x", "y", "z");
|
||||
Stream.concat(stream1, stream2).forEach(System.out::println);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void pringString(Printable p) {
|
||||
p.print("hihihi!");
|
||||
}
|
||||
|
||||
public static int method(int number, Calcable c) {
|
||||
return c.calsAbs(number);
|
||||
}
|
||||
|
||||
public static void printName(String name, PersonBuilder pb) {
|
||||
Person person = pb.builder(name);
|
||||
System.out.println(person.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zw.zwdemospringboot.entity;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
||||
*/
|
||||
public class User {
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer age;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.zw.zwdemospringboot.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("zw_user")
|
||||
public class ZwUser {
|
||||
private Integer id;
|
||||
|
||||
private String userName;
|
||||
|
||||
private Integer age;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.zw.zwdemospringboot.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zw.zwdemospringboot.entity.ZwUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ZwUserMapper {
|
||||
Boolean saveCombo(ZwUser dto);
|
||||
|
||||
Boolean updateCombo(ZwUser dto);
|
||||
|
||||
Page<ZwUser> pageComboVo(ZwUser dto);
|
||||
|
||||
ZwUser getComboById(Integer id);
|
||||
|
||||
Boolean removeComboById(Integer id);
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.zw.zwdemospringboot.service;
|
||||
|
||||
public interface Calcable {
|
||||
int calsAbs(int number);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.zw.zwdemospringboot.service;
|
||||
|
||||
public class Method {
|
||||
public int printUpp(String str){
|
||||
System.out.println(str.toUpperCase());
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.zw.zwdemospringboot.service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
public class Person {
|
||||
private String name;
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
private Integer age;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Person(String name, Integer age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Person{" +
|
||||
"name='" + name + '\'' +
|
||||
", age=" + age +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.zw.zwdemospringboot.service;
|
||||
|
||||
public interface PersonBuilder {
|
||||
Person builder(String name);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.zw.zwdemospringboot.service;
|
||||
|
||||
|
||||
public interface Printable {
|
||||
void print(String s);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.zw.zwdemospringboot.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zw.zwdemospringboot.entity.ZwUser;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ZwUserService {
|
||||
|
||||
Boolean saveCombo(ZwUser dto);
|
||||
|
||||
Boolean updateCombo(ZwUser dto);
|
||||
|
||||
Page<ZwUser> pageComboVo(ZwUser dto);
|
||||
|
||||
ZwUser getComboById(Integer id);
|
||||
|
||||
Boolean removeComboById(Integer id);
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.zw.zwdemospringboot.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.kotlin.KtQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.kotlin.KtUpdateChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zw.zwdemospringboot.entity.ZwUser;
|
||||
import com.zw.zwdemospringboot.mapper.ZwUserMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class ZwUserServiceImpl implements ZwUserService {
|
||||
|
||||
@Autowired
|
||||
private ZwUserMapper zwUserMapper;
|
||||
@Override
|
||||
public Boolean saveCombo(ZwUser dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateCombo(ZwUser dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ZwUser> pageComboVo(ZwUser dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZwUser getComboById(Integer id) {
|
||||
|
||||
return zwUserMapper.getComboById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean removeComboById(Integer id) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.zw.zwdemospringboot.service.father;
|
||||
|
||||
public interface Greetable {
|
||||
void greet();
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.zw.zwdemospringboot.service.father;
|
||||
|
||||
public class Human {
|
||||
public void say(){
|
||||
System.out.println("i am father!");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.zw.zwdemospringboot.service.father;
|
||||
|
||||
public class Man extends Human{
|
||||
public void say(){
|
||||
System.out.println("i am man!");
|
||||
}
|
||||
|
||||
public void method(Greetable g){
|
||||
g.greet();
|
||||
}
|
||||
|
||||
public void show(){
|
||||
method(()->{
|
||||
Human human = new Human();
|
||||
human.say();
|
||||
});
|
||||
|
||||
method(()->{super.say();});
|
||||
method(super::say);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.zw.zwdemospringboot.service.father;
|
||||
|
||||
public class SuperMethodRe {
|
||||
public static void main(String[] args) {
|
||||
Man man = new Man();
|
||||
man.show();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.zw.zwdemospringboot.service.son;
|
||||
|
||||
public class Husband {
|
||||
public void buyHouse(){
|
||||
System.out.println("buy it!");
|
||||
}
|
||||
|
||||
public void marry(Rich r){
|
||||
r.buy();
|
||||
}
|
||||
|
||||
public void soHappy(){
|
||||
marry(()->this.buyHouse());
|
||||
|
||||
marry(this::buyHouse);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.zw.zwdemospringboot.service.son;
|
||||
|
||||
public class MethBuy {
|
||||
public static void main(String[] args) {
|
||||
new Husband().soHappy();
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.zw.zwdemospringboot.service.son;
|
||||
|
||||
public interface Rich {
|
||||
void buy();
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
server:
|
||||
port: 8081
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
url: jdbc:mysql://192.168.2.223:3306/zw_database?useUnicode=true&characterEncoding=utf-8&serverTimezone=America/New_York
|
||||
username: mepsking
|
||||
password: Meps@2099fpv
|
||||
hikari:
|
||||
minimum-idle: 3
|
||||
maximum-pool-size: 5
|
||||
auto-commit: true
|
||||
idle-timeout: 30000
|
||||
pool-name: HikariCP_star
|
||||
max-lifetime: 1800000
|
||||
connection-timeout: 30000
|
@ -0,0 +1,33 @@
|
||||
<?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.zw.zwdemospringboot.mapper.ZwUserMapper">
|
||||
<sql id="sql">
|
||||
SELECT id,
|
||||
user_name,
|
||||
age
|
||||
FROM zw_user
|
||||
</sql>
|
||||
|
||||
<select id="getComboById" resultType="com.zw.zwdemospringboot.entity.ZwUser">
|
||||
<include refid="sql"></include>
|
||||
where id=#{id}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<select id="queryCartItemByMemberId" resultType="com.tmotor.cloud.common.vo.CartItemVo">
|
||||
SELECT ci.id,
|
||||
ci.member_id,
|
||||
ci.sku_id,
|
||||
ci.spu_code,
|
||||
combo_sku_id,
|
||||
ci.cart_count
|
||||
FROM cart_item ci
|
||||
where ci.member_id = #{dto.memberId}
|
||||
order by ci.create_time desc
|
||||
</select>
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>hello word!!!</h1>
|
||||
<p>this is a html page</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,63 @@
|
||||
package com.zw.zwdemospringboot;
|
||||
|
||||
import com.zw.zwdemospringboot.service.Person;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.*;
|
||||
|
||||
public class InstantTest {
|
||||
@Test
|
||||
public void test1(){
|
||||
|
||||
Instant now = Instant.now();
|
||||
Instant now1 = Instant.now();
|
||||
//System.out.println(nano);
|
||||
try {
|
||||
Thread.sleep(5);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Instant now2 = Instant.now();
|
||||
System.out.println(now2.getNano() - now.getNano());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2(){
|
||||
LocalTime now = LocalTime.now();
|
||||
LocalTime time = LocalTime.of(21, 12, 33);
|
||||
|
||||
System.out.println(now);
|
||||
System.out.println(time);
|
||||
//时间差
|
||||
Duration duration = Duration.between(now, time);
|
||||
System.out.println(duration.toDays());
|
||||
System.out.println(duration.toHours());
|
||||
System.out.println(duration.toMinutes());
|
||||
|
||||
//日期差
|
||||
LocalDate nowDate = LocalDate.now();
|
||||
LocalDate date = LocalDate.of(1997, 2, 5);
|
||||
|
||||
Period period = Period.between(date,nowDate);
|
||||
System.out.println(period.getYears());
|
||||
System.out.println(period.getMonths());
|
||||
System.out.println(period.getDays());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3(){
|
||||
//ZoneId.getAvailableZoneIds().forEach(System.out::println);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
System.out.println("now = " + now);
|
||||
|
||||
ZonedDateTime bz = ZonedDateTime.now(Clock.systemUTC());
|
||||
System.out.println("bz = " + bz);
|
||||
|
||||
ZonedDateTime now1 = ZonedDateTime.now();
|
||||
System.out.println("now1 = " + now1);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.zw.zwdemospringboot;
|
||||
|
||||
import com.zw.zwdemospringboot.service.Person;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class OptionalTest1 {
|
||||
@Test
|
||||
public void test1(){
|
||||
Person tom = new Person("tom", 19);
|
||||
Optional<Person> tom1 = Optional.of(tom);
|
||||
String name = getNameForOp(tom1);
|
||||
System.out.println(name);
|
||||
}
|
||||
|
||||
public String getNameForOp(Optional<Person> op){
|
||||
if (op.isPresent()){
|
||||
String msg = op.map(Person::getName)
|
||||
//.map(n -> n.toUpperCase())
|
||||
.map(String::toUpperCase)
|
||||
.orElse(null);
|
||||
return msg;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.zw.zwdemospringboot;
|
||||
|
||||
import com.zw.zwdemospringboot.service.Person;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.IntSummaryStatistics;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class StreamTest1 {
|
||||
@Test
|
||||
public void test01(){
|
||||
Optional<Person> maxAge = Stream.of(
|
||||
new Person("tom", 18),
|
||||
new Person("jack", 19),
|
||||
new Person("jim", 20),
|
||||
new Person("tony", 21),
|
||||
new Person("anny", 22))
|
||||
.collect(Collectors.maxBy((p1, p2) -> {
|
||||
return p1.getAge() - p2.getAge();
|
||||
}));
|
||||
System.out.println(maxAge.get());
|
||||
|
||||
IntSummaryStatistics sumAge = Stream.of(
|
||||
new Person("tom", 18),
|
||||
new Person("jack", 19),
|
||||
new Person("jim", 20),
|
||||
new Person("tony", 21),
|
||||
new Person("anny", 22))
|
||||
.collect(Collectors.summarizingInt(s -> s.getAge()));
|
||||
System.out.println(sumAge.getSum());
|
||||
|
||||
Double avg = Stream.of(
|
||||
new Person("tom", 18),
|
||||
new Person("jack", 19),
|
||||
new Person("jim", 20),
|
||||
new Person("tony", 21),
|
||||
new Person("anny", 22))
|
||||
.collect(Collectors.averagingInt(Person::getAge));
|
||||
System.out.println(avg);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.zw.zwdemospringboot;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ZwDemoSpringBootApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue