@ -0,0 +1,31 @@ | |||
HELP.md | |||
target/ | |||
!.mvn/wrapper/maven-wrapper.jar | |||
!**/src/main/** | |||
!**/src/test/** | |||
### 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/ | |||
### VS Code ### | |||
.vscode/ |
@ -0,0 +1,117 @@ | |||
/* | |||
* Copyright 2007-present 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. | |||
*/ | |||
import java.net.*; | |||
import java.io.*; | |||
import java.nio.channels.*; | |||
import java.util.Properties; | |||
public class MavenWrapperDownloader { | |||
private static final String WRAPPER_VERSION = "0.5.6"; | |||
/** | |||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. | |||
*/ | |||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" | |||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; | |||
/** | |||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to | |||
* use instead of the default one. | |||
*/ | |||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = | |||
".mvn/wrapper/maven-wrapper.properties"; | |||
/** | |||
* Path where the maven-wrapper.jar will be saved to. | |||
*/ | |||
private static final String MAVEN_WRAPPER_JAR_PATH = | |||
".mvn/wrapper/maven-wrapper.jar"; | |||
/** | |||
* Name of the property which should be used to override the default download url for the wrapper. | |||
*/ | |||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; | |||
public static void main(String args[]) { | |||
System.out.println("- Downloader started"); | |||
File baseDirectory = new File(args[0]); | |||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); | |||
// If the maven-wrapper.properties exists, read it and check if it contains a custom | |||
// wrapperUrl parameter. | |||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); | |||
String url = DEFAULT_DOWNLOAD_URL; | |||
if(mavenWrapperPropertyFile.exists()) { | |||
FileInputStream mavenWrapperPropertyFileInputStream = null; | |||
try { | |||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); | |||
Properties mavenWrapperProperties = new Properties(); | |||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); | |||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); | |||
} catch (IOException e) { | |||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); | |||
} finally { | |||
try { | |||
if(mavenWrapperPropertyFileInputStream != null) { | |||
mavenWrapperPropertyFileInputStream.close(); | |||
} | |||
} catch (IOException e) { | |||
// Ignore ... | |||
} | |||
} | |||
} | |||
System.out.println("- Downloading from: " + url); | |||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); | |||
if(!outputFile.getParentFile().exists()) { | |||
if(!outputFile.getParentFile().mkdirs()) { | |||
System.out.println( | |||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); | |||
} | |||
} | |||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); | |||
try { | |||
downloadFileFromURL(url, outputFile); | |||
System.out.println("Done"); | |||
System.exit(0); | |||
} catch (Throwable e) { | |||
System.out.println("- Error downloading"); | |||
e.printStackTrace(); | |||
System.exit(1); | |||
} | |||
} | |||
private static void downloadFileFromURL(String urlString, File destination) throws Exception { | |||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { | |||
String username = System.getenv("MVNW_USERNAME"); | |||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); | |||
Authenticator.setDefault(new Authenticator() { | |||
@Override | |||
protected PasswordAuthentication getPasswordAuthentication() { | |||
return new PasswordAuthentication(username, password); | |||
} | |||
}); | |||
} | |||
URL website = new URL(urlString); | |||
ReadableByteChannel rbc; | |||
rbc = Channels.newChannel(website.openStream()); | |||
FileOutputStream fos = new FileOutputStream(destination); | |||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); | |||
fos.close(); | |||
rbc.close(); | |||
} | |||
} |
@ -0,0 +1,2 @@ | |||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip | |||
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar |
@ -0,0 +1 @@ | |||
12 |
@ -0,0 +1 @@ | |||
12 |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework:spring-aop:5.2.7.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/5.2.7.RELEASE/spring-aop-5.2.7.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/5.2.7.RELEASE/spring-aop-5.2.7.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/5.2.7.RELEASE/spring-aop-5.2.7.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,4 @@ | |||
------------------------------------------------------------------------------- | |||
Test set: com.whn.hellospring.OrderTest | |||
------------------------------------------------------------------------------- | |||
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.082 s - in com.whn.hellospring.OrderTest |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework.boot:spring-boot-starter:2.3.1.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter/2.3.1.RELEASE/spring-boot-starter-2.3.1.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter/2.3.1.RELEASE/spring-boot-starter-2.3.1.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter/2.3.1.RELEASE/spring-boot-starter-2.3.1.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: jakarta.persistence:jakarta.persistence-api:2.2.3"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: net.bytebuddy:byte-buddy-agent:1.10.11"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.10.11/byte-buddy-agent-1.10.11.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.10.11/byte-buddy-agent-1.10.11-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.10.11/byte-buddy-agent-1.10.11-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,33 @@ | |||
package com.whn.hellospring.repository; | |||
import com.whn.hellospring.model.CoffeeDO; | |||
import org.apache.ibatis.annotations.Delete; | |||
import org.springframework.data.jpa.repository.JpaRepository; | |||
import org.springframework.data.jpa.repository.Modifying; | |||
import org.springframework.data.jpa.repository.Query; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.util.List; | |||
/** | |||
* 咖啡 | |||
*/ | |||
public interface CoffeeRepository extends JpaRepository<CoffeeDO, Long> { | |||
/** | |||
* 获取一个订单下的所有咖啡 | |||
*/ | |||
@Query(value = "SELECT * FROM t_coffee where order_id_fk=?1", nativeQuery = true) | |||
List<CoffeeDO> selectCoffeeListWithOrder(Long order_id_fk); | |||
/** | |||
* 删除一个订单下的咖啡 | |||
*/ | |||
@Transactional //事务 | |||
@Modifying //更新 | |||
@Query(value = "delete FROM T_COFFEE where order_id_fk=?1", nativeQuery = true) | |||
int deleteCoffeeByOrderId(Long order_id_fk); | |||
} |
@ -0,0 +1,321 @@ | |||
package com.whn.hellospring.utils; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.apache.http.HttpResponse; | |||
import org.apache.http.NameValuePair; | |||
import org.apache.http.client.HttpClient; | |||
import org.apache.http.client.entity.UrlEncodedFormEntity; | |||
import org.apache.http.client.methods.HttpDelete; | |||
import org.apache.http.client.methods.HttpGet; | |||
import org.apache.http.client.methods.HttpPost; | |||
import org.apache.http.client.methods.HttpPut; | |||
import org.apache.http.conn.ClientConnectionManager; | |||
import org.apache.http.conn.scheme.Scheme; | |||
import org.apache.http.conn.scheme.SchemeRegistry; | |||
import org.apache.http.conn.ssl.SSLSocketFactory; | |||
import org.apache.http.entity.ByteArrayEntity; | |||
import org.apache.http.entity.StringEntity; | |||
import org.apache.http.impl.client.DefaultHttpClient; | |||
import org.apache.http.message.BasicNameValuePair; | |||
import javax.net.ssl.SSLContext; | |||
import javax.net.ssl.TrustManager; | |||
import javax.net.ssl.X509TrustManager; | |||
import java.io.UnsupportedEncodingException; | |||
import java.net.URLEncoder; | |||
import java.security.KeyManagementException; | |||
import java.security.NoSuchAlgorithmException; | |||
import java.security.cert.X509Certificate; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* 功能描述: | |||
* | |||
* @author Administrator | |||
* @date 2021/7/23 | |||
*/ | |||
public class HttpUtils { | |||
/** | |||
* get | |||
* | |||
* @param host | |||
* @param path | |||
* @param method | |||
* @param headers | |||
* @param querys | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static HttpResponse doGet(String host, String path, String method, | |||
Map<String, String> headers, | |||
Map<String, String> querys) | |||
throws Exception { | |||
HttpClient httpClient = wrapClient(host); | |||
HttpGet request = new HttpGet(buildUrl(host, path, querys)); | |||
for (Map.Entry<String, String> e : headers.entrySet()) { | |||
request.addHeader(e.getKey(), e.getValue()); | |||
} | |||
return httpClient.execute(request); | |||
} | |||
/** | |||
* post form | |||
* | |||
* @param host | |||
* @param path | |||
* @param method | |||
* @param headers | |||
* @param querys | |||
* @param bodys | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static HttpResponse doPost(String host, String path, String method, | |||
Map<String, String> headers, | |||
Map<String, String> querys, | |||
Map<String, String> bodys) | |||
throws Exception { | |||
HttpClient httpClient = wrapClient(host); | |||
HttpPost request = new HttpPost(buildUrl(host, path, querys)); | |||
for (Map.Entry<String, String> e : headers.entrySet()) { | |||
request.addHeader(e.getKey(), e.getValue()); | |||
} | |||
if (bodys != null) { | |||
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>(); | |||
for (String key : bodys.keySet()) { | |||
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key))); | |||
} | |||
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8"); | |||
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8"); | |||
request.setEntity(formEntity); | |||
} | |||
return httpClient.execute(request); | |||
} | |||
/** | |||
* Post String | |||
* | |||
* @param host | |||
* @param path | |||
* @param method | |||
* @param headers | |||
* @param querys | |||
* @param body | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static HttpResponse doPost(String host, String path, String method, | |||
Map<String, String> headers, | |||
Map<String, String> querys, | |||
String body) | |||
throws Exception { | |||
HttpClient httpClient = wrapClient(host); | |||
HttpPost request = new HttpPost(buildUrl(host, path, querys)); | |||
for (Map.Entry<String, String> e : headers.entrySet()) { | |||
request.addHeader(e.getKey(), e.getValue()); | |||
} | |||
if (StringUtils.isNotBlank(body)) { | |||
request.setEntity(new StringEntity(body, "utf-8")); | |||
} | |||
return httpClient.execute(request); | |||
} | |||
/** | |||
* Post stream | |||
* | |||
* @param host | |||
* @param path | |||
* @param method | |||
* @param headers | |||
* @param querys | |||
* @param body | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static HttpResponse doPost(String host, String path, String method, | |||
Map<String, String> headers, | |||
Map<String, String> querys, | |||
byte[] body) | |||
throws Exception { | |||
HttpClient httpClient = wrapClient(host); | |||
HttpPost request = new HttpPost(buildUrl(host, path, querys)); | |||
for (Map.Entry<String, String> e : headers.entrySet()) { | |||
request.addHeader(e.getKey(), e.getValue()); | |||
} | |||
if (body != null) { | |||
request.setEntity(new ByteArrayEntity(body)); | |||
} | |||
return httpClient.execute(request); | |||
} | |||
/** | |||
* Put String | |||
* @param host | |||
* @param path | |||
* @param method | |||
* @param headers | |||
* @param querys | |||
* @param body | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static HttpResponse doPut(String host, String path, String method, | |||
Map<String, String> headers, | |||
Map<String, String> querys, | |||
String body) | |||
throws Exception { | |||
HttpClient httpClient = wrapClient(host); | |||
HttpPut request = new HttpPut(buildUrl(host, path, querys)); | |||
for (Map.Entry<String, String> e : headers.entrySet()) { | |||
request.addHeader(e.getKey(), e.getValue()); | |||
} | |||
if (StringUtils.isNotBlank(body)) { | |||
request.setEntity(new StringEntity(body, "utf-8")); | |||
} | |||
return httpClient.execute(request); | |||
} | |||
/** | |||
* Put stream | |||
* @param host | |||
* @param path | |||
* @param method | |||
* @param headers | |||
* @param querys | |||
* @param body | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static HttpResponse doPut(String host, String path, String method, | |||
Map<String, String> headers, | |||
Map<String, String> querys, | |||
byte[] body) | |||
throws Exception { | |||
HttpClient httpClient = wrapClient(host); | |||
HttpPut request = new HttpPut(buildUrl(host, path, querys)); | |||
for (Map.Entry<String, String> e : headers.entrySet()) { | |||
request.addHeader(e.getKey(), e.getValue()); | |||
} | |||
if (body != null) { | |||
request.setEntity(new ByteArrayEntity(body)); | |||
} | |||
return httpClient.execute(request); | |||
} | |||
/** | |||
* Delete | |||
* | |||
* @param host | |||
* @param path | |||
* @param method | |||
* @param headers | |||
* @param querys | |||
* @return | |||
* @throws Exception | |||
*/ | |||
public static HttpResponse doDelete(String host, String path, String method, | |||
Map<String, String> headers, | |||
Map<String, String> querys) | |||
throws Exception { | |||
HttpClient httpClient = wrapClient(host); | |||
HttpDelete request = new HttpDelete(buildUrl(host, path, querys)); | |||
for (Map.Entry<String, String> e : headers.entrySet()) { | |||
request.addHeader(e.getKey(), e.getValue()); | |||
} | |||
return httpClient.execute(request); | |||
} | |||
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException { | |||
StringBuilder sbUrl = new StringBuilder(); | |||
sbUrl.append(host); | |||
if (!StringUtils.isBlank(path)) { | |||
sbUrl.append(path); | |||
} | |||
if (null != querys) { | |||
StringBuilder sbQuery = new StringBuilder(); | |||
for (Map.Entry<String, String> query : querys.entrySet()) { | |||
if (0 < sbQuery.length()) { | |||
sbQuery.append("&"); | |||
} | |||
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) { | |||
sbQuery.append(query.getValue()); | |||
} | |||
if (!StringUtils.isBlank(query.getKey())) { | |||
sbQuery.append(query.getKey()); | |||
if (!StringUtils.isBlank(query.getValue())) { | |||
sbQuery.append("="); | |||
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8")); | |||
} | |||
} | |||
} | |||
if (0 < sbQuery.length()) { | |||
sbUrl.append("?").append(sbQuery); | |||
} | |||
} | |||
return sbUrl.toString(); | |||
} | |||
private static HttpClient wrapClient(String host) { | |||
HttpClient httpClient = new DefaultHttpClient(); | |||
if (host.startsWith("https://")) { | |||
sslClient(httpClient); | |||
} | |||
return httpClient; | |||
} | |||
private static void sslClient(HttpClient httpClient) { | |||
try { | |||
SSLContext ctx = SSLContext.getInstance("TLS"); | |||
X509TrustManager tm = new X509TrustManager() { | |||
@Override | |||
public X509Certificate[] getAcceptedIssuers() { | |||
return null; | |||
} | |||
@Override | |||
public void checkClientTrusted(X509Certificate[] xcs, String str) { | |||
} | |||
@Override | |||
public void checkServerTrusted(X509Certificate[] xcs, String str) { | |||
} | |||
}; | |||
ctx.init(null, new TrustManager[] { tm }, null); | |||
SSLSocketFactory ssf = new SSLSocketFactory(ctx); | |||
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); | |||
ClientConnectionManager ccm = httpClient.getConnectionManager(); | |||
SchemeRegistry registry = ccm.getSchemeRegistry(); | |||
registry.register(new Scheme("https", 443, ssf)); | |||
} catch (KeyManagementException ex) { | |||
throw new RuntimeException(ex); | |||
} catch (NoSuchAlgorithmException ex) { | |||
throw new RuntimeException(ex); | |||
} | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.hibernate:hibernate-core:5.4.17.Final"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/hibernate-core/5.4.17.Final/hibernate-core-5.4.17.Final.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/hibernate-core/5.4.17.Final/hibernate-core-5.4.17.Final-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/hibernate-core/5.4.17.Final/hibernate-core-5.4.17.Final-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,184 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | |||
<component name="FacetManager"> | |||
<facet type="Spring" name="Spring"> | |||
<configuration /> | |||
</facet> | |||
<facet type="web" name="Web"> | |||
<configuration> | |||
<webroots> | |||
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" /> | |||
</webroots> | |||
<sourceRoots> | |||
<root url="file://$MODULE_DIR$/src/main/java" /> | |||
<root url="file://$MODULE_DIR$/src/main/resources" /> | |||
</sourceRoots> | |||
</configuration> | |||
</facet> | |||
<facet type="kotlin-language" name="Kotlin"> | |||
<configuration version="3" platform="JVM 1.8" useProjectSettings="false"> | |||
<compilerSettings> | |||
<option name="additionalArguments" value="-java-parameters" /> | |||
</compilerSettings> | |||
<compilerArguments> | |||
<option name="jvmTarget" value="1.8" /> | |||
<option name="languageVersion" value="1.3" /> | |||
<option name="apiVersion" value="1.3" /> | |||
<option name="pluginOptions"> | |||
<array /> | |||
</option> | |||
<option name="pluginClasspaths"> | |||
<array /> | |||
</option> | |||
<option name="errors"> | |||
<ArgumentParseErrors /> | |||
</option> | |||
</compilerArguments> | |||
</configuration> | |||
</facet> | |||
</component> | |||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | |||
<output url="file://$MODULE_DIR$/target/classes" /> | |||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | |||
<content url="file://$MODULE_DIR$"> | |||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | |||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | |||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | |||
<excludeFolder url="file://$MODULE_DIR$/target" /> | |||
</content> | |||
<orderEntry type="inheritedJdk" /> | |||
<orderEntry type="sourceFolder" forTests="false" /> | |||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" /> | |||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.8.0" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" /> | |||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" /> | |||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.13.3" level="project" /> | |||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.13.3" level="project" /> | |||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" /> | |||
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" /> | |||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.26" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.0" level="project" /> | |||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.0" level="project" /> | |||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.0" level="project" /> | |||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.0" level="project" /> | |||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.0" level="project" /> | |||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.0" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.36" level="project" /> | |||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.36" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" /> | |||
<orderEntry type="library" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3" level="project" /> | |||
<orderEntry type="library" name="Maven: jakarta.activation:jakarta.activation-api:1.2.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.16.1" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.6.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.6.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.6.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.6.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.6.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.6.2" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.3.3" level="project" /> | |||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.11" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.11" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.3.3" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.7.0" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.5" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" scope="RUNTIME" name="Maven: com.h2database:h2:1.4.200" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.5" level="project" /> | |||
<orderEntry type="library" name="Maven: jakarta.transaction:jakarta.transaction-api:1.3.3" level="project" /> | |||
<orderEntry type="library" name="Maven: jakarta.persistence:jakarta.persistence-api:2.2.3" level="project" /> | |||
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.4.17.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.24.0-GA" level="project" /> | |||
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jboss:jandex:2.1.3.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> | |||
<orderEntry type="library" name="Maven: org.dom4j:dom4j:2.1.3" level="project" /> | |||
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.1.0.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: org.glassfish.jaxb:jaxb-runtime:2.3.3" level="project" /> | |||
<orderEntry type="library" name="Maven: org.glassfish.jaxb:txw2:2.3.3" level="project" /> | |||
<orderEntry type="library" name="Maven: com.sun.istack:istack-commons-runtime:3.0.11" level="project" /> | |||
<orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.activation:jakarta.activation:1.2.2" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-orm:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework:spring-aspects:5.2.7.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.joda:joda-money:1.0.1" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jadira.usertype:usertype.core:6.0.1.GA" level="project" /> | |||
<orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:5.4.17.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: javax.persistence:javax.persistence-api:2.2" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.1.1.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jadira.usertype:usertype.spi:6.0.1.GA" level="project" /> | |||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.12" level="project" /> | |||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2" level="project" /> | |||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.2" level="project" /> | |||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.4.6" level="project" /> | |||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.3.2" level="project" /> | |||
<orderEntry type="library" name="Maven: org.mybatis.generator:mybatis-generator-core:1.3.7" level="project" /> | |||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.13" level="project" /> | |||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.2.13" level="project" /> | |||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.1.11" level="project" /> | |||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:2.0" level="project" /> | |||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.20" level="project" /> | |||
<orderEntry type="library" name="Maven: com.googlecode.log4jdbc:log4jdbc:1.2" level="project" /> | |||
<orderEntry type="library" name="Maven: com.spring4all:swagger-spring-boot-starter:1.9.0.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.9.2" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" /> | |||
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.20" level="project" /> | |||
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.20" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.9.2" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.9.2" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" /> | |||
<orderEntry type="library" name="Maven: com.google.guava:guava:20.0" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:2.9.2" level="project" /> | |||
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-16" level="project" /> | |||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.3.1.RELEASE" level="project" /> | |||
<orderEntry type="library" name="Maven: org.glassfish:jakarta.el:3.0.3" level="project" /> | |||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.1.5.Final" level="project" /> | |||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.3.50" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" /> | |||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test:1.3.50" level="project" /> | |||
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test-common:1.3.50" level="project" /> | |||
</component> | |||
</module> |
@ -0,0 +1,40 @@ | |||
package com.whn.hellospring.repository; | |||
import com.whn.hellospring.model.OilDO; | |||
import org.springframework.data.domain.Page; | |||
import org.springframework.data.domain.Pageable; | |||
import org.springframework.data.domain.Sort; | |||
import org.springframework.data.jpa.domain.Specification; | |||
import org.springframework.data.jpa.repository.JpaRepository; | |||
import org.springframework.data.jpa.repository.Query; | |||
import org.springframework.stereotype.Repository; | |||
import java.util.List; | |||
@Repository | |||
public interface OilRepository extends JpaRepository<OilDO,Long> { | |||
/** | |||
* 分页查询所有 | |||
* | |||
* @param spec | |||
* @param pageable | |||
* @return | |||
*/ | |||
Page<OilDO> findAll(Specification spec, Pageable pageable); | |||
@Query(value = "select * from t_oil where customer_id = ?1 ORDER BY time Desc ",nativeQuery = true) | |||
List<OilDO> finAllSortByTime(Long customer_id); | |||
@Query(value = "select sum(num) from t_oil where status=1 && customer_id = ?1",nativeQuery = true) | |||
double countNum(Long customer_id); | |||
@Query(value = "select sum(interval_mileage) from t_oil where status=1 && customer_id = ?1",nativeQuery = true) | |||
double countIntervalMileage(Long customer_id); | |||
@Query(value = "select interval_oil_wear from t_oil where status=1 && customer_id=?1 ORDER BY time ASC",nativeQuery = true) | |||
List<Double> findWearList(Long customer_id); | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework.boot:spring-boot-starter-aop:2.3.1.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-aop/2.3.1.RELEASE/spring-boot-starter-aop-2.3.1.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-aop/2.3.1.RELEASE/spring-boot-starter-aop-2.3.1.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-aop/2.3.1.RELEASE/spring-boot-starter-aop-2.3.1.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.apiguardian:apiguardian-api:1.1.0"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.36"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/tomcat/embed/tomcat-embed-core/9.0.36/tomcat-embed-core-9.0.36.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/tomcat/embed/tomcat-embed-core/9.0.36/tomcat-embed-core-9.0.36-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/tomcat/embed/tomcat-embed-core/9.0.36/tomcat-embed-core-9.0.36-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework:spring-webmvc:5.2.7.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-webmvc/5.2.7.RELEASE/spring-webmvc-5.2.7.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-webmvc/5.2.7.RELEASE/spring-webmvc-5.2.7.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-webmvc/5.2.7.RELEASE/spring-webmvc-5.2.7.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: com.sun.istack:istack-commons-runtime:3.0.11"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/sun/istack/istack-commons-runtime/3.0.11/istack-commons-runtime-3.0.11.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/sun/istack/istack-commons-runtime/3.0.11/istack-commons-runtime-3.0.11-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/sun/istack/istack-commons-runtime/3.0.11/istack-commons-runtime-3.0.11-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,21 @@ | |||
<?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="hellospring" /> | |||
</profile> | |||
</annotationProcessing> | |||
<bytecodeTargetLevel> | |||
<module name="hellospring" target="1.8" /> | |||
</bytecodeTargetLevel> | |||
</component> | |||
<component name="JavacSettings"> | |||
<option name="ADDITIONAL_OPTIONS_OVERRIDE"> | |||
<module name="hellospring" options="-parameters" /> | |||
</option> | |||
</component> | |||
</project> |
@ -0,0 +1,31 @@ | |||
package com.whn.hellospring.model; | |||
import lombok.*; | |||
import org.hibernate.annotations.Type; | |||
import org.joda.money.Money; | |||
import javax.persistence.Column; | |||
import javax.persistence.Entity; | |||
import javax.persistence.Table; | |||
import java.io.Serializable; | |||
@Entity | |||
@Table(name = "T_MENU_COFFEE") | |||
@Builder | |||
@Data | |||
@ToString(callSuper = true) | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
public class MenuCoffeeDO extends BaseEntity implements Serializable { | |||
private Long menu_id_fk; | |||
private String name; | |||
@Column | |||
@Type(type = "org.jadira.usertype.moneyandcurrency.joda.PersistentMoneyAmount", | |||
parameters = {@org.hibernate.annotations.Parameter(name = "currencyCode", value = "CNY")}) | |||
private Money price; | |||
} | |||
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.3.1.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-data-jpa/2.3.1.RELEASE/spring-boot-starter-data-jpa-2.3.1.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-data-jpa/2.3.1.RELEASE/spring-boot-starter-data-jpa-2.3.1.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-data-jpa/2.3.1.RELEASE/spring-boot-starter-data-jpa-2.3.1.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.hibernate.common:hibernate-commons-annotations:5.1.0.Final"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/common/hibernate-commons-annotations/5.1.0.Final/hibernate-commons-annotations-5.1.0.Final.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/common/hibernate-commons-annotations/5.1.0.Final/hibernate-commons-annotations-5.1.0.Final-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/common/hibernate-commons-annotations/5.1.0.Final/hibernate-commons-annotations-5.1.0.Final-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,93 @@ | |||
package com.whn.hellospring.common; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
public class Status { | |||
private boolean state; | |||
private String errorCode; | |||
private String message; | |||
private Map<String, Object> data; | |||
public Status(StateMessage stateMessage) { | |||
this.state = stateMessage.getState(); | |||
this.errorCode = stateMessage.getErrorCode(); | |||
this.message = stateMessage.getMessage(); | |||
data = new HashMap<>(); | |||
} | |||
public static Status result(StateMessage stateMessage,Map<String, Object> dataMap){ | |||
Status status = new Status(stateMessage); | |||
status.setData(dataMap); | |||
return status; | |||
} | |||
/** | |||
* 返回客户端数据类型 | |||
* | |||
* @param stateMessage 返回客户端消息 | |||
* @param value 返回客户端值 | |||
*/ | |||
public Status(StateMessage stateMessage, Object value) { | |||
this.state = stateMessage.getState(); | |||
this.errorCode = stateMessage.getErrorCode(); | |||
this.message = stateMessage.getMessage(); | |||
data = new HashMap<>(); | |||
data.put("result", value); | |||
} | |||
/** | |||
* 返回客户端数据类型 | |||
* | |||
* @param stateMessage 返回客户端消息 | |||
* @param map 返回客户端数据集合 | |||
*/ | |||
public Status(StateMessage stateMessage, Map<String, Object> map) { | |||
this.state = stateMessage.getState(); | |||
this.errorCode = stateMessage.getErrorCode(); | |||
this.message = stateMessage.getMessage(); | |||
data = new HashMap<>(); | |||
data.putAll(map); | |||
} | |||
public boolean getState() { | |||
return state; | |||
} | |||
public void setState(boolean state) { | |||
this.state = state; | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
public void setMessage(String message) { | |||
this.message = message; | |||
} | |||
public Object getData() { | |||
return data; | |||
} | |||
public void setData(Map<String, Object> dataMap) { | |||
this.data = dataMap; | |||
} | |||
public void setData(String key, Object value) { | |||
this.data.put(key, value); | |||
} | |||
@Override | |||
public String toString() { | |||
return "Status [state=" + state + ", message=" + message + ", data=" + data + "]"; | |||
} | |||
public String getErrorCode() { | |||
return errorCode; | |||
} | |||
public void setErrorCode(String errorCode) { | |||
this.errorCode = errorCode; | |||
} | |||
} |
@ -0,0 +1,163 @@ | |||
package com.whn.hellospring; | |||
import com.whn.hellospring.model.*; | |||
import com.whn.hellospring.repository.CoffeeOrderRepository; | |||
import com.whn.hellospring.repository.CoffeeRepository; | |||
import com.whn.hellospring.utils.DO2DTOUtil; | |||
import org.joda.money.CurrencyUnit; | |||
import org.joda.money.Money; | |||
import org.junit.jupiter.api.Test; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.boot.test.context.SpringBootTest; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
@SpringBootTest | |||
class HellospringApplicationTests { | |||
// @Autowired | |||
// private CoffeeRepository coffeeRepository; | |||
// | |||
// @Autowired | |||
// private CoffeeOrderRepository orderRepository; | |||
// | |||
// | |||
// /** | |||
// * 查询一个订单信息,包含咖啡 | |||
// */ | |||
// @Test | |||
// void queryOrder() { | |||
// Long id = 8L; | |||
// CoffeeOrderDO orderDO = orderRepository.queryOrderWithId(id); | |||
// CoffeeOrderDTO orderDTO = (CoffeeOrderDTO) doToDto(orderDO, CoffeeOrderDTO.class); | |||
// List<CoffeeDO> coffeeDOList = coffeeRepository.selectCoffeeListWithOrder(id); | |||
// List<CoffeeDTO> coffeeDTOList = (List<CoffeeDTO>) DO2DTOUtil.getInstance().doListToDtoList(coffeeDOList, CoffeeDTO.class); | |||
// | |||
// orderDTO.setItems(coffeeDTOList); | |||
// System.out.println("顾客:" + orderDTO.getCustomer()); | |||
// for (CoffeeDTO coffee : | |||
// orderDTO.getItems()) { | |||
// System.out.println("咖啡:" + coffee.getName()); | |||
// } | |||
// } | |||
// | |||
// | |||
// /** | |||
// * 创建一个订单,包含咖啡 | |||
// */ | |||
// @Test | |||
// void createOrderWithCoffee() { | |||
// //创建一个订单,包含一杯咖啡 | |||
// CoffeeDO espresso = CoffeeDO.builder().name("订单下的咖啡3") | |||
// .price(Money.of(CurrencyUnit.of("CNY"), 10.0)) | |||
// .build(); | |||
// coffeeRepository.save(espresso); | |||
// CoffeeOrderDTO orderDTO = CoffeeOrderDTO.builder() | |||
// .customer("me3") | |||
// .state(OrderState.INIT) | |||
// .build(); | |||
// | |||
// | |||
// //保存订单,拆解DTO为DO | |||
// CoffeeOrderDO order = (CoffeeOrderDO) dtoToDo(orderDTO, CoffeeOrderDO.class); | |||
// orderRepository.save(order); | |||
// | |||
// //保存咖啡 | |||
// List<CoffeeDTO> list = orderDTO.getItems(); | |||
// for (CoffeeDTO coffee : list) { | |||
// coffee.setOrder_id_fk(order.getId()); | |||
//// coffeeRepository.save(coffee); | |||
// } | |||
// } | |||
// | |||
// /** | |||
// * 创建一杯咖啡 | |||
// */ | |||
// @Test | |||
// void createCoffee() { | |||
// CoffeeDO espresso = CoffeeDO.builder().name("espresso") | |||
// .price(Money.of(CurrencyUnit.of("CNY"), 20.0)) | |||
// .build(); | |||
// coffeeRepository.save(espresso); | |||
// } | |||
// | |||
// /** | |||
// * 获取一个订单下的咖啡列表 | |||
// */ | |||
// @Test | |||
// void getCoffeeListWithOrder() { | |||
// List<CoffeeDO> list = coffeeRepository.selectCoffeeListWithOrder(1L); | |||
// System.out.println("列表长度:" + list.size()); | |||
// for (CoffeeDO item : list) { | |||
// System.out.println("列表:" + item.getName()); | |||
// } | |||
// } | |||
// | |||
// | |||
// /** | |||
// * DTO模型转换成DO | |||
// * | |||
// * @param objectDto DTO 对象 | |||
// * @param doClass DO 类型 | |||
// * @return doClass类型的对象 | |||
// */ | |||
// public Object dtoToDo(Object objectDto, Class doClass) { | |||
// if (objectDto == null) { | |||
// return null; | |||
// } | |||
// Object objectDo = null; | |||
// try { | |||
// objectDo = doClass.newInstance(); | |||
// BeanUtils.copyProperties(objectDto, objectDo); | |||
// } catch (Exception ex) { | |||
// ex.printStackTrace(); | |||
// } | |||
// return objectDo; | |||
// } | |||
// | |||
// | |||
// /** | |||
// * DO集合转换成DTO集合 | |||
// * | |||
// * @param doList DO 对象集合 | |||
// * @param dtoClass DTO 类型 | |||
// * @return dtoClass类型的集合 | |||
// */ | |||
// public Object doListToDtoList(Object doList, Class dtoClass) { | |||
// if (doList == null) { | |||
// return null; | |||
// } | |||
// List<Object> dtoList = new ArrayList<>(); | |||
// for (Object i : (List) doList) { | |||
// Object dto = doToDto(i, dtoClass); | |||
// if (dto != null) { | |||
// dtoList.add(dto); | |||
// } | |||
// } | |||
// return dtoList; | |||
// } | |||
// | |||
// /** | |||
// * DO转换成DTO | |||
// * | |||
// * @param objectDo DO 对象 | |||
// * @param dtoClass DTO 类型 | |||
// * @return dtoClass类型的对象 | |||
// */ | |||
// public Object doToDto(Object objectDo, Class dtoClass) { | |||
// if (objectDo == null) { | |||
// return null; | |||
// } | |||
// Object objectDto = null; | |||
// try { | |||
// objectDto = dtoClass.newInstance(); | |||
// BeanUtils.copyProperties(objectDo, objectDto); | |||
// } catch (Exception ex) { | |||
// ex.printStackTrace(); | |||
// } | |||
// return objectDto; | |||
// } | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework:spring-core:5.2.7.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/5.2.7.RELEASE/spring-core-5.2.7.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/5.2.7.RELEASE/spring-core-5.2.7.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/5.2.7.RELEASE/spring-core-5.2.7.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,9 @@ | |||
# 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.3.1.RELEASE/maven-plugin/reference/html/) | |||
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/maven-plugin/reference/html/#build-image) | |||
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.50/kotlin-stdlib-common-1.3.50.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.50/kotlin-stdlib-common-1.3.50-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.50/kotlin-stdlib-common-1.3.50-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: ch.qos.logback:logback-core:1.2.3"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,99 @@ | |||
package com.whn.hellospring.service; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
import java.io.*; | |||
import java.net.URL; | |||
import java.net.URLConnection; | |||
import java.util.List; | |||
import java.util.Map; | |||
@Slf4j | |||
@Service | |||
public class JuheService { | |||
public String getOilPrice() { | |||
String url = "http://apis.juhe.cn/gnyj/query?key=212b6526c4f8a3899ca406a1173bafa8"; | |||
String result = ""; | |||
BufferedReader in = null; | |||
try { | |||
String urlNameString = url; | |||
URL realUrl = new URL(urlNameString); | |||
URLConnection connection = realUrl.openConnection(); | |||
connection.setRequestProperty("accept", "*/*"); | |||
connection.setRequestProperty("connection", "Keep-Alive"); | |||
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); | |||
connection.connect(); | |||
Map<String, List<String>> map = connection.getHeaderFields(); | |||
for (String key : map.keySet()) { | |||
System.out.println(key + "--->" + map.get(key)); | |||
} | |||
in = new BufferedReader(new InputStreamReader( | |||
connection.getInputStream())); | |||
String line; | |||
while ((line = in.readLine()) != null) { | |||
result += line; | |||
} | |||
} catch (Exception e) { | |||
System.out.println("异常" + e); | |||
e.printStackTrace(); | |||
} finally { | |||
try { | |||
if (in != null) { | |||
in.close(); | |||
} | |||
} catch (Exception e2) { | |||
e2.printStackTrace(); | |||
} | |||
} | |||
return result; | |||
} | |||
public static String sendPost(String url, String param) { | |||
PrintWriter out = null; | |||
BufferedReader in = null; | |||
String result = ""; | |||
try { | |||
URL realUrl = new URL(url); | |||
URLConnection conn = realUrl.openConnection(); | |||
conn.setRequestProperty("Content-Type", "application/json"); | |||
conn.setRequestProperty("charset", "utf-8"); | |||
conn.setRequestProperty("accept", "*/*"); | |||
conn.setRequestProperty("connection", "Keep-Alive"); | |||
conn.setRequestProperty("user-agent", | |||
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); | |||
conn.setDoOutput(true); | |||
conn.setDoInput(true); | |||
out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "utf-8")); | |||
out.print(param); | |||
out.flush(); | |||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); | |||
String line; | |||
while ((line = in.readLine()) != null) { | |||
result += line; | |||
} | |||
System.out.println("sendPost" + result); | |||
} catch (Exception e) { | |||
System.out.println("异常" + e); | |||
e.printStackTrace(); | |||
} finally { | |||
try { | |||
if (out != null) { | |||
out.close(); | |||
} | |||
if (in != null) { | |||
in.close(); | |||
} | |||
} catch (IOException ex) { | |||
ex.printStackTrace(); | |||
} | |||
} | |||
return result; | |||
} | |||
} |
@ -0,0 +1,127 @@ | |||
<component name="ArtifactManager"> | |||
<artifact type="exploded-war" name="hellospring:war exploded"> | |||
<output-path>$PROJECT_DIR$/target/test</output-path> | |||
<properties id="maven-jee-properties"> | |||
<options> | |||
<exploded>true</exploded> | |||
<module>hellospring</module> | |||
<packaging>war</packaging> | |||
</options> | |||
</properties> | |||
<root id="root"> | |||
<element id="directory" name="WEB-INF"> | |||
<element id="directory" name="classes"> | |||
<element id="module-output" name="hellospring" /> | |||
</element> | |||
<element id="directory" name="lib"> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-web:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: ch.qos.logback:logback-classic:1.2.3" /> | |||
<element id="library" level="project" name="Maven: ch.qos.logback:logback-core:1.2.3" /> | |||
<element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.13.3" /> | |||
<element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-api:2.13.3" /> | |||
<element id="library" level="project" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" /> | |||
<element id="library" level="project" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" /> | |||
<element id="library" level="project" name="Maven: org.yaml:snakeyaml:1.26" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-json:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.0" /> | |||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.0" /> | |||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.0" /> | |||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.0" /> | |||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.0" /> | |||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.0" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.36" /> | |||
<element id="library" level="project" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.36" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-web:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-beans:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-webmvc:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-aop:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-context:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-expression:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3" /> | |||
<element id="library" level="project" name="Maven: jakarta.activation:jakarta.activation-api:1.2.2" /> | |||
<element id="library" level="project" name="Maven: net.bytebuddy:byte-buddy:1.10.11" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-core:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-jcl:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: com.zaxxer:HikariCP:3.4.5" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-jdbc:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-tx:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: com.h2database:h2:1.4.200" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.aspectj:aspectjweaver:1.9.5" /> | |||
<element id="library" level="project" name="Maven: jakarta.transaction:jakarta.transaction-api:1.3.3" /> | |||
<element id="library" level="project" name="Maven: jakarta.persistence:jakarta.persistence-api:2.2.3" /> | |||
<element id="library" level="project" name="Maven: org.hibernate:hibernate-core:5.4.17.Final" /> | |||
<element id="library" level="project" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" /> | |||
<element id="library" level="project" name="Maven: org.javassist:javassist:3.24.0-GA" /> | |||
<element id="library" level="project" name="Maven: antlr:antlr:2.7.7" /> | |||
<element id="library" level="project" name="Maven: org.jboss:jandex:2.1.3.Final" /> | |||
<element id="library" level="project" name="Maven: com.fasterxml:classmate:1.5.1" /> | |||
<element id="library" level="project" name="Maven: org.dom4j:dom4j:2.1.3" /> | |||
<element id="library" level="project" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.1.0.Final" /> | |||
<element id="library" level="project" name="Maven: org.glassfish.jaxb:jaxb-runtime:2.3.3" /> | |||
<element id="library" level="project" name="Maven: org.glassfish.jaxb:txw2:2.3.3" /> | |||
<element id="library" level="project" name="Maven: com.sun.istack:istack-commons-runtime:3.0.11" /> | |||
<element id="library" level="project" name="Maven: com.sun.activation:jakarta.activation:1.2.2" /> | |||
<element id="library" level="project" name="Maven: org.springframework.data:spring-data-jpa:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework.data:spring-data-commons:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-orm:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework:spring-aspects:5.2.7.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.joda:joda-money:1.0.1" /> | |||
<element id="library" level="project" name="Maven: org.jadira.usertype:usertype.core:6.0.1.GA" /> | |||
<element id="library" level="project" name="Maven: org.hibernate:hibernate-entitymanager:5.4.17.Final" /> | |||
<element id="library" level="project" name="Maven: javax.persistence:javax.persistence-api:2.2" /> | |||
<element id="library" level="project" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.1.1.Final" /> | |||
<element id="library" level="project" name="Maven: org.slf4j:slf4j-api:1.7.30" /> | |||
<element id="library" level="project" name="Maven: org.jadira.usertype:usertype.spi:6.0.1.GA" /> | |||
<element id="library" level="project" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2" /> | |||
<element id="library" level="project" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.2" /> | |||
<element id="library" level="project" name="Maven: org.mybatis:mybatis:3.4.6" /> | |||
<element id="library" level="project" name="Maven: org.mybatis:mybatis-spring:1.3.2" /> | |||
<element id="library" level="project" name="Maven: org.mybatis.generator:mybatis-generator-core:1.3.7" /> | |||
<element id="library" level="project" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.13" /> | |||
<element id="library" level="project" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.2.13" /> | |||
<element id="library" level="project" name="Maven: com.github.pagehelper:pagehelper:5.1.11" /> | |||
<element id="library" level="project" name="Maven: com.github.jsqlparser:jsqlparser:2.0" /> | |||
<element id="library" level="project" name="Maven: mysql:mysql-connector-java:8.0.20" /> | |||
<element id="library" level="project" name="Maven: com.googlecode.log4jdbc:log4jdbc:1.2" /> | |||
<element id="library" level="project" name="Maven: com.spring4all:swagger-spring-boot-starter:1.9.0.RELEASE" /> | |||
<element id="library" level="project" name="Maven: io.springfox:springfox-swagger-ui:2.9.2" /> | |||
<element id="library" level="project" name="Maven: io.springfox:springfox-spring-web:2.9.2" /> | |||
<element id="library" level="project" name="Maven: io.springfox:springfox-swagger2:2.9.2" /> | |||
<element id="library" level="project" name="Maven: io.swagger:swagger-annotations:1.5.20" /> | |||
<element id="library" level="project" name="Maven: io.swagger:swagger-models:1.5.20" /> | |||
<element id="library" level="project" name="Maven: io.springfox:springfox-spi:2.9.2" /> | |||
<element id="library" level="project" name="Maven: io.springfox:springfox-core:2.9.2" /> | |||
<element id="library" level="project" name="Maven: io.springfox:springfox-schema:2.9.2" /> | |||
<element id="library" level="project" name="Maven: io.springfox:springfox-swagger-common:2.9.2" /> | |||
<element id="library" level="project" name="Maven: com.google.guava:guava:20.0" /> | |||
<element id="library" level="project" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" /> | |||
<element id="library" level="project" name="Maven: io.springfox:springfox-bean-validators:2.9.2" /> | |||
<element id="library" level="project" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-16" /> | |||
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.3.1.RELEASE" /> | |||
<element id="library" level="project" name="Maven: org.glassfish:jakarta.el:3.0.3" /> | |||
<element id="library" level="project" name="Maven: org.hibernate.validator:hibernate-validator:6.1.5.Final" /> | |||
<element id="library" level="project" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" /> | |||
<element id="library" level="project" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10" /> | |||
<element id="library" level="project" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.4.10" /> | |||
<element id="library" level="project" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.4.10" /> | |||
<element id="library" level="project" name="Maven: org.jetbrains:annotations:13.0" /> | |||
<element id="library" level="project" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10" /> | |||
</element> | |||
</element> | |||
<element id="directory" name="META-INF"> | |||
<element id="file-copy" path="$PROJECT_DIR$/target/test/META-INF/MANIFEST.MF" /> | |||
</element> | |||
<element id="javaee-facet-resources" facet="hellospring/web/Web" /> | |||
</root> | |||
</artifact> | |||
</component> |
@ -0,0 +1,44 @@ | |||
package com.whn.hellospring.handler; | |||
import org.apache.ibatis.type.BaseTypeHandler; | |||
import org.apache.ibatis.type.JdbcType; | |||
import org.joda.money.CurrencyUnit; | |||
import org.joda.money.Money; | |||
import java.sql.CallableStatement; | |||
import java.sql.PreparedStatement; | |||
import java.sql.ResultSet; | |||
import java.sql.SQLException; | |||
/** | |||
* 在Money与Long之间转换的TypeHandler,处理CNY和人民币 | |||
*/ | |||
public class MoneyTypeHandler extends BaseTypeHandler<Money> { | |||
@Override | |||
public void setNonNullParameter(PreparedStatement preparedStatement, int i, Money money, JdbcType jdbcType) throws SQLException { | |||
preparedStatement.setLong(i,money.getAmountMinorLong()); //存储为Long类型,精确到分 | |||
} | |||
@Override | |||
public Money getNullableResult(ResultSet resultSet, String s) throws SQLException { | |||
return parseMoney(resultSet.getLong(s)); | |||
} | |||
@Override | |||
public Money getNullableResult(ResultSet resultSet, int i) throws SQLException { | |||
return parseMoney(resultSet.getLong(i)); | |||
} | |||
@Override | |||
public Money getNullableResult(CallableStatement callableStatement, int i) throws SQLException { | |||
return parseMoney(callableStatement.getLong(i)); | |||
} | |||
/** | |||
* 将Long值转换为Money | |||
*/ | |||
private Money parseMoney(Long value){ | |||
return Money.ofMinor(CurrencyUnit.of("CNY"),value); | |||
} | |||
} |
@ -0,0 +1,117 @@ | |||
/* | |||
* Copyright 2007-present 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. | |||
*/ | |||
import java.net.*; | |||
import java.io.*; | |||
import java.nio.channels.*; | |||
import java.util.Properties; | |||
public class MavenWrapperDownloader { | |||
private static final String WRAPPER_VERSION = "0.5.6"; | |||
/** | |||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. | |||
*/ | |||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" | |||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; | |||
/** | |||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to | |||
* use instead of the default one. | |||
*/ | |||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = | |||
".mvn/wrapper/maven-wrapper.properties"; | |||
/** | |||
* Path where the maven-wrapper.jar will be saved to. | |||
*/ | |||
private static final String MAVEN_WRAPPER_JAR_PATH = | |||
".mvn/wrapper/maven-wrapper.jar"; | |||
/** | |||
* Name of the property which should be used to override the default download url for the wrapper. | |||
*/ | |||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; | |||
public static void main(String args[]) { | |||
System.out.println("- Downloader started"); | |||
File baseDirectory = new File(args[0]); | |||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); | |||
// If the maven-wrapper.properties exists, read it and check if it contains a custom | |||
// wrapperUrl parameter. | |||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); | |||
String url = DEFAULT_DOWNLOAD_URL; | |||
if(mavenWrapperPropertyFile.exists()) { | |||
FileInputStream mavenWrapperPropertyFileInputStream = null; | |||
try { | |||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); | |||
Properties mavenWrapperProperties = new Properties(); | |||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); | |||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); | |||
} catch (IOException e) { | |||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); | |||
} finally { | |||
try { | |||
if(mavenWrapperPropertyFileInputStream != null) { | |||
mavenWrapperPropertyFileInputStream.close(); | |||
} | |||
} catch (IOException e) { | |||
// Ignore ... | |||
} | |||
} | |||
} | |||
System.out.println("- Downloading from: " + url); | |||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); | |||
if(!outputFile.getParentFile().exists()) { | |||
if(!outputFile.getParentFile().mkdirs()) { | |||
System.out.println( | |||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); | |||
} | |||
} | |||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); | |||
try { | |||
downloadFileFromURL(url, outputFile); | |||
System.out.println("Done"); | |||
System.exit(0); | |||
} catch (Throwable e) { | |||
System.out.println("- Error downloading"); | |||
e.printStackTrace(); | |||
System.exit(1); | |||
} | |||
} | |||
private static void downloadFileFromURL(String urlString, File destination) throws Exception { | |||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { | |||
String username = System.getenv("MVNW_USERNAME"); | |||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); | |||
Authenticator.setDefault(new Authenticator() { | |||
@Override | |||
protected PasswordAuthentication getPasswordAuthentication() { | |||
return new PasswordAuthentication(username, password); | |||
} | |||
}); | |||
} | |||
URL website = new URL(urlString); | |||
ReadableByteChannel rbc; | |||
rbc = Channels.newChannel(website.openStream()); | |||
FileOutputStream fos = new FileOutputStream(destination); | |||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); | |||
fos.close(); | |||
rbc.close(); | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: jakarta.transaction:jakarta.transaction-api:1.3.3"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,6 @@ | |||
<component name="ArtifactManager"> | |||
<artifact type="war" name="test"> | |||
<output-path>F:/</output-path> | |||
<root id="archive" name="test.war" /> | |||
</artifact> | |||
</component> |
@ -0,0 +1,29 @@ | |||
package com.whn.hellospring.model; | |||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
import lombok.*; | |||
import javax.persistence.Entity; | |||
import javax.persistence.Id; | |||
import javax.persistence.Table; | |||
import java.io.Serializable; | |||
@Entity | |||
@Table(name = "T_CUSTOMER") | |||
@Builder | |||
@Data | |||
@ToString(callSuper = true) | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
@JsonIgnoreProperties(value = {"hibernateLazyInitializer","handler"}) | |||
public class CustomerDO extends BaseEntity implements Serializable { | |||
private String name; | |||
private int age; | |||
private String phone; | |||
private String pass_word; | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.projectlombok:lombok:1.18.12"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.12/lombok-1.18.12.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.12/lombok-1.18.12-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.12/lombok-1.18.12-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.hibernate.validator:hibernate-validator:6.1.5.Final"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.13"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/github/pagehelper/pagehelper-spring-boot-starter/1.2.13/pagehelper-spring-boot-starter-1.2.13.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/github/pagehelper/pagehelper-spring-boot-starter/1.2.13/pagehelper-spring-boot-starter-1.2.13-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/github/pagehelper/pagehelper-spring-boot-starter/1.2.13/pagehelper-spring-boot-starter-1.2.13-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,26 @@ | |||
package com.whn.hellospring.model; | |||
import lombok.*; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import java.util.List; | |||
@Data | |||
@Builder | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
public class CoffeeOrderDTO implements Serializable { | |||
private String customer; | |||
private String customer_id; | |||
private Long id; | |||
private Date createTime; | |||
private Date updateTime; | |||
private OrderState state; | |||
private List<CoffeeDTO> items; | |||
} | |||
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.objenesis:objenesis:2.6"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.6/objenesis-2.6.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.6/objenesis-2.6-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.6/objenesis-2.6-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: com.google.guava:guava:20.0"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/20.0/guava-20.0.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/20.0/guava-20.0-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/20.0/guava-20.0-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework:spring-expression:5.2.7.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/5.2.7.RELEASE/spring-expression-5.2.7.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/5.2.7.RELEASE/spring-expression-5.2.7.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/5.2.7.RELEASE/spring-expression-5.2.7.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,14 @@ | |||
<component name="ArtifactManager"> | |||
<artifact type="war" name="hellospring:war"> | |||
<output-path>$PROJECT_DIR$/target</output-path> | |||
<properties id="maven-jee-properties"> | |||
<options> | |||
<module>hellospring</module> | |||
<packaging>war</packaging> | |||
</options> | |||
</properties> | |||
<root id="archive" name="test.war"> | |||
<element id="artifact" artifact-name="hellospring:war exploded" /> | |||
</root> | |||
</artifact> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework:spring-jdbc:5.2.7.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-jdbc/5.2.7.RELEASE/spring-jdbc-5.2.7.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-jdbc/5.2.7.RELEASE/spring-jdbc-5.2.7.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-jdbc/5.2.7.RELEASE/spring-jdbc-5.2.7.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,32 @@ | |||
package com.whn.hellospring.utils; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Calendar; | |||
import java.util.Date; | |||
public class DateUtils { | |||
/** | |||
* 计算两个日期之间相差的天数 | |||
* | |||
* @param smdate 较小的时间 | |||
* @param bdate 较大的时间 | |||
* @return 相差天数 | |||
*/ | |||
public static int daysBetween(Date smdate, Date bdate) { | |||
try { | |||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |||
smdate = sdf.parse(sdf.format(smdate)); | |||
bdate = sdf.parse(sdf.format(bdate)); | |||
Calendar cal = Calendar.getInstance(); | |||
cal.setTime(smdate); | |||
long time1 = cal.getTimeInMillis(); | |||
cal.setTime(bdate); | |||
long time2 = cal.getTimeInMillis(); | |||
long between_days = (time2 - time1) / (1000 * 3600 * 24); | |||
return Integer.parseInt(String.valueOf(between_days)); | |||
} catch (Exception e) { | |||
return -1; | |||
} | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework:spring-aspects:5.2.7.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aspects/5.2.7.RELEASE/spring-aspects-5.2.7.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aspects/5.2.7.RELEASE/spring-aspects-5.2.7.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aspects/5.2.7.RELEASE/spring-aspects-5.2.7.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework.boot:spring-boot-starter-web:2.3.1.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-web/2.3.1.RELEASE/spring-boot-starter-web-2.3.1.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-web/2.3.1.RELEASE/spring-boot-starter-web-2.3.1.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-web/2.3.1.RELEASE/spring-boot-starter-web-2.3.1.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,5 @@ | |||
F:\java\workspace\hellospring\src\test\java\com\whn\hellospring\CustomerTest.java | |||
F:\java\workspace\hellospring\src\test\java\com\whn\hellospring\HellospringApplicationTests.java | |||
F:\java\workspace\hellospring\src\test\java\com\whn\hellospring\OrderTest.java | |||
F:\java\workspace\hellospring\src\test\java\com\whn\hellospring\MenuTest.java | |||
F:\java\workspace\hellospring\src\test\java\com\whn\hellospring\AppTest.java |
@ -0,0 +1,44 @@ | |||
package com.whn.hellospring.service; | |||
import com.whn.hellospring.model.MenuDO; | |||
import com.whn.hellospring.repository.MenuCoffeeRepository; | |||
import com.whn.hellospring.repository.MenuRepository; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
@Service | |||
@Slf4j | |||
public class MenuService { | |||
@Autowired | |||
private MenuRepository menuRepository; | |||
@Autowired | |||
private MenuCoffeeRepository menuCoffeeRepository; | |||
/** | |||
* 获取菜单类型列表 | |||
*/ | |||
public List<MenuDO> getMenuTypeList() { | |||
return menuRepository.getMenuList(); | |||
// List<MenuDTO> returnList = new ArrayList<>(); | |||
// for (MenuDO menudo : menuRepository.getMenuList()) { | |||
// Optional<MenuCoffeeDO> coffeeList = menuCoffeeRepository.findById(menudo.getId()); | |||
// | |||
// MenuDTO menuDTO = new MenuDTO(); | |||
// if (coffeeList.isPresent()) menuDTO.setCoffee_list(MyOptional.toList(coffeeList)); | |||
// menuDTO.setId(menudo.getId()); | |||
// menuDTO.setCreateTime(menudo.getCreateTime()); | |||
// menuDTO.setUpdateTime(menudo.getUpdateTime()); | |||
// menuDTO.setType(menudo.getType()); | |||
// | |||
// returnList.add(menuDTO); | |||
// } | |||
// return returnList; | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: com.github.pagehelper:pagehelper:5.1.11"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/github/pagehelper/pagehelper/5.1.11/pagehelper-5.1.11.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/github/pagehelper/pagehelper/5.1.11/pagehelper-5.1.11-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/github/pagehelper/pagehelper/5.1.11/pagehelper-5.1.11-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,506 @@ | |||
package com.whn.hellospring.utils | |||
import java.io.UnsupportedEncodingException | |||
import java.text.DecimalFormat | |||
import java.text.ParseException | |||
import java.text.SimpleDateFormat | |||
import java.util.Date | |||
import java.util.regex.Pattern | |||
import java.util.regex.PatternSyntaxException | |||
/** | |||
* 字符串操作类 | |||
*/ | |||
object StringUtil { | |||
/** | |||
* 处理重叠字符 | |||
* ABCCCD -> AB3CD | |||
*/ | |||
fun overlapCharacter(list: List<String>): String { | |||
//排序 | |||
// java.util.Collections.sort(list) | |||
var j = 0 | |||
var finalStr = "" | |||
while (j < list.size) { | |||
val str = list[j] //C | |||
//如果已经存在当前要添加的字符 ABC + C AB2C +C | |||
if (finalStr.contains(str)) { | |||
if (j - 1 < 0) { //第一位 C+C | |||
finalStr = "2" + finalStr | |||
} else { | |||
val index = finalStr.indexOf(str) | |||
if (index > 0) { | |||
val timesStr = finalStr.substring(index - 1, index) //倍数2 | |||
if (isInteger(timesStr)) {// AB2C +C | |||
val timesInt = timesStr.toInt() + 1 | |||
finalStr = finalStr.substring(0, finalStr.length - 2) | |||
finalStr += timesInt.toString() | |||
finalStr += str | |||
} else {// ABC + C | |||
finalStr = finalStr.substring(0, finalStr.length - 1) | |||
finalStr += "2" | |||
finalStr += str | |||
} | |||
} else { //B2C4D + B | |||
finalStr = "2" + finalStr | |||
} | |||
} | |||
} else { | |||
finalStr += str | |||
} | |||
j++ | |||
} | |||
return finalStr | |||
} | |||
/*方法二:推荐,速度最快 | |||
* 判断是否为整数 | |||
* @param str 传入的字符串 | |||
* @return 是整数返回true,否则返回false | |||
*/ | |||
fun isInteger(str: String): Boolean { | |||
val pattern = Pattern.compile("^[-\\+]?[\\d]*$") | |||
return pattern.matcher(str).matches() | |||
} | |||
/** | |||
* 保留一位小数,四舍五入 | |||
* 使用0.00不足位补0,#.##仅保留有效位 | |||
*/ | |||
fun doubleToString1(num: Double?): String { | |||
// if(!isNumber(num.toString()))return "0.0" | |||
// return DecimalFormat("0.0").format(num) | |||
if(!isNumber(num.toString()))return "0.0" | |||
return String.format("%.1f", num!!.toDouble()) | |||
} | |||
/** | |||
* 保留两位小数,四舍五入 | |||
* 使用0.00不足位补0,#.##仅保留有效位 | |||
*/ | |||
fun doubleToString2(num: Double?): String { | |||
// if(!isNumber(num.toString()))return "0.00" | |||
// return DecimalFormat("0.00").format(num) | |||
if(!isNumber(num.toString()))return "0.00" | |||
return String.format("%.2f", num!!.toDouble()) | |||
} | |||
/** | |||
* 四舍五入 | |||
* 1位小数 | |||
*/ | |||
fun rounding1(num: String?): String { | |||
if(!isNumber(num))return "0.0" | |||
return String.format("%.1f", num!!.toDouble()) | |||
} | |||
/** | |||
* 四舍五入 | |||
* 2位小数 | |||
*/ | |||
fun rounding2(num: String?): String { | |||
if(!isNumber(num))return "0.00" | |||
return String.format("%.2f", num!!.toDouble()) | |||
} | |||
/** | |||
* 按长度截取中英文混合string | |||
* | |||
* @param text 字符串 | |||
* @param length 长度 | |||
* @param endWith 末尾追加 | |||
* @return | |||
*/ | |||
fun subStringIncludeChinese(text: String, length: Int, | |||
endWith: String): String { | |||
var text = text | |||
text = text.trim { it <= ' ' } | |||
val textLength = text.length | |||
var byteLength = 0 | |||
val returnStr = StringBuffer() | |||
var i = 0 | |||
while (i < textLength && byteLength < length * 2) { | |||
val str_i = text.substring(i, i + 1) | |||
if (str_i.toByteArray().size == 1) {// 英文 | |||
byteLength++ | |||
} else {// 中文 | |||
byteLength += 2 | |||
} | |||
returnStr.append(str_i) | |||
i++ | |||
} | |||
try { | |||
if (byteLength < text.toByteArray(charset("GBK")).size) {// getBytes("GBK")每个汉字长2,getBytes("UTF-8")每个汉字长度为3 | |||
returnStr.append(endWith) | |||
} | |||
} catch (e: UnsupportedEncodingException) { | |||
e.printStackTrace() | |||
} | |||
return returnStr.toString() | |||
} | |||
/** | |||
* 获取字符串的长度,如果有中文,则每个中文字符计为2位 | |||
* | |||
* @param text 指定的字符串 | |||
* @return 字符串的长度 | |||
*/ | |||
fun getStringLengthIncludeChinese(text: String): Int { | |||
var text = text | |||
text = text.trim { it <= ' ' } | |||
var valueLength = 0 | |||
val chinese = "[\u0391-\uFFE5]" | |||
/* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */ | |||
for (i in 0..text.length - 1) { | |||
/* 获取一个字符 */ | |||
val temp = text.substring(i, i + 1) | |||
/* 判断是否为中文字符 */ | |||
if (temp.matches(chinese.toRegex())) { | |||
/* 中文字符长度为2 */ | |||
valueLength += 2 | |||
} else { | |||
/* 其他字符长度为1 */ | |||
valueLength += 1 | |||
} | |||
} | |||
return valueLength | |||
} | |||
/** | |||
* 验证邮箱地址是否正确 | |||
* | |||
* @param email | |||
* @return | |||
*/ | |||
fun checkEmail(email: String): Boolean { | |||
var flag = false | |||
try { | |||
val check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$" | |||
val regex = Pattern.compile(check) | |||
val matcher = regex.matcher(email) | |||
flag = matcher.matches() | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
flag = false | |||
} | |||
return flag | |||
} | |||
/** | |||
* 判断字符串是否是数字 | |||
* | |||
* @param number | |||
* @return | |||
*/ | |||
fun isNumber(number: String?): Boolean { | |||
//如果为空,false | |||
if (!isNotNull(number)) { | |||
return false | |||
} | |||
//只有. | |||
if (number == ".") { | |||
return false | |||
} | |||
//如果有多个点,false | |||
val list = number!!.split(".") | |||
if (list.size > 2) { | |||
return false | |||
} | |||
//如果有其他字符 false | |||
var flag = false | |||
try { | |||
val p = Pattern.compile("[0-9.-]+") | |||
val m = p.matcher(number) | |||
flag = m.matches() | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
flag = false | |||
} | |||
return flag | |||
} | |||
/** | |||
* 判断是否全是英文字母组成(不区分大小写) | |||
* | |||
* @param letters | |||
* @return | |||
*/ | |||
fun isLetters(letters: String): Boolean { | |||
var flag = false | |||
try { | |||
val p = Pattern.compile("^[A-Za-z]+$") | |||
val m = p.matcher(letters) | |||
flag = m.matches() | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
flag = false | |||
} | |||
return flag | |||
} | |||
/** | |||
* 判断是否全是大写字母 | |||
* | |||
* @param letters | |||
* @return | |||
*/ | |||
fun isUppercaseLetters(letters: String): Boolean { | |||
var flag = false | |||
try { | |||
val p = Pattern.compile("^[A-Z]+$") | |||
val m = p.matcher(letters) | |||
flag = m.matches() | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
flag = false | |||
} | |||
return flag | |||
} | |||
/** | |||
* 判断是否全是小写字母 | |||
* | |||
* @param letters | |||
* @return | |||
*/ | |||
fun isLowercaseLetters(letters: String): Boolean { | |||
var flag = false | |||
try { | |||
val p = Pattern.compile("^[a-z]+$") | |||
val m = p.matcher(letters) | |||
flag = m.matches() | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
flag = false | |||
} | |||
return flag | |||
} | |||
/** | |||
* 是否数字和字母组成 | |||
* | |||
* @param text | |||
* @return | |||
*/ | |||
fun isNumbersAndLetters(text: String): Boolean { | |||
var flag = false | |||
try { | |||
val p = Pattern.compile("^[A-Za-z0-9]+$") | |||
val m = p.matcher(text) | |||
flag = m.matches() | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
flag = false | |||
} | |||
return flag | |||
} | |||
/** | |||
* 包含数字,字母,下划线,不可以下划线开头 | |||
* | |||
* @param text | |||
* @return | |||
*/ | |||
fun isNumbersUnderlineLetters(text: String): Boolean { | |||
var flag = false | |||
try { | |||
val p = Pattern.compile("^(?!_)(?!.*?_$)[a-zA-Z0-9_]+$") | |||
val m = p.matcher(text) | |||
flag = m.matches() | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
flag = false | |||
} | |||
return flag | |||
} | |||
/** | |||
* 是否是密码,(字母或数字开头,包含下划线) | |||
* | |||
* @param text | |||
* @param lowest_median 最低位数 | |||
* @param highest_median 最高位数 | |||
* @return | |||
*/ | |||
fun isPassword(text: String, lowest_median: Int, | |||
highest_median: Int): Boolean { | |||
var flag = false | |||
try { | |||
val p = Pattern | |||
.compile("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{" | |||
+ lowest_median.toString() + "," | |||
+ highest_median.toString() + "}$") | |||
val m = p.matcher(text) | |||
flag = m.matches() | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
flag = false | |||
} | |||
return flag | |||
} | |||
// 过滤特殊字符 | |||
@Throws(PatternSyntaxException::class) | |||
fun StringFilter(str: String): String { | |||
// 只允许字母和数字 | |||
// String regEx = "[^a-zA-Z0-9]"; | |||
// 清除掉所有特殊字符 | |||
val regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]" | |||
val p = Pattern.compile(regEx) | |||
val m = p.matcher(str) | |||
return m.replaceAll("").trim { it <= ' ' } | |||
} | |||
// 中文识别 | |||
fun hasChinese(source: String): Boolean { | |||
val reg_charset = "([\\u4E00-\\u9FA5]*+)" | |||
val p = Pattern.compile(reg_charset) | |||
val m = p.matcher(source) | |||
var hasChinese = false | |||
while (m.find()) { | |||
if ("" != m.group(1)) { | |||
hasChinese = true | |||
} | |||
} | |||
return hasChinese | |||
} | |||
/** | |||
* 判断是否有特殊字符 | |||
*/ | |||
fun hasString(str: String): Boolean { | |||
val regEx = "[`~!@#$%^&*()+=|{}':;',//[//].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"// 特殊字符 | |||
val p = Pattern.compile(regEx) | |||
val m = p.matcher(str) | |||
return m.find() | |||
} | |||
//获取当前时间 | |||
fun refFormatNowDate(): String { | |||
val nowTime = Date(System.currentTimeMillis()) | |||
val sdFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") | |||
return sdFormatter.format(nowTime) | |||
} | |||
//时间格式 | |||
fun Realtime(time: String): String { | |||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") | |||
var str = "" | |||
try { | |||
val curDate = formatter.parse(time) | |||
str = formatter.format(curDate) | |||
} catch (e: ParseException) { | |||
e.printStackTrace() | |||
} | |||
//获取当前时间 | |||
return str | |||
} | |||
/** | |||
* 转换文件大小 | |||
* | |||
* @param fileS | |||
* @return | |||
*/ | |||
fun FormetFileSize(fileS: Long): String { | |||
val df = DecimalFormat("#.00") | |||
var fileSizeString = "" | |||
val wrongSize = "0B" | |||
if (fileS == 0L) { | |||
return wrongSize | |||
} | |||
if (fileS < 1024) { | |||
fileSizeString = df.format(fileS.toDouble()) + "B" | |||
} else if (fileS < 1048576) { | |||
fileSizeString = df.format(fileS.toDouble() / 1024) + "KB" | |||
} else if (fileS < 1073741824) { | |||
fileSizeString = df.format(fileS.toDouble() / 1048576) + "MB" | |||
} else { | |||
fileSizeString = df.format(fileS.toDouble() / 1073741824) + "GB" | |||
} | |||
return fileSizeString | |||
} | |||
/** | |||
* 检验数字的有效性 | |||
* | |||
* @param str | |||
* @return | |||
*/ | |||
fun isNumberTrue(str: String): Boolean { | |||
val c = str.substring(str.length - 1, str.length) | |||
if (c == ".") { | |||
return false | |||
} | |||
val pattern = Pattern.compile("^[0-9]+(.[0-9]*)?$") | |||
val match = pattern.matcher(str) | |||
return match.matches() | |||
} | |||
/** | |||
* 大陆号码或香港号码均可 | |||
*/ | |||
@Throws(PatternSyntaxException::class) | |||
fun isPhoneLegal(str: String): Boolean { | |||
return isChinaPhoneLegal(str) || isHKPhoneLegal(str) | |||
} | |||
/** | |||
* 大陆手机号码11位数,匹配格式:前三位固定格式+后8位任意数 | |||
* 此方法中前三位格式有: | |||
* 13+任意数 | |||
* 15+除4的任意数 | |||
* 18+除1和4的任意数 | |||
* 17+除9的任意数 | |||
* 147 | |||
*/ | |||
@Throws(PatternSyntaxException::class) | |||
fun isChinaPhoneLegal(str: String): Boolean { | |||
// String regExp = "^((13[0-9])|(15[^4])|(18[0-9])|(17[0-9])|(16[0-9])|(147))\\d{8}$"; | |||
val regExp = "^\\d{11}$" | |||
val p = Pattern.compile(regExp) | |||
val m = p.matcher(str) | |||
return m.matches() | |||
} | |||
/** | |||
* 香港手机号码8位数,5|6|8|9开头+7位任意数 | |||
*/ | |||
@Throws(PatternSyntaxException::class) | |||
fun isHKPhoneLegal(str: String): Boolean { | |||
val regExp = "^(5|6|8|9)\\d{7}$" | |||
val p = Pattern.compile(regExp) | |||
val m = p.matcher(str) | |||
return m.matches() | |||
} | |||
} |
@ -0,0 +1,35 @@ | |||
package com.whn.hellospring.repository; | |||
import com.whn.hellospring.model.CoffeeOrderDO; | |||
import org.apache.ibatis.annotations.Delete; | |||
import org.springframework.data.jpa.repository.JpaRepository; | |||
import org.springframework.data.jpa.repository.Modifying; | |||
import org.springframework.data.jpa.repository.Query; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import javax.xml.ws.soap.MTOM; | |||
import java.util.List; | |||
/** | |||
* 订单数据操作 | |||
*/ | |||
public interface CoffeeOrderRepository extends JpaRepository<CoffeeOrderDO, Long> { | |||
// //根据咖啡名,获取订单 | |||
// List<CoffeeOrderDO> findByItems_Name(String name); | |||
//根据订单id获取订单 | |||
@Query(value = "select * from T_ORDER where id=?1",nativeQuery = true) | |||
CoffeeOrderDO queryOrderWithId(Long id); | |||
//根据订单id删除订单 | |||
@Transactional //事务 | |||
@Modifying //更新 | |||
@Query(value = "DELETE from T_ORDER where id=?1",nativeQuery = true) | |||
int deleteOrderWithId(Long id); | |||
//根据客户,获取订单 | |||
@Query(value = "select * from t_order where customer_id = ?1", nativeQuery = true) | |||
List<CoffeeOrderDO> queryOrderListWithCustomerId(String customerId); | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: net.minidev:json-smart:2.3"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/net/minidev/json-smart/2.3/json-smart-2.3.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/net/minidev/json-smart/2.3/json-smart-2.3-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/net/minidev/json-smart/2.3/json-smart-2.3-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.2"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/spring/boot/mybatis-spring-boot-autoconfigure/1.3.2/mybatis-spring-boot-autoconfigure-1.3.2.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/spring/boot/mybatis-spring-boot-autoconfigure/1.3.2/mybatis-spring-boot-autoconfigure-1.3.2-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/spring/boot/mybatis-spring-boot-autoconfigure/1.3.2/mybatis-spring-boot-autoconfigure-1.3.2-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.glassfish.jaxb:txw2:2.3.3"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jaxb/txw2/2.3.3/txw2-2.3.3.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jaxb/txw2/2.3.3/txw2-2.3.3-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jaxb/txw2/2.3.3/txw2-2.3.3-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.mybatis:mybatis:3.4.6"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/mybatis/3.4.6/mybatis-3.4.6.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/mybatis/3.4.6/mybatis-3.4.6-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/mybatis/mybatis/3.4.6/mybatis-3.4.6-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework.boot:spring-boot:2.3.1.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot/2.3.1.RELEASE/spring-boot-2.3.1.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot/2.3.1.RELEASE/spring-boot-2.3.1.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot/2.3.1.RELEASE/spring-boot-2.3.1.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,2 @@ | |||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip | |||
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar |
@ -0,0 +1,118 @@ | |||
package com.whn.hellospring.service; | |||
import com.whn.hellospring.model.OilDO; | |||
import com.whn.hellospring.repository.OilRepository; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@Slf4j | |||
@Service | |||
public class OilService { | |||
@Autowired | |||
private OilRepository oilRepository; | |||
/** | |||
* 油耗列表 | |||
*/ | |||
public List<Double> getWearList(Long customer_id){ | |||
return oilRepository.findWearList(customer_id); | |||
} | |||
/** | |||
* 获取有效数量num之和 | |||
* @return | |||
*/ | |||
public double getNumTotal(Long customer_id){ | |||
return oilRepository.countNum(customer_id); | |||
} | |||
/** | |||
* 获取有效区间里程和 | |||
* @return | |||
*/ | |||
public double getIntervalMileageTotal(Long customer_id){ | |||
return oilRepository.countIntervalMileage(customer_id); | |||
} | |||
/** | |||
* 获取最新的一条有效记录 | |||
*/ | |||
public OilDO getRecentlyRecord(Long customer_id) { | |||
List<OilDO> recordList = oilRepository.finAllSortByTime(customer_id); | |||
if (recordList == null || recordList.size() == 0) return null; | |||
int index = -1; | |||
for (int i = 0; i < recordList.size(); i++) { | |||
OilDO oilDO = recordList.get(i); | |||
if (oilDO.getStatus() == 1) { | |||
index = i; | |||
break; | |||
} | |||
} | |||
if(index==-1){ | |||
return null; | |||
}else{ | |||
return recordList.get(index); | |||
} | |||
} | |||
/** | |||
* 获取有效记录列表 | |||
*/ | |||
public List<OilDO> getRecordList(Long customer_id) { | |||
List<OilDO> recordList = oilRepository.finAllSortByTime(customer_id); | |||
// Collections.reverse(recordList); | |||
List<OilDO> list = new ArrayList<>(); | |||
for (int i = 0; i < recordList.size(); i++) { | |||
if (recordList.get(i).getStatus() == 1) { | |||
list.add(recordList.get(i)); | |||
} | |||
} | |||
log.info("list:{}", list); | |||
return list; | |||
} | |||
/** | |||
* 获取全部记录列表 | |||
* 包括被删除的status = 0 | |||
*/ | |||
public List<OilDO> getRecordAllList(Long customer_id) { | |||
List<OilDO> recordList = oilRepository.finAllSortByTime(customer_id); | |||
// Collections.reverse(recordList); | |||
log.info("recordList:{}", recordList); | |||
return recordList; | |||
} | |||
/** | |||
* 新增更新 | |||
*/ | |||
public OilDO addUpdateRecord(OilDO oilDO) { | |||
OilDO save = oilRepository.save(oilDO); | |||
return save; | |||
} | |||
/** | |||
* 删除 | |||
* | |||
* @return | |||
*/ | |||
public OilDO deleteRecord(Long id) { | |||
OilDO oilDO = oilRepository.getOne(id); | |||
oilDO.setStatus(0); | |||
return oilRepository.save(oilDO); | |||
} | |||
} |
@ -0,0 +1,297 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ArtifactsWorkspaceSettings"> | |||
<artifacts-to-build> | |||
<artifact name="web" /> | |||
</artifacts-to-build> | |||
</component> | |||
<component name="ChangeListManager"> | |||
<list default="true" id="4ac83321-addc-493f-bf36-c1df665b9161" name="Default Changelist" comment="" /> | |||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> | |||
<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="DatabaseView"> | |||
<option name="SHOW_INTERMEDIATE" value="true" /> | |||
<option name="GROUP_DATA_SOURCES" value="true" /> | |||
<option name="GROUP_SCHEMA" value="true" /> | |||
<option name="GROUP_CONTENTS" value="false" /> | |||
<option name="SORT_POSITIONED" value="false" /> | |||
<option name="SHOW_EMPTY_GROUPS" value="false" /> | |||
<option name="AUTO_SCROLL_FROM_SOURCE" value="false" /> | |||
<option name="HIDDEN_KINDS"> | |||
<set /> | |||
</option> | |||
<expand> | |||
<path> | |||
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" /> | |||
<item name="MySQL for 5.1 - @localhost" type="feb32156:DbDataSourceImpl" /> | |||
</path> | |||
<path> | |||
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" /> | |||
<item name="MySQL for 5.1 - @localhost" type="feb32156:DbDataSourceImpl" /> | |||
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" /> | |||
</path> | |||
<path> | |||
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" /> | |||
<item name="MySQL for 5.1 - @localhost" type="feb32156:DbDataSourceImpl" /> | |||
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" /> | |||
<item name="test: schema" type="76f4a085:MysqlImplModel$Schema" /> | |||
</path> | |||
</expand> | |||
<select /> | |||
</component> | |||
<component name="FileTemplateManagerImpl"> | |||
<option name="RECENT_TEMPLATES"> | |||
<list> | |||
<option value="Interface" /> | |||
<option value="Class" /> | |||
</list> | |||
</option> | |||
</component> | |||
<component name="MavenImportPreferences"> | |||
<option name="importingSettings"> | |||
<MavenImportingSettings> | |||
<option name="importAutomatically" value="true" /> | |||
<option name="vmOptionsForImporter" value="-Xmx768m" /> | |||
</MavenImportingSettings> | |||
</option> | |||
</component> | |||
<component name="ProjectId" id="1e7TyAErjqLx4yHALZIOB4CjAFV" /> | |||
<component name="PropertiesComponent"> | |||
<property name="DatabaseDriversLRU" value="mysql" /> | |||
<property name="RequestMappingsPanelOrder0" value="0" /> | |||
<property name="RequestMappingsPanelOrder1" value="1" /> | |||
<property name="RequestMappingsPanelWidth0" value="75" /> | |||
<property name="RequestMappingsPanelWidth1" value="75" /> | |||
<property name="WebServerToolWindowFactoryState" value="false" /> | |||
<property name="aspect.path.notification.shown" value="true" /> | |||
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/java/com/whn/hellospring/top" /> | |||
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> | |||
<property name="nodejs_package_manager_path" value="npm" /> | |||
<property name="project.structure.last.edited" value="Artifacts" /> | |||
<property name="project.structure.proportion" value="0.15" /> | |||
<property name="project.structure.side.proportion" value="0.2" /> | |||
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" /> | |||
</component> | |||
<component name="RecentsManager"> | |||
<key name="CopyClassDialog.RECENTS_KEY"> | |||
<recent name="com.whn.hellospring.request" /> | |||
<recent name="com.whn.hellospring.model" /> | |||
<recent name="com.whn.hellospring.common" /> | |||
</key> | |||
<key name="CopyFile.RECENT_KEYS"> | |||
<recent name="F:\java\workspace\hellospring\src\main\java\com\whn\hellospring\top" /> | |||
<recent name="F:\java\workspace\hellospring\src\main\java\com\whn\hellospring\utils" /> | |||
</key> | |||
</component> | |||
<component name="RunDashboard"> | |||
<option name="ruleStates"> | |||
<list> | |||
<RuleState> | |||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" /> | |||
</RuleState> | |||
<RuleState> | |||
<option name="name" value="StatusDashboardGroupingRule" /> | |||
</RuleState> | |||
</list> | |||
</option> | |||
</component> | |||
<component name="RunManager" selected="Spring Boot.HellospringApplication"> | |||
<configuration name="AppTest.getVersion" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true"> | |||
<module name="hellospring" /> | |||
<extension name="coverage"> | |||
<pattern> | |||
<option name="PATTERN" value="com.whn.hellospring.*" /> | |||
<option name="ENABLED" value="true" /> | |||
</pattern> | |||
</extension> | |||
<option name="PACKAGE_NAME" value="com.whn.hellospring" /> | |||
<option name="MAIN_CLASS_NAME" value="com.whn.hellospring.AppTest" /> | |||
<option name="METHOD_NAME" value="getVersion" /> | |||
<option name="TEST_OBJECT" value="method" /> | |||
<method v="2"> | |||
<option name="Make" enabled="true" /> | |||
</method> | |||
</configuration> | |||
<configuration name="CustomerTest.createCustomer" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true"> | |||
<module name="hellospring" /> | |||
<extension name="coverage"> | |||
<pattern> | |||
<option name="PATTERN" value="com.whn.hellospring.controller.*" /> | |||
<option name="ENABLED" value="true" /> | |||
</pattern> | |||
</extension> | |||
<option name="PACKAGE_NAME" value="com.whn.hellospring" /> | |||
<option name="MAIN_CLASS_NAME" value="com.whn.hellospring.CustomerTest" /> | |||
<option name="METHOD_NAME" value="createCustomer" /> | |||
<option name="TEST_OBJECT" value="method" /> | |||
<method v="2"> | |||
<option name="Make" enabled="true" /> | |||
</method> | |||
</configuration> | |||
<configuration name="CustomerTest.queryCustomerList" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true"> | |||
<module name="hellospring" /> | |||
<extension name="coverage"> | |||
<pattern> | |||
<option name="PATTERN" value="com.whn.hellospring.controller.*" /> | |||
<option name="ENABLED" value="true" /> | |||
</pattern> | |||
</extension> | |||
<option name="PACKAGE_NAME" value="com.whn.hellospring" /> | |||
<option name="MAIN_CLASS_NAME" value="com.whn.hellospring.CustomerTest" /> | |||
<option name="METHOD_NAME" value="queryCustomerList" /> | |||
<option name="TEST_OBJECT" value="method" /> | |||
<method v="2"> | |||
<option name="Make" enabled="true" /> | |||
</method> | |||
</configuration> | |||
<configuration name="MenuTest.getTypeList" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true"> | |||
<module name="hellospring" /> | |||
<extension name="coverage"> | |||
<pattern> | |||
<option name="PATTERN" value="com.whn.hellospring.*" /> | |||
<option name="ENABLED" value="true" /> | |||
</pattern> | |||
</extension> | |||
<option name="PACKAGE_NAME" value="com.whn.hellospring" /> | |||
<option name="MAIN_CLASS_NAME" value="com.whn.hellospring.MenuTest" /> | |||
<option name="METHOD_NAME" value="getTypeList" /> | |||
<option name="TEST_OBJECT" value="method" /> | |||
<method v="2"> | |||
<option name="Make" enabled="true" /> | |||
</method> | |||
</configuration> | |||
<configuration name="OrderTest.getOrderListByCustomer" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true"> | |||
<module name="hellospring" /> | |||
<extension name="coverage"> | |||
<pattern> | |||
<option name="PATTERN" value="com.whn.hellospring.*" /> | |||
<option name="ENABLED" value="true" /> | |||
</pattern> | |||
</extension> | |||
<option name="PACKAGE_NAME" value="com.whn.hellospring" /> | |||
<option name="MAIN_CLASS_NAME" value="com.whn.hellospring.OrderTest" /> | |||
<option name="METHOD_NAME" value="getOrderListByCustomer" /> | |||
<option name="TEST_OBJECT" value="method" /> | |||
<method v="2"> | |||
<option name="Make" enabled="true" /> | |||
</method> | |||
</configuration> | |||
<configuration name="hellospring [package]" type="MavenRunConfiguration" factoryName="Maven"> | |||
<MavenSettings> | |||
<option name="myGeneralSettings" /> | |||
<option name="myRunnerSettings" /> | |||
<option name="myRunnerParameters"> | |||
<MavenRunnerParameters> | |||
<option name="profiles"> | |||
<set /> | |||
</option> | |||
<option name="goals"> | |||
<list> | |||
<option value="clean" /> | |||
<option value="package" /> | |||
</list> | |||
</option> | |||
<option name="pomFileName" value="pom.xml" /> | |||
<option name="profilesMap"> | |||
<map /> | |||
</option> | |||
<option name="resolveToWorkspace" value="false" /> | |||
<option name="workingDirPath" value="$PROJECT_DIR$" /> | |||
</MavenRunnerParameters> | |||
</option> | |||
</MavenSettings> | |||
<method v="2" /> | |||
</configuration> | |||
<configuration name="HellospringApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot"> | |||
<module name="hellospring" /> | |||
<option name="SPRING_BOOT_MAIN_CLASS" value="com.whn.hellospring.HelloSpringApplication" /> | |||
<method v="2"> | |||
<option name="Make" enabled="true" /> | |||
</method> | |||
</configuration> | |||
<recent_temporary> | |||
<list> | |||
<item itemvalue="JUnit.OrderTest.getOrderListByCustomer" /> | |||
<item itemvalue="JUnit.AppTest.getVersion" /> | |||
<item itemvalue="JUnit.MenuTest.getTypeList" /> | |||
<item itemvalue="JUnit.CustomerTest.queryCustomerList" /> | |||
<item itemvalue="JUnit.CustomerTest.createCustomer" /> | |||
</list> | |||
</recent_temporary> | |||
</component> | |||
<component name="SvnConfiguration"> | |||
<configuration /> | |||
</component> | |||
<component name="TaskManager"> | |||
<task active="true" id="Default" summary="Default task"> | |||
<changelist id="4ac83321-addc-493f-bf36-c1df665b9161" name="Default Changelist" comment="" /> | |||
<created>1593671883249</created> | |||
<option name="number" value="Default" /> | |||
<option name="presentableId" value="Default" /> | |||
<updated>1593671883249</updated> | |||
<workItem from="1593671885863" duration="4524000" /> | |||
<workItem from="1593677673425" duration="762000" /> | |||
<workItem from="1593737836147" duration="2536000" /> | |||
<workItem from="1593742607955" duration="1162000" /> | |||
<workItem from="1594001384549" duration="16359000" /> | |||
<workItem from="1594279295601" duration="1656000" /> | |||
<workItem from="1594693203284" duration="9083000" /> | |||
<workItem from="1594708755510" duration="2513000" /> | |||
<workItem from="1594773582682" duration="901000" /> | |||
<workItem from="1599617545853" duration="458000" /> | |||
<workItem from="1599618332390" duration="12929000" /> | |||
<workItem from="1599638229466" duration="174000" /> | |||
<workItem from="1599638410014" duration="5016000" /> | |||
<workItem from="1599698444454" duration="9196000" /> | |||
<workItem from="1599720039599" duration="5498000" /> | |||
<workItem from="1599791771693" duration="11410000" /> | |||
<workItem from="1600155844117" duration="1979000" /> | |||
<workItem from="1600217250398" duration="28949000" /> | |||
<workItem from="1600414011667" duration="2000" /> | |||
<workItem from="1600744532530" duration="3567000" /> | |||
<workItem from="1600842523881" duration="1797000" /> | |||
<workItem from="1601357689886" duration="11000" /> | |||
<workItem from="1603156074398" duration="7159000" /> | |||
<workItem from="1603171512363" duration="12000" /> | |||
<workItem from="1603172575824" duration="15293000" /> | |||
<workItem from="1603335556027" duration="692000" /> | |||
<workItem from="1603349250851" duration="813000" /> | |||
<workItem from="1604392664473" duration="2251000" /> | |||
<workItem from="1604713941462" duration="3308000" /> | |||
<workItem from="1605072510241" duration="6567000" /> | |||
<workItem from="1605144104971" duration="10091000" /> | |||
<workItem from="1605660438369" duration="109000" /> | |||
<workItem from="1606701499160" duration="1453000" /> | |||
<workItem from="1606972912770" duration="114000" /> | |||
<workItem from="1608258652910" duration="5617000" /> | |||
<workItem from="1608275126842" duration="1984000" /> | |||
<workItem from="1612425322917" duration="34000" /> | |||
<workItem from="1615790331897" duration="16791000" /> | |||
<workItem from="1617152159077" duration="51000" /> | |||
<workItem from="1618464676907" duration="178000" /> | |||
<workItem from="1619165257485" duration="626000" /> | |||
<workItem from="1623980339280" duration="352000" /> | |||
<workItem from="1624582330528" duration="216000" /> | |||
<workItem from="1625014165167" duration="5675000" /> | |||
<workItem from="1626139111485" duration="17000" /> | |||
<workItem from="1626140437987" duration="7597000" /> | |||
<workItem from="1626239169575" duration="1987000" /> | |||
<workItem from="1626402750510" duration="1660000" /> | |||
<workItem from="1626421794576" duration="4398000" /> | |||
<workItem from="1626499162143" duration="939000" /> | |||
<workItem from="1626676705230" duration="6228000" /> | |||
<workItem from="1627270316455" duration="358000" /> | |||
<workItem from="1629184261905" duration="2621000" /> | |||
<workItem from="1629699187872" duration="2729000" /> | |||
<workItem from="1629771259639" duration="14607000" /> | |||
</task> | |||
<servers /> | |||
</component> | |||
<component name="TypeScriptGeneratedFilesManager"> | |||
<option name="version" value="1" /> | |||
</component> | |||
</project> |
@ -0,0 +1,31 @@ | |||
package com.whn.hellospring.model; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import org.hibernate.annotations.CreationTimestamp; | |||
import org.hibernate.annotations.Sort; | |||
import org.hibernate.annotations.UpdateTimestamp; | |||
import javax.persistence.*; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
@MappedSuperclass | |||
@Data | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
public class BaseEntity implements Serializable { | |||
@Id | |||
@GeneratedValue(strategy = GenerationType.IDENTITY) | |||
private Long id; | |||
@Column(updatable = false) | |||
@CreationTimestamp | |||
private Date createTime; | |||
@UpdateTimestamp | |||
private Date updateTime; | |||
} |
@ -0,0 +1,37 @@ | |||
package com.whn.hellospring; | |||
import com.whn.hellospring.model.CustomerDO; | |||
import com.whn.hellospring.repository.CustomerRepository; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.junit.jupiter.api.Test; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.boot.test.context.SpringBootTest; | |||
import java.util.List; | |||
@SpringBootTest | |||
@Slf4j | |||
public class CustomerTest { | |||
@Autowired | |||
CustomerRepository customerRepository; | |||
/** | |||
* 新增一个顾客 | |||
*/ | |||
@Test | |||
void createCustomer(){ | |||
CustomerDO customerDO = CustomerDO.builder().age(18).name("李四").phone("18657545213").pass_word("123456").build(); | |||
customerRepository.save(customerDO); | |||
} | |||
/** | |||
* 获取顾客列表 | |||
*/ | |||
@Test | |||
void queryCustomerList(){ | |||
log.info("CustomerList{}",customerRepository.findAll()); | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.junit.platform:junit-platform-commons:1.6.2"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.6.2/junit-platform-commons-1.6.2.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.6.2/junit-platform-commons-1.6.2-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.6.2/junit-platform-commons-1.6.2-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.3.50"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.3.50/kotlin-stdlib-1.3.50.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.3.50/kotlin-stdlib-1.3.50-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.3.50/kotlin-stdlib-1.3.50-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,8 @@ | |||
package com.whn.hellospring.request; | |||
import lombok.Data; | |||
@Data | |||
public class DeleteOrderRequest extends BaseRequest { | |||
private Long id; | |||
} |
@ -0,0 +1,25 @@ | |||
package com.whn.hellospring; | |||
import com.whn.hellospring.model.VersionDO; | |||
import com.whn.hellospring.service.AppService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.junit.jupiter.api.Test; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.boot.test.context.SpringBootTest; | |||
import java.util.List; | |||
@SpringBootTest | |||
@Slf4j | |||
public class AppTest { | |||
@Autowired | |||
AppService service; | |||
@Test | |||
public void getVersion(){ | |||
List<VersionDO> version = service.getVersion(1); | |||
log.info("version{}:"+version); | |||
} | |||
} |
@ -0,0 +1,25 @@ | |||
package com.whn.hellospring.service; | |||
import com.whn.hellospring.model.VersionDO; | |||
import com.whn.hellospring.repository.AppRepository; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
@Service | |||
public class AppService { | |||
@Autowired | |||
AppRepository repository; | |||
/** | |||
* 获取版本列表 | |||
*/ | |||
public List<VersionDO> getVersion(int equipment) { | |||
List<VersionDO> versionDOList = repository.findByEquipment(equipment); | |||
return versionDOList; | |||
} | |||
} |
@ -0,0 +1,21 @@ | |||
package com.whn.hellospring.utils; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import java.util.stream.Collector; | |||
public class MyOptional { | |||
public static <T> List<T> toList(Optional<T> option) { | |||
return option. | |||
map(Collections::singletonList). | |||
orElse(Collections.emptyList()); | |||
} | |||
public static <R, A, T> R collect(Optional<T> option, Collector<? super T, A, R> collector) { | |||
final A container = collector.supplier().get(); | |||
option.ifPresent(v -> collector.accumulator().accept(container, v)); | |||
return collector.finisher().apply(container); | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: org.springframework.boot:spring-boot-starter-logging:2.3.1.RELEASE"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-logging/2.3.1.RELEASE/spring-boot-starter-logging-2.3.1.RELEASE.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-logging/2.3.1.RELEASE/spring-boot-starter-logging-2.3.1.RELEASE-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-logging/2.3.1.RELEASE/spring-boot-starter-logging-2.3.1.RELEASE-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: commons-codec:commons-codec:1.14"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.14/commons-codec-1.14.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.14/commons-codec-1.14-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.14/commons-codec-1.14-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,65 @@ | |||
package com.whn.hellospring.controller; | |||
import com.whn.hellospring.model.CoffeeDO; | |||
import com.whn.hellospring.model.CoffeeDTO; | |||
import com.whn.hellospring.request.DeleteCoffeeRequest; | |||
import com.whn.hellospring.request.GetCoffeeListByOrderIdRequest; | |||
import com.whn.hellospring.service.CoffeeService; | |||
import com.whn.hellospring.utils.DO2DTOUtil; | |||
import org.joda.money.CurrencyUnit; | |||
import org.joda.money.Money; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import javax.validation.Valid; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@RestController | |||
@RequestMapping(value = "/coffee") | |||
public class CoffeeController { | |||
@Autowired | |||
CoffeeService service; | |||
/** | |||
* 创建编辑咖啡 | |||
*/ | |||
@PostMapping(value = "/update") | |||
public String createCoffee(@Valid @RequestBody CoffeeDTO coffeeDTO){ | |||
CoffeeDO coffeeDO = (CoffeeDO) DO2DTOUtil.getInstance().dtoToDo(coffeeDTO, CoffeeDO.class); | |||
coffeeDO.setPrice(Money.of(CurrencyUnit.of("CNY"),coffeeDTO.getPrice())); | |||
service.updateCoffee(coffeeDO); | |||
return "success"; | |||
} | |||
/** | |||
* 删除咖啡 | |||
*/ | |||
@PostMapping(value = "/delete") | |||
public String deleteCoffeeById(@RequestBody DeleteCoffeeRequest request){ | |||
service.deleteCoffee(request.getId()); | |||
return "success"; | |||
} | |||
/** | |||
* 获取一个订单下的咖啡列表 | |||
* @return | |||
*/ | |||
@PostMapping(value = "/coffeeListByOrderId") | |||
public List<CoffeeDTO> getCoffeeListByOrderId(@RequestBody GetCoffeeListByOrderIdRequest request){ | |||
List<CoffeeDO> coffeeList = service.getCoffeeListWithOrderId(request.getOrderId()); | |||
List<CoffeeDTO> coffeeDTOList = new ArrayList<>(); | |||
for (CoffeeDO coffeeDo :coffeeList) { | |||
CoffeeDTO dto = new CoffeeDTO(coffeeDo); | |||
coffeeDTOList.add(dto); | |||
} | |||
return coffeeDTOList; | |||
} | |||
} |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="Encoding"> | |||
<file url="file://$PROJECT_DIR$" charset="UTF-8" /> | |||
</component> | |||
</project> |
@ -0,0 +1,21 @@ | |||
package com.whn.hellospring.repository; | |||
import com.whn.hellospring.model.CustomerDO; | |||
import org.springframework.data.jpa.repository.JpaRepository; | |||
import org.springframework.data.jpa.repository.Query; | |||
import java.util.List; | |||
public interface CustomerRepository extends JpaRepository<CustomerDO,Long> { | |||
/** | |||
* 是否存在该手机号 | |||
*/ | |||
@Query(value = "select * from t_customer where phone=?1", nativeQuery = true) | |||
List<CustomerDO> isHaveThisPhone(String phone); | |||
} |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: com.fasterxml:classmate:1.5.1"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/classmate/1.5.1/classmate-1.5.1-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/classmate/1.5.1/classmate-1.5.1-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |
@ -0,0 +1,13 @@ | |||
<component name="libraryTable"> | |||
<library name="Maven: io.springfox:springfox-bean-validators:2.9.2"> | |||
<CLASSES> | |||
<root url="jar://$MAVEN_REPOSITORY$/io/springfox/springfox-bean-validators/2.9.2/springfox-bean-validators-2.9.2.jar!/" /> | |||
</CLASSES> | |||
<JAVADOC> | |||
<root url="jar://$MAVEN_REPOSITORY$/io/springfox/springfox-bean-validators/2.9.2/springfox-bean-validators-2.9.2-javadoc.jar!/" /> | |||
</JAVADOC> | |||
<SOURCES> | |||
<root url="jar://$MAVEN_REPOSITORY$/io/springfox/springfox-bean-validators/2.9.2/springfox-bean-validators-2.9.2-sources.jar!/" /> | |||
</SOURCES> | |||
</library> | |||
</component> |