commit 0219c054ade18aa14346763be220195dcd9caf61 Author: Xiao Fan <461179989@qq.com> Date: Wed Nov 15 19:46:40 2023 +0800 new diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..1296681 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..bfc585f --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/day4-zy.iml b/.idea/day4-zy.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/.idea/day4-zy.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..a288659 --- /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..2a89eda --- /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..3ccb27b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/new.iml b/.idea/new.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/.idea/new.iml @@ -0,0 +1,2 @@ + + \ 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/bwie-auth/pom.xml b/bwie-auth/pom.xml new file mode 100644 index 0000000..7f1c01a --- /dev/null +++ b/bwie-auth/pom.xml @@ -0,0 +1,44 @@ + + + + day4-zy + com.bwie + 1.0-SNAPSHOT + + 4.0.0 + + bwie-auth + + + + + com.bwie + bwie-common + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-starter-amqp + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.9.10 + + + + + + diff --git a/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java b/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java new file mode 100644 index 0000000..b1cac8b --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java @@ -0,0 +1,13 @@ +package com.bwie.auth; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@SpringBootApplication +@EnableFeignClients +public class AuthApp { + public static void main(String[] args) { + SpringApplication.run(AuthApp.class); + } +} diff --git a/bwie-auth/src/main/java/com/bwie/auth/config/ConfirmCallbackConfig.java b/bwie-auth/src/main/java/com/bwie/auth/config/ConfirmCallbackConfig.java new file mode 100644 index 0000000..7b7c230 --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/config/ConfirmCallbackConfig.java @@ -0,0 +1,48 @@ +package com.bwie.auth.config; + +import lombok.extern.log4j.Log4j2; +import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +/** + * 消息发送确认配置 + * 消息发送到交换机的回调 + */ +@Component +@Log4j2 +public class ConfirmCallbackConfig implements RabbitTemplate.ConfirmCallback { + + @Autowired + private RabbitTemplate rabbitTemplate; + + /** + * @PostContruct是spring框架的注解,在⽅法上加该注解会在项⽬启动的时候执⾏该⽅法,也可以理解为在spring容器初始化的时候执 + */ + @PostConstruct + public void init() { + rabbitTemplate.setConfirmCallback(this); + } + + /** + * 交换机不管是否收到消息的一个回调方法 + * + * @param correlationData 消息相关数据 + * @param ack 交换机是否收到消息 + * @param cause 失败原因 + */ + @Override + public void confirm(CorrelationData correlationData, boolean ack, String cause) { + if (!ack) { + String exchange = correlationData.getReturned().getExchange(); + String message = correlationData.getReturned().getMessage().getBody().toString(); + // 发送异常 + log.error("消息:{},发送到交换机:{}失败,原因是:{}", message, exchange, cause); + // TODO 可以把异常信息 以及 消息的内容直接添加到 MYSQL + } + } + +} diff --git a/bwie-auth/src/main/java/com/bwie/auth/config/ReturnCallbackConfig.java b/bwie-auth/src/main/java/com/bwie/auth/config/ReturnCallbackConfig.java new file mode 100644 index 0000000..f3c2220 --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/config/ReturnCallbackConfig.java @@ -0,0 +1,41 @@ +package com.bwie.auth.config; + +import lombok.extern.log4j.Log4j2; +import org.springframework.amqp.core.ReturnedMessage; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +/** + * 消息发送到队列的确认 + */ +@Component +@Log4j2 +public class ReturnCallbackConfig implements RabbitTemplate.ReturnsCallback { + + @Autowired + private RabbitTemplate rabbitTemplate; + + /** + * @PostContruct是spring框架的注解,在⽅法上加该注解会在项⽬启动的时候执⾏该⽅法,也可以理解为在spring容器初始化的时候执 + */ + @PostConstruct + public void init() { + rabbitTemplate.setReturnsCallback(this); + } + + /** + * 消息发送失败 则会执行这个方法 + * + * @param returnedMessage the returned message and metadata. + */ + @Override + public void returnedMessage(ReturnedMessage returnedMessage) { + log.error("消息:{},被交换机:{} 回退!退回原因为:{}", + returnedMessage.getMessage().toString(), returnedMessage.getExchange(), returnedMessage.getReplyText()); + // TODO 回退了所有的信息,可做补偿机制 + } + +} diff --git a/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java b/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java new file mode 100644 index 0000000..45bb8be --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java @@ -0,0 +1,54 @@ +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.LoginRequest; +import com.bwie.common.domain.response.JwtResponse; +import com.bwie.common.result.Result; +import lombok.extern.log4j.Log4j2; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; + +@RestController +@Log4j2 +public class AuthController { + @Autowired + AuthService authService; + @Autowired + HttpServletRequest request; + @PostMapping("/sendCode/{phone}") + public Result sendCode(@PathVariable String phone){ + log.info("获取验证码,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(phone)); + Result result=authService.sendCode(phone); + log.info("获取验证码,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(result)); + return Result.success(result); + } + + @PostMapping("/login") + public Result login(@RequestBody LoginRequest loginRequest){ + log.info("执行操作:登陆,请求URl:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(loginRequest)); + Result result=authService.login(loginRequest); + log.info("执行操作:登陆,请求URl:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(result)); + return result; + } + + @GetMapping("/info") + public Result info(){ + log.info("执行操作:获取登录人信息,请求URl:{},请求方式:{}",request.getRequestURI(), + request.getMethod()); + User user=authService.info(); + log.info("执行操作:获取登录人信息,请求URl:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(user)); + return Result.success(user); + } +} + + diff --git a/bwie-auth/src/main/java/com/bwie/auth/feign/UserFeignService.java b/bwie-auth/src/main/java/com/bwie/auth/feign/UserFeignService.java new file mode 100644 index 0000000..9e0cce1 --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/feign/UserFeignService.java @@ -0,0 +1,14 @@ +package com.bwie.auth.feign; + +import com.bwie.common.domain.User; +import com.bwie.common.result.Result; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +@FeignClient("bwie-user") +public interface UserFeignService { + @GetMapping("/findByPhone/{phone}") + public Result findByPhone(@PathVariable String phone); +} diff --git a/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java b/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java new file mode 100644 index 0000000..c6ef72e --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java @@ -0,0 +1,16 @@ +package com.bwie.auth.service; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; +import com.bwie.common.domain.response.JwtResponse; +import com.bwie.common.result.Result; + +public interface AuthService { + Result sendCode(String phone); + + Result login(LoginRequest loginRequest); + + User info(); + + +} diff --git a/bwie-auth/src/main/java/com/bwie/auth/service/AuthServiceimpl.java b/bwie-auth/src/main/java/com/bwie/auth/service/AuthServiceimpl.java new file mode 100644 index 0000000..656c493 --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/service/AuthServiceimpl.java @@ -0,0 +1,95 @@ +package com.bwie.auth.service; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.alibaba.nacos.common.utils.StringUtils; +import com.bwie.auth.feign.UserFeignService; +import com.bwie.common.constants.JwtConstants; +import com.bwie.common.constants.RabbitMQQueueConstants; +import com.bwie.common.constants.TokenConstants; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; +import com.bwie.common.domain.response.JwtResponse; +import com.bwie.common.result.Result; +import com.bwie.common.utils.JwtUtils; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +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; +import java.util.regex.Pattern; + +@Service +public class AuthServiceimpl implements AuthService{ + @Autowired + HttpServletRequest request; + @Autowired + RedisTemplate redisTemplate; + @Autowired + RabbitTemplate rabbitTemplate; + @Autowired + UserFeignService userFeignService; + @Override + public Result sendCode(String phone) { + if (!vailPhone(phone)){ + return Result.error("手机号格式错误"); + } + Result byPhone = userFeignService.findByPhone(phone); + User user = byPhone.getData(); + if (user==null){ + return Result.error("手机号或验证码不能为空"); + } + rabbitTemplate.convertAndSend(RabbitMQQueueConstants.SENS_SMS_QUEUE,phone,message -> { + message.getMessageProperties().setMessageId(UUID.randomUUID().toString().replaceAll("-","")); + return message; + }); + return Result.success(); + } + + @Override + public Result login(LoginRequest loginRequest) { + if (!vailPhone(loginRequest.getPhone())){ + return Result.error("手机号格式错误"); + } + Result byPhone = userFeignService.findByPhone(loginRequest.getPhone()); + User user = byPhone.getData(); + if (user==null){ + return Result.error("手机号或验证码不能为空"); + } + String code = redisTemplate.opsForValue().get(loginRequest.getPhone()); + if (StringUtils.isEmpty(code)){ + return Result.error("请注册"); + } + if (!code.equals(loginRequest.getCode())){ + return Result.error("验证码错误"); + } + String userKey = UUID.randomUUID().toString().replaceAll("-", ""); + HashMap claims = new HashMap<>(); + claims.put(JwtConstants.USER_KEY, userKey); + String token = JwtUtils.createToken(claims); + + redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey, JSONObject.toJSONString(user),30, TimeUnit.MINUTES); + + JwtResponse jwtResponse = new JwtResponse(); + jwtResponse.setTime("30MIN"); + jwtResponse.setToken(token); + return Result.success(jwtResponse); + } + + @Override + public User info() { + String token = request.getHeader(TokenConstants.TOKEN); + String userKey = JwtUtils.getUserKey(token); + String jsonKeyStr = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey); + return JSONObject.parseObject(jsonKeyStr,User.class); + } + + public Boolean vailPhone(String phone){ + Pattern compile = Pattern.compile("^\\d{11}$"); + return compile.matcher(phone).matches(); + } +} diff --git a/bwie-auth/src/main/resources/bootstrap.yml b/bwie-auth/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..c08a8be --- /dev/null +++ b/bwie-auth/src/main/resources/bootstrap.yml @@ -0,0 +1,30 @@ +# 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: bwie-auth + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + diff --git a/bwie-auth/target/bwie-auth-1.0-SNAPSHOT.jar b/bwie-auth/target/bwie-auth-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..1754de8 Binary files /dev/null and b/bwie-auth/target/bwie-auth-1.0-SNAPSHOT.jar differ diff --git a/bwie-auth/target/classes/bootstrap.yml b/bwie-auth/target/classes/bootstrap.yml new file mode 100644 index 0000000..c08a8be --- /dev/null +++ b/bwie-auth/target/classes/bootstrap.yml @@ -0,0 +1,30 @@ +# 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: bwie-auth + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + diff --git a/bwie-auth/target/classes/com/bwie/auth/AuthApp.class b/bwie-auth/target/classes/com/bwie/auth/AuthApp.class new file mode 100644 index 0000000..1969bb2 Binary files /dev/null and b/bwie-auth/target/classes/com/bwie/auth/AuthApp.class differ diff --git a/bwie-auth/target/classes/com/bwie/auth/config/ConfirmCallbackConfig.class b/bwie-auth/target/classes/com/bwie/auth/config/ConfirmCallbackConfig.class new file mode 100644 index 0000000..b70cddb Binary files /dev/null and b/bwie-auth/target/classes/com/bwie/auth/config/ConfirmCallbackConfig.class differ diff --git a/bwie-auth/target/classes/com/bwie/auth/config/ReturnCallbackConfig.class b/bwie-auth/target/classes/com/bwie/auth/config/ReturnCallbackConfig.class new file mode 100644 index 0000000..5bdde91 Binary files /dev/null and b/bwie-auth/target/classes/com/bwie/auth/config/ReturnCallbackConfig.class differ diff --git a/bwie-auth/target/classes/com/bwie/auth/controller/AuthController.class b/bwie-auth/target/classes/com/bwie/auth/controller/AuthController.class new file mode 100644 index 0000000..bf90758 Binary files /dev/null and b/bwie-auth/target/classes/com/bwie/auth/controller/AuthController.class differ diff --git a/bwie-auth/target/classes/com/bwie/auth/feign/UserFeignService.class b/bwie-auth/target/classes/com/bwie/auth/feign/UserFeignService.class new file mode 100644 index 0000000..6aea9af Binary files /dev/null and b/bwie-auth/target/classes/com/bwie/auth/feign/UserFeignService.class differ diff --git a/bwie-auth/target/classes/com/bwie/auth/service/AuthService.class b/bwie-auth/target/classes/com/bwie/auth/service/AuthService.class new file mode 100644 index 0000000..b3824a3 Binary files /dev/null and b/bwie-auth/target/classes/com/bwie/auth/service/AuthService.class differ diff --git a/bwie-auth/target/classes/com/bwie/auth/service/AuthServiceimpl.class b/bwie-auth/target/classes/com/bwie/auth/service/AuthServiceimpl.class new file mode 100644 index 0000000..68fa29e Binary files /dev/null and b/bwie-auth/target/classes/com/bwie/auth/service/AuthServiceimpl.class differ diff --git a/bwie-auth/target/maven-archiver/pom.properties b/bwie-auth/target/maven-archiver/pom.properties new file mode 100644 index 0000000..34c155a --- /dev/null +++ b/bwie-auth/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=bwie-auth +groupId=com.bwie +version=1.0-SNAPSHOT diff --git a/bwie-auth/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/bwie-auth/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..3ba0280 --- /dev/null +++ b/bwie-auth/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,7 @@ +com\bwie\auth\config\ConfirmCallbackConfig.class +com\bwie\auth\service\AuthServiceimpl.class +com\bwie\auth\controller\AuthController.class +com\bwie\auth\feign\UserFeignService.class +com\bwie\auth\AuthApp.class +com\bwie\auth\service\AuthService.class +com\bwie\auth\config\ReturnCallbackConfig.class diff --git a/bwie-auth/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/bwie-auth/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..c2e809f --- /dev/null +++ b/bwie-auth/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,7 @@ +D:\zhuangao5\new\bwie-auth\src\main\java\com\bwie\auth\config\ReturnCallbackConfig.java +D:\zhuangao5\new\bwie-auth\src\main\java\com\bwie\auth\service\AuthServiceimpl.java +D:\zhuangao5\new\bwie-auth\src\main\java\com\bwie\auth\config\ConfirmCallbackConfig.java +D:\zhuangao5\new\bwie-auth\src\main\java\com\bwie\auth\AuthApp.java +D:\zhuangao5\new\bwie-auth\src\main\java\com\bwie\auth\feign\UserFeignService.java +D:\zhuangao5\new\bwie-auth\src\main\java\com\bwie\auth\controller\AuthController.java +D:\zhuangao5\new\bwie-auth\src\main\java\com\bwie\auth\service\AuthService.java diff --git a/bwie-auth/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/bwie-auth/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-auth/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/bwie-auth/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-common/pom.xml b/bwie-common/pom.xml new file mode 100644 index 0000000..23a9924 --- /dev/null +++ b/bwie-common/pom.xml @@ -0,0 +1,112 @@ + + + + day4-zy + com.bwie + 1.0-SNAPSHOT + + 4.0.0 + + bwie-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 + + + + com.aliyun.oss + aliyun-sdk-oss + 3.12.0 + + + + org.springframework.boot + spring-boot-starter-amqp + + + + com.github.tobato + fastdfs-client + 1.26.5 + + + + diff --git a/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java b/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java new file mode 100644 index 0000000..b62e4b1 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java @@ -0,0 +1,40 @@ +package com.bwie.common.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +public class RedisConfig { + + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(factory); + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new + Jackson2JsonRedisSerializer(Object.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); + jackson2JsonRedisSerializer.setObjectMapper(om); + + StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); + // key采用String的序列化方式 + template.setKeySerializer(stringRedisSerializer); + // hash的key也采用String的序列化方式 + template.setHashKeySerializer(stringRedisSerializer); + // value序列化方式采用jackson + template.setValueSerializer(jackson2JsonRedisSerializer); + // hash的value序列化方式采用jackson + template.setHashValueSerializer(jackson2JsonRedisSerializer); + template.afterPropertiesSet(); + + return template; + } +} diff --git a/bwie-common/src/main/java/com/bwie/common/constants/Constants.java b/bwie-common/src/main/java/com/bwie/common/constants/Constants.java new file mode 100644 index 0000000..2fdc9fe --- /dev/null +++ b/bwie-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/bwie-common/src/main/java/com/bwie/common/constants/JwtConstants.java b/bwie-common/src/main/java/com/bwie/common/constants/JwtConstants.java new file mode 100644 index 0000000..03692c1 --- /dev/null +++ b/bwie-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/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQQueueConstants.java b/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQQueueConstants.java new file mode 100644 index 0000000..b054d9c --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQQueueConstants.java @@ -0,0 +1,25 @@ +package com.bwie.common.constants; + +/** + * @ClassName: + * @Description: RabbitMQ 队列名称常量 + * @Author: zhuwenqiang + * @Date: 2023/9/19 + */ +public class RabbitMQQueueConstants { + + /** + * 短信队列名称 + */ + public static final String SENS_SMS_QUEUE = "send_sms_queue"; + + /** + * 登录日志队列名称 + */ + public static final String LONG_LOG_QUEUE = "long_log_queue"; + + /** + * 添加入库队列名称 + */ + public static final String ADD_RECEIPT_QUEUE = "add_receipt_queue"; +} diff --git a/bwie-common/src/main/java/com/bwie/common/constants/RabbitName.java b/bwie-common/src/main/java/com/bwie/common/constants/RabbitName.java new file mode 100644 index 0000000..e0d4956 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/constants/RabbitName.java @@ -0,0 +1,5 @@ +package com.bwie.common.constants; + +public class RabbitName { + public static final String RabbitConName = "rabbit"; +} diff --git a/bwie-common/src/main/java/com/bwie/common/constants/TokenConstants.java b/bwie-common/src/main/java/com/bwie/common/constants/TokenConstants.java new file mode 100644 index 0000000..1871fb7 --- /dev/null +++ b/bwie-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/bwie-common/src/main/java/com/bwie/common/domain/New.java b/bwie-common/src/main/java/com/bwie/common/domain/New.java new file mode 100644 index 0000000..1e40b92 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/New.java @@ -0,0 +1,18 @@ +package com.bwie.common.domain; + +import lombok.Data; + +import java.util.Date; + +@Data +public class New { + private String id; + private String newBt; + private String newZw; + private String newZz; + private Date newDate; + private Integer createId; + private Integer typeId; + private String typeName; + private String userName; +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/User.java b/bwie-common/src/main/java/com/bwie/common/domain/User.java new file mode 100644 index 0000000..6783eb9 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/User.java @@ -0,0 +1,12 @@ +package com.bwie.common.domain; + +import lombok.Data; + +@Data +public class User { + private Integer userId; + private String userName; + private String userPwd; + private String phone; + private Integer role; +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/LoginRequest.java b/bwie-common/src/main/java/com/bwie/common/domain/request/LoginRequest.java new file mode 100644 index 0000000..36c8497 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/request/LoginRequest.java @@ -0,0 +1,9 @@ +package com.bwie.common.domain.request; + +import lombok.Data; + +@Data +public class LoginRequest { + private String phone; + private String code; +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/NewRequest.java b/bwie-common/src/main/java/com/bwie/common/domain/request/NewRequest.java new file mode 100644 index 0000000..7e15d88 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/request/NewRequest.java @@ -0,0 +1,15 @@ +package com.bwie.common.domain.request; + +import lombok.Data; + +import java.util.Date; + +@Data +public class NewRequest { + private String newZz; + private Date beginTime; + private Date endTime; + private Integer pageNum=1; + private Integer pageSize=3; + private Integer createId; +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/response/JwtResponse.java b/bwie-common/src/main/java/com/bwie/common/domain/response/JwtResponse.java new file mode 100644 index 0000000..df20d8a --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/response/JwtResponse.java @@ -0,0 +1,9 @@ +package com.bwie.common.domain.response; + +import lombok.Data; + +@Data +public class JwtResponse { + private String token; + private String time; +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/response/NewResponse.java b/bwie-common/src/main/java/com/bwie/common/domain/response/NewResponse.java new file mode 100644 index 0000000..22fe490 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/response/NewResponse.java @@ -0,0 +1,8 @@ +package com.bwie.common.domain.response; + +import com.bwie.common.domain.New; + +public class NewResponse extends New { + private String userName; + private String typeName; +} diff --git a/bwie-common/src/main/java/com/bwie/common/result/PageResult.java b/bwie-common/src/main/java/com/bwie/common/result/PageResult.java new file mode 100644 index 0000000..85ecdda --- /dev/null +++ b/bwie-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/bwie-common/src/main/java/com/bwie/common/result/Result.java b/bwie-common/src/main/java/com/bwie/common/result/Result.java new file mode 100644 index 0000000..30b1e73 --- /dev/null +++ b/bwie-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/bwie-common/src/main/java/com/bwie/common/utils/FastUtil.java b/bwie-common/src/main/java/com/bwie/common/utils/FastUtil.java new file mode 100644 index 0000000..94b1722 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/utils/FastUtil.java @@ -0,0 +1,55 @@ +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.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/bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java b/bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java new file mode 100644 index 0000000..f560aa9 --- /dev/null +++ b/bwie-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/bwie-common/src/main/java/com/bwie/common/utils/OssUtil.java b/bwie-common/src/main/java/com/bwie/common/utils/OssUtil.java new file mode 100644 index 0000000..9c1383f --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/utils/OssUtil.java @@ -0,0 +1,153 @@ +package com.bwie.common.utils; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.GetObjectRequest; +import com.aliyun.oss.model.PutObjectRequest; +import lombok.extern.log4j.Log4j2; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.time.LocalDateTime; +import java.util.UUID; + +/** + * Oss服务调用 + */ +@Log4j2 +public class OssUtil { + + /** + * Endpoint 存储对象概述 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 访问路径前缀 存储对象概述 + */ + private static String endPoint = "oss-cn-shanghai.aliyuncs.com"; + private static String accessKeyId = "LTAI5tD2tppzLQ4Rb6yKYyph"; + private static String accessKeySecret = "KEKNKwVvDq7PZLjE63NPBouqHXox4Q"; + private static String accessPre = "https://dzlmuyu.oss-cn-shanghai.aliyuncs.com/"; + + /** + * bucket名称 + * @return + */ + private static String bucketName = "dzlmuyu"; + + private static OSS ossClient ; + + static { + ossClient = new OSSClientBuilder().build( + endPoint, + accessKeyId, + accessKeySecret); + log.info("oss服务连接成功!"); + } + + /** + * 默认路径上传本地文件 + * @param filePath + */ + public static String uploadFile(String filePath){ + return uploadFileForBucket(bucketName,getOssFilePath(filePath) ,filePath); + } + + /** + * 默认路径上传multipartFile文件 + * @param multipartFile + */ + public static String uploadMultipartFile(MultipartFile multipartFile) { + return uploadMultipartFile(bucketName,getOssFilePath(multipartFile.getOriginalFilename()),multipartFile); + } + /** + * 上传 multipartFile 类型文件 + * @param bucketName + * @param ossPath + * @param multipartFile + */ + public static String uploadMultipartFile(String bucketName , String ossPath , MultipartFile multipartFile){ + InputStream inputStream = null; + try { + inputStream = multipartFile.getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + } + uploadFileInputStreamForBucket(bucketName, ossPath, inputStream); + return accessPre+ossPath; + } + + /** + * 使用File上传PutObject上传文件 ** 程序默认使用次方法上传 + * @param bucketName 实例名称 + * @param ossPath oss存储路径 + * @param filePath 本地文件路径 + */ + public static String uploadFileForBucket(String bucketName , String ossPath , String filePath) { + // 创建PutObjectRequest对象。 + PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath)); + + // 上传 + ossClient.putObject(putObjectRequest); + return accessPre+ossPath; + } + + /** + * 使用文件流上传到指定的bucket实例 + * @param bucketName 实例名称 + * @param ossPath oss存储路径 + * @param filePath 本地文件路径 + */ + public static String uploadFileInputStreamForBucket(String bucketName , String ossPath , String filePath){ + + // 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。 + InputStream inputStream = null; + try { + inputStream = new FileInputStream(filePath); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + // 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。 + uploadFileInputStreamForBucket(bucketName, ossPath, inputStream); + return accessPre+ossPath; + } + + public static void uploadFileInputStreamForBucket(String bucketName , String ossPath , InputStream inputStream ){ + ossClient.putObject(bucketName, ossPath, inputStream); + } + + /** + * 下载 + * @param ossFilePath + * @param filePath + */ + public static void downloadFile(String ossFilePath , String filePath ){ + downloadFileForBucket(bucketName , ossFilePath , filePath); + } + /** + * 下载 + * @param bucketName 实例名称 + * @param ossFilePath oss存储路径 + * @param filePath 本地文件路径 + */ + public static void downloadFileForBucket(String bucketName , String ossFilePath , String filePath ){ + ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath)); + } + + /** + * + * @return + */ + public static String getOssDefaultPath(){ + LocalDateTime now = LocalDateTime.now(); + String url = + now.getYear()+"/"+ + now.getMonth()+"/"+ + now.getDayOfMonth()+"/"+ + now.getHour()+"/"+ + now.getMinute()+"/"; + return url; + } + + public static String getOssFilePath(String filePath){ + String fileSuf = filePath.substring(filePath.indexOf(".") + 1); + return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf; + } + +} diff --git a/bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java b/bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java new file mode 100644 index 0000000..93c47fd --- /dev/null +++ b/bwie-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/bwie-common/src/main/java/com/bwie/common/utils/TelSmsUtils.java b/bwie-common/src/main/java/com/bwie/common/utils/TelSmsUtils.java new file mode 100644 index 0000000..36a1207 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/utils/TelSmsUtils.java @@ -0,0 +1,88 @@ +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.HashMap; +import java.util.Map; + +/** + * 短信工具类 + */ +@Log4j2 +public class TelSmsUtils { + + /** + * 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 + */ + private static String accessKeyId = "LTAI5tQYiKvBrFCLCdJViegZ"; + private static String accessKeySecret = "pzGYeyC6BuXrdIW8f8ueLbdgHSb8MW"; + private static String templateCode = "SMS10001"; + /** + * 短信访问域名 + */ + 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 phone + * @param sendDataMap + */ + public static String sendSms(String phone , Map sendDataMap){ + SendSmsRequest sendSmsRequest = new SendSmsRequest() + .setPhoneNumbers(phone) + .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("短信发送异常,手机号:【{}】,短信内容:【{}】,异常信息:【{}】", phone, sendDataMap, e); + } + return JSONObject.toJSONString(sendSmsResponse.getBody()); + } + + +} diff --git a/bwie-common/target/bwie-common-1.0-SNAPSHOT.jar b/bwie-common/target/bwie-common-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..11c4927 Binary files /dev/null and b/bwie-common/target/bwie-common-1.0-SNAPSHOT.jar differ diff --git a/bwie-common/target/classes/com/bwie/common/config/RedisConfig.class b/bwie-common/target/classes/com/bwie/common/config/RedisConfig.class new file mode 100644 index 0000000..e636e57 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/config/RedisConfig.class differ diff --git a/bwie-common/target/classes/com/bwie/common/constants/Constants.class b/bwie-common/target/classes/com/bwie/common/constants/Constants.class new file mode 100644 index 0000000..ca526b6 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/constants/Constants.class differ diff --git a/bwie-common/target/classes/com/bwie/common/constants/JwtConstants.class b/bwie-common/target/classes/com/bwie/common/constants/JwtConstants.class new file mode 100644 index 0000000..452b534 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/constants/JwtConstants.class differ diff --git a/bwie-common/target/classes/com/bwie/common/constants/RabbitMQQueueConstants.class b/bwie-common/target/classes/com/bwie/common/constants/RabbitMQQueueConstants.class new file mode 100644 index 0000000..fc4eccb Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/constants/RabbitMQQueueConstants.class differ diff --git a/bwie-common/target/classes/com/bwie/common/constants/RabbitName.class b/bwie-common/target/classes/com/bwie/common/constants/RabbitName.class new file mode 100644 index 0000000..6b173f9 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/constants/RabbitName.class differ diff --git a/bwie-common/target/classes/com/bwie/common/constants/TokenConstants.class b/bwie-common/target/classes/com/bwie/common/constants/TokenConstants.class new file mode 100644 index 0000000..684ace3 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/constants/TokenConstants.class differ diff --git a/bwie-common/target/classes/com/bwie/common/domain/New.class b/bwie-common/target/classes/com/bwie/common/domain/New.class new file mode 100644 index 0000000..36c0a62 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/domain/New.class differ diff --git a/bwie-common/target/classes/com/bwie/common/domain/User.class b/bwie-common/target/classes/com/bwie/common/domain/User.class new file mode 100644 index 0000000..ca3d7c7 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/domain/User.class differ diff --git a/bwie-common/target/classes/com/bwie/common/domain/request/LoginRequest.class b/bwie-common/target/classes/com/bwie/common/domain/request/LoginRequest.class new file mode 100644 index 0000000..5f5443e Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/domain/request/LoginRequest.class differ diff --git a/bwie-common/target/classes/com/bwie/common/domain/request/NewRequest.class b/bwie-common/target/classes/com/bwie/common/domain/request/NewRequest.class new file mode 100644 index 0000000..47e1151 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/domain/request/NewRequest.class differ diff --git a/bwie-common/target/classes/com/bwie/common/domain/response/JwtResponse.class b/bwie-common/target/classes/com/bwie/common/domain/response/JwtResponse.class new file mode 100644 index 0000000..200c979 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/domain/response/JwtResponse.class differ diff --git a/bwie-common/target/classes/com/bwie/common/domain/response/NewResponse.class b/bwie-common/target/classes/com/bwie/common/domain/response/NewResponse.class new file mode 100644 index 0000000..19e6411 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/domain/response/NewResponse.class differ diff --git a/bwie-common/target/classes/com/bwie/common/result/PageResult.class b/bwie-common/target/classes/com/bwie/common/result/PageResult.class new file mode 100644 index 0000000..29e9687 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/result/PageResult.class differ diff --git a/bwie-common/target/classes/com/bwie/common/result/Result.class b/bwie-common/target/classes/com/bwie/common/result/Result.class new file mode 100644 index 0000000..39ab3df Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/result/Result.class differ diff --git a/bwie-common/target/classes/com/bwie/common/utils/FastUtil.class b/bwie-common/target/classes/com/bwie/common/utils/FastUtil.class new file mode 100644 index 0000000..c87c0cf Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/utils/FastUtil.class differ diff --git a/bwie-common/target/classes/com/bwie/common/utils/JwtUtils.class b/bwie-common/target/classes/com/bwie/common/utils/JwtUtils.class new file mode 100644 index 0000000..bb09882 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/utils/JwtUtils.class differ diff --git a/bwie-common/target/classes/com/bwie/common/utils/OssUtil.class b/bwie-common/target/classes/com/bwie/common/utils/OssUtil.class new file mode 100644 index 0000000..6d54e46 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/utils/OssUtil.class differ diff --git a/bwie-common/target/classes/com/bwie/common/utils/StringUtils.class b/bwie-common/target/classes/com/bwie/common/utils/StringUtils.class new file mode 100644 index 0000000..c7aabd6 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/utils/StringUtils.class differ diff --git a/bwie-common/target/classes/com/bwie/common/utils/TelSmsUtils.class b/bwie-common/target/classes/com/bwie/common/utils/TelSmsUtils.class new file mode 100644 index 0000000..2547872 Binary files /dev/null and b/bwie-common/target/classes/com/bwie/common/utils/TelSmsUtils.class differ diff --git a/bwie-common/target/maven-archiver/pom.properties b/bwie-common/target/maven-archiver/pom.properties new file mode 100644 index 0000000..b19b7dc --- /dev/null +++ b/bwie-common/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=bwie-common +groupId=com.bwie +version=1.0-SNAPSHOT diff --git a/bwie-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/bwie-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..062ec68 --- /dev/null +++ b/bwie-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,19 @@ +com\bwie\common\result\PageResult.class +com\bwie\common\domain\request\LoginRequest.class +com\bwie\common\domain\User.class +com\bwie\common\utils\TelSmsUtils.class +com\bwie\common\utils\JwtUtils.class +com\bwie\common\constants\RabbitMQQueueConstants.class +com\bwie\common\utils\StringUtils.class +com\bwie\common\constants\JwtConstants.class +com\bwie\common\domain\request\NewRequest.class +com\bwie\common\constants\Constants.class +com\bwie\common\domain\response\NewResponse.class +com\bwie\common\constants\TokenConstants.class +com\bwie\common\utils\OssUtil.class +com\bwie\common\result\Result.class +com\bwie\common\domain\New.class +com\bwie\common\config\RedisConfig.class +com\bwie\common\utils\FastUtil.class +com\bwie\common\constants\RabbitName.class +com\bwie\common\domain\response\JwtResponse.class diff --git a/bwie-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/bwie-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..d8564f7 --- /dev/null +++ b/bwie-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,19 @@ +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\constants\JwtConstants.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\domain\response\NewResponse.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\domain\request\NewRequest.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\utils\JwtUtils.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\utils\OssUtil.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\utils\StringUtils.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\constants\RabbitName.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\utils\FastUtil.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\result\Result.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\constants\Constants.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\constants\RabbitMQQueueConstants.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\config\RedisConfig.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\domain\request\LoginRequest.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\domain\response\JwtResponse.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\domain\User.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\domain\New.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\result\PageResult.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\constants\TokenConstants.java +D:\zhuangao5\new\bwie-common\src\main\java\com\bwie\common\utils\TelSmsUtils.java diff --git a/bwie-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/bwie-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/bwie-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-gateway/pom.xml b/bwie-gateway/pom.xml new file mode 100644 index 0000000..553b5be --- /dev/null +++ b/bwie-gateway/pom.xml @@ -0,0 +1,44 @@ + + + + day4-zy + com.bwie + 1.0-SNAPSHOT + + 4.0.0 + + bwie-gateway + + + + + + + com.bwie + bwie-common + + + + + + 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/bwie-gateway/src/main/java/com/bwie/gateway/GatewayApp.java b/bwie-gateway/src/main/java/com/bwie/gateway/GatewayApp.java new file mode 100644 index 0000000..962bc29 --- /dev/null +++ b/bwie-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/bwie-gateway/src/main/java/com/bwie/gateway/config/IgnoreWhiteConfig.java b/bwie-gateway/src/main/java/com/bwie/gateway/config/IgnoreWhiteConfig.java new file mode 100644 index 0000000..5705d6f --- /dev/null +++ b/bwie-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/bwie-gateway/src/main/java/com/bwie/gateway/filters/AuthFilter.java b/bwie-gateway/src/main/java/com/bwie/gateway/filters/AuthFilter.java new file mode 100644 index 0000000..3afd7d6 --- /dev/null +++ b/bwie-gateway/src/main/java/com/bwie/gateway/filters/AuthFilter.java @@ -0,0 +1,99 @@ +package com.bwie.gateway.filters; + +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONObject; +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.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.stereotype.Component; +import org.springframework.core.Ordered; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +import java.util.Date; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @ClassName: + * @Description: 网关过滤器 过滤用户的请求 验证 token gateway 全局过滤器 + * @Author: zhuwenqiang + * @Date: 2023/6/19 + */ +@Component +public class AuthFilter implements GlobalFilter, Ordered { + + @Autowired + private IgnoreWhiteConfig ignoreWhitesConfig; + + @Autowired + private RedisTemplate redisTemplate; + + /** + * 过滤方法 + * @param exchange 请求上下文 + * @param chain 过滤器链 + * @return + */ + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + // 判断 当前的请求 是否 是 白名单 请求 + // 获取 系统定义的白名单 请求 + List whites = ignoreWhitesConfig.getWhites(); + // 获取 当前请求的 URI + 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 合法性 如果token 是假的的 方法就会抛出异常 + try { + JwtUtils.parseToken(token); + } catch (Exception e) { + return GatewayUtils.errorResponse(exchange, "token不合法!"); + } + // token 有效 【是否过期】 + // 获取 UserKey + String userKey = JwtUtils.getUserKey(token); + Boolean hasKey = redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY + userKey); + if (null == hasKey || !hasKey) { + return GatewayUtils.errorResponse(exchange, "token过期!"); + } + + // String jsonStr = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey); + // SysUser sysUser = JSONObject.parseObject(jsonStr, SysUser.class); + + // Date lastLoginTime = sysUser.getLastLoginTime(); + + // long between = DateUtil.between(lastLoginTime, new Date(), DateUnit.MINUTE); + // if (between >= 10) { + // redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY + userKey, 15, TimeUnit.MINUTES); + // } + // 验证通过放行 + return chain.filter(exchange); + } + + /** + * 指定当前过滤器执行顺序 数值越小执行优先级越高 + * @return + */ + @Override + public int getOrder() { + return 0; + } +} diff --git a/bwie-gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java b/bwie-gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java new file mode 100644 index 0000000..7b789e5 --- /dev/null +++ b/bwie-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/bwie-gateway/src/main/resources/bootstrap.yml b/bwie-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..5b1a714 --- /dev/null +++ b/bwie-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,29 @@ +# Tomcat +server: + port: 18080 +# Spring +spring: + application: + # 应用名称 + name: bwie-gateway + profiles: + # 环境配置 + active: dev + main: + # 允许使用循环引用 + allow-circular-references: true + # 允许定义相同的bean对象 去覆盖原有的 + allow-bean-definition-overriding: true + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-gateway/target/bwie-gateway-1.0-SNAPSHOT.jar b/bwie-gateway/target/bwie-gateway-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..3c9dab9 Binary files /dev/null and b/bwie-gateway/target/bwie-gateway-1.0-SNAPSHOT.jar differ diff --git a/bwie-gateway/target/classes/bootstrap.yml b/bwie-gateway/target/classes/bootstrap.yml new file mode 100644 index 0000000..5b1a714 --- /dev/null +++ b/bwie-gateway/target/classes/bootstrap.yml @@ -0,0 +1,29 @@ +# Tomcat +server: + port: 18080 +# Spring +spring: + application: + # 应用名称 + name: bwie-gateway + profiles: + # 环境配置 + active: dev + main: + # 允许使用循环引用 + allow-circular-references: true + # 允许定义相同的bean对象 去覆盖原有的 + allow-bean-definition-overriding: true + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-gateway/target/classes/com/bwie/gateway/GatewayApp.class b/bwie-gateway/target/classes/com/bwie/gateway/GatewayApp.class new file mode 100644 index 0000000..47ed25b Binary files /dev/null and b/bwie-gateway/target/classes/com/bwie/gateway/GatewayApp.class differ diff --git a/bwie-gateway/target/classes/com/bwie/gateway/config/IgnoreWhiteConfig.class b/bwie-gateway/target/classes/com/bwie/gateway/config/IgnoreWhiteConfig.class new file mode 100644 index 0000000..a84d020 Binary files /dev/null and b/bwie-gateway/target/classes/com/bwie/gateway/config/IgnoreWhiteConfig.class differ diff --git a/bwie-gateway/target/classes/com/bwie/gateway/filters/AuthFilter.class b/bwie-gateway/target/classes/com/bwie/gateway/filters/AuthFilter.class new file mode 100644 index 0000000..3fe30f5 Binary files /dev/null and b/bwie-gateway/target/classes/com/bwie/gateway/filters/AuthFilter.class differ diff --git a/bwie-gateway/target/classes/com/bwie/gateway/utils/GatewayUtils.class b/bwie-gateway/target/classes/com/bwie/gateway/utils/GatewayUtils.class new file mode 100644 index 0000000..ab7f2c5 Binary files /dev/null and b/bwie-gateway/target/classes/com/bwie/gateway/utils/GatewayUtils.class differ diff --git a/bwie-gateway/target/maven-archiver/pom.properties b/bwie-gateway/target/maven-archiver/pom.properties new file mode 100644 index 0000000..87bdbf4 --- /dev/null +++ b/bwie-gateway/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=bwie-gateway +groupId=com.bwie +version=1.0-SNAPSHOT diff --git a/bwie-gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/bwie-gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..18d6926 --- /dev/null +++ b/bwie-gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,4 @@ +com\bwie\gateway\config\IgnoreWhiteConfig.class +com\bwie\gateway\filters\AuthFilter.class +com\bwie\gateway\GatewayApp.class +com\bwie\gateway\utils\GatewayUtils.class diff --git a/bwie-gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/bwie-gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..ef6727d --- /dev/null +++ b/bwie-gateway/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +D:\zhuangao5\new\bwie-gateway\src\main\java\com\bwie\gateway\filters\AuthFilter.java +D:\zhuangao5\new\bwie-gateway\src\main\java\com\bwie\gateway\GatewayApp.java +D:\zhuangao5\new\bwie-gateway\src\main\java\com\bwie\gateway\config\IgnoreWhiteConfig.java +D:\zhuangao5\new\bwie-gateway\src\main\java\com\bwie\gateway\utils\GatewayUtils.java diff --git a/bwie-gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/bwie-gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/bwie-gateway/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/bwie-es/pom.xml b/bwie-moudels/bwie-es/pom.xml new file mode 100644 index 0000000..ece52d4 --- /dev/null +++ b/bwie-moudels/bwie-es/pom.xml @@ -0,0 +1,37 @@ + + + + bwie-moudels + com.bwie + 1.0-SNAPSHOT + + 4.0.0 + + bwie-es + + + + com.bwie + bwie-common + + + org.springframework.boot + spring-boot-starter-web + + + org.elasticsearch.client + elasticsearch-rest-high-level-client + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + diff --git a/bwie-moudels/bwie-es/src/main/java/com/bwie/es/EsApp.java b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/EsApp.java new file mode 100644 index 0000000..b378a12 --- /dev/null +++ b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/EsApp.java @@ -0,0 +1,15 @@ +package com.bwie.es; + +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 +@EnableScheduling +public class EsApp { + public static void main(String[] args) { + SpringApplication.run(EsApp.class); + } +} diff --git a/bwie-moudels/bwie-es/src/main/java/com/bwie/es/config/InitElasticSearchRestHighClient.java b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/config/InitElasticSearchRestHighClient.java new file mode 100644 index 0000000..813a8b2 --- /dev/null +++ b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/config/InitElasticSearchRestHighClient.java @@ -0,0 +1,33 @@ +package com.bwie.es.config; + +import lombok.Data; +import org.apache.http.HttpHost; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestHighLevelClient; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @ClassName: + * @Description: 初始化es 客户端 然后通过 客户端 操作es + * @Author: zhuwenqiang + * @Date: 2023/9/23 + */ +@Configuration +@ConfigurationProperties(prefix = "es") +@Data +public class InitElasticSearchRestHighClient { + + private String host; + private int port; + private String scheme; + + @Bean + public RestHighLevelClient init() { + return new RestHighLevelClient( + RestClient.builder(new HttpHost(host, port, scheme)) + ); + } + +} diff --git a/bwie-moudels/bwie-es/src/main/java/com/bwie/es/controller/EsController.java b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/controller/EsController.java new file mode 100644 index 0000000..d7d9557 --- /dev/null +++ b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/controller/EsController.java @@ -0,0 +1,34 @@ +package com.bwie.es.controller; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.common.domain.request.NewRequest; +import com.bwie.common.domain.response.NewResponse; +import com.bwie.common.result.PageResult; +import com.bwie.common.result.Result; +import com.bwie.es.service.EsService; +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.RestController; + +import javax.servlet.http.HttpServletRequest; + +@RestController +@Log4j2 +public class EsController { + @Autowired + EsService esService; + @Autowired + HttpServletRequest request; + + @PostMapping("/search") + public Result> search(@RequestBody NewRequest newRequest){ + log.info("执行操作:高量查询列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(newRequest)); + Result> result=esService.search(newRequest); + log.info("执行操作:高量查询列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(result)); + return result; + } +} diff --git a/bwie-moudels/bwie-es/src/main/java/com/bwie/es/feign/NewFeignService.java b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/feign/NewFeignService.java new file mode 100644 index 0000000..98e845e --- /dev/null +++ b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/feign/NewFeignService.java @@ -0,0 +1,14 @@ +package com.bwie.es.feign; + +import com.bwie.common.domain.response.NewResponse; +import com.bwie.common.result.Result; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +import java.util.List; + +@FeignClient("bwie-new") +public interface NewFeignService { + @GetMapping("/findAll") + public Result> findAll(); +} diff --git a/bwie-moudels/bwie-es/src/main/java/com/bwie/es/service/EsService.java b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/service/EsService.java new file mode 100644 index 0000000..4857a91 --- /dev/null +++ b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/service/EsService.java @@ -0,0 +1,14 @@ +package com.bwie.es.service; + +import com.bwie.common.domain.request.NewRequest; +import com.bwie.common.domain.response.NewResponse; +import com.bwie.common.result.PageResult; +import com.bwie.common.result.Result; + +import java.util.List; + +public interface EsService { + void batchAdd(List data); + + Result> search(NewRequest newRequest); +} diff --git a/bwie-moudels/bwie-es/src/main/java/com/bwie/es/service/EsServiceimpl.java b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/service/EsServiceimpl.java new file mode 100644 index 0000000..0abe0b1 --- /dev/null +++ b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/service/EsServiceimpl.java @@ -0,0 +1,137 @@ +package com.bwie.es.service; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SimplePropertyPreFilter; +import com.bwie.common.constants.TokenConstants; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.NewRequest; +import com.bwie.common.domain.response.NewResponse; +import com.bwie.common.result.PageResult; +import com.bwie.common.result.Result; +import com.bwie.common.utils.JwtUtils; +import com.bwie.common.utils.StringUtils; +import netscape.javascript.JSObject; +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.common.text.Text; +import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.SearchHits; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; +import org.elasticsearch.search.fetch.subphase.highlight.HighlightField; +import org.elasticsearch.search.sort.SortOrder; +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.ArrayList; +import java.util.List; +import java.util.Map; + +@Service +public class EsServiceimpl implements EsService{ + @Autowired + RestHighLevelClient restHighLevelClient; + private static final String INDEX_NAME="new"; + @Autowired + RedisTemplate redisTemplate; + @Autowired + HttpServletRequest request; + @Override + public void batchAdd(List data) { + BulkRequest bulkRequest = new BulkRequest(INDEX_NAME); + SimplePropertyPreFilter filter = new SimplePropertyPreFilter(); + filter.getExcludes().add("id"); + try { + data.forEach(item->{ + bulkRequest.add( + new IndexRequest() + .id(item.getId()+"") + .source(JSONObject.toJSONString(item,filter), XContentType.JSON) + ); + }); + restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT); + }catch (Exception e){ + e.printStackTrace(); + } + + } + + @Override + public Result> search(NewRequest newRequest) { + long total=0; + ArrayList newResponses = new ArrayList<>(); + try { + SearchRequest searchRequest = new SearchRequest(INDEX_NAME); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + + if (StringUtils.isNotEmpty(newRequest.getNewZz())){ + boolQuery.must(QueryBuilders.matchQuery("newZz",newRequest.getNewZz())); + } + if (newRequest.getBeginTime()!=null){ + boolQuery.must(QueryBuilders.rangeQuery("newDate").gte(newRequest.getBeginTime().getTime())); + } + if (newRequest.getEndTime()!=null){ + boolQuery.must(QueryBuilders.rangeQuery("newDate").lte(newRequest.getEndTime().getTime())); + } + searchSourceBuilder.query(boolQuery); + searchSourceBuilder.size(newRequest.getPageSize()); + searchSourceBuilder.from((newRequest.getPageNum()-1)*newRequest.getPageSize()); + searchSourceBuilder.sort("newDate", SortOrder.DESC); + Integer role = info().getRole(); + if (role==1){ + newRequest.setCreateId(info().getUserId()); + } + searchSourceBuilder.highlighter( + new HighlightBuilder() + .field("newZz") + .postTags("") + .preTags("") + ); + searchRequest.source(searchSourceBuilder); + SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT); + SearchHits hits = searchResponse.getHits(); + total = hits.getTotalHits().value; + SearchHit[] hits1 = hits.getHits(); + for (SearchHit hit : hits1) { + Map highlightFields = hit.getHighlightFields(); + String sourceAsString = hit.getSourceAsString(); + NewResponse newResponse = JSONObject.parseObject(sourceAsString, NewResponse.class); + if (highlightFields!=null){ + HighlightField highlightField = highlightFields.get("newZz"); + if (highlightField!=null){ + StringBuilder sb = new StringBuilder(); + Text[] fragments = highlightField.getFragments(); + for (Text fragment : fragments) { + sb.append(fragment); + } + newResponse.setNewZz(sb.toString()); + } + } + newResponse.setId(hit.getId()); + newResponses.add(newResponse); + } + + }catch (Exception e){ + e.printStackTrace(); + } + return PageResult.toResult(total,newResponses); + } + + + public User info() { + String token = request.getHeader(TokenConstants.TOKEN); + String userKey = JwtUtils.getUserKey(token); + String jsonKeyStr = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey); + return JSONObject.parseObject(jsonKeyStr,User.class); + } +} diff --git a/bwie-moudels/bwie-es/src/main/java/com/bwie/es/sync/Async.java b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/sync/Async.java new file mode 100644 index 0000000..048672c --- /dev/null +++ b/bwie-moudels/bwie-es/src/main/java/com/bwie/es/sync/Async.java @@ -0,0 +1,37 @@ +package com.bwie.es.sync; + +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.bwie.common.domain.New; +import com.bwie.common.domain.response.NewResponse; +import com.bwie.common.result.Result; +import com.bwie.es.feign.NewFeignService; +import com.bwie.es.service.EsService; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +@Component +@Log4j2 +public class Async { + @Autowired + NewFeignService newFeignService; + @Autowired + EsService esService; + + @Scheduled(cron = "0 */1 * * * *") + public void async(){ + Result> all = newFeignService.findAll(); + List data = all.getData(); + if (!CollectionUtils.isEmpty(data)){ + log.info("查询到:{}条数据,开始同步...",data.size()); + long s = System.currentTimeMillis(); + esService.batchAdd(data); + log.info("数据同步完成,用时:{}毫秒",System.currentTimeMillis()-s); + } + + } +} diff --git a/bwie-moudels/bwie-es/src/main/resources/bootstrap.yml b/bwie-moudels/bwie-es/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..78ff92e --- /dev/null +++ b/bwie-moudels/bwie-es/src/main/resources/bootstrap.yml @@ -0,0 +1,22 @@ +server: + port: 9006 +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd + time-zone: GMT+8 + application: + name: bwie-es + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + serverAddr: 111.229.36.192:8848 + config: + serverAddr: 111.229.36.192:8848 + fileExtension: yml + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-moudels/bwie-es/target/bwie-es-1.0-SNAPSHOT.jar b/bwie-moudels/bwie-es/target/bwie-es-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..2caa73b Binary files /dev/null and b/bwie-moudels/bwie-es/target/bwie-es-1.0-SNAPSHOT.jar differ diff --git a/bwie-moudels/bwie-es/target/classes/bootstrap.yml b/bwie-moudels/bwie-es/target/classes/bootstrap.yml new file mode 100644 index 0000000..78ff92e --- /dev/null +++ b/bwie-moudels/bwie-es/target/classes/bootstrap.yml @@ -0,0 +1,22 @@ +server: + port: 9006 +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd + time-zone: GMT+8 + application: + name: bwie-es + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + serverAddr: 111.229.36.192:8848 + config: + serverAddr: 111.229.36.192:8848 + fileExtension: yml + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-moudels/bwie-es/target/classes/com/bwie/es/EsApp.class b/bwie-moudels/bwie-es/target/classes/com/bwie/es/EsApp.class new file mode 100644 index 0000000..b7dcafb Binary files /dev/null and b/bwie-moudels/bwie-es/target/classes/com/bwie/es/EsApp.class differ diff --git a/bwie-moudels/bwie-es/target/classes/com/bwie/es/config/InitElasticSearchRestHighClient.class b/bwie-moudels/bwie-es/target/classes/com/bwie/es/config/InitElasticSearchRestHighClient.class new file mode 100644 index 0000000..61c5294 Binary files /dev/null and b/bwie-moudels/bwie-es/target/classes/com/bwie/es/config/InitElasticSearchRestHighClient.class differ diff --git a/bwie-moudels/bwie-es/target/classes/com/bwie/es/controller/EsController.class b/bwie-moudels/bwie-es/target/classes/com/bwie/es/controller/EsController.class new file mode 100644 index 0000000..e1a901e Binary files /dev/null and b/bwie-moudels/bwie-es/target/classes/com/bwie/es/controller/EsController.class differ diff --git a/bwie-moudels/bwie-es/target/classes/com/bwie/es/feign/NewFeignService.class b/bwie-moudels/bwie-es/target/classes/com/bwie/es/feign/NewFeignService.class new file mode 100644 index 0000000..f15ed12 Binary files /dev/null and b/bwie-moudels/bwie-es/target/classes/com/bwie/es/feign/NewFeignService.class differ diff --git a/bwie-moudels/bwie-es/target/classes/com/bwie/es/service/EsService.class b/bwie-moudels/bwie-es/target/classes/com/bwie/es/service/EsService.class new file mode 100644 index 0000000..879d5a8 Binary files /dev/null and b/bwie-moudels/bwie-es/target/classes/com/bwie/es/service/EsService.class differ diff --git a/bwie-moudels/bwie-es/target/classes/com/bwie/es/service/EsServiceimpl.class b/bwie-moudels/bwie-es/target/classes/com/bwie/es/service/EsServiceimpl.class new file mode 100644 index 0000000..1618283 Binary files /dev/null and b/bwie-moudels/bwie-es/target/classes/com/bwie/es/service/EsServiceimpl.class differ diff --git a/bwie-moudels/bwie-es/target/classes/com/bwie/es/sync/Async.class b/bwie-moudels/bwie-es/target/classes/com/bwie/es/sync/Async.class new file mode 100644 index 0000000..b386ddc Binary files /dev/null and b/bwie-moudels/bwie-es/target/classes/com/bwie/es/sync/Async.class differ diff --git a/bwie-moudels/bwie-es/target/maven-archiver/pom.properties b/bwie-moudels/bwie-es/target/maven-archiver/pom.properties new file mode 100644 index 0000000..d75f30b --- /dev/null +++ b/bwie-moudels/bwie-es/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=bwie-es +groupId=com.bwie +version=1.0-SNAPSHOT diff --git a/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..fbb84d5 --- /dev/null +++ b/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,7 @@ +com\bwie\es\controller\EsController.class +com\bwie\es\service\EsService.class +com\bwie\es\sync\Async.class +com\bwie\es\feign\NewFeignService.class +com\bwie\es\service\EsServiceimpl.class +com\bwie\es\EsApp.class +com\bwie\es\config\InitElasticSearchRestHighClient.class diff --git a/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..84a4c6c --- /dev/null +++ b/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,7 @@ +D:\zhuangao5\new\bwie-moudels\bwie-es\src\main\java\com\bwie\es\service\EsService.java +D:\zhuangao5\new\bwie-moudels\bwie-es\src\main\java\com\bwie\es\EsApp.java +D:\zhuangao5\new\bwie-moudels\bwie-es\src\main\java\com\bwie\es\sync\Async.java +D:\zhuangao5\new\bwie-moudels\bwie-es\src\main\java\com\bwie\es\service\EsServiceimpl.java +D:\zhuangao5\new\bwie-moudels\bwie-es\src\main\java\com\bwie\es\feign\NewFeignService.java +D:\zhuangao5\new\bwie-moudels\bwie-es\src\main\java\com\bwie\es\controller\EsController.java +D:\zhuangao5\new\bwie-moudels\bwie-es\src\main\java\com\bwie\es\config\InitElasticSearchRestHighClient.java diff --git a/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/bwie-moudels/bwie-es/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/bwie-new/pom.xml b/bwie-moudels/bwie-new/pom.xml new file mode 100644 index 0000000..3cb2659 --- /dev/null +++ b/bwie-moudels/bwie-new/pom.xml @@ -0,0 +1,50 @@ + + + + bwie-moudels + com.bwie + 1.0-SNAPSHOT + + 4.0.0 + + bwie-new + + + + + com.bwie + bwie-common + + + + 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 + + + + diff --git a/bwie-moudels/bwie-new/src/main/java/com/bwie/student/NewApp.java b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/NewApp.java new file mode 100644 index 0000000..02079fa --- /dev/null +++ b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/NewApp.java @@ -0,0 +1,11 @@ +package com.bwie.student; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class NewApp { + public static void main(String[] args) { + SpringApplication.run(NewApp.class); + } +} diff --git a/bwie-moudels/bwie-new/src/main/java/com/bwie/student/controller/NewController.java b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/controller/NewController.java new file mode 100644 index 0000000..bfb674c --- /dev/null +++ b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/controller/NewController.java @@ -0,0 +1,45 @@ +package com.bwie.student.controller; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.common.domain.request.NewRequest; +import com.bwie.common.domain.response.NewResponse; +import com.bwie.common.result.PageResult; +import com.bwie.common.result.Result; +import com.bwie.student.service.NewService; +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; +import java.util.List; + +@RestController +@Log4j2 +public class NewController { + @Autowired + NewService newService; + @Autowired + HttpServletRequest request; + @GetMapping("/findAll") + public Result> findAll(){ + log.info("执行操作:查询列表,请求URL:{},请求方式:{}",request.getRequestURI(), + request.getMethod()); + List list=newService.findAll(); + log.info("执行操作:查询列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(list)); + return Result.success(list); + } + + @PostMapping("/list") + public Result> list(@RequestBody NewRequest newRequest){ + log.info("查询列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(newRequest)); + Result> result=newService.list(newRequest); + log.info("查询列表,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(result)); + return result; + } +} diff --git a/bwie-moudels/bwie-new/src/main/java/com/bwie/student/mapper/NewMapper.java b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/mapper/NewMapper.java new file mode 100644 index 0000000..5d97062 --- /dev/null +++ b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/mapper/NewMapper.java @@ -0,0 +1,14 @@ +package com.bwie.student.mapper; + +import com.bwie.common.domain.request.NewRequest; +import com.bwie.common.domain.response.NewResponse; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface NewMapper { + List findAll(); + + List list(NewRequest newRequest); +} diff --git a/bwie-moudels/bwie-new/src/main/java/com/bwie/student/service/NewService.java b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/service/NewService.java new file mode 100644 index 0000000..2fcd631 --- /dev/null +++ b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/service/NewService.java @@ -0,0 +1,14 @@ +package com.bwie.student.service; + +import com.bwie.common.domain.request.NewRequest; +import com.bwie.common.domain.response.NewResponse; +import com.bwie.common.result.PageResult; +import com.bwie.common.result.Result; + +import java.util.List; + +public interface NewService { + List findAll(); + + Result> list(NewRequest newRequest); +} diff --git a/bwie-moudels/bwie-new/src/main/java/com/bwie/student/service/NewServiceimpl.java b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/service/NewServiceimpl.java new file mode 100644 index 0000000..7146f2c --- /dev/null +++ b/bwie-moudels/bwie-new/src/main/java/com/bwie/student/service/NewServiceimpl.java @@ -0,0 +1,31 @@ +package com.bwie.student.service; + +import com.bwie.common.domain.request.NewRequest; +import com.bwie.common.domain.response.NewResponse; +import com.bwie.common.result.PageResult; +import com.bwie.common.result.Result; +import com.bwie.student.mapper.NewMapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class NewServiceimpl implements NewService{ + @Autowired + NewMapper newMapper; + @Override + public List findAll() { + return newMapper.findAll(); + } + + @Override + public Result> list(NewRequest newRequest) { + PageHelper.startPage(newRequest.getPageNum(),newRequest.getPageSize()); + List list=newMapper.list(newRequest); + PageInfo info = new PageInfo<>(); + return PageResult.toResult(info.getTotal(),list); + } +} diff --git a/bwie-moudels/bwie-new/src/main/resources/bootstrap.yml b/bwie-moudels/bwie-new/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..e81ba61 --- /dev/null +++ b/bwie-moudels/bwie-new/src/main/resources/bootstrap.yml @@ -0,0 +1,29 @@ +# 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: bwie-new + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-moudels/bwie-new/src/main/resources/mapper/NewMapper.xml b/bwie-moudels/bwie-new/src/main/resources/mapper/NewMapper.xml new file mode 100644 index 0000000..afdda5f --- /dev/null +++ b/bwie-moudels/bwie-new/src/main/resources/mapper/NewMapper.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/bwie-moudels/bwie-new/target/bwie-new-1.0-SNAPSHOT.jar b/bwie-moudels/bwie-new/target/bwie-new-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..e95161b Binary files /dev/null and b/bwie-moudels/bwie-new/target/bwie-new-1.0-SNAPSHOT.jar differ diff --git a/bwie-moudels/bwie-new/target/classes/bootstrap.yml b/bwie-moudels/bwie-new/target/classes/bootstrap.yml new file mode 100644 index 0000000..e81ba61 --- /dev/null +++ b/bwie-moudels/bwie-new/target/classes/bootstrap.yml @@ -0,0 +1,29 @@ +# 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: bwie-new + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-moudels/bwie-new/target/classes/com/bwie/student/NewApp.class b/bwie-moudels/bwie-new/target/classes/com/bwie/student/NewApp.class new file mode 100644 index 0000000..ee8b294 Binary files /dev/null and b/bwie-moudels/bwie-new/target/classes/com/bwie/student/NewApp.class differ diff --git a/bwie-moudels/bwie-new/target/classes/com/bwie/student/controller/NewController.class b/bwie-moudels/bwie-new/target/classes/com/bwie/student/controller/NewController.class new file mode 100644 index 0000000..a921889 Binary files /dev/null and b/bwie-moudels/bwie-new/target/classes/com/bwie/student/controller/NewController.class differ diff --git a/bwie-moudels/bwie-new/target/classes/com/bwie/student/mapper/NewMapper.class b/bwie-moudels/bwie-new/target/classes/com/bwie/student/mapper/NewMapper.class new file mode 100644 index 0000000..1d5d44a Binary files /dev/null and b/bwie-moudels/bwie-new/target/classes/com/bwie/student/mapper/NewMapper.class differ diff --git a/bwie-moudels/bwie-new/target/classes/com/bwie/student/service/NewService.class b/bwie-moudels/bwie-new/target/classes/com/bwie/student/service/NewService.class new file mode 100644 index 0000000..f81577f Binary files /dev/null and b/bwie-moudels/bwie-new/target/classes/com/bwie/student/service/NewService.class differ diff --git a/bwie-moudels/bwie-new/target/classes/com/bwie/student/service/NewServiceimpl.class b/bwie-moudels/bwie-new/target/classes/com/bwie/student/service/NewServiceimpl.class new file mode 100644 index 0000000..7649b40 Binary files /dev/null and b/bwie-moudels/bwie-new/target/classes/com/bwie/student/service/NewServiceimpl.class differ diff --git a/bwie-moudels/bwie-new/target/classes/mapper/NewMapper.xml b/bwie-moudels/bwie-new/target/classes/mapper/NewMapper.xml new file mode 100644 index 0000000..afdda5f --- /dev/null +++ b/bwie-moudels/bwie-new/target/classes/mapper/NewMapper.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/bwie-moudels/bwie-new/target/maven-archiver/pom.properties b/bwie-moudels/bwie-new/target/maven-archiver/pom.properties new file mode 100644 index 0000000..3033018 --- /dev/null +++ b/bwie-moudels/bwie-new/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=bwie-new +groupId=com.bwie +version=1.0-SNAPSHOT diff --git a/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..1cd9b57 --- /dev/null +++ b/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,5 @@ +com\bwie\student\mapper\NewMapper.class +com\bwie\student\service\NewService.class +com\bwie\student\NewApp.class +com\bwie\student\service\NewServiceimpl.class +com\bwie\student\controller\NewController.class diff --git a/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..068b333 --- /dev/null +++ b/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,5 @@ +D:\zhuangao5\new\bwie-moudels\bwie-new\src\main\java\com\bwie\student\controller\NewController.java +D:\zhuangao5\new\bwie-moudels\bwie-new\src\main\java\com\bwie\student\mapper\NewMapper.java +D:\zhuangao5\new\bwie-moudels\bwie-new\src\main\java\com\bwie\student\service\NewService.java +D:\zhuangao5\new\bwie-moudels\bwie-new\src\main\java\com\bwie\student\NewApp.java +D:\zhuangao5\new\bwie-moudels\bwie-new\src\main\java\com\bwie\student\service\NewServiceimpl.java diff --git a/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/bwie-moudels/bwie-new/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/bwie-rabbit/pom.xml b/bwie-moudels/bwie-rabbit/pom.xml new file mode 100644 index 0000000..7c65123 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/pom.xml @@ -0,0 +1,37 @@ + + + + bwie-moudels + com.bwie + 1.0-SNAPSHOT + + 4.0.0 + + bwie-rabbit + + + + + com.bwie + bwie-common + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-amqp + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.9.10 + + + + + diff --git a/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/MqTest.java b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/MqTest.java new file mode 100644 index 0000000..67136e1 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/MqTest.java @@ -0,0 +1,11 @@ +package com.bwie.rabbit; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MqTest { + public static void main(String[] args) { + SpringApplication.run(MqTest.class); + } +} diff --git a/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/config/RabbitAdminConfig.java b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/config/RabbitAdminConfig.java new file mode 100644 index 0000000..dfb03e1 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/config/RabbitAdminConfig.java @@ -0,0 +1,55 @@ +package com.bwie.rabbit.config; + +import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.core.RabbitAdmin; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * RabbitAdmin RabbitAdmin是Spring-AMQP中的核心基础组件,是我们在Spring中对RabbitMQ进行初始化的必须组件,提供了RabbitMQ中声明交换机、声明队列、绑定交换机和队列,以及绑定路由Key等其他AP + * RabbitAdmin 配置类初始化 RabbitAdmin + */ +@Configuration +public class RabbitAdminConfig { + + @Value("${spring.rabbitmq.host}") + private String host; + + @Value("${spring.rabbitmq.username}") + private String username; + + @Value("${spring.rabbitmq.password}") + private String password; + + @Value("${spring.rabbitmq.virtualhost}") + private String virtualhost; + + /** + * 初始化 rabbit mq 连接工厂 + * @return + */ + @Bean + public ConnectionFactory connectionFactory() { + CachingConnectionFactory connectionFactory = new CachingConnectionFactory(); + connectionFactory.setAddresses(host); + connectionFactory.setUsername(username); + connectionFactory.setPassword(password); + connectionFactory.setVirtualHost(virtualhost); + return connectionFactory; + } + + /** + * 初始化 RabbitAdmin + * @param connectionFactory + * @return + */ + @Bean + public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) { + RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory); + // 设置自动启动 + rabbitAdmin.setAutoStartup(true); + return rabbitAdmin; + } +} diff --git a/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/config/RabbitmqConfig.java b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/config/RabbitmqConfig.java new file mode 100644 index 0000000..7b55a00 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/config/RabbitmqConfig.java @@ -0,0 +1,16 @@ +package com.bwie.rabbit.config; + +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; +import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RabbitmqConfig { + // 消息转换配置 + @Bean + public MessageConverter jsonMessageConverter(){ + return new Jackson2JsonMessageConverter(); + } + +} diff --git a/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/consumer/SendSmsConsumer.java b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/consumer/SendSmsConsumer.java new file mode 100644 index 0000000..2882660 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/consumer/SendSmsConsumer.java @@ -0,0 +1,64 @@ +package com.bwie.rabbit.consumer; + +import cn.hutool.core.util.RandomUtil; +import com.alibaba.fastjson.JSONObject; +import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody; +import com.bwie.common.constants.RabbitMQQueueConstants; +import com.bwie.common.result.Result; +import com.bwie.common.utils.TelSmsUtils; +import com.rabbitmq.client.Channel; +import lombok.extern.log4j.Log4j2; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.concurrent.TimeUnit; + +@Component +@Log4j2 +public class SendSmsConsumer { + + @Autowired + RedisTemplate redisTemplate; + + @RabbitListener(queuesToDeclare = {@Queue(RabbitMQQueueConstants.SENS_SMS_QUEUE)}) + public void sendSms(String phone,Message message,Channel channel){ + log.info("开始发送消息"); + String messageId = message.getMessageProperties().getMessageId(); + try { + Long l = redisTemplate.opsForSet().add(RabbitMQQueueConstants.SENS_SMS_QUEUE, messageId); + if (l==1){ + String code = RandomUtil.randomNumbers(4); + HashMap map = new HashMap<>(); + map.put("code",code); + String StringStr = TelSmsUtils.sendSms(phone, new HashMap() {{ + put("code", code); + }}); + SendSmsResponseBody sendSmsResponseBody = JSONObject.parseObject(StringStr, SendSmsResponseBody.class); + if (!"ok".equals(sendSmsResponseBody.getCode())){ + TelSmsUtils.sendSms(phone,new HashMap(){{ + put("code",code); + }}); + } + redisTemplate.opsForValue().set(phone,code,5, TimeUnit.MINUTES); + channel.basicAck(message.getMessageProperties().getDeliveryTag(),false); + log.info("消息发送成功"+code); + }else{ + log.info("消息已发送,请勿重复发送"); + } + }catch (Exception e){ + try { + channel.basicReject(message.getMessageProperties().getDeliveryTag(),true); + redisTemplate.opsForSet().add(RabbitMQQueueConstants.SENS_SMS_QUEUE,messageId); + }catch (Exception e1){ + e1.printStackTrace(); + } + e.printStackTrace(); + } + } +} diff --git a/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/DLXQueue.java b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/DLXQueue.java new file mode 100644 index 0000000..c7a8618 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/DLXQueue.java @@ -0,0 +1,84 @@ +package com.bwie.rabbit.utils; + +import org.springframework.amqp.core.Binding; +import org.springframework.amqp.core.BindingBuilder; +import org.springframework.amqp.core.DirectExchange; +import org.springframework.amqp.core.Queue; +import org.springframework.amqp.rabbit.core.RabbitAdmin; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +/** + * 死信队列工具类 + */ +@Component +public class DLXQueue { + // routingKey + private static final String DEAD_ROUTING_KEY = "dead.routingkey"; + + private static final String ROUTING_KEY = "routingkey"; + + private static final String DEAD_EXCHANGE = "dead.exchange"; + + private static final String EXCHANGE = "common.exchange"; + + @Autowired + RabbitTemplate rabbitTemplate; + @Resource + RabbitAdmin rabbitAdmin; + + /** + * 发送死信队列,过期后进入死信交换机,进入死信队列 + * + * @param queueName 队列名称 + * @param deadQueueName 死信队列名称 + * @param params 消息内容 + * @param expiration 过期时间 毫秒 + */ + public void sendDLXQueue(String queueName, String deadQueueName, Object params, Integer expiration) { + /** + * ----------------------------------先创建一个ttl队列和死信队列-------------------------------------------- + */ + Map map = new HashMap<>(); + // 队列设置存活时间,单位ms, 必须是整形数据。 + map.put("x-message-ttl", expiration); + // 设置死信交换机 + map.put("x-dead-letter-exchange", DEAD_EXCHANGE); + // 设置死信交换器路由 + map.put("x-dead-letter-routing-key", DEAD_ROUTING_KEY); + /*参数1:队列名称 参数2:持久化 参数3:是否排他 参数4:自动删除队列 参数5:队列参数*/ + Queue queue = new Queue(queueName, true, false, false, map); + rabbitAdmin.declareQueue(queue); + /** + * ---------------------------------创建交换机--------------------------------------------- + */ + DirectExchange directExchange = new DirectExchange(EXCHANGE, true, false); + rabbitAdmin.declareExchange(directExchange); + /** + * ---------------------------------队列绑定交换机--------------------------------------------- + */ + Binding binding = BindingBuilder.bind(queue).to(directExchange).with(ROUTING_KEY); + rabbitAdmin.declareBinding(binding); + /** + * ---------------------------------在创建一个死信交换机和队列,接收死信队列--------------------------------------------- + */ + DirectExchange deadExchange = new DirectExchange(DEAD_EXCHANGE, true, false); + rabbitAdmin.declareExchange(deadExchange); + + Queue deadQueue = new Queue(deadQueueName, true, false, false); + rabbitAdmin.declareQueue(deadQueue); + /** + * ---------------------------------队列绑定死信交换机--------------------------------------------- + */ + // 将队列和交换机绑定 + Binding deadbinding = BindingBuilder.bind(deadQueue).to(deadExchange).with(DEAD_ROUTING_KEY); + rabbitAdmin.declareBinding(deadbinding); + // 发送消息 + rabbitTemplate.convertAndSend(EXCHANGE, ROUTING_KEY, params); + } +} diff --git a/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/DelayedQueue.java b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/DelayedQueue.java new file mode 100644 index 0000000..bcfe767 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/DelayedQueue.java @@ -0,0 +1,83 @@ +package com.bwie.rabbit.utils; + +import org.springframework.amqp.AmqpException; +import org.springframework.amqp.core.*; +import org.springframework.amqp.rabbit.core.RabbitAdmin; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +/** + * 延迟队列工具类 发送延迟队列 + */ +@Component +public class DelayedQueue { + + /** + * routingKey + */ + private static final String DELAYED_ROUTING_KEY = "delayed.routingkey"; + /** + * 延迟交换机的名称 + */ + private static final String DELAYED_EXCHANGE = "delayed.exchange"; + + @Autowired + RabbitTemplate rabbitTemplate; + + @Resource + RabbitAdmin rabbitAdmin; + + /** + * 发送延迟队列 + * + * @param queueName 队列名称 + * @param params 消息内容 + * @param expiration 延迟时间 毫秒 + */ + public void sendDelayedQueue(String queueName, Object params, Integer expiration) { + // 先创建一个队列 + Queue queue = new Queue(queueName); + rabbitAdmin.declareQueue(queue); + + // 创建延迟队列交换机 + CustomExchange customExchange = createCustomExchange(); + rabbitAdmin.declareExchange(customExchange); + + // 将队列和交换机绑定 + Binding binding = BindingBuilder.bind(queue).to(customExchange).with(DELAYED_ROUTING_KEY).noargs(); + rabbitAdmin.declareBinding(binding); + + // 发送延迟消息 + rabbitTemplate.convertAndSend(DELAYED_EXCHANGE, DELAYED_ROUTING_KEY, params, message -> { + message.getMessageProperties().setDelay(expiration); + return message; + }); + } + + /** + * 构建延迟交换机 + * + * @return + */ + public CustomExchange createCustomExchange() { + Map arguments = new HashMap<>(); + /** + * 参数说明: + * 1.交换机的名称 + * 2.交换机的类型 + * 3.是否需要持久化 + * 4.是否自动删除 + * 5.其它参数 + */ + arguments.put("x-delayed-type", "direct"); + return new CustomExchange(DELAYED_EXCHANGE, "x-delayed-message", + true, false, arguments); + } + +} + diff --git a/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/TtlQueue.java b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/TtlQueue.java new file mode 100644 index 0000000..1992b93 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/src/main/java/com/bwie/rabbit/utils/TtlQueue.java @@ -0,0 +1,64 @@ +package com.bwie.rabbit.utils; + +import org.springframework.amqp.core.*; +import org.springframework.amqp.rabbit.core.RabbitAdmin; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +/** + * 发送TTL队列 + */ +@Component +public class TtlQueue { + // routingKey + private static final String TTL_KEY = "ttl.routingkey"; + /** + * TTL 交换机大的名称 + */ + private static final String TTL_EXCHANGE = "ttl.exchange"; + + @Autowired + RabbitTemplate rabbitTemplate; + + @Resource + RabbitAdmin rabbitAdmin; + + /** + * 发送TTL队列 + * + * @param queueName 队列名称 + * @param params 消息内容 + * @param expiration 过期时间 毫秒 + */ + public void sendTtlQueue(String queueName, Object params, Integer expiration) { + /** + * ----------------------------------先创建一个ttl队列-------------------------------------------- + */ + Map map = new HashMap<>(); + // 队列设置存活时间,单位ms,必须是整形数据。 + map.put("x-message-ttl", expiration); + /*参数1:队列名称 参数2:持久化 参数3:是否排他 参数4:自动删除队列 参数5:队列参数*/ + Queue queue = new Queue(queueName, true, false, false, map); + rabbitAdmin.declareQueue(queue); + /** + * ---------------------------------创建交换机--------------------------------------------- + */ + DirectExchange directExchange = new DirectExchange(TTL_EXCHANGE, true, false); + rabbitAdmin.declareExchange(directExchange); + /** + * ---------------------------------队列绑定交换机--------------------------------------------- + */ + // 将队列和交换机绑定 + Binding binding = BindingBuilder.bind(queue).to(directExchange).with(TTL_KEY); + rabbitAdmin.declareBinding(binding); + + // 发送消息 + rabbitTemplate.convertAndSend(TTL_EXCHANGE, TTL_KEY, params); + } +} + diff --git a/bwie-moudels/bwie-rabbit/src/main/resources/bootstrap.yml b/bwie-moudels/bwie-rabbit/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..8a7f28a --- /dev/null +++ b/bwie-moudels/bwie-rabbit/src/main/resources/bootstrap.yml @@ -0,0 +1,43 @@ +# Tomcat +server: + port: 9008 +# Spring +spring: + rabbitmq: + host: 111.229.36.192 + port: 5672 + virtualHost: / + username: guest + password: guest + listener: + simple: + prefetch: 1 # 每次取出来一条消息消费 消费完成消费下一条 + acknowledge-mode: manual # 设置消费端手动 ack确认 + retry: + enabled: true # # 是否支持重试 + publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange) + publisher-returns: true #确认消息已发送到队列(Queue) + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: bwie-rabbit + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-moudels/bwie-rabbit/target/bwie-rabbit-1.0-SNAPSHOT.jar b/bwie-moudels/bwie-rabbit/target/bwie-rabbit-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..0461168 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/bwie-rabbit-1.0-SNAPSHOT.jar differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/bootstrap.yml b/bwie-moudels/bwie-rabbit/target/classes/bootstrap.yml new file mode 100644 index 0000000..8a7f28a --- /dev/null +++ b/bwie-moudels/bwie-rabbit/target/classes/bootstrap.yml @@ -0,0 +1,43 @@ +# Tomcat +server: + port: 9008 +# Spring +spring: + rabbitmq: + host: 111.229.36.192 + port: 5672 + virtualHost: / + username: guest + password: guest + listener: + simple: + prefetch: 1 # 每次取出来一条消息消费 消费完成消费下一条 + acknowledge-mode: manual # 设置消费端手动 ack确认 + retry: + enabled: true # # 是否支持重试 + publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange) + publisher-returns: true #确认消息已发送到队列(Queue) + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: bwie-rabbit + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/MqTest.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/MqTest.class new file mode 100644 index 0000000..0f7f2f3 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/MqTest.class differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/config/RabbitAdminConfig.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/config/RabbitAdminConfig.class new file mode 100644 index 0000000..7c9c706 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/config/RabbitAdminConfig.class differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/config/RabbitmqConfig.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/config/RabbitmqConfig.class new file mode 100644 index 0000000..e996f85 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/config/RabbitmqConfig.class differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer$1.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer$1.class new file mode 100644 index 0000000..9e53af7 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer$1.class differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer$2.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer$2.class new file mode 100644 index 0000000..e3ff8b1 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer$2.class differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer.class new file mode 100644 index 0000000..d76a974 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/consumer/SendSmsConsumer.class differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/DLXQueue.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/DLXQueue.class new file mode 100644 index 0000000..ff901f9 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/DLXQueue.class differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/DelayedQueue.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/DelayedQueue.class new file mode 100644 index 0000000..64a1643 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/DelayedQueue.class differ diff --git a/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/TtlQueue.class b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/TtlQueue.class new file mode 100644 index 0000000..d157c09 Binary files /dev/null and b/bwie-moudels/bwie-rabbit/target/classes/com/bwie/rabbit/utils/TtlQueue.class differ diff --git a/bwie-moudels/bwie-rabbit/target/maven-archiver/pom.properties b/bwie-moudels/bwie-rabbit/target/maven-archiver/pom.properties new file mode 100644 index 0000000..6b84e51 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=bwie-rabbit +groupId=com.bwie +version=1.0-SNAPSHOT diff --git a/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..f790bf2 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,9 @@ +com\bwie\rabbit\consumer\SendSmsConsumer$1.class +com\bwie\rabbit\consumer\SendSmsConsumer.class +com\bwie\rabbit\config\RabbitAdminConfig.class +com\bwie\rabbit\utils\DLXQueue.class +com\bwie\rabbit\MqTest.class +com\bwie\rabbit\consumer\SendSmsConsumer$2.class +com\bwie\rabbit\utils\DelayedQueue.class +com\bwie\rabbit\config\RabbitmqConfig.class +com\bwie\rabbit\utils\TtlQueue.class diff --git a/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..a72a881 --- /dev/null +++ b/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,7 @@ +D:\zhuangao5\new\bwie-moudels\bwie-rabbit\src\main\java\com\bwie\rabbit\utils\DLXQueue.java +D:\zhuangao5\new\bwie-moudels\bwie-rabbit\src\main\java\com\bwie\rabbit\config\RabbitAdminConfig.java +D:\zhuangao5\new\bwie-moudels\bwie-rabbit\src\main\java\com\bwie\rabbit\config\RabbitmqConfig.java +D:\zhuangao5\new\bwie-moudels\bwie-rabbit\src\main\java\com\bwie\rabbit\consumer\SendSmsConsumer.java +D:\zhuangao5\new\bwie-moudels\bwie-rabbit\src\main\java\com\bwie\rabbit\utils\DelayedQueue.java +D:\zhuangao5\new\bwie-moudels\bwie-rabbit\src\main\java\com\bwie\rabbit\utils\TtlQueue.java +D:\zhuangao5\new\bwie-moudels\bwie-rabbit\src\main\java\com\bwie\rabbit\MqTest.java diff --git a/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/bwie-moudels/bwie-rabbit/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/bwie-user/pom.xml b/bwie-moudels/bwie-user/pom.xml new file mode 100644 index 0000000..dc266fc --- /dev/null +++ b/bwie-moudels/bwie-user/pom.xml @@ -0,0 +1,50 @@ + + + + bwie-moudels + com.bwie + 1.0-SNAPSHOT + + 4.0.0 + + bwie-user + + + + + com.bwie + bwie-common + + + + 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 + + + + diff --git a/bwie-moudels/bwie-user/src/main/java/com/bwie/user/UserApp.java b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/UserApp.java new file mode 100644 index 0000000..49424c5 --- /dev/null +++ b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/UserApp.java @@ -0,0 +1,11 @@ +package com.bwie.user; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class UserApp { + public static void main(String[] args) { + SpringApplication.run(UserApp.class); + } +} diff --git a/bwie-moudels/bwie-user/src/main/java/com/bwie/user/controller/UserController.java b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/controller/UserController.java new file mode 100644 index 0000000..485a763 --- /dev/null +++ b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/controller/UserController.java @@ -0,0 +1,35 @@ +package com.bwie.user.controller; + +import com.alibaba.fastjson.JSONObject; +import com.bwie.common.domain.User; +import com.bwie.common.result.Result; +import com.bwie.user.service.UserService; +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.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +@RestController +@Log4j2 +public class UserController { + @Autowired + UserService userService; + @Autowired + HttpServletRequest request; + @GetMapping("/findByPhone/{phone}") + public Result findByPhone(@PathVariable String phone){ + log.info("执行操作:查询手机号,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(phone)); + User user=userService.findByPhone(phone); + log.info("执行操作:查询手机号,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(), JSONObject.toJSONString(user)); + return Result.success(user); + } + +} diff --git a/bwie-moudels/bwie-user/src/main/java/com/bwie/user/mapper/UserMapper.java b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/mapper/UserMapper.java new file mode 100644 index 0000000..faca87b --- /dev/null +++ b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/mapper/UserMapper.java @@ -0,0 +1,10 @@ +package com.bwie.user.mapper; + + +import com.bwie.common.domain.User; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface UserMapper { + User findByPhone(String phone); +} diff --git a/bwie-moudels/bwie-user/src/main/java/com/bwie/user/service/UserService.java b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/service/UserService.java new file mode 100644 index 0000000..63cc995 --- /dev/null +++ b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/service/UserService.java @@ -0,0 +1,8 @@ +package com.bwie.user.service; + + +import com.bwie.common.domain.User; + +public interface UserService { + User findByPhone(String phone); +} diff --git a/bwie-moudels/bwie-user/src/main/java/com/bwie/user/service/UserServiceimpl.java b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/service/UserServiceimpl.java new file mode 100644 index 0000000..aa83395 --- /dev/null +++ b/bwie-moudels/bwie-user/src/main/java/com/bwie/user/service/UserServiceimpl.java @@ -0,0 +1,17 @@ +package com.bwie.user.service; + +import com.bwie.common.domain.User; +import com.bwie.user.mapper.UserMapper; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class UserServiceimpl implements UserService{ + @Autowired + UserMapper userMapper; + @Override + public User findByPhone(String phone) { + return userMapper.findByPhone(phone); + } +} diff --git a/bwie-moudels/bwie-user/src/main/resources/bootstrap.yml b/bwie-moudels/bwie-user/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..8ddfde6 --- /dev/null +++ b/bwie-moudels/bwie-user/src/main/resources/bootstrap.yml @@ -0,0 +1,29 @@ +# Tomcat +server: + port: 9002 +# Spring +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: bwie-user + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-moudels/bwie-user/src/main/resources/mapper/UserMapper.xml b/bwie-moudels/bwie-user/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..acb3256 --- /dev/null +++ b/bwie-moudels/bwie-user/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/bwie-moudels/bwie-user/target/bwie-user-1.0-SNAPSHOT.jar b/bwie-moudels/bwie-user/target/bwie-user-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..b451645 Binary files /dev/null and b/bwie-moudels/bwie-user/target/bwie-user-1.0-SNAPSHOT.jar differ diff --git a/bwie-moudels/bwie-user/target/classes/bootstrap.yml b/bwie-moudels/bwie-user/target/classes/bootstrap.yml new file mode 100644 index 0000000..8ddfde6 --- /dev/null +++ b/bwie-moudels/bwie-user/target/classes/bootstrap.yml @@ -0,0 +1,29 @@ +# Tomcat +server: + port: 9002 +# Spring +spring: + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: bwie-user + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 111.229.36.192:8848 + config: + # 配置中心地址 + server-addr: 111.229.36.192:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/bwie-moudels/bwie-user/target/classes/com/bwie/user/UserApp.class b/bwie-moudels/bwie-user/target/classes/com/bwie/user/UserApp.class new file mode 100644 index 0000000..91817a7 Binary files /dev/null and b/bwie-moudels/bwie-user/target/classes/com/bwie/user/UserApp.class differ diff --git a/bwie-moudels/bwie-user/target/classes/com/bwie/user/controller/UserController.class b/bwie-moudels/bwie-user/target/classes/com/bwie/user/controller/UserController.class new file mode 100644 index 0000000..ab8c761 Binary files /dev/null and b/bwie-moudels/bwie-user/target/classes/com/bwie/user/controller/UserController.class differ diff --git a/bwie-moudels/bwie-user/target/classes/com/bwie/user/mapper/UserMapper.class b/bwie-moudels/bwie-user/target/classes/com/bwie/user/mapper/UserMapper.class new file mode 100644 index 0000000..1244567 Binary files /dev/null and b/bwie-moudels/bwie-user/target/classes/com/bwie/user/mapper/UserMapper.class differ diff --git a/bwie-moudels/bwie-user/target/classes/com/bwie/user/service/UserService.class b/bwie-moudels/bwie-user/target/classes/com/bwie/user/service/UserService.class new file mode 100644 index 0000000..efa136a Binary files /dev/null and b/bwie-moudels/bwie-user/target/classes/com/bwie/user/service/UserService.class differ diff --git a/bwie-moudels/bwie-user/target/classes/com/bwie/user/service/UserServiceimpl.class b/bwie-moudels/bwie-user/target/classes/com/bwie/user/service/UserServiceimpl.class new file mode 100644 index 0000000..5001579 Binary files /dev/null and b/bwie-moudels/bwie-user/target/classes/com/bwie/user/service/UserServiceimpl.class differ diff --git a/bwie-moudels/bwie-user/target/classes/mapper/UserMapper.xml b/bwie-moudels/bwie-user/target/classes/mapper/UserMapper.xml new file mode 100644 index 0000000..acb3256 --- /dev/null +++ b/bwie-moudels/bwie-user/target/classes/mapper/UserMapper.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/bwie-moudels/bwie-user/target/maven-archiver/pom.properties b/bwie-moudels/bwie-user/target/maven-archiver/pom.properties new file mode 100644 index 0000000..bff4d91 --- /dev/null +++ b/bwie-moudels/bwie-user/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=bwie-user +groupId=com.bwie +version=1.0-SNAPSHOT diff --git a/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..c6831c5 --- /dev/null +++ b/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,5 @@ +com\bwie\user\UserApp.class +com\bwie\user\service\UserService.class +com\bwie\user\mapper\UserMapper.class +com\bwie\user\controller\UserController.class +com\bwie\user\service\UserServiceimpl.class diff --git a/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..f1a0df9 --- /dev/null +++ b/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,5 @@ +D:\zhuangao5\new\bwie-moudels\bwie-user\src\main\java\com\bwie\user\controller\UserController.java +D:\zhuangao5\new\bwie-moudels\bwie-user\src\main\java\com\bwie\user\service\UserService.java +D:\zhuangao5\new\bwie-moudels\bwie-user\src\main\java\com\bwie\user\service\UserServiceimpl.java +D:\zhuangao5\new\bwie-moudels\bwie-user\src\main\java\com\bwie\user\UserApp.java +D:\zhuangao5\new\bwie-moudels\bwie-user\src\main\java\com\bwie\user\mapper\UserMapper.java diff --git a/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/bwie-moudels/bwie-user/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/bwie-moudels/pom.xml b/bwie-moudels/pom.xml new file mode 100644 index 0000000..9dc22fb --- /dev/null +++ b/bwie-moudels/pom.xml @@ -0,0 +1,92 @@ + + + + day4-zy + com.bwie + 1.0-SNAPSHOT + + 4.0.0 + + bwie-moudels + pom + + bwie-es + bwie-new + bwie-user + bwie-rabbit + + + + + + + + com.bwie + bwie-common + + + + + 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 + + + + + com.github.tobato + fastdfs-client + 1.26.5 + + + + + com.github.xiaoymin + knife4j-spring-boot-starter + 2.0.9 + + + + + org.springframework.boot + spring-boot-starter-amqp + + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.9.10 + + + + + diff --git a/day4-zy.iml b/day4-zy.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/day4-zy.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..91340c9 --- /dev/null +++ b/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + com.bwie + day4-zy + pom + 1.0-SNAPSHOT + + bwie-auth + bwie-common + bwie-gateway + bwie-moudels + + + + 8 + 8 + UTF-8 + 2021.0.0 + 0.9.1 + + + + + + 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 + + + + + com.bwie + bwie-common + 1.0-SNAPSHOT + + + + + +