first commit
23
.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
1
app效果图/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
20e0d234-2d28-4128-9b9d-f6a7e3763c18
|
||||
BIN
app效果图/1.jpg
Executable file
|
After Width: | Height: | Size: 45 KiB |
BIN
app效果图/10.jpg
Executable file
|
After Width: | Height: | Size: 35 KiB |
BIN
app效果图/11.jpg
Executable file
|
After Width: | Height: | Size: 32 KiB |
BIN
app效果图/12.jpg
Executable file
|
After Width: | Height: | Size: 21 KiB |
BIN
app效果图/13.jpg
Executable file
|
After Width: | Height: | Size: 25 KiB |
BIN
app效果图/2.jpg
Executable file
|
After Width: | Height: | Size: 41 KiB |
BIN
app效果图/3.jpg
Executable file
|
After Width: | Height: | Size: 26 KiB |
BIN
app效果图/4.jpg
Executable file
|
After Width: | Height: | Size: 25 KiB |
BIN
app效果图/5.jpg
Executable file
|
After Width: | Height: | Size: 18 KiB |
BIN
app效果图/6.jpg
Executable file
|
After Width: | Height: | Size: 43 KiB |
BIN
app效果图/7.jpg
Executable file
|
After Width: | Height: | Size: 43 KiB |
BIN
app效果图/8.jpg
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
app效果图/9.jpg
Executable file
|
After Width: | Height: | Size: 23 KiB |
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
@@ -0,0 +1 @@
|
||||
8735cea4-aa6f-43af-81c4-34a5011c1e02
|
||||
1
httpapi/logs/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
2273c60d-073a-4922-a827-3785242d2127
|
||||
1575
httpapi/logs/api.log
Executable 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-21.gz
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
@@ -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
@@ -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
@@ -0,0 +1 @@
|
||||
88d62796-b77b-4893-a107-8ecfebc0f2cd
|
||||
1
httpapi/src/main/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
598d5dce-d2bf-48bf-b8dc-d5b862f4b55e
|
||||
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
@@ -0,0 +1 @@
|
||||
2457193c-fda4-4ead-8b99-3e508e8ac003
|
||||
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
@@ -0,0 +1 @@
|
||||
e1cb9145-753c-49d6-9873-0e840df171a1
|
||||
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
@@ -0,0 +1 @@
|
||||
8ce46c35-a6c9-4c89-b05b-b836f77a6bf2
|
||||
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
@@ -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
@@ -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
@@ -0,0 +1 @@
|
||||
18ba9635-fc2e-4a77-810e-f96be0588d29
|
||||
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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1 @@
|
||||
0bde7e07-2634-4fb2-9f02-1deab137051b
|
||||
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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1 @@
|
||||
fbe4fbb6-ed7d-44eb-ade3-ccc3485bd4db
|
||||
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
@@ -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
@@ -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
@@ -0,0 +1 @@
|
||||
6fe35a0c-2085-481f-8046-80bd349e7be2
|
||||
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1 @@
|
||||
9b0a3722-5a1a-4f95-8ca9-69b99a72e72b
|
||||
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
@@ -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
@@ -0,0 +1 @@
|
||||
b8808753-505d-4806-ae09-42e315aa577f
|
||||
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1 @@
|
||||
8387306a-2462-4519-be6f-c4b8e1dee91c
|
||||
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
@@ -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
@@ -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
@@ -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
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
@@ -0,0 +1 @@
|
||||
785efd17-4d48-4865-8ce6-aa188f1ff73e
|
||||
1
httpapi/src/test/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
f9dc6c03-2aa6-4909-9f83-e93f03aa7600
|
||||
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
@@ -0,0 +1 @@
|
||||
00965725-244d-4880-924c-a1860141bf5e
|
||||
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
@@ -0,0 +1 @@
|
||||
5a84e672-9267-49d2-b581-237ec68b025e
|
||||
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() {
|
||||
}
|
||||
|
||||
}
|
||||
1
node+vue/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
57af376b-3727-4a55-8a3f-c18b14882356
|
||||
1
node+vue/shop-bend/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
977e97ad-3d32-417a-8112-4cc8fccb6164
|
||||
58
node+vue/shop-bend/app.js
Executable file
@@ -0,0 +1,58 @@
|
||||
var createError = require('http-errors');
|
||||
var express = require('express');
|
||||
var cookieParser = require('cookie-parser');
|
||||
var logger = require('morgan');
|
||||
var config = require('./config');
|
||||
|
||||
// 导入路由
|
||||
var CartRouter = require('./routes/cart');
|
||||
var OrderRouter = require('./routes/order');
|
||||
var ShopRouter = require('./routes/shop');
|
||||
var UserRouter = require('./routes/user');
|
||||
|
||||
var app = express();
|
||||
// 跨域请求头设置
|
||||
app.all("*", function (req, res, next) {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header(
|
||||
"Access-Control-Allow-Headers",
|
||||
"Content-Type,token,Content-Length, Authorization, Accept,X-Requested-With"
|
||||
);
|
||||
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
|
||||
res.header("X-Powered-By", "bmy");
|
||||
if (req.method == "OPTIONS") res.sendStatus(200);
|
||||
else next();
|
||||
});
|
||||
|
||||
// 中间件设置
|
||||
app.use(logger('dev'));
|
||||
// 设置 HTTP请求的大小限制 为100mb
|
||||
app.use(express.json({
|
||||
limit: config.dev.httpSize
|
||||
}));
|
||||
app.use(express.urlencoded({ limit: config.dev.httpSize, extended: false }));
|
||||
app.use(cookieParser());
|
||||
|
||||
// 配置挂载路由
|
||||
app.use('/api/json/shop/', ShopRouter);
|
||||
app.use('/api/json/user/', UserRouter);
|
||||
app.use('/api/json/cart/', CartRouter)
|
||||
app.use('/api/json/order/', OrderRouter)
|
||||
|
||||
// 捕捉404错误
|
||||
app.use(function (req, res, next) {
|
||||
next(createError(404));
|
||||
});
|
||||
|
||||
// 错误处理
|
||||
app.use(function (err, req, res, next) {
|
||||
// set locals, only providing error in development
|
||||
res.locals.message = err.message;
|
||||
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
||||
|
||||
// render the error page
|
||||
res.status(err.status || 500);
|
||||
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
1
node+vue/shop-bend/bin/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
44ccb1d1-5187-42b2-a1ef-586343d71f3c
|
||||
90
node+vue/shop-bend/bin/www
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var app = require('../app');
|
||||
var debug = require('debug')('shop-bend:server');
|
||||
var http = require('http');
|
||||
var config = require('./../config')
|
||||
/**
|
||||
* Get port from environment and store in Express.
|
||||
*/
|
||||
|
||||
var port = normalizePort(process.env.PORT || config.dev.port);
|
||||
app.set('port', port);
|
||||
|
||||
/**
|
||||
* Create HTTP server.
|
||||
*/
|
||||
|
||||
var server = http.createServer(app);
|
||||
|
||||
/**
|
||||
* Listen on provided port, on all network interfaces.
|
||||
*/
|
||||
|
||||
server.listen(port);
|
||||
server.on('error', onError);
|
||||
server.on('listening', onListening);
|
||||
|
||||
/**
|
||||
* Normalize a port into a number, string, or false.
|
||||
*/
|
||||
|
||||
function normalizePort(val) {
|
||||
var port = parseInt(val, 10);
|
||||
|
||||
if (isNaN(port)) {
|
||||
// named pipe
|
||||
return val;
|
||||
}
|
||||
|
||||
if (port >= 0) {
|
||||
// port number
|
||||
return port;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "error" event.
|
||||
*/
|
||||
|
||||
function onError(error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
throw error;
|
||||
}
|
||||
|
||||
var bind = typeof port === 'string'
|
||||
? 'Pipe ' + port
|
||||
: 'Port ' + port;
|
||||
|
||||
// handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
console.error(bind + ' requires elevated privileges');
|
||||
process.exit(1);
|
||||
break;
|
||||
case 'EADDRINUSE':
|
||||
console.error(bind + ' is already in use');
|
||||
process.exit(1);
|
||||
break;
|
||||
default:
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "listening" event.
|
||||
*/
|
||||
|
||||
function onListening() {
|
||||
var addr = server.address();
|
||||
var bind = typeof addr === 'string'
|
||||
? 'pipe ' + addr
|
||||
: 'port ' + addr.port;
|
||||
console.log(`Api is run this: ${config.dev.ipAddress}:${config.dev.port}`);
|
||||
}
|
||||
1
node+vue/shop-bend/cache/.pydio
vendored
Normal file
@@ -0,0 +1 @@
|
||||
c4e4d830-303d-4c00-bb1f-c77d83c90ba3
|
||||
37
node+vue/shop-bend/cache/index.js
vendored
Executable file
@@ -0,0 +1,37 @@
|
||||
const redis = require("redis");
|
||||
const config = require("../config");
|
||||
|
||||
class Redis {
|
||||
constructor() {
|
||||
// 创建redis服务
|
||||
this.client = redis.createClient(config.dev.redis.port, config.dev.redis.host);
|
||||
// 监听错误
|
||||
this.client.on("error", function (err) {
|
||||
console.log("redis 连接失败:" + err);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 设置缓存值
|
||||
* @param {*string} key 名称
|
||||
* @param {*string} value 数值
|
||||
*/
|
||||
Set(key, value) {
|
||||
this.client.set(key, JSON.stringify(value), redis.print)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存数值
|
||||
* @param {*string} key 名称
|
||||
*/
|
||||
Get(key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.client.expire(key, config.dev.redis.timeout);
|
||||
this.client.get(key, function (error, result) {
|
||||
if (error) reject(error)
|
||||
resolve(JSON.parse(result))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Redis()
|
||||
1
node+vue/shop-bend/config/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
8c41a9e9-d24a-4e24-8b98-acdc9d2838f2
|
||||
57
node+vue/shop-bend/config/index.js
Executable file
@@ -0,0 +1,57 @@
|
||||
const config = {
|
||||
dev: {
|
||||
port: 3080, // 端口配置,网站上线服务器后改这个为 80端口
|
||||
ipAddress: "http://127.0.0.1",
|
||||
httpSize: "100mb",
|
||||
api: {
|
||||
success: 200, //网络请求成功
|
||||
error: 404, // 网络请求失败
|
||||
CodeError: 500 // 服务器内部错误或者异常
|
||||
},
|
||||
// 公私钥地址
|
||||
rsa: {
|
||||
privateKey: "../config/rsa_private_key.pem",
|
||||
publicKey: "../config/rsa_public_key.pem",
|
||||
},
|
||||
// mysql 数据库连接信息
|
||||
mysql: {
|
||||
host: '127.0.0.1',
|
||||
user: 'root',
|
||||
password: 'root',
|
||||
database: 'shop'
|
||||
},
|
||||
// redis 连接配置信息
|
||||
redis: {
|
||||
host: "127.0.0.1",
|
||||
port: "6379",
|
||||
timeout: 60
|
||||
},
|
||||
// 后端各api接口的sql语句
|
||||
sql: {
|
||||
shop: {
|
||||
index: "select * from shop_commodity ORDER BY id DESC limit ?,?",
|
||||
info: "select * from shop_commodity where id = ?",
|
||||
brand: "select * from shop_commodity where commodity_brand = ?"
|
||||
},
|
||||
order: {
|
||||
addOrder: "insert into shop_order(user_id,commodity_id,order_number,order_status,order_total,order_size) value (?,?,?,?,?,?)",
|
||||
deleteCarts: "delete from shop_cart where user_id = ? and commodity_id = ?",
|
||||
selectOrder: "SELECT user_id,commodity_id,order_number,order_status,order_total,order_size, shop_commodity.* FROM shop_order ,shop_commodity WHERE shop_order.commodity_id = shop_commodity.id AND shop_order.user_id = ? AND shop_order.order_status = ? "
|
||||
},
|
||||
user: {
|
||||
add: "insert into shop_user(user_name,user_pwd,user_nicname) value (?,?,?)",
|
||||
login: "select id,user_name,user_nicname,user_icons,user_money from shop_user where user_name = ? and user_pwd = ?",
|
||||
setAddress: "UPDATE shop_user SET user_truename = ? , user_addres = ? WHERE id = ? ",
|
||||
updateMoney: "UPDATE shop_user SET user_money = ? WHERE id = ? "
|
||||
},
|
||||
cart: {
|
||||
add: "insert into shop_cart(commodity_id,user_id,cart_nums) value (?,?,1)",
|
||||
checkCart: "select * from shop_cart where commodity_id = ? and user_id = ?",
|
||||
selectCart: "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 = ?",
|
||||
deleteCart: "delete from shop_cart where id = ?"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
15
node+vue/shop-bend/config/rsa_private_key.pem
Executable file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQCzkEs/kJgaFGIAM/TQRjzUtJ9ve9enk6heGj/JbcvHVOwFYw2q
|
||||
CNUhuaFE9rYDL+CzX3+cf7inRIJCvSnC0bdGCZ+i943uSudTkqT+guv03jTzvLy2
|
||||
TD+Bp41/ToNiPWG56p1keHE0Gwsr7o0waIcWrLpFJnzyW/fOYQjboRz7nwIDAQAB
|
||||
AoGADgMCfDFSTSauBwoG3oG8mXSGxHJLf74b80vlEljJAAL2b+0s0cnip8EOfo0p
|
||||
4tHHnPekw5eL1zGXYJHWQmeO/3ymZS/nnVq1K5YRM+AtYyUMAiChIt/zWOGXPN6k
|
||||
yUARaTK/cRZNY2XPPDK0H44eLF2RDE/SObPD0BZ0u9m92aECQQDYSIrYw0klyGJe
|
||||
ePaV0+2ZtVVhDYN+eYmWHu9/T+aOIPFS5ePUonBftSfcp7pTeJZ3O/eI/4W6pdzz
|
||||
13MRseUZAkEA1ImPvtbL39A8OtciY16LgDX5O5Vkm5p5+TKRhG5B38bgnOQQHu2d
|
||||
oJKvxjEJcWDfiJ6/ThHsFHqyvViJ+cIFdwJBAIWlpe62FdA8F9UK6EzDLXIq5DxZ
|
||||
rmSL06IpMZM5G12+K4EvP26YhdoORjiKiI+l10yMiLRmOQuSDIu9GYTYqZkCQEQ5
|
||||
/Ij4ju3D/PGuif14JjP8H4u/A1LoHeufDhODCWZ6gzQaCgrDoGwhaoemyi85N8i1
|
||||
nRfErRJN6P7bYz9nxzUCQDC8yEIcgKczxFIo20k4R+CINyJTB5S6dsVW6gmpiHZK
|
||||
6+MWkDut4o/Fibwp4jm5Fh9zau597aP5Xnt8mA2LRc8=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
6
node+vue/shop-bend/config/rsa_public_key.pem
Executable file
@@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzkEs/kJgaFGIAM/TQRjzUtJ9v
|
||||
e9enk6heGj/JbcvHVOwFYw2qCNUhuaFE9rYDL+CzX3+cf7inRIJCvSnC0bdGCZ+i
|
||||
943uSudTkqT+guv03jTzvLy2TD+Bp41/ToNiPWG56p1keHE0Gwsr7o0waIcWrLpF
|
||||
JnzyW/fOYQjboRz7nwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
1
node+vue/shop-bend/db/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
6e1b7194-265c-4144-a2cb-64013f9ccde9
|
||||
37
node+vue/shop-bend/db/index.js
Executable file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* mysql 数据库连接&操作的基础类
|
||||
*/
|
||||
const mysql = require('mysql');
|
||||
const config = require("../config")
|
||||
class DB {
|
||||
constructor() {
|
||||
// 创建数据库链接
|
||||
this.db = mysql.createConnection(config.dev.mysql);
|
||||
// 链接数据库
|
||||
this.db.connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行数据库操作
|
||||
* @param {*string} sql 数据库语句
|
||||
* @param {*array} par sql语句的参数
|
||||
*/
|
||||
query(sql, par = []) {
|
||||
var status;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db.query(sql, par, function (error, results, fields) {
|
||||
if (error) reject(error)
|
||||
results.length == 0 ? resolve({
|
||||
status: config.dev.api.error,
|
||||
data: "没有数据..."
|
||||
}) : resolve({
|
||||
status: config.dev.api.success,
|
||||
data: results
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = new DB()
|
||||
3
node+vue/shop-bend/index.http
Executable file
@@ -0,0 +1,3 @@
|
||||
GET http://127.0.0.1:3000/api/json/shop/index HTTP/1.1
|
||||
content-type: application/json
|
||||
token : "csLYAGBfv5VvkH/R623nXPvoPsVtdielryGPtLGi2VUHyeuHKlmz31aNzbKZm5IXWTA5ek/1O/4JTq11iw3gmJy/eYxdzgZQwMgHx28z/eg7VMs9s8hbN2xa7+/UdTiSjteluqs5Bwk1lMjqWosfphIOagYLU7gE1/l+z494Qxw="
|
||||
14
node+vue/shop-bend/index.js
Executable file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 公共依赖导入
|
||||
*/
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const mysql = require("./db")
|
||||
const utils = require("./utils")
|
||||
const Ver = require("./utils/ver")
|
||||
const redis = require("./cache")
|
||||
const config = require("./config")
|
||||
|
||||
|
||||
|
||||
module.exports = { express, router, mysql, Ver, redis, config, utils }
|
||||
27
node+vue/shop-bend/package.json
Executable file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "shop-bend",
|
||||
"version": "1.2.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "./node_modules/.bin/node-dev ./bin/www",
|
||||
"start": "pm2 start ./bin/www --watch -i max --name be",
|
||||
"restart": "pm2 restart ./bin/www",
|
||||
"stop": "pm2 stop be",
|
||||
"list": "pm2 list",
|
||||
"log": "pm2 logs"
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie-parser": "~1.4.3",
|
||||
"debug": "~2.6.9",
|
||||
"express": "~4.16.0",
|
||||
"http-errors": "~1.6.2",
|
||||
"morgan": "~1.9.0",
|
||||
"node-rsa": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"md5": "^2.2.1",
|
||||
"mysql": "^2.16.0",
|
||||
"node-dev": "^3.1.3",
|
||||
"redis": "^2.8.0"
|
||||
}
|
||||
}
|
||||
1
node+vue/shop-bend/routes/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
e3a7d513-22f1-4c5a-9073-8bad84db8b6c
|
||||