4815 lines
168 KiB
Diff
4815 lines
168 KiB
Diff
Index: bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1723468474763)
|
||
+++ b/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java (date 1723468474763)
|
||
@@ -0,0 +1,102 @@
|
||
+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.UserRequest;
|
||
+import com.bwie.common.domain.response.TokenResponse;
|
||
+import com.bwie.common.result.Result;
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.web.bind.annotation.*;
|
||
+
|
||
+import javax.servlet.http.HttpServletRequest;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 用户控制层
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 09:49:40
|
||
+ */
|
||
+@Slf4j
|
||
+@RestController
|
||
+public class AuthController {
|
||
+
|
||
+ @Autowired
|
||
+ private AuthService authService;
|
||
+
|
||
+ @Autowired
|
||
+ private HttpServletRequest httpServletRequest;
|
||
+
|
||
+ /**
|
||
+ * 发送验证码
|
||
+ * @param phone
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/sendCode")
|
||
+ public Result sendCode(@RequestParam String phone){
|
||
+ log.info("功能:发送验证码");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+JSONObject.toJSONString(phone));
|
||
+ authService.sendCode(phone);
|
||
+ log.info("功能:发送验证码");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ return Result.success();
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 登录
|
||
+ * @param request
|
||
+ * @return
|
||
+ */
|
||
+ @PostMapping("/login")
|
||
+ public Result<TokenResponse> login(@RequestBody UserRequest request){
|
||
+ log.info("功能:登录");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+JSONObject.toJSONString(request));
|
||
+ TokenResponse login = authService.login(request);
|
||
+ log.info("功能:登录");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("响应结果:"+ JSONObject.toJSONString(login));
|
||
+ return Result.success(login);
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 获取用户信息
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/info")
|
||
+ public Result<User> info(){
|
||
+ log.info("功能:获取用户信息");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ User info = authService.info();
|
||
+ log.info("功能:获取用户信息");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("响应结果:"+ JSONObject.toJSONString(info));
|
||
+ return Result.success(info);
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 退出登录
|
||
+ */
|
||
+ @GetMapping("/logout")
|
||
+ public Result logout(){
|
||
+ log.info("功能:退出登录");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ authService.logout();
|
||
+ log.info("功能:退出登录");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ return Result.success();
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/domain/response/TokenResponse.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/response/TokenResponse.java b/bwie-common/src/main/java/com/bwie/common/domain/response/TokenResponse.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723429293512)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/domain/response/TokenResponse.java (date 1723429293512)
|
||
@@ -0,0 +1,31 @@
|
||
+package com.bwie.common.domain.response;
|
||
+
|
||
+import lombok.AllArgsConstructor;
|
||
+import lombok.Builder;
|
||
+import lombok.Data;
|
||
+import lombok.NoArgsConstructor;
|
||
+
|
||
+import javax.validation.constraints.NotEmpty;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 返回用户数据
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 09:44:50
|
||
+ */
|
||
+@Data
|
||
+@Builder
|
||
+@NoArgsConstructor
|
||
+@AllArgsConstructor
|
||
+public class TokenResponse {
|
||
+ /**
|
||
+ * token
|
||
+ */
|
||
+ @NotEmpty(message = "token不能为空")
|
||
+ private String token;
|
||
+ /**
|
||
+ * 过期时间
|
||
+ */
|
||
+ @NotEmpty(message = "过期时间不能为空")
|
||
+ private String expireTime;
|
||
+}
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/config/ReturnCallbackConfig.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/config/ReturnCallbackConfig.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/config/ReturnCallbackConfig.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723447119047)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/config/ReturnCallbackConfig.java (date 1723447119047)
|
||
@@ -0,0 +1,37 @@
|
||
+package com.bwie.es.config;
|
||
+
|
||
+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
|
||
+public class ReturnCallbackConfig implements RabbitTemplate.ReturnsCallback {
|
||
+
|
||
+ @Autowired
|
||
+ private RabbitTemplate rabbitTemplate;
|
||
+
|
||
+ @PostConstruct
|
||
+ public void init() {
|
||
+ rabbitTemplate.setReturnsCallback(this);
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 消息发送到队列如何未成功会执行
|
||
+ *
|
||
+ * @param returnedMessage the returned message and metadata.
|
||
+ */
|
||
+ @Override
|
||
+ public void returnedMessage(ReturnedMessage returnedMessage) {
|
||
+ System.out.println("消息" + returnedMessage.getMessage().toString() + "被交换机" + returnedMessage.getExchange() + "回退!"
|
||
+ + "退回原因为:" + returnedMessage.getReplyText());
|
||
+ // TODO 回退了 可做补偿机制
|
||
+ // 可以将消息 记录下来 到 MySQL 中
|
||
+
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/config/ConfirmCallbackConfig.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/config/ConfirmCallbackConfig.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/config/ConfirmCallbackConfig.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723447119037)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/config/ConfirmCallbackConfig.java (date 1723447119037)
|
||
@@ -0,0 +1,45 @@
|
||
+package com.bwie.es.config;
|
||
+
|
||
+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;
|
||
+
|
||
+/**
|
||
+ * @ClassName:
|
||
+ * @Description: 消息发送到交换件确认的 回调
|
||
+ * @Author: zhuwenqiang
|
||
+ * @Date: 2024/4/28
|
||
+ */
|
||
+@Component
|
||
+public class ConfirmCallbackConfig implements RabbitTemplate.ConfirmCallback {
|
||
+
|
||
+ @Autowired
|
||
+ private RabbitTemplate rabbitTemplate;
|
||
+
|
||
+ /**
|
||
+ * bean 初始化方法
|
||
+ */
|
||
+ @PostConstruct
|
||
+ public void init() {
|
||
+ this.rabbitTemplate.setConfirmCallback(this);
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 消息发送到交换机 成功 或者 失败 都会执行
|
||
+ * @param correlationData correlation data for the callback.
|
||
+ * @param ack true for ack, false for nack
|
||
+ * @param cause An optional cause, for nack, when available, otherwise null.
|
||
+ */
|
||
+ @Override
|
||
+ public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||
+ if (ack) {
|
||
+ System.out.println("消息发送到交换机成功...");
|
||
+ } else {
|
||
+ System.out.println("消息发送到交换机失败,失败的原因:" + cause);
|
||
+ }
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java b/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723428174100)
|
||
+++ b/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java (date 1723428174100)
|
||
@@ -0,0 +1,124 @@
|
||
+package com.bwie.auth.service.impl;
|
||
+
|
||
+import cn.hutool.core.util.RandomUtil;
|
||
+import com.alibaba.fastjson.JSONObject;
|
||
+import com.bwie.auth.remote.AuthRemote;
|
||
+import com.bwie.auth.service.AuthService;
|
||
+import com.bwie.common.constants.JwtConstants;
|
||
+import com.bwie.common.constants.TokenConstants;
|
||
+import com.bwie.common.domain.User;
|
||
+import com.bwie.common.domain.request.UserRequest;
|
||
+import com.bwie.common.domain.response.TokenResponse;
|
||
+import com.bwie.common.utils.JwtUtils;
|
||
+import com.bwie.common.utils.StringUtils;
|
||
+import com.bwie.common.utils.TelSmsUtils;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.data.redis.core.StringRedisTemplate;
|
||
+import org.springframework.stereotype.Service;
|
||
+
|
||
+import javax.servlet.http.HttpServletRequest;
|
||
+import java.util.HashMap;
|
||
+import java.util.UUID;
|
||
+import java.util.concurrent.TimeUnit;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 鉴权实现层
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 09:36:20
|
||
+ */
|
||
+@Service
|
||
+public class AuthServiceImpl implements AuthService {
|
||
+
|
||
+ @Autowired
|
||
+ private AuthRemote remote;
|
||
+
|
||
+ @Autowired
|
||
+ private StringRedisTemplate redisTemplate;
|
||
+
|
||
+ @Autowired
|
||
+ private HttpServletRequest httpServletRequest;
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 发送验证码
|
||
+ * @param phone
|
||
+ */
|
||
+ @Override
|
||
+ public void sendCode(String phone) {
|
||
+ if (StringUtils.isBlank(phone)){
|
||
+ throw new RuntimeException("手机号不能为空");
|
||
+ }
|
||
+
|
||
+ User user = remote.findByPhone(phone).getData();
|
||
+ if (user == null){
|
||
+ throw new RuntimeException("请注册");
|
||
+ }
|
||
+
|
||
+ String userCode = RandomUtil.randomNumbers(4);
|
||
+ redisTemplate.opsForValue().set(phone,userCode,5, TimeUnit.MINUTES);
|
||
+
|
||
+ TelSmsUtils.sendSms(phone,new HashMap<String,String>(){{
|
||
+ put("code",userCode);
|
||
+ }});
|
||
+
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 登录
|
||
+ * @param request
|
||
+ * @return
|
||
+ */
|
||
+ @Override
|
||
+ public TokenResponse login(UserRequest request) {
|
||
+ if (StringUtils.isAnyBlank(request.getPhone(),request.getCode())){
|
||
+ throw new RuntimeException("手机号或验证码不能为空");
|
||
+ }
|
||
+
|
||
+ User user = remote.findByPhone(request.getPhone()).getData();
|
||
+ if (user == null){
|
||
+ throw new RuntimeException("请注册");
|
||
+ }
|
||
+
|
||
+ if (!redisTemplate.hasKey(request.getPhone())){
|
||
+ throw new RuntimeException("验证码已过期");
|
||
+ }
|
||
+
|
||
+ if (!redisTemplate.opsForValue().get(request.getPhone()).equals(request.getCode())){
|
||
+ throw new RuntimeException("验证码错误");
|
||
+ }
|
||
+
|
||
+ HashMap<String, Object> map = new HashMap<>();
|
||
+ String userKey = UUID.randomUUID().toString().replaceAll("-", "");
|
||
+ map.put(JwtConstants.USER_KEY,userKey);
|
||
+ String token = JwtUtils.createToken(map);
|
||
+ redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey, JSONObject.toJSONString(user),30,TimeUnit.MINUTES);
|
||
+ TokenResponse response = new TokenResponse();
|
||
+ response.setToken(token);
|
||
+ response.setExpireTime("30MINUTES");
|
||
+ return response;
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 获取用户信息
|
||
+ * @return
|
||
+ */
|
||
+ @Override
|
||
+ public User info() {
|
||
+ String token = httpServletRequest.getHeader(TokenConstants.TOKEN);
|
||
+ String userKey = JwtUtils.getUserKey(token);
|
||
+ String user = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||
+ return JSONObject.parseObject(user,User.class);
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 退出登录
|
||
+ */
|
||
+ @Override
|
||
+ public void logout() {
|
||
+ String token = httpServletRequest.getHeader(TokenConstants.TOKEN);
|
||
+ String userKey = JwtUtils.getUserKey(token);
|
||
+ redisTemplate.delete(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||
+ }
|
||
+}
|
||
Index: .idea/uiDesigner.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723427464065)
|
||
+++ b/.idea/uiDesigner.xml (date 1723427464065)
|
||
@@ -0,0 +1,124 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project version="4">
|
||
+ <component name="Palette2">
|
||
+ <group name="Swing">
|
||
+ <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||
+ </item>
|
||
+ <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||
+ <initial-values>
|
||
+ <property name="text" value="Button" />
|
||
+ </initial-values>
|
||
+ </item>
|
||
+ <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||
+ <initial-values>
|
||
+ <property name="text" value="RadioButton" />
|
||
+ </initial-values>
|
||
+ </item>
|
||
+ <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||
+ <initial-values>
|
||
+ <property name="text" value="CheckBox" />
|
||
+ </initial-values>
|
||
+ </item>
|
||
+ <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||
+ <initial-values>
|
||
+ <property name="text" value="Label" />
|
||
+ </initial-values>
|
||
+ </item>
|
||
+ <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||
+ <preferred-size width="150" height="-1" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||
+ <preferred-size width="150" height="-1" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||
+ <preferred-size width="150" height="-1" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||
+ <preferred-size width="150" height="50" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||
+ <preferred-size width="150" height="50" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||
+ <preferred-size width="150" height="50" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||
+ <preferred-size width="150" height="50" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||
+ <preferred-size width="150" height="50" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||
+ <preferred-size width="150" height="50" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||
+ <preferred-size width="200" height="200" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||
+ <preferred-size width="200" height="200" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||
+ <preferred-size width="-1" height="20" />
|
||
+ </default-constraints>
|
||
+ </item>
|
||
+ <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||
+ </item>
|
||
+ <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||
+ <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||
+ </item>
|
||
+ </group>
|
||
+ </component>
|
||
+</project>
|
||
\ No newline at end of file
|
||
Index: bwie-module/bwie-volume/src/main/resources/bootstrap.yml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/resources/bootstrap.yml b/bwie-module/bwie-volume/src/main/resources/bootstrap.yml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723432410398)
|
||
+++ b/bwie-module/bwie-volume/src/main/resources/bootstrap.yml (date 1723432410398)
|
||
@@ -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-volume
|
||
+ profiles:
|
||
+ # 环境配置
|
||
+ active: dev
|
||
+ cloud:
|
||
+ nacos:
|
||
+ discovery:
|
||
+ # 服务注册地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ config:
|
||
+ # 配置中心地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ # 配置文件格式
|
||
+ file-extension: yml
|
||
+ # 共享配置
|
||
+ shared-configs:
|
||
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||
Index: bwie-gateway/src/main/java/com/bwie/gateway/config/IgnoreWhiteConfig.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860196829)
|
||
+++ b/bwie-gateway/src/main/java/com/bwie/gateway/config/IgnoreWhiteConfig.java (date 1715860196829)
|
||
@@ -0,0 +1,31 @@
|
||
+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: 放行白名单配置
|
||
+ */
|
||
+@Configuration
|
||
+@RefreshScope
|
||
+@ConfigurationProperties(prefix = "ignore")
|
||
+@Data
|
||
+@Log4j2
|
||
+public class IgnoreWhiteConfig {
|
||
+ /**
|
||
+ * 放行白名单配置,网关不校验此处的白名单
|
||
+ */
|
||
+ private List<String> whites = new ArrayList<>();
|
||
+
|
||
+ public void setWhites(List<String> whites) {
|
||
+ log.info("加载网关路径白名单:{}", JSONObject.toJSONString(whites));
|
||
+ this.whites = whites;
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/VolumeApplication.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/VolumeApplication.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/VolumeApplication.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723450483497)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/VolumeApplication.java (date 1723450483497)
|
||
@@ -0,0 +1,21 @@
|
||
+package com.bwie.volume;
|
||
+
|
||
+import org.mybatis.spring.annotation.MapperScan;
|
||
+import org.springframework.boot.SpringApplication;
|
||
+import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||
+import org.springframework.cloud.openfeign.EnableFeignClients;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 11:16:19
|
||
+ */
|
||
+@SpringBootApplication
|
||
+@MapperScan("com.bwie.volume.mapper")
|
||
+@EnableFeignClients
|
||
+public class VolumeApplication {
|
||
+ public static void main(String[] args) {
|
||
+ SpringApplication.run(VolumeApplication.class, args);
|
||
+ }
|
||
+}
|
||
Index: bwie-gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860322709)
|
||
+++ b/bwie-gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java (date 1715860322709)
|
||
@@ -0,0 +1,97 @@
|
||
+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;
|
||
+
|
||
+/**
|
||
+ * @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<Void> 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<Void> 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));
|
||
+ }
|
||
+
|
||
+
|
||
+}
|
||
Index: bwie-gateway/src/main/java/com/bwie/gateway/GatewayApplication.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-gateway/src/main/java/com/bwie/gateway/GatewayApplication.java b/bwie-gateway/src/main/java/com/bwie/gateway/GatewayApplication.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723427946488)
|
||
+++ b/bwie-gateway/src/main/java/com/bwie/gateway/GatewayApplication.java (date 1723427946488)
|
||
@@ -0,0 +1,15 @@
|
||
+package com.bwie.gateway;
|
||
+
|
||
+import com.alibaba.cloud.sentinel.gateway.SentinelGatewayAutoConfiguration;
|
||
+import org.springframework.boot.SpringApplication;
|
||
+import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||
+
|
||
+@SpringBootApplication(exclude = {SentinelGatewayAutoConfiguration.class, DataSourceAutoConfiguration.class})
|
||
+public class GatewayApplication {
|
||
+
|
||
+ public static void main(String[] args) {
|
||
+ SpringApplication.run(GatewayApplication.class,args);
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-gateway/src/main/java/com/bwie/gateway/filters/AuthFilter.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1723432286395)
|
||
+++ b/bwie-gateway/src/main/java/com/bwie/gateway/filters/AuthFilter.java (date 1723432286395)
|
||
@@ -0,0 +1,116 @@
|
||
+package com.bwie.gateway.filters;
|
||
+
|
||
+import com.bwie.common.constants.TokenConstants;
|
||
+import com.bwie.common.utils.JwtUtils;
|
||
+import com.bwie.common.utils.StringUtils;
|
||
+import com.bwie.gateway.config.IgnoreWhiteConfig;
|
||
+import com.bwie.gateway.utils.GatewayUtils;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||
+import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||
+import org.springframework.core.Ordered;
|
||
+import org.springframework.data.redis.core.StringRedisTemplate;
|
||
+import org.springframework.http.server.reactive.ServerHttpRequest;
|
||
+import org.springframework.stereotype.Component;
|
||
+import org.springframework.web.server.ServerWebExchange;
|
||
+import reactor.core.publisher.Mono;
|
||
+
|
||
+import java.util.List;
|
||
+import java.util.concurrent.TimeUnit;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 鉴权过滤器
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 10:52:14
|
||
+ */
|
||
+@Component
|
||
+public class AuthFilter implements GlobalFilter, Ordered {
|
||
+
|
||
+ @Autowired
|
||
+ private IgnoreWhiteConfig ignoreWhiteConfig;
|
||
+
|
||
+ @Autowired
|
||
+ private StringRedisTemplate redisTemplate;
|
||
+
|
||
+ @Override
|
||
+ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||
+ List<String> whites = ignoreWhiteConfig.getWhites();
|
||
+ ServerHttpRequest request = exchange.getRequest();
|
||
+ String path = request.getURI().getPath();
|
||
+ if (StringUtils.matches(path, whites)) {
|
||
+ return chain.filter(exchange);
|
||
+ }
|
||
+ String token = request.getHeaders().getFirst(TokenConstants.TOKEN);
|
||
+ if (StringUtils.isBlank(token)) {
|
||
+ return GatewayUtils.errorResponse(exchange, "无权访问");
|
||
+ }
|
||
+ try {
|
||
+ JwtUtils.parseToken(token);
|
||
+ } catch (Exception ex) {
|
||
+ return GatewayUtils.errorResponse(exchange, "token不合法");
|
||
+ }
|
||
+ String userKey = JwtUtils.getUserKey(token);
|
||
+ if (!redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY + userKey)) {
|
||
+ return GatewayUtils.errorResponse(exchange, "token过期");
|
||
+ } else {
|
||
+ Long remainingExpireTime = redisTemplate.getExpire(TokenConstants.LOGIN_TOKEN_KEY + userKey, TimeUnit.SECONDS);
|
||
+ if (remainingExpireTime <= 600) {
|
||
+ redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY + userKey, 900, TimeUnit.SECONDS); // 900 秒即 15 分钟
|
||
+ }
|
||
+ }
|
||
+ return chain.filter(exchange);
|
||
+ }
|
||
+
|
||
+ @Override
|
||
+ public int getOrder() {
|
||
+ return 0;
|
||
+ }
|
||
+
|
||
+}
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
+
|
||
Index: bwie-module/bwie-es/pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/pom.xml b/bwie-module/bwie-es/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723433586352)
|
||
+++ b/bwie-module/bwie-es/pom.xml (date 1723433586352)
|
||
@@ -0,0 +1,31 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+ <parent>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>month</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ <relativePath>../../pom.xml</relativePath>
|
||
+ </parent>
|
||
+
|
||
+ <artifactId>bwie-es</artifactId>
|
||
+
|
||
+ <dependencies>
|
||
+ <dependency>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-common</artifactId>
|
||
+ </dependency>
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.boot</groupId>
|
||
+ <artifactId>spring-boot-starter-web</artifactId>
|
||
+ </dependency>
|
||
+ <!-- es -->
|
||
+ <dependency>
|
||
+ <groupId>org.elasticsearch.client</groupId>
|
||
+ <artifactId>elasticsearch-rest-high-level-client</artifactId>
|
||
+ </dependency>
|
||
+ </dependencies>
|
||
+
|
||
+</project>
|
||
Index: bwie-common/src/main/java/com/bwie/common/result/PageResult.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860115550)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/result/PageResult.java (date 1715860115550)
|
||
@@ -0,0 +1,37 @@
|
||
+package com.bwie.common.result;
|
||
+
|
||
+import lombok.Data;
|
||
+
|
||
+import java.io.Serializable;
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @description: 列表返回结果集
|
||
+ */
|
||
+@Data
|
||
+public class PageResult<T> implements Serializable {
|
||
+ /**
|
||
+ * 总条数
|
||
+ */
|
||
+ private long total;
|
||
+ /**
|
||
+ * 结果集合
|
||
+ */
|
||
+ private List<T> list;
|
||
+
|
||
+ public PageResult() {
|
||
+ }
|
||
+
|
||
+ public PageResult(long total, List<T> list) {
|
||
+ this.total = total;
|
||
+ this.list = list;
|
||
+ }
|
||
+
|
||
+ public static <T> PageResult<T> toPageResult(long total, List<T> list) {
|
||
+ return new PageResult(total, list);
|
||
+ }
|
||
+
|
||
+ public static <T> Result<PageResult<T>> toResult(long total, List<T> list) {
|
||
+ return Result.success(PageResult.toPageResult(total, list));
|
||
+ }
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/result/Result.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860115555)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/result/Result.java (date 1715860115555)
|
||
@@ -0,0 +1,75 @@
|
||
+package com.bwie.common.result;
|
||
+
|
||
+import com.bwie.common.constants.Constants;
|
||
+import lombok.Data;
|
||
+
|
||
+import java.io.Serializable;
|
||
+
|
||
+/**
|
||
+ * @description: 响应信息主体
|
||
+ */
|
||
+@Data
|
||
+public class Result<T> 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 <T> Result<T> success() {
|
||
+ return restResult(null, SUCCESS, Constants.SUCCESS_MSG);
|
||
+ }
|
||
+
|
||
+ public static <T> Result<T> success(T data) {
|
||
+ return restResult(data, SUCCESS, Constants.SUCCESS_MSG);
|
||
+ }
|
||
+
|
||
+ public static <T> Result<T> success(T data, String msg) {
|
||
+ return restResult(data, SUCCESS, msg);
|
||
+ }
|
||
+
|
||
+ public static <T> Result<T> error() {
|
||
+ return restResult(null, FAIL, Constants.ERROR_MSG);
|
||
+ }
|
||
+
|
||
+ public static <T> Result<T> error(String msg) {
|
||
+ return restResult(null, FAIL, msg);
|
||
+ }
|
||
+
|
||
+ public static <T> Result<T> error(T data) {
|
||
+ return restResult(data, FAIL, Constants.ERROR_MSG);
|
||
+ }
|
||
+
|
||
+ public static <T> Result<T> error(T data, String msg) {
|
||
+ return restResult(data, FAIL, msg);
|
||
+ }
|
||
+
|
||
+ public static <T> Result<T> error(int code, String msg) {
|
||
+ return restResult(null, code, msg);
|
||
+ }
|
||
+
|
||
+ private static <T> Result<T> restResult(T data, int code, String msg) {
|
||
+ Result<T> apiResult = new Result<>();
|
||
+ apiResult.setCode(code);
|
||
+ apiResult.setData(data);
|
||
+ apiResult.setMsg(msg);
|
||
+ return apiResult;
|
||
+ }
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/constants/RabbitMQQueueNameConstants.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQQueueNameConstants.java b/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQQueueNameConstants.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723447529010)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQQueueNameConstants.java (date 1723447529010)
|
||
@@ -0,0 +1,10 @@
|
||
+package com.bwie.common.constants;
|
||
+
|
||
+public class RabbitMQQueueNameConstants {
|
||
+
|
||
+ /**
|
||
+ * 短信队列名称
|
||
+ */
|
||
+ public static final String SEND_VOLUME_QUEUE = "SEND_VOLUME_QUEUE";
|
||
+
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/constants/TokenConstants.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860082208)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/constants/TokenConstants.java (date 1715860082208)
|
||
@@ -0,0 +1,23 @@
|
||
+package com.bwie.common.constants;
|
||
+
|
||
+/**
|
||
+ * @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";
|
||
+}
|
||
Index: bwie-module/bwie-volume/pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/pom.xml b/bwie-module/bwie-volume/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723432361080)
|
||
+++ b/bwie-module/bwie-volume/pom.xml (date 1723432361080)
|
||
@@ -0,0 +1,25 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+ <parent>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-module</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ </parent>
|
||
+
|
||
+ <artifactId>bwie-volume</artifactId>
|
||
+
|
||
+ <dependencies>
|
||
+ <dependency>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-common</artifactId>
|
||
+ </dependency>
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.boot</groupId>
|
||
+ <artifactId>spring-boot-starter-web</artifactId>
|
||
+ </dependency>
|
||
+ </dependencies>
|
||
+
|
||
+</project>
|
||
Index: bwie-common/src/main/java/com/bwie/common/constants/JwtConstants.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860082215)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/constants/JwtConstants.java (date 1715860082215)
|
||
@@ -0,0 +1,28 @@
|
||
+package com.bwie.common.constants;
|
||
+
|
||
+/**
|
||
+ * @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";
|
||
+
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/constants/Constants.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860082221)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/constants/Constants.java (date 1715860082221)
|
||
@@ -0,0 +1,17 @@
|
||
+package com.bwie.common.constants;
|
||
+
|
||
+/**
|
||
+ * @description: 系统常量
|
||
+ */
|
||
+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 = "操作异常";
|
||
+}
|
||
Index: bwie-module/bwie-system/src/main/java/com/bwie/system/mapper/UserMapper.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-system/src/main/java/com/bwie/system/mapper/UserMapper.java b/bwie-module/bwie-system/src/main/java/com/bwie/system/mapper/UserMapper.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723429123647)
|
||
+++ b/bwie-module/bwie-system/src/main/java/com/bwie/system/mapper/UserMapper.java (date 1723429123647)
|
||
@@ -0,0 +1,16 @@
|
||
+package com.bwie.system.mapper;
|
||
+
|
||
+import com.bwie.common.domain.User;
|
||
+import org.apache.ibatis.annotations.Param;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+/**
|
||
+ * 用户mapper 接口
|
||
+ */
|
||
+@Component
|
||
+public interface UserMapper {
|
||
+ // 根据手机号查询用户信息
|
||
+ User findByPhone(@Param("phone") String phone);
|
||
+ //注册
|
||
+ void register(User user);
|
||
+}
|
||
Index: bwie-gateway/pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-gateway/pom.xml b/bwie-gateway/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723424903982)
|
||
+++ b/bwie-gateway/pom.xml (date 1723424903982)
|
||
@@ -0,0 +1,38 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+ <parent>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>month</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ </parent>
|
||
+
|
||
+ <artifactId>bwie-gateway</artifactId>
|
||
+
|
||
+ <dependencies>
|
||
+ <!-- 公共模块 -->
|
||
+ <dependency>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-common</artifactId>
|
||
+ </dependency>
|
||
+ <!-- 网关依赖 -->
|
||
+ <!-- SpringCloud Gateway -->
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.cloud</groupId>
|
||
+ <artifactId>spring-cloud-starter-gateway</artifactId>
|
||
+ </dependency>
|
||
+ <!-- SpringCloud Alibaba Sentinel Gateway -->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba.cloud</groupId>
|
||
+ <artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
|
||
+ </dependency>
|
||
+ <!-- 引入阿里巴巴sentinel限流 依赖-->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba.csp</groupId>
|
||
+ <artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
|
||
+ </dependency>
|
||
+ </dependencies>
|
||
+
|
||
+</project>
|
||
Index: bwie-common/src/main/java/com/bwie/common/domain/request/UserRequest.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/UserRequest.java b/bwie-common/src/main/java/com/bwie/common/domain/request/UserRequest.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723429293527)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/domain/request/UserRequest.java (date 1723429293527)
|
||
@@ -0,0 +1,31 @@
|
||
+package com.bwie.common.domain.request;
|
||
+
|
||
+import lombok.AllArgsConstructor;
|
||
+import lombok.Builder;
|
||
+import lombok.Data;
|
||
+import lombok.NoArgsConstructor;
|
||
+
|
||
+import javax.validation.constraints.NotEmpty;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 用户表请求参数
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 09:15:46
|
||
+ */
|
||
+@Data
|
||
+@Builder
|
||
+@NoArgsConstructor
|
||
+@AllArgsConstructor
|
||
+public class UserRequest {
|
||
+ /**
|
||
+ * 手机号
|
||
+ */
|
||
+ @NotEmpty(message = "手机号不能为空")
|
||
+ private String phone;
|
||
+ /**
|
||
+ * 验证码
|
||
+ */
|
||
+ @NotEmpty(message = "验证码不能为空")
|
||
+ private String code;
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/domain/User.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1723429293519)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/domain/User.java (date 1723429293519)
|
||
@@ -0,0 +1,44 @@
|
||
+package com.bwie.common.domain;
|
||
+
|
||
+import com.baomidou.mybatisplus.annotation.IdType;
|
||
+import com.baomidou.mybatisplus.annotation.TableId;
|
||
+import com.baomidou.mybatisplus.annotation.TableName;
|
||
+import lombok.AllArgsConstructor;
|
||
+import lombok.Builder;
|
||
+import lombok.Data;
|
||
+import lombok.NoArgsConstructor;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 用户表实体类
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 09:13:12
|
||
+ */
|
||
+@Data
|
||
+@Builder
|
||
+@NoArgsConstructor
|
||
+@AllArgsConstructor
|
||
+@TableName(value = "t_user")
|
||
+public class User {
|
||
+ /**
|
||
+ * 主键
|
||
+ */
|
||
+ @TableId(type = IdType.AUTO)
|
||
+ private Integer userId;
|
||
+ /**
|
||
+ * 用户名称
|
||
+ */
|
||
+ private String userName;
|
||
+ /**
|
||
+ * 用户密码
|
||
+ */
|
||
+ private String userPwd;
|
||
+ /**
|
||
+ * 手机号
|
||
+ */
|
||
+ private String phone;
|
||
+ /**
|
||
+ * 用户角色1.管理员2.普通员工
|
||
+ */
|
||
+ private Integer userRole;
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/exception/CustomException.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/exception/CustomException.java b/bwie-common/src/main/java/com/bwie/common/exception/CustomException.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1720591322647)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/exception/CustomException.java (date 1720591322647)
|
||
@@ -0,0 +1,25 @@
|
||
+package com.bwie.common.exception;
|
||
+
|
||
+import lombok.Data;
|
||
+
|
||
+/**
|
||
+ * TODO 自定义异常
|
||
+ */
|
||
+@Data
|
||
+public class CustomException extends RuntimeException {
|
||
+
|
||
+ /**
|
||
+ * 错误吗
|
||
+ */
|
||
+ private int code;
|
||
+
|
||
+ /**
|
||
+ * 初始化构造方法
|
||
+ * @param code 错误码
|
||
+ * @param msg 错误提示消息
|
||
+ */
|
||
+ public CustomException(int code, String msg) {
|
||
+ super(msg);
|
||
+ this.code = code;
|
||
+ }
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/aop/Aop.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/aop/Aop.java b/bwie-common/src/main/java/com/bwie/common/aop/Aop.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723467602933)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/aop/Aop.java (date 1723467602933)
|
||
@@ -0,0 +1,28 @@
|
||
+package com.bwie.common.aop;
|
||
+
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+import java.util.logging.Level;
|
||
+import java.util.logging.Logger;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 20:56:26
|
||
+ */
|
||
+@Component
|
||
+@Slf4j
|
||
+public class Aop {
|
||
+ //使用AOP记录操作所有接口请求、响应日志
|
||
+ @Autowired
|
||
+ private Logger logger;
|
||
+
|
||
+ public void log(String request, String response, String error) {
|
||
+ logger.log(Level.parse(request), response, error);
|
||
+ log.info("请求:" + request + "响应:" + response + "错误:" + error);
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-auth/src/main/java/com/bwie/auth/remote/impl/Fusing.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-auth/src/main/java/com/bwie/auth/remote/impl/Fusing.java b/bwie-auth/src/main/java/com/bwie/auth/remote/impl/Fusing.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723426459732)
|
||
+++ b/bwie-auth/src/main/java/com/bwie/auth/remote/impl/Fusing.java (date 1723426459732)
|
||
@@ -0,0 +1,26 @@
|
||
+package com.bwie.auth.remote.impl;
|
||
+
|
||
+import com.bwie.auth.remote.AuthRemote;
|
||
+import com.bwie.common.domain.User;
|
||
+import com.bwie.common.result.Result;
|
||
+import org.springframework.cloud.openfeign.FallbackFactory;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 熔断处理器
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 09:32:40
|
||
+ */
|
||
+@Component
|
||
+public class Fusing implements FallbackFactory<AuthRemote> {
|
||
+ @Override
|
||
+ public AuthRemote create(Throwable cause) {
|
||
+ return new AuthRemote() {
|
||
+ @Override
|
||
+ public Result<User> findByPhone(String phone) {
|
||
+ throw new RuntimeException("服务器繁忙,远程调用失败");
|
||
+ }
|
||
+ };
|
||
+ }
|
||
+}
|
||
Index: bwie-auth/src/main/java/com/bwie/auth/remote/AuthRemote.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-auth/src/main/java/com/bwie/auth/remote/AuthRemote.java b/bwie-auth/src/main/java/com/bwie/auth/remote/AuthRemote.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723426459727)
|
||
+++ b/bwie-auth/src/main/java/com/bwie/auth/remote/AuthRemote.java (date 1723426459727)
|
||
@@ -0,0 +1,18 @@
|
||
+package com.bwie.auth.remote;
|
||
+
|
||
+import com.bwie.auth.remote.impl.Fusing;
|
||
+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.RequestParam;
|
||
+@FeignClient(value = "bwie-system",fallbackFactory = Fusing.class)
|
||
+public interface AuthRemote {
|
||
+ /**
|
||
+ * 根据手机号查询用户
|
||
+ * @param phone
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/findByPhone")
|
||
+ public Result<User> findByPhone(@RequestParam String phone);
|
||
+}
|
||
Index: bwie-module/bwie-system/src/main/java/com/bwie/system/controller/UserController.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-system/src/main/java/com/bwie/system/controller/UserController.java b/bwie-module/bwie-system/src/main/java/com/bwie/system/controller/UserController.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723429123639)
|
||
+++ b/bwie-module/bwie-system/src/main/java/com/bwie/system/controller/UserController.java (date 1723429123639)
|
||
@@ -0,0 +1,66 @@
|
||
+package com.bwie.system.controller;
|
||
+
|
||
+import com.alibaba.fastjson.JSONObject;
|
||
+import com.bwie.common.domain.User;
|
||
+import com.bwie.common.result.Result;
|
||
+import com.bwie.system.service.UserService;
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.web.bind.annotation.*;
|
||
+
|
||
+import javax.servlet.http.HttpServletRequest;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 用户表控制层
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 09:24:20
|
||
+ */
|
||
+@Slf4j
|
||
+@RestController
|
||
+public class UserController {
|
||
+
|
||
+ @Autowired
|
||
+ private UserService userService;
|
||
+
|
||
+ @Autowired
|
||
+ private HttpServletRequest httpServletRequest;
|
||
+
|
||
+ /**
|
||
+ * 根据手机号查询用户
|
||
+ * @param phone
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/findByPhone")
|
||
+ public Result<User> findByPhone(@RequestParam String phone){
|
||
+ log.info("功能:根据手机号查询用户");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+JSONObject.toJSONString(phone));
|
||
+ User byPhone = userService.findByPhone(phone);
|
||
+ log.info("功能:根据手机号查询用户");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("响应结果:"+ JSONObject.toJSONString(byPhone));
|
||
+ return Result.success(byPhone);
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 注册
|
||
+ * @param user
|
||
+ */
|
||
+ @PostMapping("/register")
|
||
+ public Result register(@RequestBody User user){
|
||
+ log.info("功能:注册");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+JSONObject.toJSONString(user));
|
||
+ userService.register(user);
|
||
+ log.info("功能:注册");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ return Result.success();
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/consumer/VolumeConsumer.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/consumer/VolumeConsumer.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/consumer/VolumeConsumer.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723447528999)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/consumer/VolumeConsumer.java (date 1723447528999)
|
||
@@ -0,0 +1,60 @@
|
||
+package com.bwie.es.consumer;
|
||
+
|
||
+import com.bwie.common.constants.RabbitMQQueueNameConstants;
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.es.remote.VolumeRemote;
|
||
+import com.rabbitmq.client.Channel;
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+import org.springframework.amqp.core.Message;
|
||
+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.StringRedisTemplate;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+import java.io.IOException;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 15:16:02
|
||
+ */
|
||
+@Slf4j
|
||
+@Component
|
||
+public class VolumeConsumer {
|
||
+
|
||
+ @Autowired
|
||
+ private StringRedisTemplate redisTemplate;
|
||
+
|
||
+ /**
|
||
+ * redis 消息唯一标识 key 名称
|
||
+ */
|
||
+ private static final String SEND_VOLUME_KEY = "SEND_VOLUME_KEY";
|
||
+
|
||
+ @Autowired
|
||
+ private VolumeRemote volumeRemote;
|
||
+
|
||
+ @RabbitListener(queuesToDeclare = @Queue(RabbitMQQueueNameConstants.SEND_VOLUME_QUEUE))
|
||
+ public void receiveMsg(Volume volume, Message message, Channel channel) {
|
||
+ log.info("MQ队列消费者接收到消息,消息内容:{},开始消费....", volume);
|
||
+ String messageId = message.getMessageProperties().getMessageId();
|
||
+ try {
|
||
+ Long count = redisTemplate.opsForSet().add(SEND_VOLUME_KEY, messageId);
|
||
+ if (count != null && count == 1) {
|
||
+ volumeRemote.saveVolume(volume);
|
||
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||
+ log.info("MQ队列消费者接收到消息,消息内容:{},消费完毕....", volume);
|
||
+ }
|
||
+ } catch (Exception e) {
|
||
+ log.error("MQ队列消费者接收到消息,消息内容:{},消费消息异常,异常信息:{}", volume, e);
|
||
+ redisTemplate.opsForSet().remove(SEND_VOLUME_KEY, messageId);
|
||
+ try {
|
||
+ channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||
+ } catch (IOException ex) {
|
||
+ log.error("MQ队列消费者接收到消息,消息内容:{},消费者拒绝消费消息异常,异常信息:{}", volume, ex);
|
||
+ }
|
||
+ }
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-module/bwie-system/src/main/java/com/bwie/system/service/impl/UserServiceImpl.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-system/src/main/java/com/bwie/system/service/impl/UserServiceImpl.java b/bwie-module/bwie-system/src/main/java/com/bwie/system/service/impl/UserServiceImpl.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723430055430)
|
||
+++ b/bwie-module/bwie-system/src/main/java/com/bwie/system/service/impl/UserServiceImpl.java (date 1723430055430)
|
||
@@ -0,0 +1,46 @@
|
||
+package com.bwie.system.service.impl;
|
||
+
|
||
+import cn.hutool.core.util.RandomUtil;
|
||
+import com.bwie.common.domain.User;
|
||
+import com.bwie.system.mapper.UserMapper;
|
||
+import com.bwie.system.service.UserService;
|
||
+import org.springframework.stereotype.Service;
|
||
+
|
||
+import javax.annotation.Resource;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 用户实现层
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 09:22:18
|
||
+ */
|
||
+@Service
|
||
+public class UserServiceImpl implements UserService {
|
||
+
|
||
+ @Resource
|
||
+ private UserMapper mapper;
|
||
+
|
||
+ /**
|
||
+ * 根据手机号查询用户
|
||
+ * @param phone
|
||
+ * @return
|
||
+ */
|
||
+ @Override
|
||
+ public User findByPhone(String phone) {
|
||
+ User byPhone = mapper.findByPhone(phone);
|
||
+ return byPhone;
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 注册
|
||
+ * @param user
|
||
+ */
|
||
+ @Override
|
||
+ public void register(User user) {
|
||
+ //密码随机生成并赋值
|
||
+ String code = RandomUtil.randomNumbers(7);
|
||
+ user.setUserPwd(code);
|
||
+ mapper.register(user);
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-order/src/main/java/com/bwie/order/OrderApplication.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/src/main/java/com/bwie/order/OrderApplication.java b/bwie-module/bwie-order/src/main/java/com/bwie/order/OrderApplication.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723459273520)
|
||
+++ b/bwie-module/bwie-order/src/main/java/com/bwie/order/OrderApplication.java (date 1723459273520)
|
||
@@ -0,0 +1,21 @@
|
||
+package com.bwie.order;
|
||
+
|
||
+import org.mybatis.spring.annotation.MapperScan;
|
||
+import org.springframework.boot.SpringApplication;
|
||
+import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||
+import org.springframework.scheduling.annotation.EnableScheduling;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 15:47:52
|
||
+ */
|
||
+@SpringBootApplication
|
||
+@MapperScan("com.bwie.order.mapper")
|
||
+@EnableScheduling
|
||
+public class OrderApplication {
|
||
+ public static void main(String[] args) {
|
||
+ SpringApplication.run(OrderApplication.class, args);
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-order/src/main/resources/mapper/OrderMapper.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/src/main/resources/mapper/OrderMapper.xml b/bwie-module/bwie-order/src/main/resources/mapper/OrderMapper.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723458890396)
|
||
+++ b/bwie-module/bwie-order/src/main/resources/mapper/OrderMapper.xml (date 1723458890396)
|
||
@@ -0,0 +1,56 @@
|
||
+<?xml version="1.0" encoding="UTF-8" ?>
|
||
+<!DOCTYPE mapper
|
||
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
+<!--
|
||
+1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||
+ 通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||
+ -->
|
||
+<mapper namespace="com.bwie.order.mapper.OrderMapper">
|
||
+
|
||
+ <!--批量添加订单记录-->
|
||
+ <insert id="addOrder">
|
||
+ INSERT INTO t_order(order_number,order_volume_name,order_time,order_price,order_flag,personal_amount)
|
||
+ VALUES
|
||
+ <foreach collection="orders" item="item" separator=",">
|
||
+ (#{item.orderNumber},#{item.orderVolumeName},#{item.orderTime},#{item.orderPrice},#{item.orderFlag},#{item.personalAmount})
|
||
+ </foreach>
|
||
+ </insert>
|
||
+
|
||
+
|
||
+ <!--查看订单-->
|
||
+ <select id="queryOrder" resultType="com.bwie.common.domain.Order">
|
||
+ SELECT
|
||
+ order_id,
|
||
+ order_number,
|
||
+ order_volume_name,
|
||
+ order_time,
|
||
+ order_price,
|
||
+ order_flag,
|
||
+ personal_amount
|
||
+ FROM
|
||
+ t_order
|
||
+ </select>
|
||
+
|
||
+
|
||
+ <!--修改订单状态为完成-->
|
||
+ <update id="updateOrderFlag">
|
||
+ update t_order set order_flag = "完成" where order_id = #{orderId}
|
||
+ </update>
|
||
+
|
||
+ <!--查询订单属于完成之外的状态-->
|
||
+ <select id="selectOrderFlag" resultType="com.bwie.common.domain.Order">
|
||
+ SELECT
|
||
+ order_id,
|
||
+ order_number,
|
||
+ order_volume_name,
|
||
+ order_time,
|
||
+ order_price,
|
||
+ order_flag,
|
||
+ personal_amount
|
||
+ FROM
|
||
+ t_order
|
||
+ where order_flag != "完成"
|
||
+ </select>
|
||
+
|
||
+</mapper>
|
||
Index: bwie-common/src/main/java/com/bwie/common/utils/TelSmsUtils.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1714979275955)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/utils/TelSmsUtils.java (date 1714979275955)
|
||
@@ -0,0 +1,92 @@
|
||
+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.dysmsapi20170525.models.SendSmsResponseBody;
|
||
+import com.aliyun.teaopenapi.models.Config;
|
||
+import lombok.extern.log4j.Log4j2;
|
||
+
|
||
+import java.util.Map;
|
||
+
|
||
+/**
|
||
+ * 短信工具类
|
||
+ */
|
||
+@Log4j2
|
||
+public class TelSmsUtils {
|
||
+
|
||
+ /**
|
||
+ * 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限
|
||
+ */
|
||
+ private static String accessKeyId = "LTAI5tDbRqXkC5i3SMrCSDcX";
|
||
+
|
||
+ private static String accessKeySecret = "XUzMZoHPLsjNLafHsdQnMElBWZATsu";
|
||
+
|
||
+ /**
|
||
+ * 短信访问域名
|
||
+ */
|
||
+ private static String endpoint = "dysmsapi.aliyuncs.com";
|
||
+ /**
|
||
+ * 短信签名
|
||
+ */
|
||
+ private static String signName = "乐优购";
|
||
+
|
||
+ private static String templateCode = "SMS_163851467";
|
||
+
|
||
+ /**
|
||
+ * 实例化短信对象
|
||
+ */
|
||
+ private static Client client;
|
||
+
|
||
+ static {
|
||
+ log.info("初始化短信服务开始");
|
||
+ long startTime = System.currentTimeMillis();
|
||
+ try {
|
||
+ client = initClient();
|
||
+ log.info("初始化短信成功:{}", signName);
|
||
+ } catch (Exception e) {
|
||
+ e.printStackTrace();
|
||
+ }
|
||
+ log.info("初始化短信服务结束:耗时:{}MS", (System.currentTimeMillis() - startTime));
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 初始化短信对象
|
||
+ *
|
||
+ * @return
|
||
+ * @throws Exception
|
||
+ */
|
||
+ private static Client initClient() throws Exception {
|
||
+ Config config = new Config()
|
||
+ // 您的AccessKey ID
|
||
+ .setAccessKeyId(accessKeyId)
|
||
+ // 您的AccessKey Secret
|
||
+ .setAccessKeySecret(accessKeySecret);
|
||
+ // 访问的域名
|
||
+ config.endpoint = endpoint;
|
||
+ return new Client(config);
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 发送单条短信
|
||
+ *
|
||
+ * @param tel
|
||
+ */
|
||
+ public static SendSmsResponseBody sendSms(String tel, Map<String, String> sendDataMap) {
|
||
+ SendSmsRequest sendSmsRequest = new SendSmsRequest()
|
||
+ .setPhoneNumbers(tel)
|
||
+ .setSignName(signName)
|
||
+ .setTemplateCode(templateCode)
|
||
+ .setTemplateParam(JSONObject.toJSONString(sendDataMap));
|
||
+ SendSmsResponse sendSmsResponse = null;
|
||
+ try {
|
||
+ log.info("发送短信验证码:消息内容是:【{}】", JSONObject.toJSONString(sendDataMap));
|
||
+ sendSmsResponse = client.sendSms(sendSmsRequest);
|
||
+ } catch (Exception e) {
|
||
+ log.error("短信发送异常,手机号:【{}】,短信内容:【{}】,异常信息:【{}】", tel, sendDataMap, e);
|
||
+ }
|
||
+ return sendSmsResponse.getBody();
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-module/bwie-order/src/main/java/com/bwie/order/mapper/OrderMapper.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/src/main/java/com/bwie/order/mapper/OrderMapper.java b/bwie-module/bwie-order/src/main/java/com/bwie/order/mapper/OrderMapper.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723458890387)
|
||
+++ b/bwie-module/bwie-order/src/main/java/com/bwie/order/mapper/OrderMapper.java (date 1723458890387)
|
||
@@ -0,0 +1,19 @@
|
||
+package com.bwie.order.mapper;
|
||
+
|
||
+import com.bwie.common.domain.Order;
|
||
+import org.apache.ibatis.annotations.Param;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+@Component
|
||
+public interface OrderMapper {
|
||
+ //批量添加订单记录
|
||
+ void addOrder(@Param("orders") List<Order> orders);
|
||
+ //查看订单
|
||
+ List<Order> queryOrder();
|
||
+ //修改订单状态
|
||
+ void updateOrderFlag(@Param("orderId") Integer orderId);
|
||
+ //查询订单属于完成之外的状态
|
||
+ List<Order> selectOrderFlag();
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860147451)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java (date 1715860147451)
|
||
@@ -0,0 +1,67 @@
|
||
+package com.bwie.common.utils;
|
||
+
|
||
+import org.springframework.util.AntPathMatcher;
|
||
+
|
||
+import java.util.Collection;
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @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<String> 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);
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-order/src/main/resources/bootstrap.yml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/src/main/resources/bootstrap.yml b/bwie-module/bwie-order/src/main/resources/bootstrap.yml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723449392830)
|
||
+++ b/bwie-module/bwie-order/src/main/resources/bootstrap.yml (date 1723449392830)
|
||
@@ -0,0 +1,29 @@
|
||
+# Tomcat
|
||
+server:
|
||
+ port: 9005
|
||
+# Spring
|
||
+spring:
|
||
+ main:
|
||
+ allow-circular-references: true
|
||
+ jackson:
|
||
+ date-format: yyyy-MM-dd HH:mm:ss
|
||
+ time-zone: GMT+8
|
||
+ application:
|
||
+ # 应用名称
|
||
+ name: bwie-order
|
||
+ profiles:
|
||
+ # 环境配置
|
||
+ active: dev
|
||
+ cloud:
|
||
+ nacos:
|
||
+ discovery:
|
||
+ # 服务注册地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ config:
|
||
+ # 配置中心地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ # 配置文件格式
|
||
+ file-extension: yml
|
||
+ # 共享配置
|
||
+ shared-configs:
|
||
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||
Index: bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1715860147446)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java (date 1715860147446)
|
||
@@ -0,0 +1,108 @@
|
||
+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工具类
|
||
+ */
|
||
+public class JwtUtils {
|
||
+
|
||
+ /**
|
||
+ * 秘钥
|
||
+ */
|
||
+ public static String secret = JwtConstants.SECRET;
|
||
+
|
||
+ /**
|
||
+ * 从数据声明生成令牌
|
||
+ *
|
||
+ * @param claims 数据声明
|
||
+ * @return 令牌
|
||
+ */
|
||
+ public static String createToken(Map<String, Object> 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();
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-order/src/main/java/com/bwie/order/controller/OrderController.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/src/main/java/com/bwie/order/controller/OrderController.java b/bwie-module/bwie-order/src/main/java/com/bwie/order/controller/OrderController.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723458622946)
|
||
+++ b/bwie-module/bwie-order/src/main/java/com/bwie/order/controller/OrderController.java (date 1723458622946)
|
||
@@ -0,0 +1,85 @@
|
||
+package com.bwie.order.controller;
|
||
+
|
||
+import com.alibaba.fastjson.JSONObject;
|
||
+import com.bwie.common.domain.Order;
|
||
+import com.bwie.common.domain.response.TokenResponse;
|
||
+import com.bwie.common.result.Result;
|
||
+import com.bwie.order.service.OrderService;
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.web.bind.annotation.*;
|
||
+
|
||
+import javax.servlet.http.HttpServletRequest;
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 订单控制层
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 16:07:50
|
||
+ */
|
||
+@Slf4j
|
||
+@RestController
|
||
+public class OrderController {
|
||
+
|
||
+ @Autowired
|
||
+ private OrderService orderService;
|
||
+
|
||
+ @Autowired
|
||
+ private HttpServletRequest httpServletRequest;
|
||
+
|
||
+ /**
|
||
+ * 批量添加订单
|
||
+ * @param orders
|
||
+ */
|
||
+ @PostMapping("/addOrder")
|
||
+ public Result addOrder(@RequestBody List<Order> orders){
|
||
+ log.info("功能:登录");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+ JSONObject.toJSONString(orders));
|
||
+ orderService.addOrder(orders);
|
||
+ log.info("功能:登录");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ return Result.success();
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 查询订单
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/queryOrder")
|
||
+ public Result<List<Order>> queryOrder(){
|
||
+ log.info("功能:查询订单");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ List<Order> orders = orderService.queryOrder();
|
||
+ log.info("功能:查询订单");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("返回结果:"+ JSONObject.toJSONString(orders));
|
||
+ return Result.success(orders);
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 修改订单状态
|
||
+ * @param orderId
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/updateOrderFlag")
|
||
+ public Result updateOrderFlag(@RequestParam Integer orderId){
|
||
+ log.info("功能:修改订单状态");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+JSONObject.toJSONString(orderId));
|
||
+ orderService.updateOrderFlag(orderId);
|
||
+ log.info("功能:修改订单状态");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ return Result.success();
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-module/bwie-order/src/main/java/com/bwie/order/service/impl/OrderServiceImpl.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/src/main/java/com/bwie/order/service/impl/OrderServiceImpl.java b/bwie-module/bwie-order/src/main/java/com/bwie/order/service/impl/OrderServiceImpl.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723459273512)
|
||
+++ b/bwie-module/bwie-order/src/main/java/com/bwie/order/service/impl/OrderServiceImpl.java (date 1723459273512)
|
||
@@ -0,0 +1,61 @@
|
||
+package com.bwie.order.service.impl;
|
||
+
|
||
+import com.bwie.common.domain.Order;
|
||
+import com.bwie.order.mapper.OrderMapper;
|
||
+import com.bwie.order.service.OrderService;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.stereotype.Service;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 订单服务实现类
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 16:06:31
|
||
+ */
|
||
+@Service
|
||
+public class OrderServiceImpl implements OrderService {
|
||
+
|
||
+ @Autowired
|
||
+ private OrderMapper orderMapper;
|
||
+
|
||
+ /**
|
||
+ * 批量添加订单
|
||
+ * @param orders
|
||
+ */
|
||
+ @Override
|
||
+ public void addOrder(List<Order> orders) {
|
||
+ orderMapper.addOrder(orders);
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 查询订单
|
||
+ * @return
|
||
+ */
|
||
+ @Override
|
||
+ public List<Order> queryOrder() {
|
||
+ List<Order> orders = orderMapper.queryOrder();
|
||
+ return orders;
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 修改订单状态完成
|
||
+ * @param orderId
|
||
+ */
|
||
+ @Override
|
||
+ public void updateOrderFlag(Integer orderId) {
|
||
+ orderMapper.updateOrderFlag(orderId);
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 查询订单状态属于未完成的订单
|
||
+ * @return
|
||
+ */
|
||
+ @Override
|
||
+ public List<Order> selectOrderFlag() {
|
||
+ List<Order> orders = orderMapper.selectOrderFlag();
|
||
+ return orders;
|
||
+ }
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/config/RabbitMQConfig.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/config/RabbitMQConfig.java b/bwie-common/src/main/java/com/bwie/common/config/RabbitMQConfig.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1714375795019)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/config/RabbitMQConfig.java (date 1714375795019)
|
||
@@ -0,0 +1,16 @@
|
||
+package com.bwie.common.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() {
|
||
+ // SimpleMessageConverter 默认的消息转换器 String byte[] serializer
|
||
+ return new Jackson2JsonMessageConverter();
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-order/src/main/java/com/bwie/order/service/OrderService.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/src/main/java/com/bwie/order/service/OrderService.java b/bwie-module/bwie-order/src/main/java/com/bwie/order/service/OrderService.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723459273527)
|
||
+++ b/bwie-module/bwie-order/src/main/java/com/bwie/order/service/OrderService.java (date 1723459273527)
|
||
@@ -0,0 +1,16 @@
|
||
+package com.bwie.order.service;
|
||
+
|
||
+import com.bwie.common.domain.Order;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+public interface OrderService {
|
||
+ //批量添加订单记录
|
||
+ void addOrder(List<Order> orders);
|
||
+ //查看订单
|
||
+ List<Order> queryOrder();
|
||
+ //修改订单状态
|
||
+ void updateOrderFlag(Integer orderId);
|
||
+ //查询订单属于完成之外的状态
|
||
+ List<Order> selectOrderFlag();
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/handle/GlobalExceptionHandler.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/handle/GlobalExceptionHandler.java b/bwie-common/src/main/java/com/bwie/common/handle/GlobalExceptionHandler.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1720591393197)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/handle/GlobalExceptionHandler.java (date 1720591393197)
|
||
@@ -0,0 +1,24 @@
|
||
+package com.bwie.common.handle;
|
||
+
|
||
+import com.bwie.common.exception.CustomException;
|
||
+import com.bwie.common.result.Result;
|
||
+import lombok.extern.log4j.Log4j2;
|
||
+import org.springframework.web.bind.annotation.ExceptionHandler;
|
||
+import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||
+
|
||
+/**
|
||
+ * TODO 全局异常处理器
|
||
+ */
|
||
+@Log4j2
|
||
+@RestControllerAdvice
|
||
+public class GlobalExceptionHandler {
|
||
+
|
||
+ /**
|
||
+ * 自定义异常处理器
|
||
+ */
|
||
+ @ExceptionHandler(CustomException.class)
|
||
+ public Result customExceptionHandler(CustomException e) {
|
||
+ log.error("功能异常,异常信息:{}", e.getMessage());
|
||
+ return Result.error(e.getCode(), e.getMessage());
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/remote/impl/Fusing.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/remote/impl/Fusing.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/remote/impl/Fusing.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723460201162)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/remote/impl/Fusing.java (date 1723460201162)
|
||
@@ -0,0 +1,33 @@
|
||
+package com.bwie.volume.remote.impl;
|
||
+
|
||
+import com.bwie.common.domain.Order;
|
||
+import com.bwie.common.result.Result;
|
||
+import com.bwie.volume.remote.OrderRemote;
|
||
+import org.springframework.cloud.openfeign.FallbackFactory;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 熔断处理类
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 16:11:42
|
||
+ */
|
||
+@Component
|
||
+public class Fusing implements FallbackFactory<OrderRemote> {
|
||
+ @Override
|
||
+ public OrderRemote create(Throwable cause) {
|
||
+ return new OrderRemote() {
|
||
+ @Override
|
||
+ public Result addOrder(List<Order> orders) {
|
||
+ throw new RuntimeException("服务器繁忙,远程调用失败");
|
||
+ }
|
||
+
|
||
+ @Override
|
||
+ public Result<List<Order>> queryOrder() {
|
||
+ throw new RuntimeException("服务器繁忙,远程调用失败");
|
||
+ }
|
||
+ };
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/remote/OrderRemote.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/remote/OrderRemote.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/remote/OrderRemote.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723460201182)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/remote/OrderRemote.java (date 1723460201182)
|
||
@@ -0,0 +1,28 @@
|
||
+package com.bwie.volume.remote;
|
||
+
|
||
+import com.bwie.common.domain.Order;
|
||
+import com.bwie.common.result.Result;
|
||
+import com.bwie.volume.remote.impl.Fusing;
|
||
+import org.springframework.cloud.openfeign.FeignClient;
|
||
+import org.springframework.stereotype.Component;
|
||
+import org.springframework.web.bind.annotation.GetMapping;
|
||
+import org.springframework.web.bind.annotation.PostMapping;
|
||
+import org.springframework.web.bind.annotation.RequestBody;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+@FeignClient(value = "bwie-order",fallbackFactory = Fusing.class)
|
||
+public interface OrderRemote {
|
||
+ /**
|
||
+ * 批量添加订单
|
||
+ * @param orders
|
||
+ */
|
||
+ @PostMapping("/addOrder")
|
||
+ public Result addOrder(@RequestBody List<Order> orders);
|
||
+ /**
|
||
+ * 查询订单
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/queryOrder")
|
||
+ public Result<List<Order>> queryOrder();
|
||
+}
|
||
Index: .idea/.gitignore
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/.idea/.gitignore b/.idea/.gitignore
|
||
new file mode 100644
|
||
--- /dev/null (date 1723424627460)
|
||
+++ b/.idea/.gitignore (date 1723424627460)
|
||
@@ -0,0 +1,8 @@
|
||
+# 默认忽略的文件
|
||
+/shelf/
|
||
+/workspace.xml
|
||
+# 基于编辑器的 HTTP 客户端请求
|
||
+/httpRequests/
|
||
+# Datasource local storage ignored files
|
||
+/dataSources/
|
||
+/dataSources.local.xml
|
||
Index: bwie-common/pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/pom.xml b/bwie-common/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723425175331)
|
||
+++ b/bwie-common/pom.xml (date 1723425175331)
|
||
@@ -0,0 +1,127 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+ <parent>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>month</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ </parent>
|
||
+
|
||
+ <artifactId>bwie-common</artifactId>
|
||
+
|
||
+ <dependencies>
|
||
+ <!-- bootstrap 启动器 -->
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.cloud</groupId>
|
||
+ <artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||
+ </dependency>
|
||
+ <!-- SpringCloud Alibaba Nacos -->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba.cloud</groupId>
|
||
+ <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||
+ </dependency>
|
||
+ <!-- SpringCloud Alibaba Nacos Config -->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba.cloud</groupId>
|
||
+ <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||
+ </dependency>
|
||
+ <!-- lombok依赖 -->
|
||
+ <dependency>
|
||
+ <groupId>org.projectlombok</groupId>
|
||
+ <artifactId>lombok</artifactId>
|
||
+ </dependency>
|
||
+ <!-- 负载均衡-->
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.cloud</groupId>
|
||
+ <artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||
+ </dependency>
|
||
+ <!-- SpringCloud Openfeign -->
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.cloud</groupId>
|
||
+ <artifactId>spring-cloud-starter-openfeign</artifactId>
|
||
+ </dependency>
|
||
+ <!-- JWT -->
|
||
+ <dependency>
|
||
+ <groupId>io.jsonwebtoken</groupId>
|
||
+ <artifactId>jjwt</artifactId>
|
||
+ </dependency>
|
||
+ <!-- Alibaba Fastjson -->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba</groupId>
|
||
+ <artifactId>fastjson</artifactId>
|
||
+ </dependency>
|
||
+ <!-- SpringBoot Boot Redis -->
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.boot</groupId>
|
||
+ <artifactId>spring-boot-starter-data-redis</artifactId>
|
||
+ </dependency>
|
||
+
|
||
+ <!--Hibernate Validator-->
|
||
+ <!-- <dependency>-->
|
||
+ <!-- <groupId>org.springframework.boot</groupId>-->
|
||
+ <!-- <artifactId>spring-boot-starter-validation</artifactId>-->
|
||
+ <!-- </dependency>-->
|
||
+
|
||
+ <!-- Apache Lang3 -->
|
||
+ <dependency>
|
||
+ <groupId>org.apache.commons</groupId>
|
||
+ <artifactId>commons-lang3</artifactId>
|
||
+ </dependency>
|
||
+ <!-- hutool -->
|
||
+ <dependency>
|
||
+ <groupId>cn.hutool</groupId>
|
||
+ <artifactId>hutool-all</artifactId>
|
||
+ </dependency>
|
||
+ <!-- 阿里大鱼 -->
|
||
+ <dependency>
|
||
+ <groupId>com.aliyun</groupId>
|
||
+ <artifactId>dysmsapi20170525</artifactId>
|
||
+ </dependency>
|
||
+ <!-- Druid -->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba</groupId>
|
||
+ <artifactId>druid-spring-boot-starter</artifactId>
|
||
+ </dependency>
|
||
+ <!-- Mysql Connector -->
|
||
+ <dependency>
|
||
+ <groupId>mysql</groupId>
|
||
+ <artifactId>mysql-connector-java</artifactId>
|
||
+ </dependency>
|
||
+ <!-- Mybatis 依赖配置 -->
|
||
+ <dependency>
|
||
+ <groupId>org.mybatis.spring.boot</groupId>
|
||
+ <artifactId>mybatis-spring-boot-starter</artifactId>
|
||
+ </dependency>
|
||
+ <!-- Pagehelper -->
|
||
+ <dependency>
|
||
+ <groupId>com.github.pagehelper</groupId>
|
||
+ <artifactId>pagehelper-spring-boot-starter</artifactId>
|
||
+ </dependency>
|
||
+ <!-- rabbitmq -->
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.boot</groupId>
|
||
+ <artifactId>spring-boot-starter-amqp</artifactId>
|
||
+ </dependency>
|
||
+
|
||
+ <dependency>
|
||
+ <groupId>com.github.tobato</groupId>
|
||
+ <artifactId>fastdfs-client</artifactId>
|
||
+ </dependency>
|
||
+
|
||
+ <!-- oss -->
|
||
+ <dependency>
|
||
+ <groupId>com.aliyun.oss</groupId>
|
||
+ <artifactId>aliyun-sdk-oss</artifactId>
|
||
+ <version>3.16.3</version>
|
||
+ </dependency>
|
||
+
|
||
+ <dependency>
|
||
+ <groupId>com.baomidou</groupId>
|
||
+ <artifactId>mybatis-plus-annotation</artifactId>
|
||
+ </dependency>
|
||
+
|
||
+ </dependencies>
|
||
+
|
||
+</project>
|
||
Index: bwie-module/bwie-order/src/main/java/com/bwie/order/synchronization/Timing.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/src/main/java/com/bwie/order/synchronization/Timing.java b/bwie-module/bwie-order/src/main/java/com/bwie/order/synchronization/Timing.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723459273503)
|
||
+++ b/bwie-module/bwie-order/src/main/java/com/bwie/order/synchronization/Timing.java (date 1723459273503)
|
||
@@ -0,0 +1,43 @@
|
||
+package com.bwie.order.synchronization;
|
||
+
|
||
+import com.bwie.common.domain.Order;
|
||
+import com.bwie.order.service.OrderService;
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.scheduling.annotation.Scheduled;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 查询订单自动修改为完成状态
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 18:35:30
|
||
+ */
|
||
+@Slf4j
|
||
+@Component
|
||
+public class Timing {
|
||
+
|
||
+ @Autowired
|
||
+ private OrderService orderService;
|
||
+
|
||
+ /**
|
||
+ * 每隔2天查询订单状态为未完成状态的订单,修改为已完成状态
|
||
+ */
|
||
+ @Scheduled(cron = "0 0 0 */2 * ?")
|
||
+ public void timing(){
|
||
+ long startTime = System.currentTimeMillis();
|
||
+ log.info("定时任务开始执行:{}"+startTime);
|
||
+ List<Order> orders = orderService.selectOrderFlag();
|
||
+ orders.forEach(order -> {
|
||
+ orderService.updateOrderFlag(order.getOrderId());
|
||
+ });
|
||
+ long endTime = System.currentTimeMillis();
|
||
+ log.info("定时任务执行结束:{}"+endTime);
|
||
+
|
||
+ long duration = (endTime - startTime) / 1000;
|
||
+ log.info("定时任务执行时长:{}"+duration);
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-module/bwie-volume/src/main/resources/mapper/ConsignMapper.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/resources/mapper/ConsignMapper.xml b/bwie-module/bwie-volume/src/main/resources/mapper/ConsignMapper.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723462591956)
|
||
+++ b/bwie-module/bwie-volume/src/main/resources/mapper/ConsignMapper.xml (date 1723462591956)
|
||
@@ -0,0 +1,17 @@
|
||
+<?xml version="1.0" encoding="UTF-8" ?>
|
||
+<!DOCTYPE mapper
|
||
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
+<!--
|
||
+1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||
+ 通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||
+ -->
|
||
+<mapper namespace="com.bwie.volume.mapper.ConsignMapper">
|
||
+
|
||
+ <!--添加寄售-->
|
||
+ <insert id="saveConsign">
|
||
+ INSERT INTO t_consign(consign_flag,consign_number,consign_order_name,consign_time,personal_amount)
|
||
+ VALUES(#{consignFlag},#{consignNumber},#{consignOrderName},#{consignTime},#{personalAmount})
|
||
+ </insert>
|
||
+
|
||
+</mapper>
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/mapper/ConsignMapper.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/mapper/ConsignMapper.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/mapper/ConsignMapper.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723462591966)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/mapper/ConsignMapper.java (date 1723462591966)
|
||
@@ -0,0 +1,10 @@
|
||
+package com.bwie.volume.mapper;
|
||
+
|
||
+import com.bwie.common.domain.Consign;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+@Component
|
||
+public interface ConsignMapper {
|
||
+ //添加寄售
|
||
+ void saveConsign(Consign consign);
|
||
+}
|
||
Index: .gitignore
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/.gitignore b/.gitignore
|
||
new file mode 100644
|
||
--- /dev/null (date 1723468522209)
|
||
+++ b/.gitignore (date 1723468522209)
|
||
@@ -0,0 +1,35 @@
|
||
+target/
|
||
+!.mvn/wrapper/maven-wrapper.jar
|
||
+!**/src/main/**/target/
|
||
+!**/src/test/**/target/
|
||
+
|
||
+### IntelliJ IDEA ###
|
||
+.idea
|
||
+*.iws
|
||
+*.iml
|
||
+*.ipr
|
||
+
|
||
+### Eclipse ###
|
||
+.apt_generated
|
||
+.classpath
|
||
+.factorypath
|
||
+.project
|
||
+.settings
|
||
+.springBeans
|
||
+.sts4-cache
|
||
+
|
||
+### NetBeans ###
|
||
+/nbproject/private/
|
||
+/nbbuild/
|
||
+/dist/
|
||
+/nbdist/
|
||
+/.nb-gradle/
|
||
+build/
|
||
+!**/src/main/**/build/
|
||
+!**/src/test/**/build/
|
||
+
|
||
+### VS Code ###
|
||
+.vscode/
|
||
+
|
||
+### Mac OS ###
|
||
+.DS_Store
|
||
Index: bwie-common/src/main/java/com/bwie/common/domain/Consign.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/Consign.java b/bwie-common/src/main/java/com/bwie/common/domain/Consign.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723468474826)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/domain/Consign.java (date 1723468474826)
|
||
@@ -0,0 +1,55 @@
|
||
+package com.bwie.common.domain;
|
||
+
|
||
+import com.baomidou.mybatisplus.annotation.IdType;
|
||
+import com.baomidou.mybatisplus.annotation.TableId;
|
||
+import com.baomidou.mybatisplus.annotation.TableName;
|
||
+import com.fasterxml.jackson.annotation.JsonFormat;
|
||
+import lombok.AllArgsConstructor;
|
||
+import lombok.Builder;
|
||
+import lombok.Data;
|
||
+import lombok.NoArgsConstructor;
|
||
+import org.springframework.format.annotation.DateTimeFormat;
|
||
+
|
||
+import java.math.BigDecimal;
|
||
+import java.util.Date;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 寄售
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 19:20:00
|
||
+ */
|
||
+@Data
|
||
+@Builder
|
||
+@NoArgsConstructor
|
||
+@AllArgsConstructor
|
||
+@TableName(value = "t_consign")
|
||
+public class Consign {
|
||
+ /**
|
||
+ * 主键
|
||
+ */
|
||
+ @TableId(type = IdType.AUTO)
|
||
+ private Integer consignId;
|
||
+ /**
|
||
+ * 寄售订单名称
|
||
+ */
|
||
+ private String consignOrderName;
|
||
+ /**
|
||
+ * 寄售数量
|
||
+ */
|
||
+ private Integer consignNumber;
|
||
+ /**
|
||
+ * 寄售状态
|
||
+ */
|
||
+ private String consignFlag;
|
||
+ /**
|
||
+ * 寄售日期
|
||
+ */
|
||
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||
+ private Date consignTime;
|
||
+ /**
|
||
+ * 用户余额
|
||
+ */
|
||
+ private BigDecimal personalAmount;
|
||
+}
|
||
Index: .idea/encodings.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723448893821)
|
||
+++ b/.idea/encodings.xml (date 1723448893821)
|
||
@@ -0,0 +1,17 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project version="4">
|
||
+ <component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
|
||
+ <file url="file://$PROJECT_DIR$/bwie-auth/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/bwie-common/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/bwie-gateway/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/bwie-module/bwie-es/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/bwie-module/bwie-order/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/bwie-module/bwie-system/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/bwie-module/bwie-volume/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/bwie-module/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/bwie-module/src/main/resources" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||
+ <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||
+ <file url="PROJECT" charset="UTF-8" />
|
||
+ </component>
|
||
+</project>
|
||
\ No newline at end of file
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/impl/ConsignServiceImpl.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/impl/ConsignServiceImpl.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/impl/ConsignServiceImpl.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723462591946)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/impl/ConsignServiceImpl.java (date 1723462591946)
|
||
@@ -0,0 +1,29 @@
|
||
+package com.bwie.volume.service.impl;
|
||
+
|
||
+import com.bwie.common.domain.Consign;
|
||
+import com.bwie.volume.mapper.ConsignMapper;
|
||
+import com.bwie.volume.service.ConsignService;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.stereotype.Service;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 寄售服务实现类
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 19:34:57
|
||
+ */
|
||
+@Service
|
||
+public class ConsignServiceImpl implements ConsignService {
|
||
+
|
||
+ @Autowired
|
||
+ private ConsignMapper consignMapper;
|
||
+
|
||
+ /**
|
||
+ * 保存寄售
|
||
+ * @param consign
|
||
+ */
|
||
+ @Override
|
||
+ public void saveConsign(Consign consign) {
|
||
+ consignMapper.saveConsign(consign);
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/ConsignService.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/ConsignService.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/ConsignService.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723462591934)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/ConsignService.java (date 1723462591934)
|
||
@@ -0,0 +1,8 @@
|
||
+package com.bwie.volume.service;
|
||
+
|
||
+import com.bwie.common.domain.Consign;
|
||
+
|
||
+public interface ConsignService {
|
||
+ //添加寄售
|
||
+ void saveConsign(Consign consign);
|
||
+}
|
||
Index: bwie-module/bwie-system/src/main/java/com/bwie/system/service/UserService.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-system/src/main/java/com/bwie/system/service/UserService.java b/bwie-module/bwie-system/src/main/java/com/bwie/system/service/UserService.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723429123627)
|
||
+++ b/bwie-module/bwie-system/src/main/java/com/bwie/system/service/UserService.java (date 1723429123627)
|
||
@@ -0,0 +1,13 @@
|
||
+package com.bwie.system.service;
|
||
+
|
||
+import com.bwie.common.domain.User;
|
||
+
|
||
+/**
|
||
+ * 用户业务层接口
|
||
+ */
|
||
+public interface UserService {
|
||
+ // 根据手机号查询用户信息
|
||
+ User findByPhone(String phone);
|
||
+ //注册
|
||
+ void register(User user);
|
||
+}
|
||
Index: pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/pom.xml b/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723432643868)
|
||
+++ b/pom.xml (date 1723432643868)
|
||
@@ -0,0 +1,123 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>month</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ <packaging>pom</packaging>
|
||
+ <modules>
|
||
+ <module>bwie-common</module>
|
||
+ <module>bwie-gateway</module>
|
||
+ <module>bwie-auth</module>
|
||
+ <module>bwie-module</module>
|
||
+ <module>bwie-module/bwie-es</module>
|
||
+ </modules>
|
||
+
|
||
+ <properties>
|
||
+ <maven.compiler.source>8</maven.compiler.source>
|
||
+ <maven.compiler.target>8</maven.compiler.target>
|
||
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||
+ <spring-cloud.version>2021.0.0</spring-cloud.version>
|
||
+ <spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
||
+ <jjwt.version>0.9.1</jjwt.version>
|
||
+ <fastjson.version>1.2.80</fastjson.version>
|
||
+ <hutool.version>5.8.3</hutool.version>
|
||
+ <alidy.version>2.0.1</alidy.version>
|
||
+ <fastdfs-client>1.26.5</fastdfs-client>
|
||
+ <mybatis-plus.version>3.5.6</mybatis-plus.version>
|
||
+ </properties>
|
||
+
|
||
+ <!-- 规定SpringBoot版本 -->
|
||
+ <parent>
|
||
+ <artifactId>spring-boot-starter-parent</artifactId>
|
||
+ <groupId>org.springframework.boot</groupId>
|
||
+ <version>2.6.2</version>
|
||
+ <relativePath/>
|
||
+ </parent>
|
||
+
|
||
+ <dependencyManagement>
|
||
+ <dependencies>
|
||
+ <!-- SpringCloud 微服务 -->
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.cloud</groupId>
|
||
+ <artifactId>spring-cloud-dependencies</artifactId>
|
||
+ <version>${spring-cloud.version}</version>
|
||
+ <type>pom</type>
|
||
+ <scope>import</scope>
|
||
+ </dependency>
|
||
+ <!-- SpringCloud Alibaba 微服务 -->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba.cloud</groupId>
|
||
+ <artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||
+ <version>${spring-cloud-alibaba.version}</version>
|
||
+ <type>pom</type>
|
||
+ <scope>import</scope>
|
||
+ </dependency>
|
||
+ <!-- JWT -->
|
||
+ <dependency>
|
||
+ <groupId>io.jsonwebtoken</groupId>
|
||
+ <artifactId>jjwt</artifactId>
|
||
+ <version>${jjwt.version}</version>
|
||
+ </dependency>
|
||
+ <!-- Alibaba Fastjson -->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba</groupId>
|
||
+ <artifactId>fastjson</artifactId>
|
||
+ <version>${fastjson.version}</version>
|
||
+ </dependency>
|
||
+ <!-- hutool -->
|
||
+ <dependency>
|
||
+ <groupId>cn.hutool</groupId>
|
||
+ <artifactId>hutool-all</artifactId>
|
||
+ <version>${hutool.version}</version>
|
||
+ </dependency>
|
||
+ <!-- 阿里大鱼 -->
|
||
+ <dependency>
|
||
+ <groupId>com.aliyun</groupId>
|
||
+ <artifactId>dysmsapi20170525</artifactId>
|
||
+ <version>${alidy.version}</version>
|
||
+ </dependency>
|
||
+ <!-- Druid -->
|
||
+ <dependency>
|
||
+ <groupId>com.alibaba</groupId>
|
||
+ <artifactId>druid-spring-boot-starter</artifactId>
|
||
+ <version>1.2.8</version>
|
||
+ </dependency>
|
||
+ <dependency>
|
||
+ <groupId>org.mybatis.spring.boot</groupId>
|
||
+ <artifactId>mybatis-spring-boot-starter</artifactId>
|
||
+ <version>2.2.2</version>
|
||
+ </dependency>
|
||
+ <!-- Pagehelper -->
|
||
+ <dependency>
|
||
+ <groupId>com.github.pagehelper</groupId>
|
||
+ <artifactId>pagehelper-spring-boot-starter</artifactId>
|
||
+ <version>1.4.1</version>
|
||
+ </dependency>
|
||
+ <!-- 公共模块 -->
|
||
+ <dependency>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-common</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ </dependency>
|
||
+
|
||
+ <dependency>
|
||
+ <groupId>com.github.tobato</groupId>
|
||
+ <artifactId>fastdfs-client</artifactId>
|
||
+ <version>${fastdfs-client}</version>
|
||
+ </dependency>
|
||
+
|
||
+
|
||
+ <dependency>
|
||
+ <groupId>com.baomidou</groupId>
|
||
+ <artifactId>mybatis-plus-annotation</artifactId>
|
||
+ <version>${mybatis-plus.version}</version>
|
||
+ </dependency>
|
||
+
|
||
+ </dependencies>
|
||
+ </dependencyManagement>
|
||
+
|
||
+</project>
|
||
Index: bwie-module/bwie-order/pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-order/pom.xml b/bwie-module/bwie-order/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723449344515)
|
||
+++ b/bwie-module/bwie-order/pom.xml (date 1723449344515)
|
||
@@ -0,0 +1,25 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+ <parent>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-module</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ </parent>
|
||
+
|
||
+ <artifactId>bwie-order</artifactId>
|
||
+
|
||
+ <dependencies>
|
||
+ <dependency>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-common</artifactId>
|
||
+ </dependency>
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.boot</groupId>
|
||
+ <artifactId>spring-boot-starter-web</artifactId>
|
||
+ </dependency>
|
||
+ </dependencies>
|
||
+
|
||
+</project>
|
||
Index: bwie-module/bwie-system/src/main/resources/mapper/LoginMapper.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-system/src/main/resources/mapper/LoginMapper.xml b/bwie-module/bwie-system/src/main/resources/mapper/LoginMapper.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723429123657)
|
||
+++ b/bwie-module/bwie-system/src/main/resources/mapper/LoginMapper.xml (date 1723429123657)
|
||
@@ -0,0 +1,22 @@
|
||
+<?xml version="1.0" encoding="UTF-8" ?>
|
||
+<!DOCTYPE mapper
|
||
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
+<!--
|
||
+1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||
+ 通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||
+ -->
|
||
+<mapper namespace="com.bwie.system.mapper.UserMapper">
|
||
+
|
||
+ <!--根据手机号查询用户信息-->
|
||
+ <select id="findByPhone" resultType="com.bwie.common.domain.User">
|
||
+ select user_id,user_name,user_pwd,phone,user_role from t_user where phone = #{phone}
|
||
+ </select>
|
||
+
|
||
+ <!--注册-->
|
||
+ <insert id="register">
|
||
+ insert into t_user(phone,user_name,user_pwd,user_role)
|
||
+ values(#{phone},#{userName},#{userPwd},2)
|
||
+ </insert>
|
||
+
|
||
+</mapper>
|
||
Index: bwie-common/src/main/java/com/bwie/common/domain/Order.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/Order.java b/bwie-common/src/main/java/com/bwie/common/domain/Order.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723468474808)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/domain/Order.java (date 1723468474808)
|
||
@@ -0,0 +1,59 @@
|
||
+package com.bwie.common.domain;
|
||
+
|
||
+import com.baomidou.mybatisplus.annotation.IdType;
|
||
+import com.baomidou.mybatisplus.annotation.TableId;
|
||
+import com.baomidou.mybatisplus.annotation.TableName;
|
||
+import com.fasterxml.jackson.annotation.JsonFormat;
|
||
+import lombok.AllArgsConstructor;
|
||
+import lombok.Builder;
|
||
+import lombok.Data;
|
||
+import lombok.NoArgsConstructor;
|
||
+import org.springframework.format.annotation.DateTimeFormat;
|
||
+
|
||
+import java.math.BigDecimal;
|
||
+import java.util.Date;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 订单记录
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 15:43:40
|
||
+ */
|
||
+@Data
|
||
+@Builder
|
||
+@NoArgsConstructor
|
||
+@AllArgsConstructor
|
||
+@TableName("t_order")
|
||
+public class Order {
|
||
+ /**
|
||
+ * 主键
|
||
+ */
|
||
+ @TableId(type = IdType.AUTO)
|
||
+ private Integer orderId;
|
||
+ /**
|
||
+ * 买单号
|
||
+ */
|
||
+ private Integer orderNumber;
|
||
+ /**
|
||
+ * 订单卷名称
|
||
+ */
|
||
+ private String orderVolumeName;
|
||
+ /**
|
||
+ * 日期
|
||
+ */
|
||
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||
+ private Date orderTime;
|
||
+ /**
|
||
+ * 价格
|
||
+ */
|
||
+ private BigDecimal orderPrice;
|
||
+ /**
|
||
+ * 订单状态
|
||
+ */
|
||
+ private String orderFlag;
|
||
+ /**
|
||
+ * 个人金额
|
||
+ */
|
||
+ private BigDecimal personalAmount;
|
||
+}
|
||
Index: bwie-module/bwie-system/src/main/resources/bootstrap.yml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-system/src/main/resources/bootstrap.yml b/bwie-module/bwie-system/src/main/resources/bootstrap.yml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723425531744)
|
||
+++ b/bwie-module/bwie-system/src/main/resources/bootstrap.yml (date 1723425531744)
|
||
@@ -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-system
|
||
+ profiles:
|
||
+ # 环境配置
|
||
+ active: dev
|
||
+ cloud:
|
||
+ nacos:
|
||
+ discovery:
|
||
+ # 服务注册地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ config:
|
||
+ # 配置中心地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ # 配置文件格式
|
||
+ file-extension: yml
|
||
+ # 共享配置
|
||
+ shared-configs:
|
||
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||
Index: bwie-module/bwie-system/src/main/java/com/bwie/system/SystemApplication.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-system/src/main/java/com/bwie/system/SystemApplication.java b/bwie-module/bwie-system/src/main/java/com/bwie/system/SystemApplication.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723427921186)
|
||
+++ b/bwie-module/bwie-system/src/main/java/com/bwie/system/SystemApplication.java (date 1723427921186)
|
||
@@ -0,0 +1,13 @@
|
||
+package com.bwie.system;
|
||
+
|
||
+import org.mybatis.spring.annotation.MapperScan;
|
||
+import org.springframework.boot.SpringApplication;
|
||
+import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||
+
|
||
+@SpringBootApplication
|
||
+@MapperScan("com.bwie.system.mapper")
|
||
+public class SystemApplication {
|
||
+ public static void main(String[] args) {
|
||
+ SpringApplication.run(SystemApplication.class,args);
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/EsApplication.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/EsApplication.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/EsApplication.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1715784312033)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/EsApplication.java (date 1715784312033)
|
||
@@ -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 EsApplication {
|
||
+ public static void main(String[] args) {
|
||
+ SpringApplication.run(EsApplication.class);
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-system/pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-system/pom.xml b/bwie-module/bwie-system/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723425069738)
|
||
+++ b/bwie-module/bwie-system/pom.xml (date 1723425069738)
|
||
@@ -0,0 +1,25 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+ <parent>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-module</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ </parent>
|
||
+
|
||
+ <artifactId>bwie-system</artifactId>
|
||
+
|
||
+ <dependencies>
|
||
+ <dependency>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-common</artifactId>
|
||
+ </dependency>
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.boot</groupId>
|
||
+ <artifactId>spring-boot-starter-web</artifactId>
|
||
+ </dependency>
|
||
+ </dependencies>
|
||
+
|
||
+</project>
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/remote/impl/Fusing.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/remote/impl/Fusing.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/remote/impl/Fusing.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723447008299)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/remote/impl/Fusing.java (date 1723447008299)
|
||
@@ -0,0 +1,33 @@
|
||
+package com.bwie.es.remote.impl;
|
||
+
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.common.result.Result;
|
||
+import com.bwie.es.remote.VolumeRemote;
|
||
+import org.springframework.cloud.openfeign.FallbackFactory;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 熔断处理器
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 11:35:24
|
||
+ */
|
||
+@Component
|
||
+public class Fusing implements FallbackFactory<VolumeRemote> {
|
||
+ @Override
|
||
+ public VolumeRemote create(Throwable cause) {
|
||
+ return new VolumeRemote() {
|
||
+ @Override
|
||
+ public Result<List<Volume>> queryVolume() {
|
||
+ throw new RuntimeException("服务繁忙,远程调用失败");
|
||
+ }
|
||
+
|
||
+ @Override
|
||
+ public Result<Integer> saveVolume(Volume volume) {
|
||
+ throw new RuntimeException("服务繁忙,远程调用失败");
|
||
+ }
|
||
+ };
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/remote/VolumeRemote.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/remote/VolumeRemote.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/remote/VolumeRemote.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723447008312)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/remote/VolumeRemote.java (date 1723447008312)
|
||
@@ -0,0 +1,28 @@
|
||
+package com.bwie.es.remote;
|
||
+
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.common.result.Result;
|
||
+import com.bwie.es.remote.impl.Fusing;
|
||
+import org.springframework.cloud.openfeign.FeignClient;
|
||
+import org.springframework.web.bind.annotation.GetMapping;
|
||
+import org.springframework.web.bind.annotation.PostMapping;
|
||
+import org.springframework.web.bind.annotation.RequestBody;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+@FeignClient(value = "bwie-volume",fallbackFactory = Fusing.class)
|
||
+public interface VolumeRemote {
|
||
+ /**
|
||
+ * 查询所有卷
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/queryVolume")
|
||
+ public Result<List<Volume>> queryVolume();
|
||
+ /**
|
||
+ * 保存卷
|
||
+ * @param volume
|
||
+ * @return
|
||
+ */
|
||
+ @PostMapping("/saveVolume")
|
||
+ public Result<Integer> saveVolume(@RequestBody Volume volume);
|
||
+}
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/synchronous/EsVolume.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/synchronous/EsVolume.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/synchronous/EsVolume.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723436295907)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/synchronous/EsVolume.java (date 1723436295907)
|
||
@@ -0,0 +1,63 @@
|
||
+package com.bwie.es.synchronous;
|
||
+
|
||
+import com.alibaba.fastjson.JSONObject;
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.es.remote.VolumeRemote;
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+import org.elasticsearch.action.bulk.BulkRequest;
|
||
+import org.elasticsearch.action.index.IndexRequest;
|
||
+import org.elasticsearch.client.RequestOptions;
|
||
+import org.elasticsearch.client.RestHighLevelClient;
|
||
+import org.elasticsearch.common.xcontent.XContentType;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.boot.ApplicationArguments;
|
||
+import org.springframework.boot.ApplicationRunner;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+import java.io.IOException;
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description es和volume数据同步
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 11:46:03
|
||
+ */
|
||
+@Slf4j
|
||
+@Component
|
||
+public class EsVolume implements ApplicationRunner{
|
||
+
|
||
+ @Autowired
|
||
+ private RestHighLevelClient restHighLevelClient;
|
||
+
|
||
+ private static final String INDEX_NAME = "volume";
|
||
+
|
||
+ @Autowired
|
||
+ private VolumeRemote remote;
|
||
+
|
||
+ @Override
|
||
+ public void run(ApplicationArguments args) throws Exception {
|
||
+ try {
|
||
+ log.info("----------ES和Volume开始同步数据----------");
|
||
+ //开始时间
|
||
+ long startTime = System.currentTimeMillis();
|
||
+ BulkRequest bulkRequest = new BulkRequest();
|
||
+ List<Volume> volumeList = remote.queryVolume().getData();
|
||
+ volumeList.forEach(volume -> {
|
||
+ bulkRequest.add(
|
||
+ new IndexRequest(INDEX_NAME)
|
||
+ .id(volume.getVolumeId().toString())
|
||
+ .source(JSONObject.toJSONString(volume), XContentType.JSON)
|
||
+ );
|
||
+ });
|
||
+ restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);
|
||
+ log.info("----------ES和Volume同步数据成功----------");
|
||
+ //结束时间
|
||
+ long endTime = System.currentTimeMillis();
|
||
+ long expendTime = (endTime - startTime) / 1000;
|
||
+ log.info("同步数据耗时(秒):{}", expendTime);
|
||
+ } catch (IOException e) {
|
||
+ throw new RuntimeException(e);
|
||
+ }
|
||
+ }
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/domain/request/VolumeRequest.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/VolumeRequest.java b/bwie-common/src/main/java/com/bwie/common/domain/request/VolumeRequest.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723445768447)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/domain/request/VolumeRequest.java (date 1723445768447)
|
||
@@ -0,0 +1,31 @@
|
||
+package com.bwie.common.domain.request;
|
||
+
|
||
+import lombok.AllArgsConstructor;
|
||
+import lombok.Builder;
|
||
+import lombok.Data;
|
||
+import lombok.NoArgsConstructor;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 11:38:48
|
||
+ */
|
||
+@Data
|
||
+@Builder
|
||
+@NoArgsConstructor
|
||
+@AllArgsConstructor
|
||
+public class VolumeRequest {
|
||
+ /**
|
||
+ * 卷名称
|
||
+ */
|
||
+ private String volumeName;
|
||
+ /**
|
||
+ * 卷库存
|
||
+ */
|
||
+ private Integer volumeInventory;
|
||
+ /**
|
||
+ * 卷类型1.腾讯2.爱奇艺3.哔哩哔哩4.优酷5.QQ
|
||
+ */
|
||
+ private Integer volumeType;
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/domain/request/OrderRequest.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/OrderRequest.java b/bwie-common/src/main/java/com/bwie/common/domain/request/OrderRequest.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723468474818)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/domain/request/OrderRequest.java (date 1723468474818)
|
||
@@ -0,0 +1,26 @@
|
||
+package com.bwie.common.domain.request;
|
||
+
|
||
+import lombok.AllArgsConstructor;
|
||
+import lombok.Builder;
|
||
+import lombok.Data;
|
||
+import lombok.NoArgsConstructor;
|
||
+
|
||
+import javax.validation.constraints.NotEmpty;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 订单请求实体类
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 19:12:37
|
||
+ */
|
||
+@Data
|
||
+@Builder
|
||
+@NoArgsConstructor
|
||
+@AllArgsConstructor
|
||
+public class OrderRequest {
|
||
+ /**
|
||
+ * 订单卷名称
|
||
+ */
|
||
+ @NotEmpty(message = "订单卷名称不能为空")
|
||
+ private String orderVolumeName;
|
||
+}
|
||
Index: .idea/misc.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/.idea/misc.xml b/.idea/misc.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723424919803)
|
||
+++ b/.idea/misc.xml (date 1723424919803)
|
||
@@ -0,0 +1,15 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project version="4">
|
||
+ <component name="ExternalStorageConfigurationManager" enabled="true" />
|
||
+ <component name="MavenProjectsManager">
|
||
+ <option name="originalFiles">
|
||
+ <list>
|
||
+ <option value="$PROJECT_DIR$/pom.xml" />
|
||
+ </list>
|
||
+ </option>
|
||
+ <option name="workspaceImportForciblyTurnedOn" value="true" />
|
||
+ </component>
|
||
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||
+ <output url="file://$PROJECT_DIR$/out" />
|
||
+ </component>
|
||
+</project>
|
||
\ No newline at end of file
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/controller/EsController.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/controller/EsController.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/controller/EsController.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723445619734)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/controller/EsController.java (date 1723445619734)
|
||
@@ -0,0 +1,72 @@
|
||
+package com.bwie.es.controller;
|
||
+
|
||
+import com.alibaba.fastjson.JSONObject;
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.common.domain.request.VolumeRequest;
|
||
+import com.bwie.common.domain.response.TokenResponse;
|
||
+import com.bwie.common.result.Result;
|
||
+import com.bwie.es.service.EsService;
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+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;
|
||
+import java.util.List;
|
||
+
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description es控制层
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 12:26:13
|
||
+ */
|
||
+@Slf4j
|
||
+@RestController
|
||
+public class EsController {
|
||
+
|
||
+ @Autowired
|
||
+ private EsService esService;
|
||
+
|
||
+ @Autowired
|
||
+ private HttpServletRequest httpServletRequest;
|
||
+
|
||
+ /**
|
||
+ * es查询
|
||
+ * @param request
|
||
+ * @return
|
||
+ */
|
||
+ @PostMapping("/esList")
|
||
+ public Result<List<Volume>> esList(@RequestBody VolumeRequest request){
|
||
+ log.info("功能:es查询");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+ JSONObject.toJSONString(request));
|
||
+ List<Volume> volumes = esService.esList(request);
|
||
+ log.info("功能:es查询");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("响应结果:"+ JSONObject.toJSONString(volumes));
|
||
+ return Result.success(volumes);
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * es保存
|
||
+ * @param volume
|
||
+ */
|
||
+ @PostMapping("/saveVolume")
|
||
+ public Result esSaveVolume(@RequestBody Volume volume){
|
||
+ log.info("功能:es保存");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+ JSONObject.toJSONString(volume));
|
||
+ esService.esSaveVolume(volume);
|
||
+ log.info("功能:es保存");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ return Result.success();
|
||
+ }
|
||
+
|
||
+}
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/service/impl/EsServiceImpl.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/service/impl/EsServiceImpl.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/service/impl/EsServiceImpl.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723447529004)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/service/impl/EsServiceImpl.java (date 1723447529004)
|
||
@@ -0,0 +1,112 @@
|
||
+package com.bwie.es.service.impl;
|
||
+
|
||
+import com.alibaba.fastjson.JSONObject;
|
||
+import com.bwie.common.constants.RabbitMQQueueNameConstants;
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.common.domain.request.VolumeRequest;
|
||
+import com.bwie.es.service.EsService;
|
||
+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.builder.SearchSourceBuilder;
|
||
+import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||
+import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
|
||
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.stereotype.Service;
|
||
+
|
||
+import java.io.IOException;
|
||
+import java.util.ArrayList;
|
||
+import java.util.List;
|
||
+import java.util.Map;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description es实现层
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 11:53:47
|
||
+ */
|
||
+@Service
|
||
+public class EsServiceImpl implements EsService {
|
||
+
|
||
+ @Autowired
|
||
+ private RestHighLevelClient restHighLevelClient;
|
||
+
|
||
+ private static final String INDEX_NAME = "volume";
|
||
+
|
||
+ @Override
|
||
+ public List<Volume> esList(VolumeRequest request) {
|
||
+ List<Volume> volumeArrayList = new ArrayList<>();
|
||
+ try {
|
||
+ SearchRequest searchRequest = new SearchRequest(INDEX_NAME);
|
||
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||
+ BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
|
||
+ if (request.getVolumeName() != null) {
|
||
+ boolQuery.must(QueryBuilders.matchQuery("volumeName", request.getVolumeName()));
|
||
+ }
|
||
+ if (request.getVolumeInventory() != null) {
|
||
+ boolQuery.must(QueryBuilders.matchQuery("volumeInventory", request.getVolumeInventory()));
|
||
+ }
|
||
+ if (request.getVolumeType() != null){
|
||
+ boolQuery.must(QueryBuilders.matchQuery("volumeType", request.getVolumeType()));
|
||
+ }
|
||
+ searchSourceBuilder.query(boolQuery);
|
||
+ searchSourceBuilder.highlighter(
|
||
+ new HighlightBuilder()
|
||
+ .field("volumeName")
|
||
+ .preTags("<span style=\"color:red;\">")
|
||
+ .postTags("</span>"));
|
||
+ searchRequest.source(searchSourceBuilder);
|
||
+ SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
||
+ SearchHit[] searchHits = searchResponse.getHits().getHits();
|
||
+ for (SearchHit searchHit : searchHits) {
|
||
+ String sourceAsString = searchHit.getSourceAsString();
|
||
+ Volume volume = JSONObject.parseObject(sourceAsString, Volume.class);
|
||
+ volume.setVolumeId(Integer.valueOf(searchHit.getId()));
|
||
+
|
||
+ Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
|
||
+ if (highlightFields != null){
|
||
+ HighlightField highlightField = highlightFields.get("volumeName");
|
||
+ if (highlightField != null){
|
||
+ Text[] fragments = highlightField.getFragments();
|
||
+ String str = "";
|
||
+ for (Text fragment : fragments) {
|
||
+ str += fragment;
|
||
+ }
|
||
+ volume.setVolumeName(str);
|
||
+ }
|
||
+ volumeArrayList.add(volume);
|
||
+ }
|
||
+ }
|
||
+ } catch (Exception e) {
|
||
+ throw new RuntimeException(e);
|
||
+ }
|
||
+
|
||
+ return volumeArrayList;
|
||
+ }
|
||
+
|
||
+
|
||
+ @Autowired
|
||
+ private RabbitTemplate rabbitTemplate;
|
||
+
|
||
+ @Override
|
||
+ public void esSaveVolume(Volume volume) {
|
||
+ try {
|
||
+ IndexRequest indexRequest = new IndexRequest(INDEX_NAME);
|
||
+ indexRequest.id(volume.getVolumeId() + "");
|
||
+ indexRequest.source(JSONObject.toJSONString(volume), XContentType.JSON);
|
||
+ restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
|
||
+ } catch (IOException e) {
|
||
+ throw new RuntimeException(e);
|
||
+ }
|
||
+ rabbitTemplate.convertAndSend(RabbitMQQueueNameConstants.SEND_VOLUME_QUEUE,"volume",volume);
|
||
+ }
|
||
+
|
||
+}
|
||
Index: .idea/restkit/RESTKit_CommonSetting.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/.idea/restkit/RESTKit_CommonSetting.xml b/.idea/restkit/RESTKit_CommonSetting.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723433542443)
|
||
+++ b/.idea/restkit/RESTKit_CommonSetting.xml (date 1723433542443)
|
||
@@ -0,0 +1,6 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project version="4">
|
||
+ <component name="RESTKit_CommonSetting">
|
||
+ <option name="apiFilePath" value="C:\Users\86191\.restkit\month\apifile.json" />
|
||
+ </component>
|
||
+</project>
|
||
\ No newline at end of file
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/config/InitESRestHighLevelClient.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/config/InitESRestHighLevelClient.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/config/InitESRestHighLevelClient.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723436940843)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/config/InitESRestHighLevelClient.java (date 1723436940843)
|
||
@@ -0,0 +1,139 @@
|
||
+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;
|
||
+
|
||
+
|
||
+@Configuration
|
||
+@ConfigurationProperties(prefix = "es")
|
||
+@Data
|
||
+public class InitESRestHighLevelClient {
|
||
+
|
||
+ /**
|
||
+ * es服务 地址
|
||
+ */
|
||
+ private String host;
|
||
+
|
||
+ /**
|
||
+ * 端口
|
||
+ */
|
||
+ private int port;
|
||
+
|
||
+ /**
|
||
+ * 请求方式
|
||
+ */
|
||
+ private String scheme;
|
||
+
|
||
+ /**
|
||
+ * 构建 RestHighLevelClient 用来做 es 操作
|
||
+ * @return
|
||
+ */
|
||
+ @Bean
|
||
+ public RestHighLevelClient restHighLevelClient() {
|
||
+ return new RestHighLevelClient(
|
||
+ RestClient.builder(new HttpHost(host, port, scheme))
|
||
+ );
|
||
+ }
|
||
+
|
||
+
|
||
+/**
|
||
+ * 添加商品表es
|
||
+ * @param goods
|
||
+ */
|
||
+// @Override
|
||
+// public void saveGoods(Goods goods) {
|
||
+// try {
|
||
+// IndexRequest indexRequest = new IndexRequest(INDEX_NAME);
|
||
+// indexRequest.id(goods.getGoodsId() + "");
|
||
+// indexRequest.source(JSONObject.toJSONString(goods),XContentType.JSON);
|
||
+// restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
|
||
+// } catch (IOException e) {
|
||
+// throw new RuntimeException(e);
|
||
+// }
|
||
+// }
|
||
+//
|
||
+//
|
||
+//
|
||
+///**
|
||
+// * 修改es
|
||
+// * @param goods
|
||
+// */
|
||
+// @Override
|
||
+// public void update(Goods goods) {
|
||
+//
|
||
+//
|
||
+// try {
|
||
+// UpdateRequest updateRequest = new UpdateRequest(INDEX_NAME, String.valueOf(goods.getGoodsId()));
|
||
+// SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
|
||
+// filter.getExcludes().add("goodsId");
|
||
+// updateRequest.doc(JSONObject.toJSONString(goods),XContentType.JSON);
|
||
+// restHighLevelClient.update(updateRequest,RequestOptions.DEFAULT);
|
||
+// } catch (IOException e) {
|
||
+// throw new RuntimeException(e);
|
||
+// }
|
||
+// }
|
||
+//
|
||
+// /**
|
||
+// * 删除es
|
||
+// * @param documentId
|
||
+// */
|
||
+// @Override
|
||
+// public void delete(String documentId) {
|
||
+//
|
||
+// try {
|
||
+// DeleteRequest deleteRequest = new DeleteRequest(INDEX_NAME, documentId);
|
||
+// restHighLevelClient.delete(deleteRequest,RequestOptions.DEFAULT);
|
||
+// } catch (IOException e) {
|
||
+// throw new RuntimeException(e);
|
||
+// }
|
||
+// }
|
||
+//
|
||
+//
|
||
+//
|
||
+///**
|
||
+// * 统计出各个销售员的保单数量
|
||
+// * @return
|
||
+// */
|
||
+// @Override
|
||
+// public List<Statistics> queryEsWarrantyCreatePeopleAndWarrantyCount() {
|
||
+// List<Statistics> statisticsArrayList = new ArrayList<>();
|
||
+//
|
||
+// try {
|
||
+// SearchRequest searchRequest = new SearchRequest(INDEX_NAME);
|
||
+// SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||
+// TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("warranty_number").field("warrantyCreatePeople");
|
||
+// searchSourceBuilder.aggregation(aggregationBuilder);
|
||
+// searchRequest.source(searchSourceBuilder);
|
||
+// //执行查询
|
||
+// SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
||
+// //获取聚合查询结果
|
||
+// Aggregations aggregations = searchResponse.getAggregations();
|
||
+// //根据聚合名称获取响应数据
|
||
+// //这个返回的东西要改成TERMS
|
||
+// Terms warrantyNumber = aggregations.get("warranty_number");
|
||
+// List<? extends Terms.Bucket> buckets = warrantyNumber.getBuckets();
|
||
+// //遍历
|
||
+// buckets.forEach(bucket -> {
|
||
+// String keyAsString = bucket.getKeyAsString();
|
||
+// long docCount = bucket.getDocCount();
|
||
+//
|
||
+// Statistics statistics = new Statistics();
|
||
+// statistics.setStatisticsId(keyAsString);
|
||
+// statistics.setStatisticsCount(docCount);
|
||
+// statisticsArrayList.add(statistics);
|
||
+// });
|
||
+//
|
||
+// } catch (Exception e) {
|
||
+// throw new RuntimeException(e);
|
||
+// }
|
||
+//
|
||
+// return statisticsArrayList;
|
||
+// }
|
||
+
|
||
+
|
||
+}
|
||
Index: bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
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
|
||
--- /dev/null (date 1723426735895)
|
||
+++ b/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java (date 1723426735895)
|
||
@@ -0,0 +1,16 @@
|
||
+package com.bwie.auth.service;
|
||
+
|
||
+import com.bwie.common.domain.User;
|
||
+import com.bwie.common.domain.request.UserRequest;
|
||
+import com.bwie.common.domain.response.TokenResponse;
|
||
+
|
||
+public interface AuthService {
|
||
+ //发送验证码
|
||
+ void sendCode(String phone);
|
||
+ //登录
|
||
+ TokenResponse login(UserRequest request);
|
||
+ //获取token
|
||
+ User info();
|
||
+ //退出登录
|
||
+ void logout();
|
||
+}
|
||
Index: bwie-auth/src/main/resources/bootstrap.yml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-auth/src/main/resources/bootstrap.yml b/bwie-auth/src/main/resources/bootstrap.yml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723427857911)
|
||
+++ b/bwie-auth/src/main/resources/bootstrap.yml (date 1723427857911)
|
||
@@ -0,0 +1,43 @@
|
||
+# Tomcat
|
||
+server:
|
||
+ port: 9001
|
||
+# Spring
|
||
+spring:
|
||
+ rabbitmq:
|
||
+ host: 111.229.181.183
|
||
+ port: 5672
|
||
+ username: guest
|
||
+ password: guest
|
||
+ virtual-host: /
|
||
+ listener:
|
||
+ simple:
|
||
+ retry:
|
||
+ enabled: true
|
||
+ prefetch: 1 #配置多劳多得 每次取出一条消息 消息完毕取下一条
|
||
+ acknowledge-mode: manual #设置消费端手动ack确认
|
||
+ publisher-confirm-type: correlated #确认消息已发送到交换机(exchange)或者broker
|
||
+ publisher-returns: true #开启消息发送到队列的确认
|
||
+ 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: 47.116.168.171:8848
|
||
+ config:
|
||
+ # 配置中心地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ # 配置文件格式
|
||
+ file-extension: yml
|
||
+ # 共享配置
|
||
+ shared-configs:
|
||
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||
Index: bwie-auth/src/main/java/com/bwie/auth/AuthApplication.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-auth/src/main/java/com/bwie/auth/AuthApplication.java b/bwie-auth/src/main/java/com/bwie/auth/AuthApplication.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723427946480)
|
||
+++ b/bwie-auth/src/main/java/com/bwie/auth/AuthApplication.java (date 1723427946480)
|
||
@@ -0,0 +1,18 @@
|
||
+package com.bwie.auth;
|
||
+
|
||
+import org.springframework.boot.SpringApplication;
|
||
+import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||
+import org.springframework.cloud.openfeign.EnableFeignClients;
|
||
+import org.springframework.context.annotation.Bean;
|
||
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||
+
|
||
+
|
||
+@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||
+@EnableFeignClients
|
||
+public class AuthApplication {
|
||
+
|
||
+ public static void main(String[] args) {
|
||
+ SpringApplication.run(AuthApplication.class,args);
|
||
+ }
|
||
+}
|
||
Index: bwie-module/pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/pom.xml b/bwie-module/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723448823245)
|
||
+++ b/bwie-module/pom.xml (date 1723448823245)
|
||
@@ -0,0 +1,26 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+ <parent>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>month</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ </parent>
|
||
+
|
||
+ <artifactId>bwie-module</artifactId>
|
||
+ <packaging>pom</packaging>
|
||
+ <modules>
|
||
+ <module>bwie-system</module>
|
||
+ <module>bwie-volume</module>
|
||
+ <module>bwie-order</module>
|
||
+ </modules>
|
||
+
|
||
+ <properties>
|
||
+ <maven.compiler.source>17</maven.compiler.source>
|
||
+ <maven.compiler.target>17</maven.compiler.target>
|
||
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||
+ </properties>
|
||
+
|
||
+</project>
|
||
Index: bwie-module/bwie-es/src/main/java/com/bwie/es/service/EsService.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/java/com/bwie/es/service/EsService.java b/bwie-module/bwie-es/src/main/java/com/bwie/es/service/EsService.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723445619722)
|
||
+++ b/bwie-module/bwie-es/src/main/java/com/bwie/es/service/EsService.java (date 1723445619722)
|
||
@@ -0,0 +1,13 @@
|
||
+package com.bwie.es.service;
|
||
+
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.common.domain.request.VolumeRequest;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+public interface EsService {
|
||
+ //es查询
|
||
+ List<Volume> esList(VolumeRequest request);
|
||
+ //es新增
|
||
+ void esSaveVolume(Volume volume);
|
||
+}
|
||
Index: bwie-auth/pom.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-auth/pom.xml b/bwie-auth/pom.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723424977238)
|
||
+++ b/bwie-auth/pom.xml (date 1723424977238)
|
||
@@ -0,0 +1,26 @@
|
||
+<?xml version="1.0" encoding="UTF-8"?>
|
||
+<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||
+ <modelVersion>4.0.0</modelVersion>
|
||
+ <parent>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>month</artifactId>
|
||
+ <version>1.0-SNAPSHOT</version>
|
||
+ </parent>
|
||
+
|
||
+ <artifactId>bwie-auth</artifactId>
|
||
+
|
||
+ <dependencies>
|
||
+ <!-- common -->
|
||
+ <dependency>
|
||
+ <groupId>com.bwie</groupId>
|
||
+ <artifactId>bwie-common</artifactId>
|
||
+ </dependency>
|
||
+ <!-- web -->
|
||
+ <dependency>
|
||
+ <groupId>org.springframework.boot</groupId>
|
||
+ <artifactId>spring-boot-starter-web</artifactId>
|
||
+ </dependency>
|
||
+ </dependencies>
|
||
+</project>
|
||
Index: bwie-gateway/src/main/resources/bootstrap.yml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-gateway/src/main/resources/bootstrap.yml b/bwie-gateway/src/main/resources/bootstrap.yml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723427893549)
|
||
+++ b/bwie-gateway/src/main/resources/bootstrap.yml (date 1723427893549)
|
||
@@ -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: 47.116.168.171:8848
|
||
+ config:
|
||
+ # 配置中心地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ # 配置文件格式
|
||
+ file-extension: yml
|
||
+ # 共享配置
|
||
+ shared-configs:
|
||
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||
Index: bwie-module/bwie-es/src/main/resources/mapper/LoginMapper.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/resources/mapper/LoginMapper.xml b/bwie-module/bwie-es/src/main/resources/mapper/LoginMapper.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723429123657)
|
||
+++ b/bwie-module/bwie-es/src/main/resources/mapper/LoginMapper.xml (date 1723429123657)
|
||
@@ -0,0 +1,22 @@
|
||
+<?xml version="1.0" encoding="UTF-8" ?>
|
||
+<!DOCTYPE mapper
|
||
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
+<!--
|
||
+1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||
+ 通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||
+ -->
|
||
+<mapper namespace="com.bwie.system.mapper.UserMapper">
|
||
+
|
||
+ <!--根据手机号查询用户信息-->
|
||
+ <select id="findByPhone" resultType="com.bwie.common.domain.User">
|
||
+ select user_id,user_name,user_pwd,phone,user_role from t_user where phone = #{phone}
|
||
+ </select>
|
||
+
|
||
+ <!--注册-->
|
||
+ <insert id="register">
|
||
+ insert into t_user(phone,user_name,user_pwd,user_role)
|
||
+ values(#{phone},#{userName},#{userPwd},2)
|
||
+ </insert>
|
||
+
|
||
+</mapper>
|
||
Index: bwie-module/bwie-volume/src/main/resources/mapper/VolumeMapper.xml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/resources/mapper/VolumeMapper.xml b/bwie-module/bwie-volume/src/main/resources/mapper/VolumeMapper.xml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723468191092)
|
||
+++ b/bwie-module/bwie-volume/src/main/resources/mapper/VolumeMapper.xml (date 1723468191092)
|
||
@@ -0,0 +1,68 @@
|
||
+<?xml version="1.0" encoding="UTF-8" ?>
|
||
+<!DOCTYPE mapper
|
||
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
+<!--
|
||
+1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||
+ 通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||
+ -->
|
||
+<mapper namespace="com.bwie.volume.mapper.VolumeMapper">
|
||
+
|
||
+ <!--查询所有的卷-->
|
||
+ <select id="queryVolume" resultType="com.bwie.common.domain.Volume">
|
||
+ SELECT
|
||
+ volume_id,
|
||
+ volume_code,
|
||
+ volume_name,
|
||
+ volume_price,
|
||
+ volume_inventory,
|
||
+ volume_type,
|
||
+ volume_flag,
|
||
+ volume_duration
|
||
+ FROM
|
||
+ t_volume
|
||
+ </select>
|
||
+
|
||
+ <!--添加卷-->
|
||
+ <insert id="saveVolume">
|
||
+ INSERT INTO t_volume(volume_code,volume_name,volume_price,volume_inventory,volume_type,volume_flag)
|
||
+ VALUES(#{volumeCode},#{volumeName},#{volumePrice},#{volumeInventory},#{volumeType},#{volumeFlag})
|
||
+ </insert>
|
||
+
|
||
+ <!--购买卷-->
|
||
+ <select id="purchase" resultType="com.bwie.common.domain.Volume">
|
||
+ SELECT
|
||
+ volume_id,
|
||
+ volume_code,
|
||
+ volume_name,
|
||
+ volume_price,
|
||
+ volume_inventory,
|
||
+ volume_type,
|
||
+ volume_flag,
|
||
+ volume_duration
|
||
+ FROM
|
||
+ t_volume
|
||
+ WHERE
|
||
+ volume_id IN
|
||
+ <foreach collection="volumeIds" item="item" separator=",">
|
||
+ (#{item})
|
||
+ </foreach>
|
||
+ </select>
|
||
+
|
||
+ <!--购买成功之后减去库存-->
|
||
+ <update id="updateVolumeInventory">
|
||
+ UPDATE t_volume
|
||
+ SET
|
||
+ volume_inventory = volume_inventory - 1
|
||
+ WHERE
|
||
+ volume_id = #{volumeId}
|
||
+ </update>
|
||
+
|
||
+ <!--查看卷码详情-->
|
||
+ <update id="updateVolumeTransfer">
|
||
+ update t_volume set
|
||
+ volume_transfer = #{volumeTransfer}
|
||
+ where volume_id = #{volumeId}
|
||
+ </update>
|
||
+
|
||
+</mapper>
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/mapper/VolumeMapper.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/mapper/VolumeMapper.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/mapper/VolumeMapper.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723465372399)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/mapper/VolumeMapper.java (date 1723465372399)
|
||
@@ -0,0 +1,21 @@
|
||
+package com.bwie.volume.mapper;
|
||
+
|
||
+import com.bwie.common.domain.Volume;
|
||
+import org.apache.ibatis.annotations.Param;
|
||
+import org.springframework.stereotype.Component;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+@Component
|
||
+public interface VolumeMapper {
|
||
+ //查询所有的卷
|
||
+ List<Volume> queryVolume();
|
||
+ //添加卷
|
||
+ Integer saveVolume(Volume volume);
|
||
+ //购买卷
|
||
+ List<Volume> purchase(@Param("volumeIds") List<Integer> volumeIds);
|
||
+ //购买成功之后减去库存
|
||
+ void updateVolumeInventory(@Param("volumeIds") List<Integer> volumeIds);
|
||
+ //查看卷码详情
|
||
+ void updateVolumeTransfer(Volume volume);
|
||
+}
|
||
Index: bwie-common/src/main/java/com/bwie/common/domain/Volume.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/Volume.java b/bwie-common/src/main/java/com/bwie/common/domain/Volume.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723461502792)
|
||
+++ b/bwie-common/src/main/java/com/bwie/common/domain/Volume.java (date 1723461502792)
|
||
@@ -0,0 +1,62 @@
|
||
+package com.bwie.common.domain;
|
||
+
|
||
+import com.baomidou.mybatisplus.annotation.IdType;
|
||
+import com.baomidou.mybatisplus.annotation.TableId;
|
||
+import com.baomidou.mybatisplus.annotation.TableName;
|
||
+import lombok.AllArgsConstructor;
|
||
+import lombok.Builder;
|
||
+import lombok.Data;
|
||
+import lombok.NoArgsConstructor;
|
||
+
|
||
+import java.math.BigDecimal;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description 卷
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 11:21:49
|
||
+ */
|
||
+@Data
|
||
+@Builder
|
||
+@NoArgsConstructor
|
||
+@AllArgsConstructor
|
||
+@TableName(value = "t_volume")
|
||
+public class Volume {
|
||
+ /**
|
||
+ * 主键
|
||
+ */
|
||
+ @TableId(type = IdType.AUTO)
|
||
+ private Integer volumeId;
|
||
+ /**
|
||
+ * 卷编码
|
||
+ */
|
||
+ private String volumeCode;
|
||
+ /**
|
||
+ * 卷名称
|
||
+ */
|
||
+ private String volumeName;
|
||
+ /**
|
||
+ * 卷价格
|
||
+ */
|
||
+ private BigDecimal volumePrice;
|
||
+ /**
|
||
+ * 卷库存
|
||
+ */
|
||
+ private Integer volumeInventory;
|
||
+ /**
|
||
+ * 卷类型1.腾讯2.爱奇艺3.哔哩哔哩4.优酷5.QQ
|
||
+ */
|
||
+ private Integer volumeType;
|
||
+ /**
|
||
+ * 卷状态
|
||
+ */
|
||
+ private String volumeFlag;
|
||
+ /**
|
||
+ * 质保时长
|
||
+ */
|
||
+ private Integer volumeDuration;
|
||
+ /**
|
||
+ * 转让信息
|
||
+ */
|
||
+ private String volumeTransfer;
|
||
+}
|
||
Index: bwie-module/bwie-es/src/main/resources/bootstrap.yml
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-es/src/main/resources/bootstrap.yml b/bwie-module/bwie-es/src/main/resources/bootstrap.yml
|
||
new file mode 100644
|
||
--- /dev/null (date 1723432755718)
|
||
+++ b/bwie-module/bwie-es/src/main/resources/bootstrap.yml (date 1723432755718)
|
||
@@ -0,0 +1,29 @@
|
||
+# Tomcat
|
||
+server:
|
||
+ port: 9004
|
||
+# Spring
|
||
+spring:
|
||
+ main:
|
||
+ allow-circular-references: true
|
||
+ jackson:
|
||
+ date-format: yyyy-MM-dd HH:mm:ss
|
||
+ time-zone: GMT+8
|
||
+ application:
|
||
+ # 应用名称
|
||
+ name: bwie-es
|
||
+ profiles:
|
||
+ # 环境配置
|
||
+ active: dev
|
||
+ cloud:
|
||
+ nacos:
|
||
+ discovery:
|
||
+ # 服务注册地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ config:
|
||
+ # 配置中心地址
|
||
+ server-addr: 47.116.168.171:8848
|
||
+ # 配置文件格式
|
||
+ file-extension: yml
|
||
+ # 共享配置
|
||
+ shared-configs:
|
||
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/controller/VolumeController.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/controller/VolumeController.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/controller/VolumeController.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723465372384)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/controller/VolumeController.java (date 1723465372384)
|
||
@@ -0,0 +1,109 @@
|
||
+package com.bwie.volume.controller;
|
||
+
|
||
+import com.alibaba.fastjson.JSONObject;
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.common.domain.response.TokenResponse;
|
||
+import com.bwie.common.result.Result;
|
||
+import com.bwie.volume.service.VolumeService;
|
||
+import lombok.extern.slf4j.Slf4j;
|
||
+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;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 11:29:55
|
||
+ */
|
||
+@Slf4j
|
||
+@RestController
|
||
+public class VolumeController {
|
||
+
|
||
+ @Autowired
|
||
+ private VolumeService volumeService;
|
||
+
|
||
+ @Autowired
|
||
+ private HttpServletRequest httpServletRequest;
|
||
+
|
||
+ /**
|
||
+ * 查询所有卷
|
||
+ * @return
|
||
+ */
|
||
+ @GetMapping("/queryVolume")
|
||
+ public Result<List<Volume>> queryVolume(){
|
||
+ log.info("功能:查询所有卷");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ List<Volume> volumes = volumeService.queryVolume();
|
||
+ log.info("功能:查询所有卷");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("响应结果:"+ JSONObject.toJSONString(volumes));
|
||
+ return Result.success(volumes);
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 保存卷
|
||
+ * @param volume
|
||
+ * @return
|
||
+ */
|
||
+ @PostMapping("/saveVolume")
|
||
+ public Result<Integer> saveVolume(@RequestBody Volume volume){
|
||
+ log.info("功能:保存卷");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+ JSONObject.toJSONString(volume));
|
||
+ Integer saveVolume = volumeService.saveVolume(volume);
|
||
+ log.info("功能:保存卷");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("响应结果:"+ JSONObject.toJSONString(saveVolume));
|
||
+ return Result.success(saveVolume);
|
||
+ }
|
||
+
|
||
+
|
||
+ /**
|
||
+ * 购买卷
|
||
+ * @param volumeIds
|
||
+ * @return
|
||
+ */
|
||
+ @PostMapping("/purchase")
|
||
+ public Result<List<Volume>> purchase(@RequestBody List<Integer> volumeIds){
|
||
+ log.info("功能:购买卷");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+ JSONObject.toJSONString(volumeIds));
|
||
+ List<Volume> volumeList = volumeService.purchase(volumeIds);
|
||
+ log.info("功能:购买卷");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("响应结果:"+ JSONObject.toJSONString(volumeList));
|
||
+ return Result.success(volumeList);
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 更新卷
|
||
+ * @param volume
|
||
+ */
|
||
+ @PostMapping("/updateVolumeTransfer")
|
||
+ public Result updateVolumeTransfer(@RequestBody Volume volume){
|
||
+ log.info("功能:更新卷");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ log.info("请求参数:"+ JSONObject.toJSONString(volume));
|
||
+ volumeService.updateVolumeTransfer(volume);
|
||
+ log.info("功能:更新卷");
|
||
+ log.info("请求路径:"+httpServletRequest.getRequestURL());
|
||
+ log.info("请求方法:"+httpServletRequest.getMethod());
|
||
+ return Result.success();
|
||
+ }
|
||
+
|
||
+
|
||
+}
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/impl/VolumeServiceImpl.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/impl/VolumeServiceImpl.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/impl/VolumeServiceImpl.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723468191084)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/impl/VolumeServiceImpl.java (date 1723468191084)
|
||
@@ -0,0 +1,152 @@
|
||
+package com.bwie.volume.service.impl;
|
||
+
|
||
+import cn.hutool.core.util.RandomUtil;
|
||
+import com.bwie.common.domain.Consign;
|
||
+import com.bwie.common.domain.Order;
|
||
+import com.bwie.common.domain.Volume;
|
||
+import com.bwie.volume.mapper.VolumeMapper;
|
||
+import com.bwie.volume.remote.OrderRemote;
|
||
+import com.bwie.volume.service.VolumeService;
|
||
+import org.springframework.beans.factory.annotation.Autowired;
|
||
+import org.springframework.data.redis.core.StringRedisTemplate;
|
||
+import org.springframework.stereotype.Service;
|
||
+
|
||
+import javax.annotation.Resource;
|
||
+import java.math.BigDecimal;
|
||
+import java.util.ArrayList;
|
||
+import java.util.Date;
|
||
+import java.util.List;
|
||
+
|
||
+/**
|
||
+ * @Author YuPing
|
||
+ * @Description
|
||
+ * @Version 1.0
|
||
+ * @Data 2024-08-12 11:27:49
|
||
+ */
|
||
+@Service
|
||
+public class VolumeServiceImpl implements VolumeService {
|
||
+
|
||
+ @Resource
|
||
+ private VolumeMapper volumeMapper;
|
||
+
|
||
+ @Autowired
|
||
+ private StringRedisTemplate redisTemplate;
|
||
+
|
||
+ /**
|
||
+ * 查询所有卷
|
||
+ * @return
|
||
+ */
|
||
+ @Override
|
||
+ public List<Volume> queryVolume() {
|
||
+ List<Volume> volumes = volumeMapper.queryVolume();
|
||
+ //使用Stream流进行遍历输出
|
||
+ volumes.stream().forEach(System.out::println);
|
||
+ return volumes;
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 保存卷
|
||
+ * @param volume
|
||
+ * @return
|
||
+ */
|
||
+ @Override
|
||
+ public Integer saveVolume(Volume volume) {
|
||
+ //生成卷码
|
||
+ String string = RandomUtil.randomString(4);
|
||
+ String number = RandomUtil.randomNumbers(4);
|
||
+ volume.setVolumeCode(string + number);
|
||
+ //生成库存
|
||
+ int randomInt = RandomUtil.randomInt(2);
|
||
+ volume.setVolumeInventory(randomInt);
|
||
+ //生成价格
|
||
+ BigDecimal bigDecimal = RandomUtil.randomBigDecimal();
|
||
+ volume.setVolumePrice(bigDecimal);
|
||
+ //默认卷状态是可预约状态
|
||
+ volume.setVolumeFlag("可预约");
|
||
+ Integer saveVolume = volumeMapper.saveVolume(volume);
|
||
+ if (saveVolume < 0){
|
||
+ throw new RuntimeException("保存失败");
|
||
+ }
|
||
+ return saveVolume;
|
||
+ }
|
||
+
|
||
+ /**
|
||
+ * 远程调用
|
||
+ * 订单批量添加
|
||
+ */
|
||
+ @Autowired
|
||
+ private OrderRemote orderRemote;
|
||
+
|
||
+ /**
|
||
+ * 购买卷
|
||
+ * @param volumeIds
|
||
+ * @return
|
||
+ */
|
||
+ @Override
|
||
+ public List<Volume> purchase(List<Integer> volumeIds) {
|
||
+ List<Volume> volumeList = volumeMapper.purchase(volumeIds);
|
||
+ ArrayList<Order> orderArrayList = new ArrayList<>();
|
||
+ //④ 点击购买,会有质保时长,质保时长12小时以内为当前价格0.005%,24小时为0.01%,48小时为0.02%(3分)
|
||
+ //⑤ 选择质保时长,自动计算总价(3分)
|
||
+ for (Volume volume : volumeList) {
|
||
+
|
||
+ List<Order> orderList = orderRemote.queryOrder().getData();
|
||
+ orderList.forEach(order -> {
|
||
+ if (order.getOrderVolumeName().equals(volume.getVolumeName())){
|
||
+ throw new RuntimeException("该卷已被购买,不能重复购买");
|
||
+ }
|
||
+ });
|
||
+
|
||
+ if(volume.getVolumeDuration() <= 12){
|
||
+ volume.setVolumePrice(volume.getVolumePrice().multiply(BigDecimal.valueOf(0.005)));
|
||
+ }else if (volume.getVolumeDuration() <= 24){
|
||
+ volume.setVolumePrice(volume.getVolumePrice().multiply(BigDecimal.valueOf(0.01)));
|
||
+ }else if (volume.getVolumeDuration() <= 48){
|
||
+ volume.setVolumePrice(volume.getVolumePrice().multiply(BigDecimal.valueOf(0.02)));
|
||
+ }
|
||
+
|
||
+ redisTemplate.opsForValue().set("volumeInventory", String.valueOf(volume.getVolumeInventory()));
|
||
+
|
||
+ Order order = new Order();
|
||
+ order.setPersonalAmount(BigDecimal.valueOf(9999.77));
|
||
+ order.setOrderTime(new Date());
|
||
+ order.setOrderNumber(Integer.valueOf(RandomUtil.randomNumbers(8)));
|
||
+ order.setOrderVolumeName(volume.getVolumeName());
|
||
+ order.setOrderPrice(volume.getVolumePrice());
|
||
+ order.setOrderFlag("待使用");
|
||
+ order.setPersonalAmount(order.getPersonalAmount().subtract(volume.getVolumePrice()));
|
||
+ orderArrayList.add(order);
|
||
+ orderRemote.addOrder(orderArrayList);
|
||
+
|
||
+ }
|
||
+
|
||
+ volumeMapper.updateVolumeInventory(volumeIds);
|
||
+
|
||
+
|
||
+ return volumeList;
|
||
+ }
|
||
+
|
||
+ @Autowired
|
||
+ private ConsignServiceImpl consignService;
|
||
+
|
||
+ /**
|
||
+ * 更新卷库存
|
||
+ * @param volume
|
||
+ */
|
||
+ @Override
|
||
+ public void updateVolumeTransfer(Volume volume) {
|
||
+ Consign consign = new Consign();
|
||
+ consign.setConsignOrderName(volume.getVolumeName());
|
||
+ int i = 0;
|
||
+ consign.setConsignNumber(++i);
|
||
+ consign.setPersonalAmount(BigDecimal.valueOf(77.52));
|
||
+ consign.setConsignFlag("寄售中");
|
||
+ consign.setConsignTime(new Date());
|
||
+ if (consign.getConsignFlag().equals("完成")){
|
||
+ consign.setPersonalAmount(consign.getPersonalAmount().subtract(volume.getVolumePrice()));
|
||
+ }
|
||
+ consignService.saveConsign(consign);
|
||
+ redisTemplate.opsForValue().set("consignNumber", String.valueOf(consign.getConsignNumber()));
|
||
+ volumeMapper.updateVolumeTransfer(volume);
|
||
+ }
|
||
+}
|
||
Index: bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/VolumeService.java
|
||
IDEA additional info:
|
||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||
<+>UTF-8
|
||
===================================================================
|
||
diff --git a/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/VolumeService.java b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/VolumeService.java
|
||
new file mode 100644
|
||
--- /dev/null (date 1723465372366)
|
||
+++ b/bwie-module/bwie-volume/src/main/java/com/bwie/volume/service/VolumeService.java (date 1723465372366)
|
||
@@ -0,0 +1,17 @@
|
||
+package com.bwie.volume.service;
|
||
+
|
||
+import com.bwie.common.domain.Consign;
|
||
+import com.bwie.common.domain.Volume;
|
||
+
|
||
+import java.util.List;
|
||
+
|
||
+public interface VolumeService {
|
||
+ //查询所有的卷
|
||
+ List<Volume> queryVolume();
|
||
+ //添加卷
|
||
+ Integer saveVolume(Volume volume);
|
||
+ //购买卷
|
||
+ List<Volume> purchase(List<Integer> volumeIds);
|
||
+ //查看卷码详情
|
||
+ void updateVolumeTransfer(Volume volume);
|
||
+}
|