first commit
This commit is contained in:
29
httpapi/.gitignore
vendored
Executable file
29
httpapi/.gitignore
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
HELP.md
|
||||
/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### 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/
|
||||
1
httpapi/.pydio
Normal file
1
httpapi/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
8735cea4-aa6f-43af-81c4-34a5011c1e02
|
||||
1
httpapi/logs/.pydio
Normal file
1
httpapi/logs/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
2273c60d-073a-4922-a827-3785242d2127
|
||||
1575
httpapi/logs/api.log
Executable file
1575
httpapi/logs/api.log
Executable file
File diff suppressed because it is too large
Load Diff
1
httpapi/logs/daily/.pydio
Normal file
1
httpapi/logs/daily/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
fea96269-0f72-47a0-9d22-ea49e5fda92a
|
||||
BIN
httpapi/logs/daily/api.log.2019-03-20.gz
Executable file
BIN
httpapi/logs/daily/api.log.2019-03-20.gz
Executable file
Binary file not shown.
BIN
httpapi/logs/daily/api.log.2019-03-21.gz
Executable file
BIN
httpapi/logs/daily/api.log.2019-03-21.gz
Executable file
Binary file not shown.
8
httpapi/mvnw
vendored
Executable file
8
httpapi/mvnw
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
status: 200, // 200, 404
|
||||
message: null
|
||||
result: [
|
||||
{
|
||||
}
|
||||
]
|
||||
}
|
||||
161
httpapi/mvnw.cmd
vendored
Executable file
161
httpapi/mvnw.cmd
vendored
Executable file
@@ -0,0 +1,161 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
echo Found %WRAPPER_JAR%
|
||||
) else (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
87
httpapi/pom.xml
Executable file
87
httpapi/pom.xml
Executable file
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.httpapi</groupId>
|
||||
<artifactId>bmy</artifactId>
|
||||
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>bmy</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
1
httpapi/src/.pydio
Normal file
1
httpapi/src/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
88d62796-b77b-4893-a107-8ecfebc0f2cd
|
||||
1
httpapi/src/main/.pydio
Normal file
1
httpapi/src/main/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
598d5dce-d2bf-48bf-b8dc-d5b862f4b55e
|
||||
1
httpapi/src/main/java/.pydio
Normal file
1
httpapi/src/main/java/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
21ebc146-f65a-4ea3-bffe-bad744b7d19b
|
||||
1
httpapi/src/main/java/com/.pydio
Normal file
1
httpapi/src/main/java/com/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
2457193c-fda4-4ead-8b99-3e508e8ac003
|
||||
1
httpapi/src/main/java/com/httpapi/.pydio
Normal file
1
httpapi/src/main/java/com/httpapi/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
52dc8f8b-ec8c-4db6-964a-1687bd3be456
|
||||
1
httpapi/src/main/java/com/httpapi/bmy/.pydio
Normal file
1
httpapi/src/main/java/com/httpapi/bmy/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
e1cb9145-753c-49d6-9873-0e840df171a1
|
||||
16
httpapi/src/main/java/com/httpapi/bmy/BmyApplication.java
Executable file
16
httpapi/src/main/java/com/httpapi/bmy/BmyApplication.java
Executable file
@@ -0,0 +1,16 @@
|
||||
package com.httpapi.bmy;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.httpapi.bmy.dao")
|
||||
@EnableSwagger2
|
||||
public class BmyApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BmyApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
1
httpapi/src/main/java/com/httpapi/bmy/config/.pydio
Normal file
1
httpapi/src/main/java/com/httpapi/bmy/config/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
8ce46c35-a6c9-4c89-b05b-b836f77a6bf2
|
||||
24
httpapi/src/main/java/com/httpapi/bmy/config/CorsConfig.java
Executable file
24
httpapi/src/main/java/com/httpapi/bmy/config/CorsConfig.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package com.httpapi.bmy.config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
private CorsConfiguration buildConfig() {
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
corsConfiguration.addAllowedOrigin("*"); // 允许任何域名
|
||||
corsConfiguration.addAllowedHeader("*"); // 允许任何头
|
||||
corsConfiguration.addAllowedMethod("*"); // 允许任何方法
|
||||
return corsConfiguration;
|
||||
}
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", buildConfig()); //注册
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
|
||||
}
|
||||
21
httpapi/src/main/java/com/httpapi/bmy/config/GlobalExceptionError.java
Executable file
21
httpapi/src/main/java/com/httpapi/bmy/config/GlobalExceptionError.java
Executable file
@@ -0,0 +1,21 @@
|
||||
package com.httpapi.bmy.config;
|
||||
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionError {
|
||||
@ResponseBody
|
||||
@ExceptionHandler(Exception.class)
|
||||
public Map<String,Object> exceptionHandler (Exception ex) {
|
||||
Map<String,Object> result = new HashMap<String, Object>();
|
||||
result.put("status","500");
|
||||
result.put("message",ex.getMessage());
|
||||
System.out.println(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
31
httpapi/src/main/java/com/httpapi/bmy/config/SwaggerConfig.java
Executable file
31
httpapi/src/main/java/com/httpapi/bmy/config/SwaggerConfig.java
Executable file
@@ -0,0 +1,31 @@
|
||||
package com.httpapi.bmy.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.httpapi.bmy.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("电商App")
|
||||
.description("Java后端api数据接口")
|
||||
.termsOfServiceUrl("http://www.xxxxx.com")
|
||||
.version("1.2.0")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
1
httpapi/src/main/java/com/httpapi/bmy/controller/.pydio
Normal file
1
httpapi/src/main/java/com/httpapi/bmy/controller/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
18ba9635-fc2e-4a77-810e-f96be0588d29
|
||||
43
httpapi/src/main/java/com/httpapi/bmy/controller/CartController.java
Executable file
43
httpapi/src/main/java/com/httpapi/bmy/controller/CartController.java
Executable file
@@ -0,0 +1,43 @@
|
||||
package com.httpapi.bmy.controller;
|
||||
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
import com.httpapi.bmy.service.impl.CartServiceImpl;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/cart")
|
||||
public class CartController {
|
||||
|
||||
@Autowired
|
||||
private CartServiceImpl cartService;
|
||||
|
||||
@RequestMapping(value = "/selectCart", method = RequestMethod.POST)
|
||||
@ApiOperation(value="查看用户购物车有多少商品,这里只需要userid参数即可", notes="查看用户购物车有多少商品,这里只需要userid参数即可")
|
||||
public ResultModel selectCart (@RequestBody Map<String,String> cart) {
|
||||
return cartService.getCartShopList(Integer.parseInt(cart.get("userid")));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deleteCart", method = RequestMethod.POST)
|
||||
@ApiOperation(value="用户删除购物车中某条商品时候使用", notes="用户删除购物车中某条商品时候使用")
|
||||
@ApiImplicitParam(name = "cid", value = "购物车中该商品的id", required = true, dataType = "int")
|
||||
public ResultModel deleteCart (@RequestBody Map<String,String> cart) {
|
||||
return cartService.deleteCartShop(Integer.parseInt(cart.get("cid")));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/checkCart", method = RequestMethod.POST)
|
||||
@ApiOperation(value="检查商品是否已经被添加过购物车", notes="检查商品是否已经被添加过购物车")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userid", value = "用户的id", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "shopid", value = "商品的id", required = true, dataType = "int")
|
||||
})
|
||||
public ResultModel checkCart (@RequestBody Map<String,String> cart) {
|
||||
return cartService.checkCartShop(Integer.parseInt(cart.get("userid")),Integer.parseInt(cart.get("shopid")));
|
||||
}
|
||||
|
||||
}
|
||||
36
httpapi/src/main/java/com/httpapi/bmy/controller/OrderController.java
Executable file
36
httpapi/src/main/java/com/httpapi/bmy/controller/OrderController.java
Executable file
@@ -0,0 +1,36 @@
|
||||
package com.httpapi.bmy.controller;
|
||||
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
import com.httpapi.bmy.service.impl.OrderServiceImpl;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/order")
|
||||
public class OrderController {
|
||||
|
||||
@Autowired
|
||||
private OrderServiceImpl orderService;
|
||||
|
||||
@RequestMapping(value = "/addOrder", method = RequestMethod.POST)
|
||||
@ApiOperation(value="提交订单", notes="提交订单")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "order", value = "order 订单信息<数组>", required = true, dataType = "List"),
|
||||
@ApiImplicitParam(name = "orderTotal", value = "购物车所有商品总价", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "money", value = "用户账户余额", required = true, dataType = "String")
|
||||
})
|
||||
public ResultModel addOrder (@RequestBody(required=false) Map OrderInfo) {
|
||||
List<Map<String,Object>> u = (List<Map<String, Object>>) OrderInfo.get("order");
|
||||
return orderService.AddOrder(u,OrderInfo.get("orderTotal"),OrderInfo.get("money"));
|
||||
}
|
||||
}
|
||||
37
httpapi/src/main/java/com/httpapi/bmy/controller/ShopController.java
Executable file
37
httpapi/src/main/java/com/httpapi/bmy/controller/ShopController.java
Executable file
@@ -0,0 +1,37 @@
|
||||
package com.httpapi.bmy.controller;
|
||||
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
import com.httpapi.bmy.service.impl.ShopServiceImpl;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/shop")
|
||||
public class ShopController {
|
||||
@Autowired
|
||||
private ShopServiceImpl shopService;
|
||||
|
||||
@RequestMapping(value = "/index", method = RequestMethod.GET)
|
||||
@ApiOperation(value="根据page获取分页数据", notes="根据page获取分页数据")
|
||||
@ApiImplicitParam(name = "page", value = "分页的页码", required = true, dataType = "int",paramType="query")
|
||||
public ResultModel index (@RequestParam(value = "page", required = true, defaultValue = "0") int page) {
|
||||
return shopService.getShopIndex(page);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
@ApiOperation(value="根据id进入商品详情", notes="根据id进入商品详情")
|
||||
@ApiImplicitParam(name = "id", value = "商品的id", required = true, dataType = "int",paramType="query")
|
||||
public ResultModel info (@RequestParam(value = "id", required = true) int id) {
|
||||
return shopService.getShopInfo(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/class", method = RequestMethod.GET)
|
||||
@ApiOperation(value="传入首页接口中获取到的brand参数即可进入详情", notes="传入首页接口中获取到的brand参数即可进入详情")
|
||||
@ApiImplicitParam(name = "brand ", value = "商品的brand ", required = true, dataType = "String",paramType="query")
|
||||
public ResultModel ShopClass (@RequestParam(value = "brand", required = true) String brand) {
|
||||
return shopService.getShopClass(brand);
|
||||
}
|
||||
}
|
||||
53
httpapi/src/main/java/com/httpapi/bmy/controller/UserController.java
Executable file
53
httpapi/src/main/java/com/httpapi/bmy/controller/UserController.java
Executable file
@@ -0,0 +1,53 @@
|
||||
package com.httpapi.bmy.controller;
|
||||
|
||||
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
import com.httpapi.bmy.service.impl.UserServiceImpl;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/user")
|
||||
public class UserController {
|
||||
@Autowired
|
||||
private UserServiceImpl userService;
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
||||
@ApiOperation(value="用户登录接口,登录成功后会返回账号的基本信息,请前端自己保存基本信息后面需要用到。", notes="用户登录接口,登录成功后会返回账号的基本信息,请前端自己保存基本信息后面需要用到。")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "phone", value = "手机号(前端自己验证手机号合法性)", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "pwd", value = "用户密码", required = true, dataType = "String")
|
||||
})
|
||||
public ResultModel UserLogin(@RequestBody Map<String, String> user) {
|
||||
return userService.UserLogin(user.get("phone"),user.get("pwd"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/addUser", method = RequestMethod.POST)
|
||||
@ApiOperation(value="注册一个新账号", notes="注册一个新账号")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "phone", value = "手机号(前端自己验证手机号合法性)", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "nickname", value = "昵称(显示在我的页面上)", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "pwd", value = "用户密码", required = true, dataType = "String")
|
||||
})
|
||||
public ResultModel addUser(@RequestBody Map<String, String> user) {
|
||||
return userService.addUser(user.get("phone"),user.get("pwd"),user.get("nickname"));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/addCart", method = RequestMethod.POST)
|
||||
@ApiOperation(value="添加商品到购物车", notes="添加商品到购物车")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userid", value = "用户id", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "shopid", value = "商品id", required = true, dataType = "int")
|
||||
})
|
||||
public ResultModel addCart(@RequestBody Map<String, String> cart) {
|
||||
return userService.addCart(Integer.parseInt(cart.get("userid")),Integer.parseInt(cart.get("shopid")));
|
||||
}
|
||||
|
||||
}
|
||||
1
httpapi/src/main/java/com/httpapi/bmy/dao/.pydio
Normal file
1
httpapi/src/main/java/com/httpapi/bmy/dao/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
0bde7e07-2634-4fb2-9f02-1deab137051b
|
||||
12
httpapi/src/main/java/com/httpapi/bmy/dao/CartDao.java
Executable file
12
httpapi/src/main/java/com/httpapi/bmy/dao/CartDao.java
Executable file
@@ -0,0 +1,12 @@
|
||||
package com.httpapi.bmy.dao;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public interface CartDao {
|
||||
List<HashMap<String, Object>> getCartShopList(int id);
|
||||
|
||||
void deleteCartShop(int cid);
|
||||
|
||||
List<HashMap<String, Object>> checkCartShop(int userid, int shopid);
|
||||
}
|
||||
12
httpapi/src/main/java/com/httpapi/bmy/dao/OrderDao.java
Executable file
12
httpapi/src/main/java/com/httpapi/bmy/dao/OrderDao.java
Executable file
@@ -0,0 +1,12 @@
|
||||
package com.httpapi.bmy.dao;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface OrderDao {
|
||||
// 插入到订单表
|
||||
void insertOrder(Map order);
|
||||
// 删除购物车数据
|
||||
void deleteCartShop(Map keys);
|
||||
// 更新余额
|
||||
void updateMoney(int Money,int uid);
|
||||
}
|
||||
9
httpapi/src/main/java/com/httpapi/bmy/dao/ShopDao.java
Executable file
9
httpapi/src/main/java/com/httpapi/bmy/dao/ShopDao.java
Executable file
@@ -0,0 +1,9 @@
|
||||
package com.httpapi.bmy.dao;
|
||||
import com.httpapi.bmy.model.ShopModel;
|
||||
import java.util.List;
|
||||
|
||||
public interface ShopDao {
|
||||
List<ShopModel> selectShop(int StartPage, int TotalPage);
|
||||
List<ShopModel> getShopInfo(int id);
|
||||
List<ShopModel> getShopClass(String brand);
|
||||
}
|
||||
11
httpapi/src/main/java/com/httpapi/bmy/dao/UserDao.java
Executable file
11
httpapi/src/main/java/com/httpapi/bmy/dao/UserDao.java
Executable file
@@ -0,0 +1,11 @@
|
||||
package com.httpapi.bmy.dao;
|
||||
|
||||
import com.httpapi.bmy.model.UserModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserDao {
|
||||
List<UserModel> UserLogin(String phone, String pwd);
|
||||
void addUser(String phone, String pwd, String nickname);
|
||||
void addCart(int userid, int shopid);
|
||||
}
|
||||
1
httpapi/src/main/java/com/httpapi/bmy/model/.pydio
Normal file
1
httpapi/src/main/java/com/httpapi/bmy/model/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
fbe4fbb6-ed7d-44eb-ade3-ccc3485bd4db
|
||||
12
httpapi/src/main/java/com/httpapi/bmy/model/ResultModel.java
Executable file
12
httpapi/src/main/java/com/httpapi/bmy/model/ResultModel.java
Executable file
@@ -0,0 +1,12 @@
|
||||
package com.httpapi.bmy.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ResultModel {
|
||||
private int status;
|
||||
private String message;
|
||||
private Object data;
|
||||
}
|
||||
19
httpapi/src/main/java/com/httpapi/bmy/model/ShopModel.java
Executable file
19
httpapi/src/main/java/com/httpapi/bmy/model/ShopModel.java
Executable file
@@ -0,0 +1,19 @@
|
||||
package com.httpapi.bmy.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ShopModel {
|
||||
private String commodity_name;
|
||||
private String commodity_nowprice;
|
||||
private String commodity_brand;
|
||||
private String commodity_stock;
|
||||
private String commodity_oldprice;
|
||||
private String commodity_sales;
|
||||
private String commodity_main;
|
||||
private String commodity_thumbnail;
|
||||
private String commodity_attachimg;
|
||||
private String commodity_content;
|
||||
}
|
||||
17
httpapi/src/main/java/com/httpapi/bmy/model/UserModel.java
Executable file
17
httpapi/src/main/java/com/httpapi/bmy/model/UserModel.java
Executable file
@@ -0,0 +1,17 @@
|
||||
package com.httpapi.bmy.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class UserModel {
|
||||
private int id;
|
||||
private String user_name;
|
||||
private String user_pwd;
|
||||
private String user_nicname;
|
||||
private String user_addres;
|
||||
private String user_icons;
|
||||
private String user_money;
|
||||
private String user_truename;
|
||||
}
|
||||
1
httpapi/src/main/java/com/httpapi/bmy/service/.pydio
Normal file
1
httpapi/src/main/java/com/httpapi/bmy/service/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
6fe35a0c-2085-481f-8046-80bd349e7be2
|
||||
7
httpapi/src/main/java/com/httpapi/bmy/service/CartService.java
Executable file
7
httpapi/src/main/java/com/httpapi/bmy/service/CartService.java
Executable file
@@ -0,0 +1,7 @@
|
||||
package com.httpapi.bmy.service;
|
||||
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
|
||||
public interface CartService {
|
||||
ResultModel getCartShopList(int page);
|
||||
}
|
||||
9
httpapi/src/main/java/com/httpapi/bmy/service/ShopService.java
Executable file
9
httpapi/src/main/java/com/httpapi/bmy/service/ShopService.java
Executable file
@@ -0,0 +1,9 @@
|
||||
package com.httpapi.bmy.service;
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
|
||||
public interface ShopService {
|
||||
ResultModel getShopIndex(int page);
|
||||
|
||||
ResultModel getShopInfo(int id);
|
||||
ResultModel getShopClass(String brand);
|
||||
}
|
||||
9
httpapi/src/main/java/com/httpapi/bmy/service/UserService.java
Executable file
9
httpapi/src/main/java/com/httpapi/bmy/service/UserService.java
Executable file
@@ -0,0 +1,9 @@
|
||||
package com.httpapi.bmy.service;
|
||||
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
|
||||
public interface UserService {
|
||||
ResultModel UserLogin(String phone, String pwd);
|
||||
ResultModel addUser(String phone, String nickname, String pwd);
|
||||
ResultModel addCart(int userid, int shopid);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
98da5806-18fd-4e32-b892-b6f3a008ab9b
|
||||
37
httpapi/src/main/java/com/httpapi/bmy/service/impl/CartServiceImpl.java
Executable file
37
httpapi/src/main/java/com/httpapi/bmy/service/impl/CartServiceImpl.java
Executable file
@@ -0,0 +1,37 @@
|
||||
package com.httpapi.bmy.service.impl;
|
||||
|
||||
import com.httpapi.bmy.dao.CartDao;
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
import com.httpapi.bmy.service.CartService;
|
||||
import com.httpapi.bmy.utils.ResultUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CartServiceImpl implements CartService {
|
||||
@Autowired
|
||||
private CartDao cartDao;
|
||||
|
||||
@Override
|
||||
public ResultModel getCartShopList(int uid) {
|
||||
List<HashMap<String, Object>> cartList = cartDao.getCartShopList(uid);
|
||||
return cartList.isEmpty() ? ResultUtils.Error("购物车为空") : ResultUtils.Success(cartList);
|
||||
}
|
||||
|
||||
public ResultModel deleteCartShop(int cid) {
|
||||
try {
|
||||
cartDao.deleteCartShop(cid);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.Error(e.getMessage());
|
||||
}
|
||||
return ResultUtils.Success("删除成功");
|
||||
}
|
||||
|
||||
public ResultModel checkCartShop(int userid, int shopid) {
|
||||
List<HashMap<String, Object>> checkShop = cartDao.checkCartShop(userid, shopid);
|
||||
return checkShop.isEmpty() ? ResultUtils.Error("没有商品,可以收藏") : ResultUtils.Success("已经收藏,不可以再收藏");
|
||||
}
|
||||
}
|
||||
45
httpapi/src/main/java/com/httpapi/bmy/service/impl/OrderServiceImpl.java
Executable file
45
httpapi/src/main/java/com/httpapi/bmy/service/impl/OrderServiceImpl.java
Executable file
@@ -0,0 +1,45 @@
|
||||
package com.httpapi.bmy.service.impl;
|
||||
|
||||
import com.httpapi.bmy.dao.OrderDao;
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
import com.httpapi.bmy.utils.ResultUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
@Service
|
||||
public class OrderServiceImpl {
|
||||
@Autowired
|
||||
private OrderDao orderDao;
|
||||
|
||||
public ResultModel AddOrder(List<Map<String,Object>> OrderInfo, Object orderTotal, Object money) {
|
||||
// 生成订单号
|
||||
int keys = new Random().nextInt(99999999);
|
||||
// 保存订单号
|
||||
String OrderNumber = null;
|
||||
// 计算用户剩余的钱,余额 - 商品总价
|
||||
int k = Integer.parseInt(String.valueOf(money)) - Integer.parseInt(String.valueOf(orderTotal));
|
||||
try {
|
||||
for (int i = 0;i < OrderInfo.size(); i++){
|
||||
// 构造订单号 用户id + key
|
||||
OrderNumber = String.valueOf(OrderInfo.get(i).get("uid")) + keys;
|
||||
// 修改 订单 对象,增加 onumber 订单号
|
||||
OrderInfo.get(i).put("onumber", OrderNumber);
|
||||
// 遍历 订单对象,插入订单数据
|
||||
orderDao.insertOrder(OrderInfo.get(i));
|
||||
// 删除购物车中的数据
|
||||
orderDao.deleteCartShop(OrderInfo.get(i));
|
||||
}
|
||||
// 更新用户的余额
|
||||
orderDao.updateMoney(k,(int) OrderInfo.get(0).get("uid"));
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.Error("订单保存失败");
|
||||
}
|
||||
|
||||
return ResultUtils.Success(OrderNumber);
|
||||
}
|
||||
}
|
||||
35
httpapi/src/main/java/com/httpapi/bmy/service/impl/ShopServiceImpl.java
Executable file
35
httpapi/src/main/java/com/httpapi/bmy/service/impl/ShopServiceImpl.java
Executable file
@@ -0,0 +1,35 @@
|
||||
package com.httpapi.bmy.service.impl;
|
||||
|
||||
import com.httpapi.bmy.dao.ShopDao;
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
import com.httpapi.bmy.model.ShopModel;
|
||||
import com.httpapi.bmy.service.ShopService;
|
||||
import com.httpapi.bmy.utils.ResultUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ShopServiceImpl implements ShopService {
|
||||
|
||||
@Autowired
|
||||
private ShopDao shopDao;
|
||||
|
||||
@Override
|
||||
public ResultModel getShopIndex(int page) {
|
||||
List<ShopModel> ShopList = shopDao.selectShop(page * 15, 15);
|
||||
return ShopList.isEmpty() ? ResultUtils.Error("数据为空") : ResultUtils.Success(ShopList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultModel getShopInfo(int id) {
|
||||
List<ShopModel> ShopInfo = shopDao.getShopInfo(id);
|
||||
return ShopInfo.isEmpty() ? ResultUtils.Error("商品不存在") : ResultUtils.Success(ShopInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultModel getShopClass(String brand) {
|
||||
List<ShopModel> ShopClass = shopDao.getShopClass(brand);
|
||||
return ShopClass.isEmpty() ? ResultUtils.Error("该品牌不存在或没有数据") : ResultUtils.Success(ShopClass);
|
||||
}
|
||||
}
|
||||
45
httpapi/src/main/java/com/httpapi/bmy/service/impl/UserServiceImpl.java
Executable file
45
httpapi/src/main/java/com/httpapi/bmy/service/impl/UserServiceImpl.java
Executable file
@@ -0,0 +1,45 @@
|
||||
package com.httpapi.bmy.service.impl;
|
||||
|
||||
import com.httpapi.bmy.dao.ShopDao;
|
||||
import com.httpapi.bmy.dao.UserDao;
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
import com.httpapi.bmy.model.UserModel;
|
||||
import com.httpapi.bmy.service.UserService;
|
||||
import com.httpapi.bmy.utils.MD5Utils;
|
||||
import com.httpapi.bmy.utils.ResultUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public ResultModel UserLogin(String phone, String pwd) {
|
||||
List<UserModel> UserInfo = userDao.UserLogin(phone, MD5Utils.encode(pwd));
|
||||
return UserInfo.isEmpty() ? ResultUtils.Error("账户不存在") : ResultUtils.Success(UserInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultModel addUser(String phone, String pwd, String nickname) {
|
||||
try {
|
||||
userDao.addUser(phone, MD5Utils.encode(pwd), nickname);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.Error(e.getMessage());
|
||||
}
|
||||
return ResultUtils.Success("注册成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultModel addCart(int userid, int shopid) {
|
||||
try {
|
||||
userDao.addCart(userid,shopid);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.Error(e.getMessage());
|
||||
}
|
||||
return ResultUtils.Success("添加购物车成功");
|
||||
}
|
||||
}
|
||||
1
httpapi/src/main/java/com/httpapi/bmy/utils/.pydio
Normal file
1
httpapi/src/main/java/com/httpapi/bmy/utils/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
9b0a3722-5a1a-4f95-8ca9-69b99a72e72b
|
||||
33
httpapi/src/main/java/com/httpapi/bmy/utils/MD5Utils.java
Executable file
33
httpapi/src/main/java/com/httpapi/bmy/utils/MD5Utils.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package com.httpapi.bmy.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class MD5Utils {
|
||||
private static final String SALT = "!@#$%^&*()cvb<??>";
|
||||
|
||||
public static String encode(String password) {
|
||||
MessageDigest md5 = null;
|
||||
//password = password + SALT;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
char[] charArray = password.toCharArray();
|
||||
byte[] byteArray = new byte[charArray.length];
|
||||
|
||||
for (int i = 0; i < charArray.length; i++)
|
||||
byteArray[i] = (byte) charArray[i];
|
||||
byte[] md5Bytes = md5.digest(byteArray);
|
||||
StringBuffer hexValue = new StringBuffer();
|
||||
for (int i = 0; i < md5Bytes.length; i++) {
|
||||
int val = ((int) md5Bytes[i]) & 0xff;
|
||||
if (val < 16) {
|
||||
hexValue.append("0");
|
||||
}
|
||||
|
||||
hexValue.append(Integer.toHexString(val));
|
||||
}
|
||||
return hexValue.toString();
|
||||
}
|
||||
}
|
||||
32
httpapi/src/main/java/com/httpapi/bmy/utils/ResultUtils.java
Executable file
32
httpapi/src/main/java/com/httpapi/bmy/utils/ResultUtils.java
Executable file
@@ -0,0 +1,32 @@
|
||||
package com.httpapi.bmy.utils;
|
||||
|
||||
import com.httpapi.bmy.model.ResultModel;
|
||||
|
||||
public class ResultUtils {
|
||||
|
||||
/**
|
||||
* 请求成功
|
||||
* @param par 具体的数据
|
||||
* @return
|
||||
*/
|
||||
public static ResultModel Success (Object par) {
|
||||
ResultModel resultModel = new ResultModel();
|
||||
resultModel.setStatus(200);
|
||||
resultModel.setMessage("null");
|
||||
resultModel.setData(par);
|
||||
return resultModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求失败
|
||||
* @param message 错误信息
|
||||
* @return
|
||||
*/
|
||||
public static ResultModel Error(String message) {
|
||||
ResultModel resultModel = new ResultModel();
|
||||
resultModel.setStatus(404);
|
||||
resultModel.setMessage(message);
|
||||
resultModel.setData(null);
|
||||
return resultModel;
|
||||
}
|
||||
}
|
||||
1
httpapi/src/main/resources/.pydio
Normal file
1
httpapi/src/main/resources/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
b8808753-505d-4806-ae09-42e315aa577f
|
||||
14
httpapi/src/main/resources/application-dev.yml
Executable file
14
httpapi/src/main/resources/application-dev.yml
Executable file
@@ -0,0 +1,14 @@
|
||||
server:
|
||||
port: 9090
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/shop?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
|
||||
username: root
|
||||
password: lb714500
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
springframework:
|
||||
web: debug
|
||||
14
httpapi/src/main/resources/application-prod.yml
Executable file
14
httpapi/src/main/resources/application-prod.yml
Executable file
@@ -0,0 +1,14 @@
|
||||
server:
|
||||
port: 9090
|
||||
|
||||
spring:
|
||||
main:
|
||||
banner-mode: "off"
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3306/shop?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
|
||||
username: bmy
|
||||
password: 6fb7YJYCDmN67p4x
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
10
httpapi/src/main/resources/application.yml
Executable file
10
httpapi/src/main/resources/application.yml
Executable file
@@ -0,0 +1,10 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
|
||||
mybatis:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
|
||||
logging:
|
||||
path: logs/
|
||||
file: api.log
|
||||
30
httpapi/src/main/resources/banner.txt
Executable file
30
httpapi/src/main/resources/banner.txt
Executable file
@@ -0,0 +1,30 @@
|
||||
======================================================================================
|
||||
|
||||
_ooOoo_
|
||||
o8888888o
|
||||
88" . "88
|
||||
(| -_- |)
|
||||
O\ = /O
|
||||
____/`---'\____
|
||||
.' \\| |// `.
|
||||
/ \\||| : |||// \
|
||||
/ _||||| -:- |||||- \
|
||||
| | \\\ - /// | |
|
||||
| \_| ''\---/'' | |
|
||||
\ .-\__ `-` ___/-. /
|
||||
___`. .' /--.--\ `. . __
|
||||
."" '< `.___\_<|>_/___.' >'"".
|
||||
| | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||
\ \ `-. \_ __\ /__ _/ .-` / /
|
||||
======`-.____`-.___\_____/___.-`____.-'======
|
||||
`=---='
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
佛祖保佑 永无BUG
|
||||
|
||||
电商App后端数据接口,详细请参考:
|
||||
|
||||
1:接口文档请参考:http://127.0.0.1:9090/swagger-ui.html
|
||||
2:项目设计请参考:http://www.xxx.com
|
||||
|
||||
|
||||
======================================================================================
|
||||
22
httpapi/src/main/resources/logback-spring.xml
Executable file
22
httpapi/src/main/resources/logback-spring.xml
Executable file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${LOG_PATH}${LOG_FILE}</File>
|
||||
<encoder>
|
||||
<pattern>%date [%level] [%thread] %logger{60} [%file : %line] %msg%n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_PATH}daily/${LOG_FILE}.%d{yyyy-MM-dd}.gz</fileNamePattern>
|
||||
<maxHistory>180</maxHistory> <!-- 保留180天 -->
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
</configuration>
|
||||
1
httpapi/src/main/resources/mapper/.pydio
Normal file
1
httpapi/src/main/resources/mapper/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
8387306a-2462-4519-be6f-c4b8e1dee91c
|
||||
20
httpapi/src/main/resources/mapper/CartMapper.xml
Executable file
20
httpapi/src/main/resources/mapper/CartMapper.xml
Executable file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<mapper namespace="com.httpapi.bmy.dao.CartDao">
|
||||
|
||||
<!-- id 对应 dao接口中方法,resultType 是数据返回类型,parameterType 是参数类型 -->
|
||||
<select id="getCartShopList" resultType="java.util.Map" parameterType="Integer">
|
||||
SELECT shop_cart.cart_nums, shop_cart.id AS cid, shop_commodity.* FROM shop_cart ,shop_commodity WHERE shop_cart.commodity_id = shop_commodity.id AND shop_cart.user_id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="deleteCartShop">
|
||||
delete from shop_cart where id = #{cid}
|
||||
</delete>
|
||||
|
||||
<select id="checkCartShop" parameterType="Integer" resultType="java.util.Map">
|
||||
select * from shop_cart where user_id = #{userid} and commodity_id = #{shopid}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
16
httpapi/src/main/resources/mapper/OrderMapper.xml
Executable file
16
httpapi/src/main/resources/mapper/OrderMapper.xml
Executable file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<mapper namespace="com.httpapi.bmy.dao.OrderDao">
|
||||
<!-- id 对应 dao接口中方法,resultType 是数据返回类型,parameterType 是参数类型 -->
|
||||
<insert id="insertOrder" parameterType="java.util.Map">
|
||||
insert into shop_order(user_id,commodity_id,order_number,order_status,order_total,order_size) value (#{uid},#{sid},#{onumber},'1',#{total},#{size})
|
||||
</insert>
|
||||
<delete id="deleteCartShop" parameterType="java.util.Map">
|
||||
delete from shop_cart where user_id = #{uid} and commodity_id = #{sid}
|
||||
</delete>
|
||||
<update id="updateMoney">
|
||||
UPDATE shop_user SET user_money = #{Money} WHERE id = #{uid}
|
||||
</update>
|
||||
</mapper>
|
||||
20
httpapi/src/main/resources/mapper/ShopMapper.xml
Executable file
20
httpapi/src/main/resources/mapper/ShopMapper.xml
Executable file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<mapper namespace="com.httpapi.bmy.dao.ShopDao">
|
||||
|
||||
<!-- id 对应 dao接口中方法,resultType 是数据返回类型,parameterType 是参数类型 -->
|
||||
<select id="selectShop" resultType="java.util.Map" parameterType="Integer">
|
||||
select * from shop_commodity ORDER BY id DESC limit #{StartPage},#{TotalPage}
|
||||
</select>
|
||||
|
||||
<select id="getShopInfo" resultType="java.util.Map" parameterType="Integer">
|
||||
select * from shop_commodity where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getShopClass" resultType="java.util.Map" parameterType="String">
|
||||
select * from shop_commodity where commodity_brand = #{brand}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
22
httpapi/src/main/resources/mapper/UserMapper.xml
Executable file
22
httpapi/src/main/resources/mapper/UserMapper.xml
Executable file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<mapper namespace="com.httpapi.bmy.dao.UserDao">
|
||||
|
||||
<!-- id 对应 dao接口中方法,resultType 是数据返回类型,parameterType 是参数类型 -->
|
||||
<select id="UserLogin" resultType="java.util.Map">
|
||||
select * from shop_user where user_name = #{phone} and user_pwd = #{pwd}
|
||||
</select>
|
||||
|
||||
<!-- id 对应 dao接口中方法,resultType 是数据返回类型,parameterType 是参数类型 -->
|
||||
<insert id="addUser" parameterType="java.util.Map">
|
||||
insert into shop_user(user_name,user_pwd,user_nicname) value (#{phone},#{pwd},#{nickname})
|
||||
</insert>
|
||||
|
||||
<!-- id 对应 dao接口中方法,resultType 是数据返回类型,parameterType 是参数类型 -->
|
||||
<insert id="addCart" parameterType="int">
|
||||
insert into shop_cart(user_id,commodity_id) value (#{userid},#{shopid})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
BIN
httpapi/src/main/resources/resources.zip
Executable file
BIN
httpapi/src/main/resources/resources.zip
Executable file
Binary file not shown.
1
httpapi/src/main/resources/static/.pydio
Normal file
1
httpapi/src/main/resources/static/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
82afa575-a983-4004-b23a-a8ccb22936ac
|
||||
1
httpapi/src/main/resources/templates/.pydio
Normal file
1
httpapi/src/main/resources/templates/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
785efd17-4d48-4865-8ce6-aa188f1ff73e
|
||||
1
httpapi/src/test/.pydio
Normal file
1
httpapi/src/test/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
f9dc6c03-2aa6-4909-9f83-e93f03aa7600
|
||||
1
httpapi/src/test/java/.pydio
Normal file
1
httpapi/src/test/java/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
7a44b4db-b877-476a-b7bb-83b3172cb150
|
||||
1
httpapi/src/test/java/com/.pydio
Normal file
1
httpapi/src/test/java/com/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
00965725-244d-4880-924c-a1860141bf5e
|
||||
1
httpapi/src/test/java/com/httpapi/.pydio
Normal file
1
httpapi/src/test/java/com/httpapi/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
1158a547-1332-4ff9-8a74-9310eba147f4
|
||||
1
httpapi/src/test/java/com/httpapi/bmy/.pydio
Normal file
1
httpapi/src/test/java/com/httpapi/bmy/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
5a84e672-9267-49d2-b581-237ec68b025e
|
||||
16
httpapi/src/test/java/com/httpapi/bmy/BmyApplicationTests.java
Executable file
16
httpapi/src/test/java/com/httpapi/bmy/BmyApplicationTests.java
Executable file
@@ -0,0 +1,16 @@
|
||||
package com.httpapi.bmy;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class BmyApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user