周考2
parent
5aef7628cf
commit
fddf52d2e6
|
@ -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>
|
|
@ -0,0 +1,20 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie
|
||||
* @Datetime: 2023/12/21 9:48
|
||||
* @Filename: AuthApplication
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class AuthApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.bwie.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.domain.request.UserLogin;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.service.AuthService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.controller
|
||||
* @Datetime: 2023/12/21 9:28
|
||||
* @Filename: AuthController
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
public class AuthController {
|
||||
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@PostMapping("/login")
|
||||
public Result login(@RequestBody UserLogin userlogin){
|
||||
log.info("功能名称:手机号密码登录,请求URI:{},请求方式:{},请求参数:{}",
|
||||
request.getRequestURI(),request.getMethod(),userlogin);
|
||||
Result result = authService.login(userlogin);
|
||||
log.info("功能名称:手机号密码登录,请求URI:{},请求方式:{},响应结果:{}",
|
||||
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.bwie.feign;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserLogin;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.feign
|
||||
* @Datetime: 2023/12/21 9:29
|
||||
* @Filename: AuthFeign
|
||||
*/
|
||||
@FeignClient("bwie-user")
|
||||
public interface AuthFeign {
|
||||
|
||||
@PostMapping("/findPhone")
|
||||
public Result<User> findPhone(@RequestBody UserLogin userlogin);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.service;
|
||||
|
||||
import com.bwie.common.domain.request.UserLogin;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.service
|
||||
* @Datetime: 2023/12/21 9:29
|
||||
* @Filename: AuthService
|
||||
*/
|
||||
|
||||
public interface AuthService {
|
||||
Result login(UserLogin userlogin);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.bwie.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bwie.common.constants.JwtConstants;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserLogin;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.common.utils.JwtUtils;
|
||||
import com.bwie.feign.AuthFeign;
|
||||
import com.bwie.service.AuthService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.service.impl
|
||||
* @Datetime: 2023/12/21 9:29
|
||||
* @Filename: AuthServiceImpl
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class AuthServiceImpl implements AuthService {
|
||||
|
||||
@Autowired
|
||||
private AuthFeign authFeign;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,Object> redisTemplate;
|
||||
|
||||
@Override
|
||||
public Result login(UserLogin userlogin) {
|
||||
String phone = userlogin.getPhone();
|
||||
Result<User> result = authFeign.findPhone(userlogin);
|
||||
//调用服务失败,服务熔断
|
||||
// if(result.getCode()== Constants.ERROR){
|
||||
// throw new AuthException(result.getMsg());
|
||||
// }
|
||||
//验证手机号是否存在
|
||||
User user = result.getData();
|
||||
|
||||
if(user==null){
|
||||
Result.error("手机号不存在");
|
||||
}
|
||||
//密码
|
||||
if(!user.getUserPwd().equals(userlogin.getPwd())){
|
||||
Result.error("密码有误");
|
||||
}
|
||||
//生成token
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
map.put(JwtConstants.USER_PHONE, JSON.toJSONString(user.getPhone()));
|
||||
|
||||
String token = JwtUtils.createToken(map);
|
||||
//赋值
|
||||
user.setToken(token);
|
||||
//缓存 30 min
|
||||
redisTemplate.opsForValue().set(JwtConstants.LOGIN_TOKEN+token,JSON.toJSONString(user),30, TimeUnit.MINUTES);
|
||||
return Result.success(user,"登录成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.common.domain
|
||||
* @Datetime: 2023/12/21 12:40
|
||||
* @Filename: Ding
|
||||
*/
|
||||
@Data
|
||||
public class Ding {
|
||||
private Integer dingId;
|
||||
private Integer productId;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date dingTime;
|
||||
private Integer dingType;
|
||||
private String productName;
|
||||
private Integer productPrice;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.common.domain
|
||||
* @Datetime: 2023/12/21 11:49
|
||||
* @Filename: Product
|
||||
*/
|
||||
@Data
|
||||
public class Product {
|
||||
|
||||
private Integer productId;
|
||||
private String productName;
|
||||
private Integer typeId;
|
||||
private String typeName;
|
||||
private Integer productPrice;
|
||||
private Integer productNum;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.common.domain
|
||||
* @Datetime: 2023/12/21 12:09
|
||||
* @Filename: Type
|
||||
*/
|
||||
@Data
|
||||
public class Type {
|
||||
|
||||
private Integer typeId;
|
||||
private String typeName;
|
||||
private Integer pid;
|
||||
|
||||
private List<Type> Client;
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.bwie.common.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.common.domain.request
|
||||
* @Datetime: 2023/12/21 11:50
|
||||
* @Filename: ProductRequest
|
||||
*/
|
||||
@Data
|
||||
public class ProductRequest {
|
||||
//根据商品名称和商品分类进行查询,商品名称支持模糊查询
|
||||
|
||||
|
||||
private String productName;
|
||||
|
||||
private Integer typeId;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.bwie.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.gateway
|
||||
* @Datetime: 2023/12/21 10:29
|
||||
* @Filename: GatewayApplication
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class GatewayApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GatewayApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.bwie.gateway.filters;
|
||||
|
||||
import com.bwie.common.constants.JwtConstants;
|
||||
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 io.jsonwebtoken.Claims;
|
||||
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;
|
||||
|
||||
@Component
|
||||
public class AuthFilter implements GlobalFilter, Ordered {
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private IgnoreWhiteConfig ignoreWhiteConfig;
|
||||
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
//获取白名单
|
||||
List<String> whites = ignoreWhiteConfig.getWhites();
|
||||
|
||||
//获取用户请求路径
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
String path = request.getURI().getPath();
|
||||
System.out.println("路径>>>>>>"+path);
|
||||
|
||||
//放行
|
||||
if (StringUtils.matches(path,whites)){
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
//获取token
|
||||
String token = request.getHeaders().getFirst("token");
|
||||
if(token==null){
|
||||
return GatewayUtils.errorResponse(exchange,"必须携带token");
|
||||
}
|
||||
|
||||
//token合法性
|
||||
Claims claims = null;
|
||||
try {
|
||||
claims = JwtUtils.parseToken(token);
|
||||
} catch (Exception e) {
|
||||
return GatewayUtils.errorResponse(exchange,"token不合法");
|
||||
}
|
||||
|
||||
//时效性
|
||||
if(!redisTemplate.hasKey(JwtConstants.LOGIN_TOKEN+token)){
|
||||
return GatewayUtils.errorResponse(exchange,"token过期");
|
||||
}
|
||||
|
||||
|
||||
Long expire = redisTemplate.getExpire(JwtConstants.LOGIN_TOKEN+token);
|
||||
// if(expire<jwt原定过期时间的一半){
|
||||
// redisTemplate.expire("token:"+userId, 60, TimeUnit.SECONDS);
|
||||
// }
|
||||
//自动续期 15分钟
|
||||
redisTemplate.expire(JwtConstants.LOGIN_TOKEN+token,15, TimeUnit.MINUTES);
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
# 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: 124.223.114.120:8848
|
||||
namespace: ea6d16de-21aa-4c9e-81af-0d5836cdc10c
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 124.223.114.120:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: ea6d16de-21aa-4c9e-81af-0d5836cdc10c
|
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.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
|
|
@ -0,0 +1,49 @@
|
|||
<?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-modules</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-product</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- 系统公共 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot Web-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- Druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</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>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie
|
||||
* @Datetime: 2023/12/21 9:48
|
||||
* @Filename: UserApplication
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class ProductApplication {
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(ProductApplication.class);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.bwie.controller;
|
||||
|
||||
import com.bwie.common.domain.Ding;
|
||||
import com.bwie.common.domain.request.ProductRequest;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.service.ProductService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.controller
|
||||
* @Datetime: 2023/12/21 11:47
|
||||
* @Filename: ProductController
|
||||
*/
|
||||
@RestController
|
||||
public class ProductController {
|
||||
|
||||
@Autowired
|
||||
private ProductService productService;
|
||||
|
||||
@PostMapping("/list")
|
||||
public Result list(@RequestBody ProductRequest productRequest){
|
||||
|
||||
Result result = productService.list(productRequest);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
@GetMapping("/dingAll")
|
||||
public Result dingAll(){
|
||||
|
||||
Result result = productService.dingAll();
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/dingAdd")
|
||||
public Result dingAdd(@RequestBody Ding[] dings){
|
||||
Ding ding =null;
|
||||
|
||||
for (Ding ding1 : dings) {
|
||||
ding=ding1;
|
||||
}
|
||||
|
||||
Result result = productService.dingAdd(ding);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.bwie.mapper;
|
||||
|
||||
import com.bwie.common.domain.Ding;
|
||||
import com.bwie.common.domain.Product;
|
||||
import com.bwie.common.domain.Type;
|
||||
import com.bwie.common.domain.request.ProductRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.mapper
|
||||
* @Datetime: 2023/12/21 11:48
|
||||
* @Filename: ProductMapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductMapper {
|
||||
List<Product> list(ProductRequest productRequest);
|
||||
|
||||
List<Type> typeAll();
|
||||
|
||||
|
||||
List<Ding> dingAll();
|
||||
|
||||
|
||||
int add(Ding ding);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.bwie.service;
|
||||
|
||||
import com.bwie.common.domain.Ding;
|
||||
import com.bwie.common.domain.request.ProductRequest;
|
||||
import com.bwie.common.result.Result;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.service
|
||||
* @Datetime: 2023/12/21 11:47
|
||||
* @Filename: ProductService
|
||||
*/
|
||||
|
||||
public interface ProductService {
|
||||
Result list(ProductRequest productRequest);
|
||||
|
||||
Result dingAll();
|
||||
|
||||
|
||||
Result dingAdd(Ding ding);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.bwie.service.impl;
|
||||
|
||||
import com.bwie.common.domain.Ding;
|
||||
import com.bwie.common.domain.Product;
|
||||
import com.bwie.common.domain.Type;
|
||||
import com.bwie.common.domain.request.ProductRequest;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.mapper.ProductMapper;
|
||||
import com.bwie.service.ProductService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.service.impl
|
||||
* @Datetime: 2023/12/21 11:48
|
||||
* @Filename: ProductServiceImpl
|
||||
*/
|
||||
@Service
|
||||
public class ProductServiceImpl implements ProductService {
|
||||
|
||||
@Autowired
|
||||
private ProductMapper productMapper;
|
||||
|
||||
@Override
|
||||
public Result list(ProductRequest productRequest) {
|
||||
|
||||
List<Product> list = productMapper.list(productRequest);
|
||||
|
||||
return Result.success(list,"获取列表成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result dingAll() {
|
||||
|
||||
List<Ding> list = productMapper.dingAll();
|
||||
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result dingAdd(Ding ding) {
|
||||
int add = productMapper.add(ding);
|
||||
|
||||
return Result.success("提交成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9003
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-product
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 124.223.114.120:8848
|
||||
namespace: ea6d16de-21aa-4c9e-81af-0d5836cdc10c
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 124.223.114.120:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: ea6d16de-21aa-4c9e-81af-0d5836cdc10c
|
||||
fdfs:
|
||||
so-timeout: 1500 # socket 连接时长
|
||||
connect-timeout: 600 # 连接 tracker 服务器超时时长
|
||||
# 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
|
||||
tracker-list: 124.223.114.120:22122
|
||||
web-server-url: 124.223.114.120:8888
|
||||
pool:
|
||||
jmx-enabled: false
|
||||
# 生成缩略图
|
||||
thumb-image:
|
||||
height: 500
|
||||
width: 500
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bwie.mapper.ProductMapper">
|
||||
<insert id="add">
|
||||
INSERT INTO `demo5`.`ding` (`product_id`, `ding_time`)
|
||||
VALUES (#{productId}, now())
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="list" resultType="com.bwie.common.domain.Product">
|
||||
select p.*,ty.type_name from product p left join type ty on p.type_id = ty.type_id
|
||||
<where>
|
||||
<if test="productName != null and productName!=''">
|
||||
and p.product_name like concat('%',#{productName},'%')
|
||||
</if>
|
||||
<if test="typeId != null and typeId!=''">
|
||||
and ty.type_id = #{typeId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="typeAll" resultType="com.bwie.common.domain.Type">
|
||||
select * from type
|
||||
</select>
|
||||
<select id="dingAll" resultType="com.bwie.common.domain.Ding">
|
||||
select d.*,p.product_name,p.product_price from ding d left join product p on d.product_id=p.product_id
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie
|
||||
* @Datetime: 2023/12/21 9:48
|
||||
* @Filename: UserApplication
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class UserApplication {
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(UserApplication.class);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.bwie.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserLogin;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.service.UserService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.controller
|
||||
* @Datetime: 2023/12/21 9:43
|
||||
* @Filename: UserController
|
||||
*/
|
||||
@RestController
|
||||
@Log4j2
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
|
||||
@PostMapping("/findPhone")
|
||||
public Result<User> findPhone(@RequestBody UserLogin userlogin){
|
||||
|
||||
User user = userService.findPhone(userlogin);
|
||||
Result<User> result = Result.success(user);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.bwie.mapper;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserLogin;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.mapper
|
||||
* @Datetime: 2023/12/21 9:44
|
||||
* @Filename: UserMapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
|
||||
User findPhone(UserLogin userlogin);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.service;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserLogin;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.service
|
||||
* @Datetime: 2023/12/21 11:13
|
||||
* @Filename: UserService
|
||||
*/
|
||||
|
||||
public interface UserService {
|
||||
User findPhone(UserLogin userlogin);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.bwie.service.impl;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserLogin;
|
||||
import com.bwie.mapper.UserMapper;
|
||||
import com.bwie.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: zhx
|
||||
* @Package: com.bwie.service.impl
|
||||
* @Datetime: 2023/12/21 11:13
|
||||
* @Filename: UserServiceImpl
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
@Override
|
||||
public User findPhone(UserLogin userlogin) {
|
||||
return userMapper.findPhone(userlogin);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bwie.mapper.UserMapper">
|
||||
|
||||
|
||||
<select id="findPhone" resultType="com.bwie.common.domain.User">
|
||||
select * from user where phone = #{phone}
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue