commit 6484af8cd2640579adc8d7c70ca7809a5e5115b7 Author: life <1733802689@qq.com> Date: Thu Nov 2 22:06:52 2023 +0800 SpringBoot简单酒店初始化 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..f4784a0 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..b4f9a48 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..6560a98 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,36 @@ + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..5a2f139 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..88aa9a7 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Finish.iml b/Finish.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/Finish.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/auth/pom.xml b/auth/pom.xml new file mode 100644 index 0000000..eda9963 --- /dev/null +++ b/auth/pom.xml @@ -0,0 +1,33 @@ + + + + Finish + com.wzx + 1.0-SNAPSHOT + + 4.0.0 + + auth + + + + com.wzx + common + 1.0-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + diff --git a/auth/src/main/java/com/bwie/auth/AuthApp.java b/auth/src/main/java/com/bwie/auth/AuthApp.java new file mode 100644 index 0000000..061e21c --- /dev/null +++ b/auth/src/main/java/com/bwie/auth/AuthApp.java @@ -0,0 +1,14 @@ +package com.bwie.auth; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@EnableFeignClients +public class AuthApp { + public static void main(String[] args) { + SpringApplication.run(AuthApp.class); + } +} diff --git a/auth/src/main/java/com/bwie/auth/controller/AuthController.java b/auth/src/main/java/com/bwie/auth/controller/AuthController.java new file mode 100644 index 0000000..3d83914 --- /dev/null +++ b/auth/src/main/java/com/bwie/auth/controller/AuthController.java @@ -0,0 +1,49 @@ +package com.bwie.auth.controller; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.auth.service.AuthService; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.RequestUser; +import com.bwie.common.domain.response.ResponseUser; +import com.bwie.common.result.Result; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +@RestController +@Log4j2 +public class AuthController { + + @Autowired + private AuthService authService; + + @Autowired + private HttpServletRequest request; + + /** + * 登录认证 + * @param requestUser + * @return + */ + @PostMapping("/login") + public Result login(@RequestBody RequestUser requestUser){ + log.info("功能名称:登录认证,请求URI:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(requestUser)); + Result result=authService.login(requestUser); + log.info("功能名称:登录认证,请求URI:{},请求方式:{},返回结果:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(result)); + return result; + } + + @GetMapping("/user/info") + public Result userInfo(){ + Result result=authService.userInfo(); + return result; + } + +} diff --git a/auth/src/main/java/com/bwie/auth/feign/AuthFeign.java b/auth/src/main/java/com/bwie/auth/feign/AuthFeign.java new file mode 100644 index 0000000..1c43136 --- /dev/null +++ b/auth/src/main/java/com/bwie/auth/feign/AuthFeign.java @@ -0,0 +1,19 @@ +package com.bwie.auth.feign; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.RequestUser; +import com.bwie.common.result.Result; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@FeignClient("system") +public interface AuthFeign { + /** + * 根据账号密码查询用户信息 + * @param requestUser + * @return + */ + @PostMapping("/user/findByRequestUser") + public Result findByRequestUser(@RequestBody RequestUser requestUser); +} diff --git a/auth/src/main/java/com/bwie/auth/service/AuthService.java b/auth/src/main/java/com/bwie/auth/service/AuthService.java new file mode 100644 index 0000000..d151036 --- /dev/null +++ b/auth/src/main/java/com/bwie/auth/service/AuthService.java @@ -0,0 +1,13 @@ +package com.bwie.auth.service; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.RequestUser; +import com.bwie.common.domain.response.ResponseUser; +import com.bwie.common.result.Result; + +public interface AuthService { + Result login(RequestUser requestUser); + + Result userInfo(); + +} diff --git a/auth/src/main/java/com/bwie/auth/service/Impl/AuthServiceImpl.java b/auth/src/main/java/com/bwie/auth/service/Impl/AuthServiceImpl.java new file mode 100644 index 0000000..bec4a4c --- /dev/null +++ b/auth/src/main/java/com/bwie/auth/service/Impl/AuthServiceImpl.java @@ -0,0 +1,83 @@ +package com.bwie.auth.service.Impl; + +import com.alibaba.fastjson.JSONObject; + +import com.bwie.auth.feign.AuthFeign; +import com.bwie.auth.service.AuthService; +import com.bwie.common.constants.JwtConstants; +import com.bwie.common.constants.TokenConstants; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.RequestUser; +import com.bwie.common.domain.response.ResponseUser; +import com.bwie.common.result.Result; +import com.bwie.common.utils.JwtUtils; +import com.bwie.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +@Service +public class AuthServiceImpl implements AuthService { + + @Autowired + private AuthFeign authFeign; + + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private HttpServletRequest request; + + @Override + public Result login(RequestUser requestUser) { + //判断账号密码是否为空 + if (StringUtils.isAnyEmpty(requestUser.getUsername(),requestUser.getPassword())){ + return Result.error("账号密码不能为空"); + } + //判断账号是否注册 + Result byRequestUser = authFeign.findByRequestUser(requestUser); + User data = byRequestUser.getData(); + if (null==data){ + return Result.error("账号未注册"); + } + //判断密码是否正确 + String password = data.getPassword(); + if (!password.equals(requestUser.getPassword())){ + return Result.error("密码错误"); + } + //生成userKey + String userKey = UUID.randomUUID().toString().replaceAll("-", ""); + //生成token + HashMap map = new HashMap<>(); + map.put(JwtConstants.DETAILS_USER_ID,data.getUserId()); + map.put(JwtConstants.USER_KEY,userKey); + String token = JwtUtils.createToken(map); + //存入redis + redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey, JSONObject.toJSONString(data),15, TimeUnit.MINUTES); + //赋值 + ResponseUser responseUser = new ResponseUser(); + responseUser.setToken(token); + responseUser.setExprieTime("15MIN"); + + return Result.success(responseUser); + } + + @Override + public Result userInfo() { + //获取token + String token = request.getHeader(TokenConstants.TOKEN); + //获取userKey + String userKey = JwtUtils.getUserKey(token); + //获取用户信息 + String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey); + //反序列化 + User user= JSONObject.parseObject(s, User.class); + + return Result.success(user); + } +} diff --git a/auth/src/main/resources/bootstrap.yml b/auth/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..5e6b042 --- /dev/null +++ b/auth/src/main/resources/bootstrap.yml @@ -0,0 +1,32 @@ +# Tomcat +server: + port: 9001 +# Spring +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: auth + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.221.214.183:8848 + namespace: lc + config: + # 配置中心地址 + server-addr: 124.221.214.183:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + namespace: lc + diff --git a/auth/target/auth-1.0-SNAPSHOT.jar b/auth/target/auth-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..9a6120e Binary files /dev/null and b/auth/target/auth-1.0-SNAPSHOT.jar differ diff --git a/auth/target/classes/bootstrap.yml b/auth/target/classes/bootstrap.yml new file mode 100644 index 0000000..5e6b042 --- /dev/null +++ b/auth/target/classes/bootstrap.yml @@ -0,0 +1,32 @@ +# Tomcat +server: + port: 9001 +# Spring +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: auth + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.221.214.183:8848 + namespace: lc + config: + # 配置中心地址 + server-addr: 124.221.214.183:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + namespace: lc + diff --git a/auth/target/classes/com/bwie/auth/AuthApp.class b/auth/target/classes/com/bwie/auth/AuthApp.class new file mode 100644 index 0000000..b1fbefd Binary files /dev/null and b/auth/target/classes/com/bwie/auth/AuthApp.class differ diff --git a/auth/target/classes/com/bwie/auth/controller/AuthController.class b/auth/target/classes/com/bwie/auth/controller/AuthController.class new file mode 100644 index 0000000..0e124fe Binary files /dev/null and b/auth/target/classes/com/bwie/auth/controller/AuthController.class differ diff --git a/auth/target/classes/com/bwie/auth/feign/AuthFeign.class b/auth/target/classes/com/bwie/auth/feign/AuthFeign.class new file mode 100644 index 0000000..831b246 Binary files /dev/null and b/auth/target/classes/com/bwie/auth/feign/AuthFeign.class differ diff --git a/auth/target/classes/com/bwie/auth/service/AuthService.class b/auth/target/classes/com/bwie/auth/service/AuthService.class new file mode 100644 index 0000000..72aecc9 Binary files /dev/null and b/auth/target/classes/com/bwie/auth/service/AuthService.class differ diff --git a/auth/target/classes/com/bwie/auth/service/Impl/AuthServiceImpl.class b/auth/target/classes/com/bwie/auth/service/Impl/AuthServiceImpl.class new file mode 100644 index 0000000..f70554e Binary files /dev/null and b/auth/target/classes/com/bwie/auth/service/Impl/AuthServiceImpl.class differ diff --git a/auth/target/maven-archiver/pom.properties b/auth/target/maven-archiver/pom.properties new file mode 100644 index 0000000..f6c78d3 --- /dev/null +++ b/auth/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=auth +groupId=com.wzx +version=1.0-SNAPSHOT diff --git a/auth/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/auth/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..483722a --- /dev/null +++ b/auth/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,5 @@ +com\bwie\auth\feign\AuthFeign.class +com\bwie\auth\service\Impl\AuthServiceImpl.class +com\bwie\auth\controller\AuthController.class +com\bwie\auth\AuthApp.class +com\bwie\auth\service\AuthService.class diff --git a/auth/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/auth/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..b77e70c --- /dev/null +++ b/auth/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,5 @@ +D:\Project\Finish\auth\src\main\java\com\bwie\auth\service\AuthService.java +D:\Project\Finish\auth\src\main\java\com\bwie\auth\service\Impl\AuthServiceImpl.java +D:\Project\Finish\auth\src\main\java\com\bwie\auth\feign\AuthFeign.java +D:\Project\Finish\auth\src\main\java\com\bwie\auth\AuthApp.java +D:\Project\Finish\auth\src\main\java\com\bwie\auth\controller\AuthController.java diff --git a/auth/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/auth/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/auth/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/auth/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 0000000..a2904f9 --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,119 @@ + + + + Finish + com.wzx + 1.0-SNAPSHOT + + 4.0.0 + + common + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + io.jsonwebtoken + jjwt + 0.9.1 + + + + com.alibaba + fastjson + 1.2.80 + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + org.springframework.boot + spring-boot-starter-validation + + + + org.apache.commons + commons-lang3 + + + + org.projectlombok + lombok + + + + cn.hutool + hutool-all + 5.8.3 + + + + com.aliyun + dysmsapi20170525 + 2.0.1 + + + + + org.apache.httpcomponents + httpclient + 4.2.1 + + + org.apache.httpcomponents + httpcore + 4.2.1 + + + commons-lang + commons-lang + 2.6 + + + org.eclipse.jetty + jetty-util + 9.3.7.v20160115 + + + + + com.github.tobato + fastdfs-client + 1.26.5 + + + + diff --git a/common/src/main/java/com/bwie/common/constants/Constants.java b/common/src/main/java/com/bwie/common/constants/Constants.java new file mode 100644 index 0000000..2fdc9fe --- /dev/null +++ b/common/src/main/java/com/bwie/common/constants/Constants.java @@ -0,0 +1,18 @@ +package com.bwie.common.constants; + +/** + * @description: 系统常量 + * @author DongZl + */ +public class Constants { + /** + * 成功标记 + */ + public static final Integer SUCCESS = 200; + public static final String SUCCESS_MSG = "操作成功"; + /** + * 失败标记 + */ + public static final Integer ERROR = 500; + public static final String ERROR_MSG = "操作异常"; +} diff --git a/common/src/main/java/com/bwie/common/constants/JwtConstants.java b/common/src/main/java/com/bwie/common/constants/JwtConstants.java new file mode 100644 index 0000000..03692c1 --- /dev/null +++ b/common/src/main/java/com/bwie/common/constants/JwtConstants.java @@ -0,0 +1,29 @@ +package com.bwie.common.constants; + +/** + * @author DongZl + * @description: Jwt常量 + */ +public class JwtConstants { + + /** + * 用户ID字段 + */ + public static final String DETAILS_USER_ID = "user_id"; + + /** + * 用户名字段 + */ + public static final String DETAILS_USERNAME = "username"; + + /** + * 用户标识 + */ + public static final String USER_KEY = "user_key"; + + /** + * 令牌秘钥 + */ + public final static String SECRET = "abcdefghijklmnopqrstuvwxyz"; + +} diff --git a/common/src/main/java/com/bwie/common/constants/RabbitMQConstants.java b/common/src/main/java/com/bwie/common/constants/RabbitMQConstants.java new file mode 100644 index 0000000..ad4b095 --- /dev/null +++ b/common/src/main/java/com/bwie/common/constants/RabbitMQConstants.java @@ -0,0 +1,9 @@ +package com.bwie.common.constants; + +/** + * @author WangTangDong + * @date 2023/7/28 20:04 + */ +public class RabbitMQConstants { + public static final String SEND_CODE="send_code"; +} diff --git a/common/src/main/java/com/bwie/common/constants/TokenConstants.java b/common/src/main/java/com/bwie/common/constants/TokenConstants.java new file mode 100644 index 0000000..1871fb7 --- /dev/null +++ b/common/src/main/java/com/bwie/common/constants/TokenConstants.java @@ -0,0 +1,24 @@ +package com.bwie.common.constants; + +/** + * @author DongZl + * @description: 令牌常量 + */ +public class TokenConstants { + /** + * 缓存有效期,默认720(分钟) + */ + public final static long EXPIRATION = 720; + /** + * 缓存刷新时间,默认120(分钟) + */ + public final static long REFRESH_TIME = 120; + /** + * 权限缓存前缀 + */ + public final static String LOGIN_TOKEN_KEY = "login_tokens:"; + /** + * token标识 + */ + public static final String TOKEN = "token"; +} diff --git a/common/src/main/java/com/bwie/common/domain/Hotel.java b/common/src/main/java/com/bwie/common/domain/Hotel.java new file mode 100644 index 0000000..82d7b69 --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/Hotel.java @@ -0,0 +1,15 @@ +package com.bwie.common.domain; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class Hotel { + private Integer id; + private String name; + private BigDecimal price; + private String pic; + private Integer number; + private Integer status; +} diff --git a/common/src/main/java/com/bwie/common/domain/Menu.java b/common/src/main/java/com/bwie/common/domain/Menu.java new file mode 100644 index 0000000..49cd815 --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/Menu.java @@ -0,0 +1,13 @@ +package com.bwie.common.domain; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class Menu { + private Integer menuId; + private String menuName; + private BigDecimal menuPrice; + private String pic; +} diff --git a/common/src/main/java/com/bwie/common/domain/MyMenu.java b/common/src/main/java/com/bwie/common/domain/MyMenu.java new file mode 100644 index 0000000..c446158 --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/MyMenu.java @@ -0,0 +1,13 @@ +package com.bwie.common.domain; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class MyMenu { + private Integer myId; + public Integer userId; + public Integer menuId; + public BigDecimal pay; +} diff --git a/common/src/main/java/com/bwie/common/domain/Order.java b/common/src/main/java/com/bwie/common/domain/Order.java new file mode 100644 index 0000000..6e509bc --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/Order.java @@ -0,0 +1,14 @@ +package com.bwie.common.domain; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class Order { + private Integer orderId; + private String orderCard; + private String name; + private BigDecimal price; + private Integer userId; +} diff --git a/common/src/main/java/com/bwie/common/domain/Stay.java b/common/src/main/java/com/bwie/common/domain/Stay.java new file mode 100644 index 0000000..27b65c9 --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/Stay.java @@ -0,0 +1,18 @@ +package com.bwie.common.domain; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class Stay { + private Integer sayId; + private String username; + private String phone; + private String card; + private String name; + private BigDecimal price; + private Integer dayNumber; + private BigDecimal totalPrice; + +} diff --git a/common/src/main/java/com/bwie/common/domain/User.java b/common/src/main/java/com/bwie/common/domain/User.java new file mode 100644 index 0000000..bbf00ba --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/User.java @@ -0,0 +1,16 @@ +package com.bwie.common.domain; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class User { + private Integer userId; + private String username; + private String password; + private String phone; + private BigDecimal balance; + private Integer roleId; + private String roleName; +} diff --git a/common/src/main/java/com/bwie/common/domain/request/QueryHotel.java b/common/src/main/java/com/bwie/common/domain/request/QueryHotel.java new file mode 100644 index 0000000..58baf41 --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/request/QueryHotel.java @@ -0,0 +1,16 @@ +package com.bwie.common.domain.request; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class QueryHotel { + //分页 + private Integer pageNum=1; + private Integer pageSize=2; + //条件查询 + private BigDecimal priceA; + private BigDecimal priceB; + private Integer status; +} diff --git a/common/src/main/java/com/bwie/common/domain/request/RequestUser.java b/common/src/main/java/com/bwie/common/domain/request/RequestUser.java new file mode 100644 index 0000000..f05042f --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/request/RequestUser.java @@ -0,0 +1,9 @@ +package com.bwie.common.domain.request; + +import lombok.Data; + +@Data +public class RequestUser { + private String username; + private String password; +} diff --git a/common/src/main/java/com/bwie/common/domain/response/ResponseHotel.java b/common/src/main/java/com/bwie/common/domain/response/ResponseHotel.java new file mode 100644 index 0000000..fbd952c --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/response/ResponseHotel.java @@ -0,0 +1,15 @@ +package com.bwie.common.domain.response; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class ResponseHotel { + private Integer id; + private String name; + private BigDecimal price; + private String pic; + private Integer number; + private Integer status; +} diff --git a/common/src/main/java/com/bwie/common/domain/response/ResponseUser.java b/common/src/main/java/com/bwie/common/domain/response/ResponseUser.java new file mode 100644 index 0000000..51b037d --- /dev/null +++ b/common/src/main/java/com/bwie/common/domain/response/ResponseUser.java @@ -0,0 +1,9 @@ +package com.bwie.common.domain.response; + +import lombok.Data; + +@Data +public class ResponseUser { + private String token; + private String exprieTime; +} diff --git a/common/src/main/java/com/bwie/common/result/PageResult.java b/common/src/main/java/com/bwie/common/result/PageResult.java new file mode 100644 index 0000000..85ecdda --- /dev/null +++ b/common/src/main/java/com/bwie/common/result/PageResult.java @@ -0,0 +1,34 @@ +package com.bwie.common.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author DongZl + * @description: 列表返回结果集 + */ +@Data +public class PageResult implements Serializable { + /** + * 总条数 + */ + private long total; + /** + * 结果集合 + */ + private List list; + public PageResult() { + } + public PageResult(long total, List list) { + this.total = total; + this.list = list; + } + public static PageResult toPageResult(long total, List list){ + return new PageResult(total , list); + } + public static Result> toResult(long total, List list){ + return Result.success(PageResult.toPageResult(total,list)); + } +} diff --git a/common/src/main/java/com/bwie/common/result/Result.java b/common/src/main/java/com/bwie/common/result/Result.java new file mode 100644 index 0000000..30b1e73 --- /dev/null +++ b/common/src/main/java/com/bwie/common/result/Result.java @@ -0,0 +1,76 @@ +package com.bwie.common.result; + +import com.bwie.common.constants.Constants; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author DongZl + * @description: 响应信息主体 + */ +@Data +public class Result implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 成功 + */ + public static final int SUCCESS = Constants.SUCCESS; + /** + * 失败 + */ + public static final int FAIL = Constants.ERROR; + /** + * 返回状态码 + */ + private int code; + /** + * 响应信息 + */ + private String msg; + /** + * 响应数据 + */ + private T data; + + public static Result success() { + return restResult(null, SUCCESS, Constants.SUCCESS_MSG); + } + + public static Result success(T data) { + return restResult(data, SUCCESS, Constants.SUCCESS_MSG); + } + + public static Result success(T data, String msg) { + return restResult(data, SUCCESS, msg); + } + + public static Result error() { + return restResult(null, FAIL, Constants.ERROR_MSG); + } + + public static Result error(String msg) { + return restResult(null, FAIL, msg); + } + + public static Result error(T data) { + return restResult(data, FAIL, Constants.ERROR_MSG); + } + + public static Result error(T data, String msg) { + return restResult(data, FAIL, msg); + } + + public static Result error(int code, String msg) { + return restResult(null, code, msg); + } + + private static Result restResult(T data, int code, String msg) { + Result apiResult = new Result<>(); + apiResult.setCode(code); + apiResult.setData(data); + apiResult.setMsg(msg); + return apiResult; + } +} diff --git a/common/src/main/java/com/bwie/common/utils/FastUtil.java b/common/src/main/java/com/bwie/common/utils/FastUtil.java new file mode 100644 index 0000000..9fe9f9b --- /dev/null +++ b/common/src/main/java/com/bwie/common/utils/FastUtil.java @@ -0,0 +1,56 @@ +package com.bwie.common.utils; + +import org.springframework.stereotype.Component; +import com.github.tobato.fastdfs.domain.fdfs.StorePath; +import com.github.tobato.fastdfs.service.FastFileStorageClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +/** + * @BelongsProject: 0107day02 + * @BelongsPackage: com.bw.config + * @Author: zhupengfei + * @CreateTime: 2023-02-01 08:52 + */ +@Component +public class FastUtil { + private static final Logger log = LoggerFactory.getLogger(FastUtil.class); + + @Resource + private FastFileStorageClient storageClient ; + + /** + * 上传文件 + */ + public String upload(MultipartFile multipartFile) throws Exception{ + String originalFilename = multipartFile.getOriginalFilename(). + substring(multipartFile.getOriginalFilename(). + lastIndexOf(".") + 1); + StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage( + multipartFile.getInputStream(), + multipartFile.getSize(),originalFilename , null); + return storePath.getFullPath() ; + } + /** + * 删除文件 + */ + public String deleteFile(String fileUrl) { + if (StringUtils.isEmpty(fileUrl)) { + log.info("fileUrl == >>文件路径为空..."); + return "文件路径不能为空"; + } + try { + StorePath storePath = StorePath.parseFromUrl(fileUrl); + storageClient.deleteFile(storePath.getGroup(), storePath.getPath()); + } catch (Exception e) { + log.error(e.getMessage()); + } + return "删除成功"; + } + +} diff --git a/common/src/main/java/com/bwie/common/utils/HttpUtils.java b/common/src/main/java/com/bwie/common/utils/HttpUtils.java new file mode 100644 index 0000000..e15968b --- /dev/null +++ b/common/src/main/java/com/bwie/common/utils/HttpUtils.java @@ -0,0 +1,319 @@ +package com.bwie.common.utils; + +import com.alibaba.fastjson.JSON; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class HttpUtils { + + /** + * get + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @return + * @throws Exception + */ + public static List doGet(String host, String path, String method, + Map headers, + Map querys + ,Class clazz) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpGet request = new HttpGet(buildUrl(host, path, querys)); + if(headers!=null){ + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + } + HttpResponse execute = httpClient.execute(request); + String s = EntityUtils.toString(execute.getEntity(),"UTF-8"); + List ts = JSON.parseArray(s, clazz); + return ts; + } + + /** + * post form + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param bodys + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + Map bodys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (bodys != null) { + List nameValuePairList = new ArrayList(); + + for (String key : bodys.keySet()) { + nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key))); + } + UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8"); + formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8"); + request.setEntity(formEntity); + } + + return httpClient.execute(request); + } + + /** + * Post String + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + String body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (StringUtils.isNotBlank(body)) { + request.setEntity(new StringEntity(body, "utf-8")); + } + + return httpClient.execute(request); + } + + /** + * Post stream + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + byte[] body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (body != null) { + request.setEntity(new ByteArrayEntity(body)); + } + + return httpClient.execute(request); + } + + /** + * Put String + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPut(String host, String path, String method, + Map headers, + Map querys, + String body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPut request = new HttpPut(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (StringUtils.isNotBlank(body)) { + request.setEntity(new StringEntity(body, "utf-8")); + } + + return httpClient.execute(request); + } + + /** + * Put stream + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPut(String host, String path, String method, + Map headers, + Map querys, + byte[] body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPut request = new HttpPut(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (body != null) { + request.setEntity(new ByteArrayEntity(body)); + } + + return httpClient.execute(request); + } + + /** + * Delete + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @return + * @throws Exception + */ + public static HttpResponse doDelete(String host, String path, String method, + Map headers, + Map querys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpDelete request = new HttpDelete(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + return httpClient.execute(request); + } + + private static String buildUrl(String host, String path, Map querys) throws UnsupportedEncodingException { + StringBuilder sbUrl = new StringBuilder(); + sbUrl.append(host); + if (!StringUtils.isBlank(path)) { + sbUrl.append(path); + } + if (null != querys) { + StringBuilder sbQuery = new StringBuilder(); + for (Map.Entry query : querys.entrySet()) { + if (0 < sbQuery.length()) { + sbQuery.append("&"); + } + if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) { + sbQuery.append(query.getValue()); + } + if (!StringUtils.isBlank(query.getKey())) { + sbQuery.append(query.getKey()); + if (!StringUtils.isBlank(query.getValue())) { + sbQuery.append("="); + sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8")); + } + } + } + if (0 < sbQuery.length()) { + sbUrl.append("?").append(sbQuery); + } + } + + return sbUrl.toString(); + } + + private static HttpClient wrapClient(String host) { + HttpClient httpClient = new DefaultHttpClient(); + if (host.startsWith("https://")) { + sslClient(httpClient); + } + + return httpClient; + } + + private static void sslClient(HttpClient httpClient) { + try { + SSLContext ctx = SSLContext.getInstance("TLS"); + X509TrustManager tm = new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted(X509Certificate[] xcs, String str) { + + } + public void checkServerTrusted(X509Certificate[] xcs, String str) { + + } + }; + ctx.init(null, new TrustManager[] { tm }, null); + SSLSocketFactory ssf = new SSLSocketFactory(ctx); + ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + ClientConnectionManager ccm = httpClient.getConnectionManager(); + SchemeRegistry registry = ccm.getSchemeRegistry(); + registry.register(new Scheme("https", 443, ssf)); + } catch (KeyManagementException ex) { + throw new RuntimeException(ex); + } catch (NoSuchAlgorithmException ex) { + throw new RuntimeException(ex); + } + } +} \ No newline at end of file diff --git a/common/src/main/java/com/bwie/common/utils/JwtUtils.java b/common/src/main/java/com/bwie/common/utils/JwtUtils.java new file mode 100644 index 0000000..f560aa9 --- /dev/null +++ b/common/src/main/java/com/bwie/common/utils/JwtUtils.java @@ -0,0 +1,109 @@ +package com.bwie.common.utils; + +import com.bwie.common.constants.JwtConstants; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import java.util.Map; + +/** + * @description: Jwt工具类 + * @author DongZl + */ +public class JwtUtils { + + /** + * 秘钥 + */ + public static String secret = JwtConstants.SECRET; + + /** + * 从数据声明生成令牌 + * + * @param claims 数据声明 + * @return 令牌 + */ + public static String createToken(Map claims){ + String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact(); + return token; + } + + /** + * 从令牌中获取数据声明 + * + * @param token 令牌 + * @return 数据声明 + */ + public static Claims parseToken(String token){ + return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody(); + } + /** + * 根据令牌获取用户标识 + * + * @param token 令牌 + * @return 用户ID + */ + public static String getUserKey(String token){ + Claims claims = parseToken(token); + return getValue(claims, JwtConstants.USER_KEY); + } + /** + * 根据令牌获取用户标识 + * + * @param claims 身份信息 + * @return 用户ID + */ + public static String getUserKey(Claims claims){ + return getValue(claims, JwtConstants.USER_KEY); + } + /** + * 根据令牌获取用户ID + * + * @param token 令牌 + * @return 用户ID + */ + public static String getUserId(String token){ + Claims claims = parseToken(token); + return getValue(claims, JwtConstants.DETAILS_USER_ID); + } + /** + * 根据身份信息获取用户ID + * + * @param claims 身份信息 + * @return 用户ID + */ + public static String getUserId(Claims claims){ + return getValue(claims, JwtConstants.DETAILS_USER_ID); + } + /** + * 根据令牌获取用户名 + * + * @param token 令牌 + * @return 用户名 + */ + public static String getUserName(String token){ + Claims claims = parseToken(token); + return getValue(claims, JwtConstants.DETAILS_USERNAME); + } + /** + * 根据身份信息获取用户名 + * + * @param claims 身份信息 + * @return 用户名 + */ + public static String getUserName(Claims claims){ + return getValue(claims, JwtConstants.DETAILS_USERNAME); + } + /** + * 根据身份信息获取键值 + * + * @param claims 身份信息 + * @param key 键 + * @return 值 + */ + public static String getValue(Claims claims, String key){ + Object obj = claims.get(key); + return obj == null ? "" : obj.toString(); + } +} diff --git a/common/src/main/java/com/bwie/common/utils/MsgUtil.java b/common/src/main/java/com/bwie/common/utils/MsgUtil.java new file mode 100644 index 0000000..e672bc1 --- /dev/null +++ b/common/src/main/java/com/bwie/common/utils/MsgUtil.java @@ -0,0 +1,58 @@ +package com.bwie.common.utils; + + +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; +import org.springframework.cache.annotation.CachePut; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author + * @version 1.0.0 + * @ClassName MsgUtil.java + * @Description TODO + * @createTime 2022年05月26日 15:49:00 + */ +public class MsgUtil { + + + public static void sendMsg(String phone,String code){ + String host = "https://gyytz.market.alicloudapi.com"; + String path = "/sms/smsSend"; + String method = "POST"; + String appcode = "d742f8e74e03432f92eec7267b919ee"; + Map headers = new HashMap(); + //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 + headers.put("Authorization", "APPCODE " + appcode); + Map querys = new HashMap(); + querys.put("mobile", phone); + querys.put("param", "**code**:"+code+",**minute**:5"); + +//smsSignId(短信前缀)和templateId(短信模板),可登录国阳云控制台自助申请。参考文档:http://help.guoyangyun.com/Problem/Qm.html + + querys.put("smsSignId", "2e65b1bb3d054466b82f0c9d125465e2"); + querys.put("templateId", "908e94ccf08b4476ba6c876d13f084ad"); + Map bodys = new HashMap(); + + + try { + /** + * 重要提示如下: + * HttpUtils请从\r\n\t \t* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java\r\n\t \t* 下载 + * + * 相应的依赖请参照 + * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml + */ + HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys); + System.out.println(response.toString()); + //获取response的body + System.out.println(EntityUtils.toString(response.getEntity())); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/common/src/main/java/com/bwie/common/utils/StringUtils.java b/common/src/main/java/com/bwie/common/utils/StringUtils.java new file mode 100644 index 0000000..93c47fd --- /dev/null +++ b/common/src/main/java/com/bwie/common/utils/StringUtils.java @@ -0,0 +1,68 @@ +package com.bwie.common.utils; + +import org.springframework.util.AntPathMatcher; + +import java.util.Collection; +import java.util.List; + +/** + * @author DongZl + * @description: 字符串处理工具类 + */ +public class StringUtils extends org.apache.commons.lang3.StringUtils { + + /** + * * 判断一个对象是否为空 + * + * @param object Object + * @return true:为空 false:非空 + */ + public static boolean isNull(Object object) { + return object == null; + } + + /** + * * 判断一个Collection是否为空, 包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Collection coll) { + return isNull(coll) || coll.isEmpty(); + } + + /** + * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串 + * + * @param str 指定字符串 + * @param strs 需要检查的字符串数组 + * @return 是否匹配 + */ + public static boolean matches(String str, List strs) { + if (isEmpty(str) || isEmpty(strs)) { + return false; + } + for (String pattern : strs) { + if (isMatch(pattern, str)) + { + return true; + } + } + return false; + } + + /** + * 判断url是否与规则配置: + * ? 表示单个字符; + * * 表示一层路径内的任意字符串,不可跨层级; + * ** 表示任意层路径; + * + * @param pattern 匹配规则 + * @param url 需要匹配的url + * @return + */ + public static boolean isMatch(String pattern, String url) { + AntPathMatcher matcher = new AntPathMatcher(); + return matcher.match(pattern, url); + } +} diff --git a/common/src/main/java/com/bwie/common/utils/TelSmsUtils.java b/common/src/main/java/com/bwie/common/utils/TelSmsUtils.java new file mode 100644 index 0000000..49e8c81 --- /dev/null +++ b/common/src/main/java/com/bwie/common/utils/TelSmsUtils.java @@ -0,0 +1,87 @@ +package com.bwie.common.utils; + +import com.alibaba.fastjson.JSONObject; +import com.aliyun.dysmsapi20170525.Client; +import com.aliyun.dysmsapi20170525.models.SendSmsRequest; +import com.aliyun.dysmsapi20170525.models.SendSmsResponse; +import com.aliyun.teaopenapi.models.Config; +import lombok.extern.log4j.Log4j2; + +import java.util.Map; + +/** + * 短信工具类 + */ +@Log4j2 +public class TelSmsUtils { + + /** + * 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 + */ + private static String accessKeyId = "LTAIEVXszCmcd1T5"; + private static String accessKeySecret = "2zHwciQXln8wExSEnkIYtRTSwLeRNd"; + + /** + * 短信访问域名 + */ + private static String endpoint = "dysmsapi.aliyuncs.com"; + /** + * 短信签名 + */ + private static String signName = "登录验证"; + + /** + * 实例化短信对象 + */ + private static Client client; + + static { + log.info("初始化短信服务开始"); + long startTime = System.currentTimeMillis(); + try { + client = initClient(); + log.info("初始化短信成功:{}",signName); + } catch (Exception e) { + e.printStackTrace(); + } + log.info("初始化短信服务结束:耗时:{}MS",(System.currentTimeMillis()-startTime)); + } + /** + * 初始化短信对象 + * @return + * @throws Exception + */ + private static Client initClient() throws Exception{ + Config config = new Config() + // 您的AccessKey ID + .setAccessKeyId(accessKeyId) + // 您的AccessKey Secret + .setAccessKeySecret(accessKeySecret); + // 访问的域名 + config.endpoint = endpoint; + return new Client(config); + } + + /** + * 发送单条短信 + * @param tel + * @param templateCode SMS_153991546 + * @param sendDataMap + */ + public static String sendSms(String tel , String templateCode , Map sendDataMap){ + SendSmsRequest sendSmsRequest = new SendSmsRequest() + .setPhoneNumbers(tel) + .setSignName(signName) + .setTemplateCode(templateCode) + .setTemplateParam(JSONObject.toJSONString(sendDataMap)); + SendSmsResponse sendSmsResponse = null; + try { + log.info("发送短信验证码:消息内容是:【{}】", JSONObject.toJSONString(sendDataMap)); + sendSmsResponse = client.sendSms(sendSmsRequest); + } catch (Exception e) { + log.error("短信发送异常,手机号:【{}】,短信内容:【{}】,异常信息:【{}】", tel, sendDataMap, e); + } + return JSONObject.toJSONString(sendSmsResponse.getBody()); + } + +} diff --git a/common/target/classes/com/bwie/common/constants/Constants.class b/common/target/classes/com/bwie/common/constants/Constants.class new file mode 100644 index 0000000..a46a3e2 Binary files /dev/null and b/common/target/classes/com/bwie/common/constants/Constants.class differ diff --git a/common/target/classes/com/bwie/common/constants/JwtConstants.class b/common/target/classes/com/bwie/common/constants/JwtConstants.class new file mode 100644 index 0000000..3ff632f Binary files /dev/null and b/common/target/classes/com/bwie/common/constants/JwtConstants.class differ diff --git a/common/target/classes/com/bwie/common/constants/RabbitMQConstants.class b/common/target/classes/com/bwie/common/constants/RabbitMQConstants.class new file mode 100644 index 0000000..dd3e07b Binary files /dev/null and b/common/target/classes/com/bwie/common/constants/RabbitMQConstants.class differ diff --git a/common/target/classes/com/bwie/common/constants/TokenConstants.class b/common/target/classes/com/bwie/common/constants/TokenConstants.class new file mode 100644 index 0000000..725bfe5 Binary files /dev/null and b/common/target/classes/com/bwie/common/constants/TokenConstants.class differ diff --git a/common/target/classes/com/bwie/common/domain/Hotel.class b/common/target/classes/com/bwie/common/domain/Hotel.class new file mode 100644 index 0000000..34402e4 Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/Hotel.class differ diff --git a/common/target/classes/com/bwie/common/domain/Menu.class b/common/target/classes/com/bwie/common/domain/Menu.class new file mode 100644 index 0000000..d07e083 Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/Menu.class differ diff --git a/common/target/classes/com/bwie/common/domain/MyMenu.class b/common/target/classes/com/bwie/common/domain/MyMenu.class new file mode 100644 index 0000000..602ef45 Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/MyMenu.class differ diff --git a/common/target/classes/com/bwie/common/domain/Order.class b/common/target/classes/com/bwie/common/domain/Order.class new file mode 100644 index 0000000..85fb0bd Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/Order.class differ diff --git a/common/target/classes/com/bwie/common/domain/Stay.class b/common/target/classes/com/bwie/common/domain/Stay.class new file mode 100644 index 0000000..4dc787d Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/Stay.class differ diff --git a/common/target/classes/com/bwie/common/domain/User.class b/common/target/classes/com/bwie/common/domain/User.class new file mode 100644 index 0000000..169e852 Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/User.class differ diff --git a/common/target/classes/com/bwie/common/domain/request/QueryHotel.class b/common/target/classes/com/bwie/common/domain/request/QueryHotel.class new file mode 100644 index 0000000..9a1396d Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/request/QueryHotel.class differ diff --git a/common/target/classes/com/bwie/common/domain/request/RequestUser.class b/common/target/classes/com/bwie/common/domain/request/RequestUser.class new file mode 100644 index 0000000..3edea42 Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/request/RequestUser.class differ diff --git a/common/target/classes/com/bwie/common/domain/response/ResponseHotel.class b/common/target/classes/com/bwie/common/domain/response/ResponseHotel.class new file mode 100644 index 0000000..8f8510b Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/response/ResponseHotel.class differ diff --git a/common/target/classes/com/bwie/common/domain/response/ResponseUser.class b/common/target/classes/com/bwie/common/domain/response/ResponseUser.class new file mode 100644 index 0000000..4e29fdf Binary files /dev/null and b/common/target/classes/com/bwie/common/domain/response/ResponseUser.class differ diff --git a/common/target/classes/com/bwie/common/result/PageResult.class b/common/target/classes/com/bwie/common/result/PageResult.class new file mode 100644 index 0000000..60141ad Binary files /dev/null and b/common/target/classes/com/bwie/common/result/PageResult.class differ diff --git a/common/target/classes/com/bwie/common/result/Result.class b/common/target/classes/com/bwie/common/result/Result.class new file mode 100644 index 0000000..920f38b Binary files /dev/null and b/common/target/classes/com/bwie/common/result/Result.class differ diff --git a/common/target/classes/com/bwie/common/utils/FastUtil.class b/common/target/classes/com/bwie/common/utils/FastUtil.class new file mode 100644 index 0000000..3e6e463 Binary files /dev/null and b/common/target/classes/com/bwie/common/utils/FastUtil.class differ diff --git a/common/target/classes/com/bwie/common/utils/HttpUtils$1.class b/common/target/classes/com/bwie/common/utils/HttpUtils$1.class new file mode 100644 index 0000000..252829d Binary files /dev/null and b/common/target/classes/com/bwie/common/utils/HttpUtils$1.class differ diff --git a/common/target/classes/com/bwie/common/utils/HttpUtils.class b/common/target/classes/com/bwie/common/utils/HttpUtils.class new file mode 100644 index 0000000..d9cb2c1 Binary files /dev/null and b/common/target/classes/com/bwie/common/utils/HttpUtils.class differ diff --git a/common/target/classes/com/bwie/common/utils/JwtUtils.class b/common/target/classes/com/bwie/common/utils/JwtUtils.class new file mode 100644 index 0000000..694e65b Binary files /dev/null and b/common/target/classes/com/bwie/common/utils/JwtUtils.class differ diff --git a/common/target/classes/com/bwie/common/utils/MsgUtil.class b/common/target/classes/com/bwie/common/utils/MsgUtil.class new file mode 100644 index 0000000..89d39c4 Binary files /dev/null and b/common/target/classes/com/bwie/common/utils/MsgUtil.class differ diff --git a/common/target/classes/com/bwie/common/utils/StringUtils.class b/common/target/classes/com/bwie/common/utils/StringUtils.class new file mode 100644 index 0000000..80b387c Binary files /dev/null and b/common/target/classes/com/bwie/common/utils/StringUtils.class differ diff --git a/common/target/classes/com/bwie/common/utils/TelSmsUtils.class b/common/target/classes/com/bwie/common/utils/TelSmsUtils.class new file mode 100644 index 0000000..38661c5 Binary files /dev/null and b/common/target/classes/com/bwie/common/utils/TelSmsUtils.class differ diff --git a/common/target/common-1.0-SNAPSHOT.jar b/common/target/common-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..ddbd65d Binary files /dev/null and b/common/target/common-1.0-SNAPSHOT.jar differ diff --git a/common/target/maven-archiver/pom.properties b/common/target/maven-archiver/pom.properties new file mode 100644 index 0000000..a3e56a7 --- /dev/null +++ b/common/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=common +groupId=com.wzx +version=1.0-SNAPSHOT diff --git a/common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..5e4795e --- /dev/null +++ b/common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,23 @@ +com\bwie\common\result\PageResult.class +com\bwie\common\domain\Menu.class +com\bwie\common\utils\MsgUtil.class +com\bwie\common\domain\User.class +com\bwie\common\utils\TelSmsUtils.class +com\bwie\common\utils\HttpUtils.class +com\bwie\common\utils\JwtUtils.class +com\bwie\common\domain\response\ResponseHotel.class +com\bwie\common\utils\StringUtils.class +com\bwie\common\constants\JwtConstants.class +com\bwie\common\utils\HttpUtils$1.class +com\bwie\common\constants\Constants.class +com\bwie\common\domain\request\QueryHotel.class +com\bwie\common\constants\RabbitMQConstants.class +com\bwie\common\constants\TokenConstants.class +com\bwie\common\result\Result.class +com\bwie\common\domain\request\RequestUser.class +com\bwie\common\domain\Order.class +com\bwie\common\domain\Hotel.class +com\bwie\common\domain\Stay.class +com\bwie\common\utils\FastUtil.class +com\bwie\common\domain\MyMenu.class +com\bwie\common\domain\response\ResponseUser.class diff --git a/common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..d04b956 --- /dev/null +++ b/common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,22 @@ +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\response\ResponseHotel.java +D:\Project\Finish\common\src\main\java\com\bwie\common\constants\TokenConstants.java +D:\Project\Finish\common\src\main\java\com\bwie\common\utils\TelSmsUtils.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\Hotel.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\User.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\Order.java +D:\Project\Finish\common\src\main\java\com\bwie\common\result\Result.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\request\QueryHotel.java +D:\Project\Finish\common\src\main\java\com\bwie\common\utils\MsgUtil.java +D:\Project\Finish\common\src\main\java\com\bwie\common\constants\RabbitMQConstants.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\MyMenu.java +D:\Project\Finish\common\src\main\java\com\bwie\common\result\PageResult.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\response\ResponseUser.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\Menu.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\request\RequestUser.java +D:\Project\Finish\common\src\main\java\com\bwie\common\utils\FastUtil.java +D:\Project\Finish\common\src\main\java\com\bwie\common\utils\StringUtils.java +D:\Project\Finish\common\src\main\java\com\bwie\common\utils\HttpUtils.java +D:\Project\Finish\common\src\main\java\com\bwie\common\utils\JwtUtils.java +D:\Project\Finish\common\src\main\java\com\bwie\common\constants\Constants.java +D:\Project\Finish\common\src\main\java\com\bwie\common\constants\JwtConstants.java +D:\Project\Finish\common\src\main\java\com\bwie\common\domain\Stay.java diff --git a/common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/gateway/pom.xml b/gateway/pom.xml new file mode 100644 index 0000000..cccf1d1 --- /dev/null +++ b/gateway/pom.xml @@ -0,0 +1,38 @@ + + + + Finish + com.wzx + 1.0-SNAPSHOT + + 4.0.0 + + gateway + + + + com.wzx + common + 1.0-SNAPSHOT + + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + + com.alibaba.cloud + spring-cloud-alibaba-sentinel-gateway + + + + com.alibaba.csp + sentinel-spring-cloud-gateway-adapter + + + + diff --git a/gateway/src/main/java/com/bwie/gateway/GatewayApp.java b/gateway/src/main/java/com/bwie/gateway/GatewayApp.java new file mode 100644 index 0000000..962bc29 --- /dev/null +++ b/gateway/src/main/java/com/bwie/gateway/GatewayApp.java @@ -0,0 +1,11 @@ +package com.bwie.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GatewayApp { + public static void main(String[] args) { + SpringApplication.run(GatewayApp.class); + } +} diff --git a/gateway/src/main/java/com/bwie/gateway/config/IgnoreWhiteConfig.java b/gateway/src/main/java/com/bwie/gateway/config/IgnoreWhiteConfig.java new file mode 100644 index 0000000..5705d6f --- /dev/null +++ b/gateway/src/main/java/com/bwie/gateway/config/IgnoreWhiteConfig.java @@ -0,0 +1,32 @@ +package com.bwie.gateway.config; + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.extern.log4j.Log4j2; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Configuration; + +import java.util.ArrayList; +import java.util.List; + +/** + * @description: 放行白名单配置 + * @author DongZl + */ +@Configuration +@RefreshScope +@ConfigurationProperties(prefix = "ignore") +@Data +@Log4j2 +public class IgnoreWhiteConfig { + /** + * 放行白名单配置,网关不校验此处的白名单 + */ + private List whites = new ArrayList<>(); + + public void setWhites(List whites) { + log.info("加载网关路径白名单:{}", JSONObject.toJSONString(whites)); + this.whites = whites; + } +} diff --git a/gateway/src/main/java/com/bwie/gateway/filters/AuthFilters.java b/gateway/src/main/java/com/bwie/gateway/filters/AuthFilters.java new file mode 100644 index 0000000..6cb73be --- /dev/null +++ b/gateway/src/main/java/com/bwie/gateway/filters/AuthFilters.java @@ -0,0 +1,64 @@ +package com.bwie.gateway.filters; + +import cn.hutool.jwt.JWT; +import com.bwie.common.constants.TokenConstants; +import com.bwie.common.utils.JwtUtils; +import com.bwie.common.utils.StringUtils; +import com.bwie.gateway.config.IgnoreWhiteConfig; +import com.bwie.gateway.utils.GatewayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.Ordered; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +import java.util.List; + +@Component +public class AuthFilters implements GlobalFilter, Ordered { + + @Autowired + private IgnoreWhiteConfig ignoreWhiteConfig; + @Autowired + private RedisTemplate redisTemplate; + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + //拿出白名单路径 + List whites = ignoreWhiteConfig.getWhites(); + //取出当前路径 + ServerHttpRequest request = exchange.getRequest(); + String path = request.getURI().getPath(); + //判断当前路径是否与白名单路径一致 + if (StringUtils.matches(path,whites)){ + //一致 + //放行 + return chain.filter(exchange); + } + //判断token是否为空 + String token = request.getHeaders().getFirst(TokenConstants.TOKEN); + if (StringUtils.isEmpty(token)){ + //判断 + return GatewayUtils.errorResponse(exchange,"token不能为空", HttpStatus.UNAUTHORIZED); + } + //判断token是否过期 + String userKey = JwtUtils.getUserKey(token); + Boolean aBoolean = redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY + userKey); + if (null==aBoolean && !aBoolean){ + return GatewayUtils.errorResponse(exchange,"token已经过期"); + } + + //全部放行 + return chain.filter(exchange); + } + + @Override + public int getOrder() { + return 0; + } +} diff --git a/gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java b/gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java new file mode 100644 index 0000000..7b789e5 --- /dev/null +++ b/gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java @@ -0,0 +1,98 @@ +package com.bwie.gateway.utils; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.common.result.Result; +import com.bwie.common.utils.StringUtils; +import lombok.extern.log4j.Log4j2; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +/** + * @author DongZl + * @description: 网关处理工具类 + */ +@Log4j2 +public class GatewayUtils { + /** + * 添加请求头参数 + * @param mutate 修改对象 + * @param key 键 + * @param value 值 + */ + public static void addHeader(ServerHttpRequest.Builder mutate, String key, Object value) { + if (StringUtils.isEmpty(key)){ + log.warn("添加请求头参数键不可以为空"); + return; + } + if (value == null) { + log.warn("添加请求头参数:[{}]值为空",key); + return; + } + String valueStr = value.toString(); + mutate.header(key, valueStr); + log.info("添加请求头参数成功 - 键:[{}] , 值:[{}]", key , value); + } + + /** + * 删除请求头参数 + * @param mutate 修改对象 + * @param key 键 + */ + public static void removeHeader(ServerHttpRequest.Builder mutate, String key) { + if (StringUtils.isEmpty(key)){ + log.warn("删除请求头参数键不可以为空"); + return; + } + mutate.headers(httpHeaders -> httpHeaders.remove(key)).build(); + log.info("删除请求头参数 - 键:[{}]",key); + } + + /** + * 错误结果响应 + * @param exchange 响应上下文 + * @param msg 响应消息 + * @return + */ + public static Mono errorResponse(ServerWebExchange exchange, String msg, HttpStatus httpStatus) { + ServerHttpResponse response = exchange.getResponse(); + //设置HTTP响应头状态 + response.setStatusCode(httpStatus); + //设置HTTP响应头文本格式 + response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json"); + //定义响应内容 + Result result = Result.error(msg); + String resultJson = JSONObject.toJSONString(result); + log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson); + DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes()); + //进行响应 + return response.writeWith(Mono.just(dataBuffer)); + } + + /** + * 错误结果响应 + * @param exchange 响应上下文 + * @param msg 响应消息 + * @return + */ + public static Mono errorResponse(ServerWebExchange exchange, String msg) { + ServerHttpResponse response = exchange.getResponse(); + //设置HTTP响应头状态 + response.setStatusCode(HttpStatus.OK); + //设置HTTP响应头文本格式 + response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json"); + //定义响应内容 + Result result = Result.error(msg); + String resultJson = JSONObject.toJSONString(result); + log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson); + DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes()); + //进行响应 + return response.writeWith(Mono.just(dataBuffer)); + } + + +} diff --git a/gateway/src/main/resources/bootstrap.yml b/gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..e85d644 --- /dev/null +++ b/gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,31 @@ +# Tomcat +server: + port: 18080 +# Spring +spring: + application: + # 应用名称 + name: gateway + profiles: + # 环境配置 + active: dev + main: + # 允许使用循环引用 + allow-circular-references: true + # 允许定义相同的bean对象 去覆盖原有的 + allow-bean-definition-overriding: true + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.221.214.183:8848 + namespace: lc + config: + # 配置中心地址 + server-addr: 124.221.214.183:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + namespace: lc diff --git a/gateway/target/classes/bootstrap.yml b/gateway/target/classes/bootstrap.yml new file mode 100644 index 0000000..e85d644 --- /dev/null +++ b/gateway/target/classes/bootstrap.yml @@ -0,0 +1,31 @@ +# Tomcat +server: + port: 18080 +# Spring +spring: + application: + # 应用名称 + name: gateway + profiles: + # 环境配置 + active: dev + main: + # 允许使用循环引用 + allow-circular-references: true + # 允许定义相同的bean对象 去覆盖原有的 + allow-bean-definition-overriding: true + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.221.214.183:8848 + namespace: lc + config: + # 配置中心地址 + server-addr: 124.221.214.183:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + namespace: lc diff --git a/gateway/target/classes/com/bwie/gateway/GatewayApp.class b/gateway/target/classes/com/bwie/gateway/GatewayApp.class new file mode 100644 index 0000000..e14652d Binary files /dev/null and b/gateway/target/classes/com/bwie/gateway/GatewayApp.class differ diff --git a/gateway/target/classes/com/bwie/gateway/config/IgnoreWhiteConfig.class b/gateway/target/classes/com/bwie/gateway/config/IgnoreWhiteConfig.class new file mode 100644 index 0000000..104e718 Binary files /dev/null and b/gateway/target/classes/com/bwie/gateway/config/IgnoreWhiteConfig.class differ diff --git a/gateway/target/classes/com/bwie/gateway/filters/AuthFilters.class b/gateway/target/classes/com/bwie/gateway/filters/AuthFilters.class new file mode 100644 index 0000000..a1d5ad7 Binary files /dev/null and b/gateway/target/classes/com/bwie/gateway/filters/AuthFilters.class differ diff --git a/gateway/target/classes/com/bwie/gateway/utils/GatewayUtils.class b/gateway/target/classes/com/bwie/gateway/utils/GatewayUtils.class new file mode 100644 index 0000000..2da8843 Binary files /dev/null and b/gateway/target/classes/com/bwie/gateway/utils/GatewayUtils.class differ diff --git a/gateway/target/gateway-1.0-SNAPSHOT.jar b/gateway/target/gateway-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..f153f92 Binary files /dev/null and b/gateway/target/gateway-1.0-SNAPSHOT.jar differ diff --git a/gateway/target/maven-archiver/pom.properties b/gateway/target/maven-archiver/pom.properties new file mode 100644 index 0000000..f5a8d96 --- /dev/null +++ b/gateway/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=gateway +groupId=com.wzx +version=1.0-SNAPSHOT diff --git a/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..6367346 --- /dev/null +++ b/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,4 @@ +com\bwie\gateway\filters\AuthFilters.class +com\bwie\gateway\config\IgnoreWhiteConfig.class +com\bwie\gateway\GatewayApp.class +com\bwie\gateway\utils\GatewayUtils.class diff --git a/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..04a4fcd --- /dev/null +++ b/gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +D:\Project\Finish\gateway\src\main\java\com\bwie\gateway\filters\AuthFilters.java +D:\Project\Finish\gateway\src\main\java\com\bwie\gateway\utils\GatewayUtils.java +D:\Project\Finish\gateway\src\main\java\com\bwie\gateway\config\IgnoreWhiteConfig.java +D:\Project\Finish\gateway\src\main\java\com\bwie\gateway\GatewayApp.java diff --git a/gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/models/pom.xml b/models/pom.xml new file mode 100644 index 0000000..9bca3ac --- /dev/null +++ b/models/pom.xml @@ -0,0 +1,19 @@ + + + + Finish + com.wzx + 1.0-SNAPSHOT + + 4.0.0 + + models + pom + + system + + + + diff --git a/models/system/pom.xml b/models/system/pom.xml new file mode 100644 index 0000000..94fe829 --- /dev/null +++ b/models/system/pom.xml @@ -0,0 +1,85 @@ + + + + models + com.wzx + 1.0-SNAPSHOT + + 4.0.0 + + system + + + + + com.wzx + common + 1.0-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-web + + + + com.alibaba + druid-spring-boot-starter + 1.2.8 + + + + mysql + mysql-connector-java + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.2.2 + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.4.1 + + + + org.springframework.boot + spring-boot-starter-amqp + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.qiniu + qiniu-java-sdk + 7.2.0 + + + + com.easemob.im + im-sdk-core + 0.6.0 + + + com.wzx + common + 1.0-SNAPSHOT + compile + + + com.easemob.im + im-sdk-core + 0.6.0 + + + + diff --git a/models/system/src/main/java/com/bwie/system/SystemApp.java b/models/system/src/main/java/com/bwie/system/SystemApp.java new file mode 100644 index 0000000..9fd6134 --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/SystemApp.java @@ -0,0 +1,11 @@ +package com.bwie.system; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SystemApp { + public static void main(String[] args) { + SpringApplication.run(SystemApp.class); + } +} diff --git a/models/system/src/main/java/com/bwie/system/controller/HotelController.java b/models/system/src/main/java/com/bwie/system/controller/HotelController.java new file mode 100644 index 0000000..98172cd --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/controller/HotelController.java @@ -0,0 +1,90 @@ +package com.bwie.system.controller; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.common.domain.Order; +import com.bwie.common.domain.Stay; +import com.bwie.common.domain.request.QueryHotel; +import com.bwie.common.domain.response.ResponseHotel; +import com.bwie.common.result.Result; +import com.bwie.system.service.HotelService; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@RestController +@RequestMapping("/hotel") +@Log4j2 +public class HotelController { + + @Autowired + private HotelService hotelService; + @Autowired + private HttpServletRequest request; + + /** + * 酒店列表 + * @param queryHotel + * @return + */ + @PostMapping("/ShowHotelAll") + public Result> ShowHotelAll(@RequestBody QueryHotel queryHotel){ + log.info("功能名称:查询酒店列表,请求URI:{},请求方法:{}",request.getRequestURI(), + request.getMethod()); + Result> result=hotelService.ShowHotelAll(queryHotel); + log.info("功能名称:查询酒店列表,请求URI:{},请求方法:{},返回结果:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(result)); + return result; + } + + /** + * 添加订单 + * @param order + * @return + */ + @PostMapping("/insertOrder") + public Result insertOrder(Order order){ + log.info("功能名称:添加订单,请求URI:{},请求方法:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(order)); + Result result=hotelService.insertOrder(order); + log.info("功能名称:添加订单,请求URI:{},请求方法:{},返回结果:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(result)); + return result; + } + + /** + * 添加入住登记信息 + * @param stay + * @return + */ + @PostMapping("/insertStay") + public Result insertStay(Stay stay){ + log.info("功能名称:新增入住登记信息,请求URI:{},请求方法:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(stay)); + Result result=hotelService.insertStay(stay); + log.info("功能名称:新增入住登记信息,请求URI:{},请求方法:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(result)); + return result; + } + + /** + * 上传七牛云 + * @return + */ + @PostMapping("/QiNiuUpload") + public Result QiNiuUpload(){ + return hotelService.QiNiuUpload(); + } + + /** + * 查看七牛云存储文件 + * @return + */ + @GetMapping("/SeeQiNiu") + public Result SeeQiNiu(){ + return hotelService.SeeQiNiu(); + } + +} diff --git a/models/system/src/main/java/com/bwie/system/controller/MenuController.java b/models/system/src/main/java/com/bwie/system/controller/MenuController.java new file mode 100644 index 0000000..88be462 --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/controller/MenuController.java @@ -0,0 +1,50 @@ +package com.bwie.system.controller; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.common.domain.Menu; +import com.bwie.common.domain.MyMenu; +import com.bwie.common.result.Result; +import com.bwie.system.service.MenuService; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@RestController +@RequestMapping("/menu") +@Log4j2 +public class MenuController { + + @Autowired + private MenuService menuService; + + @Autowired + private HttpServletRequest request; + + /** + * 查询菜单 + * @return + */ + @GetMapping("/ShowMenuAll") + public Result> ShowMenuAll(){ + log.info("功能名称:查询菜单列表,请求URI:{},请求方法:{}",request.getRequestURI(), + request.getMethod()); + List list=menuService.ShowMenuAll(); + log.info("功能名称:查询菜单列表,请求URI:{},请求方法:{},返回结果:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(list)); + return Result.success(list,"查询成功"); + } + + @PostMapping("/insertMyMenu") + public Result insertMyMenu(@RequestBody MyMenu menu){ + log.info("功能名称:客户点餐,请求URI:{},请求方法:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(menu)); + Result result=menuService.insertMyMenu(menu); + log.info("功能名称:客户点餐,请求URI:{},请求方法:{},返回结果:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(result)); + return result; + } + +} diff --git a/models/system/src/main/java/com/bwie/system/controller/UserController.java b/models/system/src/main/java/com/bwie/system/controller/UserController.java new file mode 100644 index 0000000..2b56a35 --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/controller/UserController.java @@ -0,0 +1,42 @@ +package com.bwie.system.controller; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.RequestUser; +import com.bwie.common.result.Result; +import com.bwie.system.service.UserService; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +@RestController +@RequestMapping("/user") +@Log4j2 +public class UserController { + + @Autowired + private UserService userService; + @Autowired + private HttpServletRequest request; + + /** + * 根据账号密码查询用户信息 + * @param requestUser + * @return + */ + @PostMapping("findByRequestUser") + public Result findByRequestUser(@RequestBody RequestUser requestUser){ + log.info("功能名称:根据账号密码查询用户信息,请求URI:{},请求方法:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(requestUser)); + Result result=userService.findByRequestUser(requestUser); + log.info("功能名称:根据账号密码查询用户信息,请求URI:{},请求方法:{},返回结果:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(result)); + return result; + + } +} diff --git a/models/system/src/main/java/com/bwie/system/mapper/HotelMapper.java b/models/system/src/main/java/com/bwie/system/mapper/HotelMapper.java new file mode 100644 index 0000000..a932c0d --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/mapper/HotelMapper.java @@ -0,0 +1,20 @@ +package com.bwie.system.mapper; + +import com.bwie.common.domain.Hotel; +import com.bwie.common.domain.Order; +import com.bwie.common.domain.Stay; +import com.bwie.common.domain.request.QueryHotel; +import com.bwie.common.domain.response.ResponseHotel; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface HotelMapper { + List ShowHotelAll(QueryHotel queryHotel); + + Integer insertOrder(Order order); + + Integer insertStay(Stay stay); + +} diff --git a/models/system/src/main/java/com/bwie/system/mapper/MenuMapper.java b/models/system/src/main/java/com/bwie/system/mapper/MenuMapper.java new file mode 100644 index 0000000..2daecf0 --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/mapper/MenuMapper.java @@ -0,0 +1,17 @@ +package com.bwie.system.mapper; + +import com.bwie.common.domain.Menu; +import com.bwie.common.domain.MyMenu; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface MenuMapper { + + + Integer insertMyMenu(MyMenu menu); + + List ShowMenuAll(); + +} diff --git a/models/system/src/main/java/com/bwie/system/mapper/UserMapper.java b/models/system/src/main/java/com/bwie/system/mapper/UserMapper.java new file mode 100644 index 0000000..335a08b --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/mapper/UserMapper.java @@ -0,0 +1,19 @@ +package com.bwie.system.mapper; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.RequestUser; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; + +@Mapper +public interface UserMapper { + User findByRequestUser(@Param("requestUser") RequestUser requestUser); + + User findByUserName(@Param("username") String username); + + void updateBalce(@Param("userId") Integer userId, @Param("userBalance") BigDecimal userBalance); + + User findByUserId(@Param("userId") Integer userId); +} diff --git a/models/system/src/main/java/com/bwie/system/service/HotelService.java b/models/system/src/main/java/com/bwie/system/service/HotelService.java new file mode 100644 index 0000000..e2ffdfc --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/service/HotelService.java @@ -0,0 +1,22 @@ +package com.bwie.system.service; + +import com.bwie.common.domain.Order; +import com.bwie.common.domain.Stay; +import com.bwie.common.domain.request.QueryHotel; +import com.bwie.common.domain.response.ResponseHotel; +import com.bwie.common.result.Result; + +import java.util.List; + +public interface HotelService { + Result> ShowHotelAll(QueryHotel queryHotel); + + Result insertOrder(Order order); + + Result insertStay(Stay stay); + + Result QiNiuUpload(); + + Result SeeQiNiu(); + +} diff --git a/models/system/src/main/java/com/bwie/system/service/MenuService.java b/models/system/src/main/java/com/bwie/system/service/MenuService.java new file mode 100644 index 0000000..04b4ffb --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/service/MenuService.java @@ -0,0 +1,13 @@ +package com.bwie.system.service; + +import com.bwie.common.domain.Menu; +import com.bwie.common.domain.MyMenu; +import com.bwie.common.result.Result; + +import java.util.List; + +public interface MenuService { + List ShowMenuAll(); + + Result insertMyMenu(MyMenu menu); +} diff --git a/models/system/src/main/java/com/bwie/system/service/UserService.java b/models/system/src/main/java/com/bwie/system/service/UserService.java new file mode 100644 index 0000000..655565f --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/service/UserService.java @@ -0,0 +1,15 @@ +package com.bwie.system.service; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.RequestUser; +import com.bwie.common.result.Result; + +import java.math.BigDecimal; + +public interface UserService { + Result findByRequestUser(RequestUser requestUser); + + User findByUserId(Integer userId); + + void update(BigDecimal money, Integer userId); +} diff --git a/models/system/src/main/java/com/bwie/system/service/impl/HotelServiceImpl.java b/models/system/src/main/java/com/bwie/system/service/impl/HotelServiceImpl.java new file mode 100644 index 0000000..352d52e --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/service/impl/HotelServiceImpl.java @@ -0,0 +1,85 @@ +package com.bwie.system.service.impl; + +import com.bwie.common.domain.Order; +import com.bwie.common.domain.Stay; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.QueryHotel; +import com.bwie.common.domain.response.ResponseHotel; +import com.bwie.common.result.Result; +import com.bwie.system.mapper.HotelMapper; +import com.bwie.system.mapper.UserMapper; +import com.bwie.system.service.HotelService; +import com.bwie.system.util.QiNiuUploadUtil; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.List; + +@Service +@Log4j2 +public class HotelServiceImpl implements HotelService { + + @Autowired + private HotelMapper hotelMapper; + @Autowired + private UserMapper userMapper; + + + @Override + public Result> ShowHotelAll(QueryHotel queryHotel) { + List responseHotels=hotelMapper.ShowHotelAll(queryHotel); + return Result.success(responseHotels); + } + + @Override + public Result insertOrder(Order order) { + Integer i=hotelMapper.insertOrder(order); + if (i<0){ + return Result.error("订单添加失败"); + } + return Result.success(i,"订单添加成功"); + } + + @Transactional + @Override + public Result insertStay(Stay stay) { + Integer i=hotelMapper.insertStay(stay); + if (i>0){ + String username = stay.getUsername(); + User user=userMapper.findByUserName(username); + double totalPrice = stay.getTotalPrice().doubleValue(); + double balance = user.getBalance().doubleValue(); + if (balance ShowMenuAll() { + List menuList=menuMapper.ShowMenuAll(); + return menuList; + } + + @Transactional + @Override + public Result insertMyMenu(MyMenu menu) { + Integer i=menuMapper.insertMyMenu(menu); + Integer userId = menu.userId; + User user =userService.findByUserId(userId); + double price = user.getBalance().doubleValue(); + double pay = menu.pay.doubleValue(); + //判断金额是否足够支付 + if (price findByRequestUser(RequestUser requestUser) { + User user=userMapper.findByRequestUser(requestUser); + return Result.success(user); + } + + @Override + public User findByUserId(Integer userId) { + User user=userMapper.findByUserId(userId); + return user; + } + + @Override + public void update(BigDecimal money, Integer userId) { + userMapper.updateBalce(userId,money); + } +} diff --git a/models/system/src/main/java/com/bwie/system/util/QiNiuUploadUtil.java b/models/system/src/main/java/com/bwie/system/util/QiNiuUploadUtil.java new file mode 100644 index 0000000..558d999 --- /dev/null +++ b/models/system/src/main/java/com/bwie/system/util/QiNiuUploadUtil.java @@ -0,0 +1,107 @@ +package com.bwie.system.util; + +import com.google.gson.Gson; +import com.qiniu.common.QiniuException; +import com.qiniu.common.Zone; +import com.qiniu.http.Response; +import com.qiniu.storage.Configuration; +import com.qiniu.storage.UploadManager; +import com.qiniu.storage.model.DefaultPutRet; +import com.qiniu.util.Auth; +import lombok.extern.log4j.Log4j2; + +import java.io.File; +@Log4j2 +public class QiNiuUploadUtil { + + // 七牛云账号的 Access Key 和 Secret Key + private static final String ACCESS_KEY = "vr53LoeAdxIgcaczwDRaS3iSxEfhWwApdMjFgAX5"; + private static final String SECRET_KEY = "mBOO_ODKQwMkyyUPLkq3rBf9FLAe1C5O2MnoVJUk"; + + // 七牛云存储空间的名称和域名 + private static final String BUCKET_NAME = "bigdeck"; + private static final String DOMAIN_NAME = "http://pili-vod.s2lpch1un.bkt.clouddn.com/"; + + /** + * 上传指定文件到七牛云存储。 + * + * @param filePath 待上传的文件路径。 + * @return 如果上传成功,返回该文件在七牛云存储上的访问路径;否则返回 null。 + */ + public static String uploadFile(String filePath) { + // 生成上传凭证 + Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY); + String uploadToken = auth.uploadToken(BUCKET_NAME); + + // 指定上传域名(如果需要的话) + Configuration cfg = new Configuration(Zone.zone2()); + UploadManager uploadManager = new UploadManager(cfg); + + try { + // 执行文件上传 + Response response = uploadManager.put(new File(filePath), null, uploadToken); + + // 解析上传成功的结果并返回访问路径 + if (response.isOK()) { + String key = new Gson().fromJson(response.bodyString(), DefaultPutRet.class).key; + log.info("存储在七牛云中的文件名:"+key); + return DOMAIN_NAME + key; + } + } catch (QiniuException e) { + e.printStackTrace(); + } + + return null; + } + + /** + * 对象储存为,企业级七牛云上传,需要自己配置相关的参数 + * + * @param accessKey 七牛云账号的 Access Key。 + * @param secretKey 七牛云账号的 Secret Key。 + * @param bucketName 存储空间的名称。 + * @param domainName 存储空间的域名。 + * @param filePath 待上传的文件路径。 + * @return 如果上传成功,返回该文件在七牛云存储上的访问路径;否则返回 null。 + */ + public static String uploadFile(String accessKey, String secretKey, + String bucketName, String domainName, String filePath) { + // 生成上传凭证 + Auth auth = Auth.create(accessKey, secretKey); + String uploadToken = auth.uploadToken(bucketName); + + // 指定上传域名(如果需要的话) + Configuration cfg = new Configuration(Zone.zone2()); + UploadManager uploadManager = new UploadManager(cfg); + + try { + // 执行文件上传 + Response response = uploadManager.put(new File(filePath), null, uploadToken); + + // 解析上传成功的结果并返回访问路径 + if (response.isOK()) { + String key = new Gson().fromJson(response.bodyString(), DefaultPutRet.class).key; + return domainName + key; + } + } catch (QiniuException e) { + e.printStackTrace(); + } + + return null; + } + + /** + * 生成七牛云的私有下载链接。 + * + * @param fileName 文件名。 + * @param expiresIn 有效期,单位为秒。 + * @return 返回生成的私有下载链接。 + */ + public static String generatePrivateDownloadUrl( String fileName, long expiresIn) { + Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY); + long expiresAt = System.currentTimeMillis() / 1000 + expiresIn; + String downloadUrl = String.format("%s?e=%d", DOMAIN_NAME + "/" + fileName, expiresAt); + String privateDownloadUrl = auth.privateDownloadUrl(downloadUrl); // 对下载链接进行签名 + return privateDownloadUrl; + } +} diff --git a/models/system/src/main/resources/bootstrap.yml b/models/system/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..46515a0 --- /dev/null +++ b/models/system/src/main/resources/bootstrap.yml @@ -0,0 +1,43 @@ +# Tomcat +server: + port: 9003 +# Spring +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: system + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.221.214.183:8848 + namespace: lc + config: + # 配置中心地址 + server-addr: 124.221.214.183:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + namespace: lc +fdfs: + so-timeout: 1500 # socket 连接时长 + connect-timeout: 600 # 连接 tracker 服务器超时时长 + # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流 + tracker-list: 124.221.214.183:22122 + web-server-url: 124.221.214.183:8888 + pool: + jmx-enabled: false + # 生成缩略图 + thumb-image: + height: 500 + width: 500 diff --git a/models/system/src/main/resources/mapper/HotelMapper.xml b/models/system/src/main/resources/mapper/HotelMapper.xml new file mode 100644 index 0000000..f8d7581 --- /dev/null +++ b/models/system/src/main/resources/mapper/HotelMapper.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + select id, + name, + price, + pic, + number, + status + from t_hotel + + + + insert into t_order( + order_card, + name, + price, + user_id + ) + values ( + #{orderCard}, + #{name}, + #{price}, + #{userId} + ) + + + insert into t_saty( + username, + phone, + card, + name, + price, + day_number, + total_price + ) + values ( + #{username}, + #{phone}, + #{card}, + #{name}, + #{price}, + #{day_number}, + #{totalPrice} + ) + + + + + + diff --git a/models/system/src/main/resources/mapper/MenuMapper.xml b/models/system/src/main/resources/mapper/MenuMapper.xml new file mode 100644 index 0000000..8475b1b --- /dev/null +++ b/models/system/src/main/resources/mapper/MenuMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + insert into t_my_menu( + my_id, + user_id, + menu_id, + pay + )values ( + #{myId}, + #{userId}, + #{menuId}, + #{pay} + ) + + + + diff --git a/models/system/src/main/resources/mapper/UserMapper.xml b/models/system/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..b225684 --- /dev/null +++ b/models/system/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + select u.user_id, + u.username, + u.password, + u.phone, + u.balance, + u.role_id, + r.role_name + from t_user u left join t_role r + on u.role_id=r.role_id + + + + update t_user set balance=#{userBalance} where user_id=#{userId} + + + + + + + + + diff --git a/models/system/target/classes/bootstrap.yml b/models/system/target/classes/bootstrap.yml new file mode 100644 index 0000000..46515a0 --- /dev/null +++ b/models/system/target/classes/bootstrap.yml @@ -0,0 +1,43 @@ +# Tomcat +server: + port: 9003 +# Spring +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: system + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.221.214.183:8848 + namespace: lc + config: + # 配置中心地址 + server-addr: 124.221.214.183:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + namespace: lc +fdfs: + so-timeout: 1500 # socket 连接时长 + connect-timeout: 600 # 连接 tracker 服务器超时时长 + # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流 + tracker-list: 124.221.214.183:22122 + web-server-url: 124.221.214.183:8888 + pool: + jmx-enabled: false + # 生成缩略图 + thumb-image: + height: 500 + width: 500 diff --git a/models/system/target/classes/com/bwie/system/SystemApp.class b/models/system/target/classes/com/bwie/system/SystemApp.class new file mode 100644 index 0000000..a09f195 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/SystemApp.class differ diff --git a/models/system/target/classes/com/bwie/system/controller/HotelController.class b/models/system/target/classes/com/bwie/system/controller/HotelController.class new file mode 100644 index 0000000..84459b8 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/controller/HotelController.class differ diff --git a/models/system/target/classes/com/bwie/system/controller/MenuController.class b/models/system/target/classes/com/bwie/system/controller/MenuController.class new file mode 100644 index 0000000..02b56bb Binary files /dev/null and b/models/system/target/classes/com/bwie/system/controller/MenuController.class differ diff --git a/models/system/target/classes/com/bwie/system/controller/UserController.class b/models/system/target/classes/com/bwie/system/controller/UserController.class new file mode 100644 index 0000000..4d78091 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/controller/UserController.class differ diff --git a/models/system/target/classes/com/bwie/system/mapper/HotelMapper.class b/models/system/target/classes/com/bwie/system/mapper/HotelMapper.class new file mode 100644 index 0000000..fcae103 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/mapper/HotelMapper.class differ diff --git a/models/system/target/classes/com/bwie/system/mapper/MenuMapper.class b/models/system/target/classes/com/bwie/system/mapper/MenuMapper.class new file mode 100644 index 0000000..a888bc9 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/mapper/MenuMapper.class differ diff --git a/models/system/target/classes/com/bwie/system/mapper/UserMapper.class b/models/system/target/classes/com/bwie/system/mapper/UserMapper.class new file mode 100644 index 0000000..dd1c383 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/mapper/UserMapper.class differ diff --git a/models/system/target/classes/com/bwie/system/service/HotelService.class b/models/system/target/classes/com/bwie/system/service/HotelService.class new file mode 100644 index 0000000..e3ad088 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/service/HotelService.class differ diff --git a/models/system/target/classes/com/bwie/system/service/MenuService.class b/models/system/target/classes/com/bwie/system/service/MenuService.class new file mode 100644 index 0000000..b40ded9 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/service/MenuService.class differ diff --git a/models/system/target/classes/com/bwie/system/service/UserService.class b/models/system/target/classes/com/bwie/system/service/UserService.class new file mode 100644 index 0000000..5344765 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/service/UserService.class differ diff --git a/models/system/target/classes/com/bwie/system/service/impl/HotelServiceImpl.class b/models/system/target/classes/com/bwie/system/service/impl/HotelServiceImpl.class new file mode 100644 index 0000000..85f76f9 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/service/impl/HotelServiceImpl.class differ diff --git a/models/system/target/classes/com/bwie/system/service/impl/MenuServiceImpl.class b/models/system/target/classes/com/bwie/system/service/impl/MenuServiceImpl.class new file mode 100644 index 0000000..2139c4c Binary files /dev/null and b/models/system/target/classes/com/bwie/system/service/impl/MenuServiceImpl.class differ diff --git a/models/system/target/classes/com/bwie/system/service/impl/UserServiceImpl.class b/models/system/target/classes/com/bwie/system/service/impl/UserServiceImpl.class new file mode 100644 index 0000000..4bf2d56 Binary files /dev/null and b/models/system/target/classes/com/bwie/system/service/impl/UserServiceImpl.class differ diff --git a/models/system/target/classes/com/bwie/system/util/QiNiuUploadUtil.class b/models/system/target/classes/com/bwie/system/util/QiNiuUploadUtil.class new file mode 100644 index 0000000..8a70dbb Binary files /dev/null and b/models/system/target/classes/com/bwie/system/util/QiNiuUploadUtil.class differ diff --git a/models/system/target/classes/mapper/HotelMapper.xml b/models/system/target/classes/mapper/HotelMapper.xml new file mode 100644 index 0000000..f8d7581 --- /dev/null +++ b/models/system/target/classes/mapper/HotelMapper.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + select id, + name, + price, + pic, + number, + status + from t_hotel + + + + insert into t_order( + order_card, + name, + price, + user_id + ) + values ( + #{orderCard}, + #{name}, + #{price}, + #{userId} + ) + + + insert into t_saty( + username, + phone, + card, + name, + price, + day_number, + total_price + ) + values ( + #{username}, + #{phone}, + #{card}, + #{name}, + #{price}, + #{day_number}, + #{totalPrice} + ) + + + + + + diff --git a/models/system/target/classes/mapper/MenuMapper.xml b/models/system/target/classes/mapper/MenuMapper.xml new file mode 100644 index 0000000..8475b1b --- /dev/null +++ b/models/system/target/classes/mapper/MenuMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + insert into t_my_menu( + my_id, + user_id, + menu_id, + pay + )values ( + #{myId}, + #{userId}, + #{menuId}, + #{pay} + ) + + + + diff --git a/models/system/target/classes/mapper/UserMapper.xml b/models/system/target/classes/mapper/UserMapper.xml new file mode 100644 index 0000000..b225684 --- /dev/null +++ b/models/system/target/classes/mapper/UserMapper.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + select u.user_id, + u.username, + u.password, + u.phone, + u.balance, + u.role_id, + r.role_name + from t_user u left join t_role r + on u.role_id=r.role_id + + + + update t_user set balance=#{userBalance} where user_id=#{userId} + + + + + + + + + diff --git a/models/system/target/maven-archiver/pom.properties b/models/system/target/maven-archiver/pom.properties new file mode 100644 index 0000000..32a1b07 --- /dev/null +++ b/models/system/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=system +groupId=com.wzx +version=1.0-SNAPSHOT diff --git a/models/system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/models/system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..493c5ed --- /dev/null +++ b/models/system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,14 @@ +com\bwie\system\mapper\HotelMapper.class +com\bwie\system\util\QiNiuUploadUtil.class +com\bwie\system\SystemApp.class +com\bwie\system\service\UserService.class +com\bwie\system\controller\MenuController.class +com\bwie\system\service\impl\HotelServiceImpl.class +com\bwie\system\service\MenuService.class +com\bwie\system\service\impl\UserServiceImpl.class +com\bwie\system\mapper\UserMapper.class +com\bwie\system\controller\HotelController.class +com\bwie\system\mapper\MenuMapper.class +com\bwie\system\service\impl\MenuServiceImpl.class +com\bwie\system\service\HotelService.class +com\bwie\system\controller\UserController.class diff --git a/models/system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/models/system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..936c94b --- /dev/null +++ b/models/system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,14 @@ +D:\Project\Finish\models\system\src\main\java\com\bwie\system\util\QiNiuUploadUtil.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\controller\UserController.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\mapper\HotelMapper.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\service\HotelService.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\controller\MenuController.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\service\MenuService.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\service\impl\MenuServiceImpl.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\SystemApp.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\service\impl\UserServiceImpl.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\service\UserService.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\service\impl\HotelServiceImpl.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\controller\HotelController.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\mapper\UserMapper.java +D:\Project\Finish\models\system\src\main\java\com\bwie\system\mapper\MenuMapper.java diff --git a/models/system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/models/system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/models/system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/models/system/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/models/system/target/system-1.0-SNAPSHOT.jar b/models/system/target/system-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..d912919 Binary files /dev/null and b/models/system/target/system-1.0-SNAPSHOT.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..2e5c5b3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + com.wzx + Finish + pom + 1.0-SNAPSHOT + + common + auth + models + gateway + + + + + + spring-boot-starter-parent + org.springframework.boot + 2.6.2 + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + 2021.0.0 + pom + import + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + 2021.1 + pom + import + + + + com.alibaba.nacos + nacos-client + 2.0.4 + + + + + +