11.17超市
parent
1b25455a98
commit
f693b6aa85
|
@ -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,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.bwie.auth;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName AuthApp
|
||||||
|
* @Description 描述
|
||||||
|
* @Author XingHua.Han
|
||||||
|
* @Date 2023/11/17 10:24
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableFeignClients
|
||||||
|
public class AuthApp {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AuthApp.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,10 +6,7 @@ import com.bwie.common.domain.dto.EmpDTO;
|
||||||
import com.bwie.common.domain.response.JwtEmp;
|
import com.bwie.common.domain.response.JwtEmp;
|
||||||
import com.bwie.common.result.Result;
|
import com.bwie.common.result.Result;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName AythController
|
* @ClassName AythController
|
||||||
|
@ -22,16 +19,21 @@ public class AuthController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AuthService authService;
|
private AuthService authService;
|
||||||
@PostMapping("send/code/{phone}")
|
@PostMapping("send/code/{phone}")
|
||||||
public Result sendCode(@PathVariable("phone") String phone){
|
public Result sendCode(@PathVariable String phone){
|
||||||
return authService.sendCode(phone);
|
return authService.sendCode(phone);
|
||||||
}
|
}
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
public Result<JwtEmp> login(@RequestBody EmpDTO empDTO){
|
public Result<JwtEmp> login(@RequestBody EmpDTO empDTO){
|
||||||
return authService.login(empDTO);
|
return authService.login(empDTO);
|
||||||
}
|
}
|
||||||
@PostMapping("info")
|
@GetMapping("info")
|
||||||
public Result info(){
|
public Result info(){
|
||||||
Emp emp = authService.info();
|
Emp emp = authService.info();
|
||||||
return Result.success(emp);
|
return Result.success(emp);
|
||||||
}
|
}
|
||||||
|
@PostMapping("outLog")
|
||||||
|
public Result outLog(){
|
||||||
|
Result result = authService.outLog();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,5 @@ public interface AuthService {
|
||||||
|
|
||||||
Emp info();
|
Emp info();
|
||||||
|
|
||||||
|
Result outLog();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ public class AuthServiceImpl implements AuthService {
|
||||||
if(!redisTemplate.hasKey(empDTO.getPhone())){
|
if(!redisTemplate.hasKey(empDTO.getPhone())){
|
||||||
return Result.error("验证码已过期");
|
return Result.error("验证码已过期");
|
||||||
}
|
}
|
||||||
String code = redisTemplate.opsForValue().get(empDTO);
|
String code = redisTemplate.opsForValue().get(empDTO.getPhone());
|
||||||
if(!code.equals(empDTO.getCoed())){
|
if(!code.equals(empDTO.getCode())){
|
||||||
return Result.error("验证码错误");
|
return Result.error("验证码错误");
|
||||||
}
|
}
|
||||||
if (!em.getEmpPwd().equals(empDTO.getPwd())){
|
if (!em.getEmpPwd().equals(empDTO.getPwd())){
|
||||||
|
@ -81,4 +81,12 @@ public class AuthServiceImpl implements AuthService {
|
||||||
Emp emp = JSONObject.parseObject(s, Emp.class);
|
Emp emp = JSONObject.parseObject(s, Emp.class);
|
||||||
return emp;
|
return emp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result outLog() {
|
||||||
|
String token = httpServletRequest.getHeader(TokenConstants.TOKEN);
|
||||||
|
String userKey = JwtUtils.getUserKey(token);
|
||||||
|
redisTemplate.delete(TokenConstants.LOGIN_TOKEN_KEY+userKey);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,9 @@ public class Emp {
|
||||||
private String empGender;
|
private String empGender;
|
||||||
private String empAddress;
|
private String empAddress;
|
||||||
private Integer empSal;
|
private Integer empSal;
|
||||||
|
|
||||||
|
private Integer managerId;
|
||||||
|
|
||||||
|
private String managerPwd;
|
||||||
|
private Integer managerPowerLevel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,5 @@ import lombok.Data;
|
||||||
public class EmpDTO {
|
public class EmpDTO {
|
||||||
private String phone;
|
private String phone;
|
||||||
private String pwd;
|
private String pwd;
|
||||||
private String coed;
|
private String code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.bwie.common.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName EmpIns
|
||||||
|
* @Description 描述
|
||||||
|
* @Author XingHua.Han
|
||||||
|
* @Date 2023/11/17 14:57
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EmpIns {
|
||||||
|
private Integer empId;
|
||||||
|
private String empName;
|
||||||
|
private String empPwd;
|
||||||
|
private String empTel;
|
||||||
|
private String empIdCard;
|
||||||
|
private Integer empAge;
|
||||||
|
private String empGender;
|
||||||
|
private String empAddress;
|
||||||
|
private Integer empSal;
|
||||||
|
|
||||||
|
private String managerPwd;
|
||||||
|
private Integer managerPowerLevel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.bwie.common.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName EmpUpd
|
||||||
|
* @Description 描述
|
||||||
|
* @Author XingHua.Han
|
||||||
|
* @Date 2023/11/17 14:44
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EmpUpd {
|
||||||
|
private Integer empId;
|
||||||
|
private String empName;
|
||||||
|
private String empTel;
|
||||||
|
private String empIdCard;
|
||||||
|
private Integer empAge;
|
||||||
|
private String empGender;
|
||||||
|
private String empAddress;
|
||||||
|
private Integer empSal;
|
||||||
|
|
||||||
|
private Integer managerPowerLevel;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.bwie.common.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName PageDTO
|
||||||
|
* @Description 描述
|
||||||
|
* @Author XingHua.Han
|
||||||
|
* @Date 2023/11/17 10:34
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PageDTO {
|
||||||
|
private Integer pageNum=1;
|
||||||
|
private Integer pageSize=3;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.bwie.gateway;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName GateWayApp
|
||||||
|
* @Description 描述
|
||||||
|
* @Author XingHua.Han
|
||||||
|
* @Date 2023/11/17 10:25
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
public class GateWayApp {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(GateWayApp.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,74 +1,74 @@
|
||||||
package com.bwie.gateway.filter;
|
//package com.bwie.gateway.filter;
|
||||||
|
//
|
||||||
import cn.hutool.core.date.DateUnit;
|
//import cn.hutool.core.date.DateUnit;
|
||||||
import cn.hutool.core.date.DateUtil;
|
//import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
//import com.alibaba.fastjson.JSON;
|
||||||
import com.bwie.common.constants.TokenConstants;
|
//import com.bwie.common.constants.TokenConstants;
|
||||||
import com.bwie.common.domain.User;
|
//import com.bwie.common.domain.User;
|
||||||
import com.bwie.common.utils.JwtUtils;
|
//import com.bwie.common.utils.JwtUtils;
|
||||||
import com.bwie.common.utils.StringUtils;
|
//import com.bwie.common.utils.StringUtils;
|
||||||
import com.bwie.gateway.config.IgnoreWhiteConfig;
|
//import com.bwie.gateway.config.IgnoreWhiteConfig;
|
||||||
import com.bwie.gateway.utils.GatewayUtils;
|
//import com.bwie.gateway.utils.GatewayUtils;
|
||||||
import jdk.management.resource.ResourceId;
|
//import jdk.management.resource.ResourceId;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
//import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
import org.springframework.core.Ordered;
|
//import org.springframework.core.Ordered;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
//import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
//import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
//import org.springframework.web.server.ServerWebExchange;
|
||||||
import reactor.core.publisher.Mono;
|
//import reactor.core.publisher.Mono;
|
||||||
|
//
|
||||||
import java.util.Date;
|
//import java.util.Date;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.util.concurrent.TimeUnit;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @ClassName AuthFilter
|
// * @ClassName AuthFilter
|
||||||
* @Description
|
// * @Description
|
||||||
* @Author
|
// * @Author
|
||||||
* @Date 2023/11/5 11:40
|
// * @Date 2023/11/5 11:40
|
||||||
*/
|
// */
|
||||||
@Component
|
//@Component
|
||||||
public class AuthFilter implements GlobalFilter, Ordered {
|
//public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IgnoreWhiteConfig ignoreWhiteConfig;
|
// private IgnoreWhiteConfig ignoreWhiteConfig;
|
||||||
@Autowired
|
// @Autowired
|
||||||
private RedisTemplate<String ,String> redisTemplate;
|
// private RedisTemplate<String ,String> redisTemplate;
|
||||||
@Override
|
// @Override
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
// public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||||
List<String> whites = ignoreWhiteConfig.getWhites();
|
// List<String> whites = ignoreWhiteConfig.getWhites();
|
||||||
ServerHttpRequest request = exchange.getRequest();
|
// ServerHttpRequest request = exchange.getRequest();
|
||||||
String path = request.getURI().getPath();
|
// String path = request.getURI().getPath();
|
||||||
if (StringUtils.matches(path,whites)){
|
// if (StringUtils.matches(path,whites)){
|
||||||
return chain.filter(exchange);
|
// return chain.filter(exchange);
|
||||||
}
|
// }
|
||||||
String token = request.getHeaders().getFirst(TokenConstants.TOKEN);
|
// String token = request.getHeaders().getFirst(TokenConstants.TOKEN);
|
||||||
if (StringUtils.isAllBlank(token)){
|
// if (StringUtils.isAllBlank(token)){
|
||||||
return GatewayUtils.errorResponse(exchange,"token不能为空");
|
// return GatewayUtils.errorResponse(exchange,"token不能为空");
|
||||||
}
|
// }
|
||||||
String userKey = "";
|
// String userKey = "";
|
||||||
try {
|
// try {
|
||||||
userKey = JwtUtils.getUserKey(token);
|
// userKey = JwtUtils.getUserKey(token);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
GatewayUtils.errorResponse(exchange,"token不合法");
|
// GatewayUtils.errorResponse(exchange,"token不合法");
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
if (redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY+userKey)){
|
// if (redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY+userKey)){
|
||||||
return GatewayUtils.errorResponse(exchange,"token过期");
|
// return GatewayUtils.errorResponse(exchange,"token过期");
|
||||||
}
|
// }
|
||||||
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
// String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||||
User user = JSON.parseObject(s, User.class);
|
// User user = JSON.parseObject(s, User.class);
|
||||||
long between = DateUtil.between(user.getTime(), new Date(), DateUnit.MINUTE);
|
// long between = DateUtil.between(user.getTime(), new Date(), DateUnit.MINUTE);
|
||||||
if (between<=10){
|
// if (between<=10){
|
||||||
redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY+userKey,30, TimeUnit.MINUTES);
|
// redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY+userKey,30, TimeUnit.MINUTES);
|
||||||
}
|
// }
|
||||||
return chain.filter(exchange);
|
// return chain.filter(exchange);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public int getOrder() {
|
// public int getOrder() {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.bwie.system;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SystemApp
|
||||||
|
* @Description 描述
|
||||||
|
* @Author XingHua.Han
|
||||||
|
* @Date 2023/11/17 10:26
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
public class SystemApp {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(SystemApp.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,16 @@
|
||||||
package com.bwie.system.controller;
|
package com.bwie.system.controller;
|
||||||
|
|
||||||
import com.bwie.common.domain.Emp;
|
import com.bwie.common.domain.Emp;
|
||||||
|
import com.bwie.common.domain.dto.EmpIns;
|
||||||
|
import com.bwie.common.domain.dto.EmpUpd;
|
||||||
|
import com.bwie.common.domain.dto.PageDTO;
|
||||||
|
import com.bwie.common.result.PageResult;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
import com.bwie.system.service.SystemService;
|
import com.bwie.system.service.SystemService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,4 +27,34 @@ public class SystemController {
|
||||||
public Emp findByPhone(@PathVariable String phone){
|
public Emp findByPhone(@PathVariable String phone){
|
||||||
return systemService.findByPhone(phone);
|
return systemService.findByPhone(phone);
|
||||||
}
|
}
|
||||||
|
@PostMapping("empAllShow")
|
||||||
|
public Result<PageResult<Emp>> empAllShow(@RequestBody PageDTO pageDTO){
|
||||||
|
Result result = systemService.empAllShow(pageDTO);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@PostMapping("authentication/{managerPwd}")
|
||||||
|
public Result authentication(@PathVariable String managerPwd){
|
||||||
|
Result result = systemService.authentication(managerPwd);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@PostMapping("deleteEmp/{empId}")
|
||||||
|
public Result deleteEmp(@PathVariable Integer empId){
|
||||||
|
Result result = systemService.deleteEmp(empId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@PostMapping("findByEmpId/{empId}")
|
||||||
|
public Result findByEmpId(@PathVariable Integer empId){
|
||||||
|
Result result = systemService.findByEmpId(empId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@PostMapping("updateEmp")
|
||||||
|
public Result updateEmp(@RequestBody EmpUpd empUpd){
|
||||||
|
Result result = systemService.updateEmp(empUpd);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@PostMapping("insertEmp")
|
||||||
|
public Result insertEmp(@RequestBody EmpIns empIns){
|
||||||
|
Result result = systemService.insertEmp(empIns);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package com.bwie.system.mapper;
|
package com.bwie.system.mapper;
|
||||||
|
|
||||||
import com.bwie.common.domain.Emp;
|
import com.bwie.common.domain.Emp;
|
||||||
|
import com.bwie.common.domain.dto.EmpIns;
|
||||||
|
import com.bwie.common.domain.dto.EmpUpd;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName SystemMapper
|
* @ClassName SystemMapper
|
||||||
* @Description 描述
|
* @Description 描述
|
||||||
|
@ -13,4 +17,20 @@ import org.apache.ibatis.annotations.Param;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SystemMapper {
|
public interface SystemMapper {
|
||||||
Emp findByPhone(@Param("phone") String phone);
|
Emp findByPhone(@Param("phone") String phone);
|
||||||
|
|
||||||
|
List<Emp> empAllShow();
|
||||||
|
|
||||||
|
void deleteEmp(@Param("empId") Integer empId);
|
||||||
|
|
||||||
|
void deleteManager(@Param("empId") Integer empId);
|
||||||
|
|
||||||
|
Emp findByEmpId(Integer empId);
|
||||||
|
|
||||||
|
void updateEmp(EmpUpd empUpd);
|
||||||
|
|
||||||
|
void updateManager(EmpUpd empUpd);
|
||||||
|
|
||||||
|
int insertEmp(EmpIns empIns);
|
||||||
|
|
||||||
|
void insertManager(EmpIns empIns);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package com.bwie.system.service;
|
package com.bwie.system.service;
|
||||||
|
|
||||||
import com.bwie.common.domain.Emp;
|
import com.bwie.common.domain.Emp;
|
||||||
|
import com.bwie.common.domain.dto.EmpIns;
|
||||||
|
import com.bwie.common.domain.dto.EmpUpd;
|
||||||
|
import com.bwie.common.domain.dto.PageDTO;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName SystemService
|
* @ClassName SystemService
|
||||||
|
@ -10,4 +14,17 @@ import com.bwie.common.domain.Emp;
|
||||||
*/
|
*/
|
||||||
public interface SystemService {
|
public interface SystemService {
|
||||||
Emp findByPhone(String phone);
|
Emp findByPhone(String phone);
|
||||||
|
|
||||||
|
|
||||||
|
Result empAllShow(PageDTO pageDTO);
|
||||||
|
|
||||||
|
Result authentication(String managerPwd);
|
||||||
|
|
||||||
|
Result deleteEmp(Integer empId);
|
||||||
|
|
||||||
|
Result findByEmpId(Integer empId);
|
||||||
|
|
||||||
|
Result updateEmp(EmpUpd empUpd);
|
||||||
|
|
||||||
|
Result insertEmp(EmpIns empIns);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,25 @@
|
||||||
package com.bwie.system.service.impl;
|
package com.bwie.system.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bwie.common.constants.TokenConstants;
|
||||||
import com.bwie.common.domain.Emp;
|
import com.bwie.common.domain.Emp;
|
||||||
|
import com.bwie.common.domain.dto.EmpIns;
|
||||||
|
import com.bwie.common.domain.dto.EmpUpd;
|
||||||
|
import com.bwie.common.domain.dto.PageDTO;
|
||||||
|
import com.bwie.common.result.PageResult;
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import com.bwie.common.utils.JwtUtils;
|
||||||
import com.bwie.system.mapper.SystemMapper;
|
import com.bwie.system.mapper.SystemMapper;
|
||||||
import com.bwie.system.service.SystemService;
|
import com.bwie.system.service.SystemService;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName SystemServiceimpl
|
* @ClassName SystemServiceimpl
|
||||||
* @Description 描述
|
* @Description 描述
|
||||||
|
@ -16,8 +30,64 @@ import org.springframework.stereotype.Service;
|
||||||
public class SystemServiceImpl implements SystemService {
|
public class SystemServiceImpl implements SystemService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemMapper systemMapper;
|
private SystemMapper systemMapper;
|
||||||
|
@Autowired
|
||||||
|
private HttpServletRequest httpServletRequest;
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
@Override
|
@Override
|
||||||
public Emp findByPhone(String phone) {
|
public Emp findByPhone(String phone) {
|
||||||
return systemMapper.findByPhone(phone);
|
return systemMapper.findByPhone(phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result empAllShow(PageDTO pageDTO) {
|
||||||
|
PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
|
||||||
|
List<Emp> list = systemMapper.empAllShow();
|
||||||
|
PageInfo<Emp> info = new PageInfo<>(list);
|
||||||
|
return PageResult.toResult(info.getTotal(),list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result authentication(String managerPwd) {
|
||||||
|
String token = httpServletRequest.getHeader(TokenConstants.TOKEN);
|
||||||
|
String userKey = JwtUtils.getUserKey(token);
|
||||||
|
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||||
|
Emp emp = JSONObject.parseObject(s, Emp.class);
|
||||||
|
if (!(emp.getManagerPowerLevel() ==1)){
|
||||||
|
return Result.error("密码错误或无权限");
|
||||||
|
}
|
||||||
|
if(!emp.getManagerPwd().equals(managerPwd)){
|
||||||
|
return Result.error("密码错误或无权限");
|
||||||
|
}
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result deleteEmp(Integer empId) {
|
||||||
|
systemMapper.deleteEmp(empId);
|
||||||
|
systemMapper.deleteManager(empId);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result findByEmpId(Integer empId) {
|
||||||
|
Emp emp = systemMapper.findByEmpId(empId);
|
||||||
|
return Result.success(emp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result updateEmp(EmpUpd empUpd) {
|
||||||
|
systemMapper.updateEmp(empUpd);
|
||||||
|
systemMapper.updateManager(empUpd);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result insertEmp(EmpIns empIns) {
|
||||||
|
systemMapper.insertEmp(empIns);
|
||||||
|
systemMapper.insertManager(empIns);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,60 @@
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<!--
|
<!--
|
||||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||||
-->
|
-->
|
||||||
<mapper namespace="com.bwie.system.mapper.SystemMapper">
|
<mapper namespace="com.bwie.system.mapper.SystemMapper">
|
||||||
|
<insert id="insertEmp" useGeneratedKeys="true" keyProperty="empId">
|
||||||
|
INSERT INTO `zhuangao5`.`t_emp`
|
||||||
|
( `emp_name`, `emp_pwd`, `emp_tel`, `emp_id_card`, `emp_age`, `emp_gender`, `emp_address`, `emp_sal`) VALUES
|
||||||
|
( #{empName}, #{empPwd}, #{empTel}, #{empIdCard}, #{empAge}, #{empGender}, #{empAddress}, #{empSal})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertManager">
|
||||||
|
insert into t_manager
|
||||||
|
(manager_pwd,
|
||||||
|
manager_power_level,
|
||||||
|
emp_id)
|
||||||
|
values
|
||||||
|
(#{managerPwd},
|
||||||
|
#{managerPowerLevel},
|
||||||
|
#{empId})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<update id="updateEmp">
|
||||||
|
update t_emp set
|
||||||
|
emp_name = #{empName},
|
||||||
|
emp_tel = #{empTel},
|
||||||
|
emp_gender = #{empGender},
|
||||||
|
emp_address = #{empAddress},
|
||||||
|
emp_sal = #{empSal},
|
||||||
|
emp_id_card = #{empIdCard},
|
||||||
|
emp_age = #{empAge} where emp_id = #{empId}
|
||||||
|
</update>
|
||||||
|
<update id="updateManager">
|
||||||
|
update t_manager set
|
||||||
|
manager_power_level = #{managerPowerLevel} where manager_id = #{empId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
<delete id="deleteEmp">
|
||||||
|
delete from t_emp where emp_id = #{empId}
|
||||||
|
</delete>
|
||||||
|
<delete id="deleteManager">
|
||||||
|
delete from t_manager where emp_id = #{empId}
|
||||||
|
</delete>
|
||||||
<!-- 添加 -->
|
<!-- 添加 -->
|
||||||
|
|
||||||
|
|
||||||
<select id="findByPhone" resultType="com.bwie.common.domain.Emp">
|
<select id="findByPhone" resultType="com.bwie.common.domain.Emp">
|
||||||
select * from emp where emp_tel = #{phone}
|
select * from t_manager m left join t_emp e on m.emp_id = e.emp_id where e.emp_tel = #{phone}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
<select id="empAllShow" resultType="com.bwie.common.domain.Emp">
|
||||||
|
select * from t_manager m left join t_emp e on m.emp_id = e.emp_id
|
||||||
|
</select>
|
||||||
|
<select id="findByEmpId" resultType="com.bwie.common.domain.Emp">
|
||||||
|
select * from t_manager m left join t_emp e on m.emp_id = e.emp_id where e.emp_id = #{empId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue