From f693b6aa8574f36d9337f788dc0873e7240dfd95 Mon Sep 17 00:00:00 2001
From: hanmou <1341644251@qq.com>
Date: Fri, 17 Nov 2023 16:47:42 +0800
Subject: [PATCH] =?UTF-8?q?11.17=E8=B6=85=E5=B8=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/uiDesigner.xml | 124 +++++++++++++++
.idea/vcs.xml | 6 +
.../src/main/java/com/bwie/auth/AuthApp.java | 19 +++
.../bwie/auth/controller/AuthController.java | 14 +-
.../com/bwie/auth/service/AuthService.java | 1 +
.../auth/service/impl/AuthServiceImpl.java | 12 +-
.../main/java/com/bwie/common/domain/Emp.java | 5 +
.../com/bwie/common/domain/dto/EmpDTO.java | 2 +-
.../com/bwie/common/domain/dto/EmpIns.java | 31 ++++
.../com/bwie/common/domain/dto/EmpUpd.java | 23 +++
.../com/bwie/common/domain/dto/PageDTO.java | 16 ++
.../java/com/bwie/gateway/GateWayApp.java | 17 ++
.../com/bwie/gateway/filter/AuthFilter.java | 148 +++++++++---------
.../main/java/com/bwie/system/SystemApp.java | 17 ++
.../system/controller/SystemController.java | 36 +++++
.../com/bwie/system/mapper/SystemMapper.java | 20 +++
.../bwie/system/service/SystemService.java | 17 ++
.../service/impl/SystemServiceImpl.java | 70 +++++++++
.../main/resources/mapper/SystemMapper.xml | 51 +++++-
19 files changed, 543 insertions(+), 86 deletions(-)
create mode 100644 .idea/uiDesigner.xml
create mode 100644 .idea/vcs.xml
create mode 100644 bwie-auth/src/main/java/com/bwie/auth/AuthApp.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/dto/EmpIns.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/dto/EmpUpd.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/dto/PageDTO.java
create mode 100644 bwie-gateway/src/main/java/com/bwie/gateway/GateWayApp.java
create mode 100644 bwie-models/bwie-system/src/main/java/com/bwie/system/SystemApp.java
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java b/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java
new file mode 100644
index 0000000..a64eb24
--- /dev/null
+++ b/bwie-auth/src/main/java/com/bwie/auth/AuthApp.java
@@ -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);
+ }
+}
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
index d292e67..8e75cbb 100644
--- a/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java
+++ b/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java
@@ -6,10 +6,7 @@ import com.bwie.common.domain.dto.EmpDTO;
import com.bwie.common.domain.response.JwtEmp;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
-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.*;
/**
* @ClassName AythController
@@ -22,16 +19,21 @@ public class AuthController {
@Autowired
private AuthService authService;
@PostMapping("send/code/{phone}")
- public Result sendCode(@PathVariable("phone") String phone){
+ public Result sendCode(@PathVariable String phone){
return authService.sendCode(phone);
}
@PostMapping("login")
public Result login(@RequestBody EmpDTO empDTO){
return authService.login(empDTO);
}
- @PostMapping("info")
+ @GetMapping("info")
public Result info(){
Emp emp = authService.info();
return Result.success(emp);
}
+ @PostMapping("outLog")
+ public Result outLog(){
+ Result result = authService.outLog();
+ return result;
+ }
}
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
index f4d9193..2423da8 100644
--- a/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java
+++ b/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java
@@ -18,4 +18,5 @@ public interface AuthService {
Emp info();
+ Result outLog();
}
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
index bd2609e..529f7db 100644
--- 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
@@ -55,8 +55,8 @@ public class AuthServiceImpl implements AuthService {
if(!redisTemplate.hasKey(empDTO.getPhone())){
return Result.error("验证码已过期");
}
- String code = redisTemplate.opsForValue().get(empDTO);
- if(!code.equals(empDTO.getCoed())){
+ String code = redisTemplate.opsForValue().get(empDTO.getPhone());
+ if(!code.equals(empDTO.getCode())){
return Result.error("验证码错误");
}
if (!em.getEmpPwd().equals(empDTO.getPwd())){
@@ -81,4 +81,12 @@ public class AuthServiceImpl implements AuthService {
Emp emp = JSONObject.parseObject(s, Emp.class);
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();
+ }
}
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/Emp.java b/bwie-common/src/main/java/com/bwie/common/domain/Emp.java
index ea4489a..6b72495 100644
--- a/bwie-common/src/main/java/com/bwie/common/domain/Emp.java
+++ b/bwie-common/src/main/java/com/bwie/common/domain/Emp.java
@@ -19,4 +19,9 @@ public class Emp {
private String empGender;
private String empAddress;
private Integer empSal;
+
+ private Integer managerId;
+
+ private String managerPwd;
+ private Integer managerPowerLevel;
}
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpDTO.java b/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpDTO.java
index 6e21929..560f984 100644
--- a/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpDTO.java
+++ b/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpDTO.java
@@ -12,5 +12,5 @@ import lombok.Data;
public class EmpDTO {
private String phone;
private String pwd;
- private String coed;
+ private String code;
}
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpIns.java b/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpIns.java
new file mode 100644
index 0000000..97322b0
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpIns.java
@@ -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;
+
+
+
+
+
+
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpUpd.java b/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpUpd.java
new file mode 100644
index 0000000..50433ee
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/domain/dto/EmpUpd.java
@@ -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;
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/dto/PageDTO.java b/bwie-common/src/main/java/com/bwie/common/domain/dto/PageDTO.java
new file mode 100644
index 0000000..411b3bc
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/domain/dto/PageDTO.java
@@ -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;
+
+}
diff --git a/bwie-gateway/src/main/java/com/bwie/gateway/GateWayApp.java b/bwie-gateway/src/main/java/com/bwie/gateway/GateWayApp.java
new file mode 100644
index 0000000..6d6b391
--- /dev/null
+++ b/bwie-gateway/src/main/java/com/bwie/gateway/GateWayApp.java
@@ -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);
+ }
+}
diff --git a/bwie-gateway/src/main/java/com/bwie/gateway/filter/AuthFilter.java b/bwie-gateway/src/main/java/com/bwie/gateway/filter/AuthFilter.java
index c3a4835..731a0f7 100644
--- a/bwie-gateway/src/main/java/com/bwie/gateway/filter/AuthFilter.java
+++ b/bwie-gateway/src/main/java/com/bwie/gateway/filter/AuthFilter.java
@@ -1,74 +1,74 @@
-package com.bwie.gateway.filter;
-
-import cn.hutool.core.date.DateUnit;
-import cn.hutool.core.date.DateUtil;
-import com.alibaba.fastjson.JSON;
-import com.bwie.common.constants.TokenConstants;
-import com.bwie.common.domain.User;
-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 jdk.management.resource.ResourceId;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.gateway.filter.GatewayFilterChain;
-import org.springframework.cloud.gateway.filter.GlobalFilter;
-import org.springframework.core.Ordered;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.http.server.reactive.ServerHttpRequest;
-import org.springframework.stereotype.Component;
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
-
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @ClassName AuthFilter
- * @Description
- * @Author
- * @Date 2023/11/5 11:40
- */
-@Component
-public class AuthFilter implements GlobalFilter, Ordered {
- @Autowired
- private IgnoreWhiteConfig ignoreWhiteConfig;
- @Autowired
- private RedisTemplate redisTemplate;
- @Override
- public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
- List whites = ignoreWhiteConfig.getWhites();
- ServerHttpRequest request = exchange.getRequest();
- String path = request.getURI().getPath();
- if (StringUtils.matches(path,whites)){
- return chain.filter(exchange);
- }
- String token = request.getHeaders().getFirst(TokenConstants.TOKEN);
- if (StringUtils.isAllBlank(token)){
- return GatewayUtils.errorResponse(exchange,"token不能为空");
- }
- String userKey = "";
- try {
- userKey = JwtUtils.getUserKey(token);
- } catch (Exception e) {
- GatewayUtils.errorResponse(exchange,"token不合法");
- e.printStackTrace();
- }
- if (redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY+userKey)){
- return GatewayUtils.errorResponse(exchange,"token过期");
- }
- String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
- User user = JSON.parseObject(s, User.class);
- long between = DateUtil.between(user.getTime(), new Date(), DateUnit.MINUTE);
- if (between<=10){
- redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY+userKey,30, TimeUnit.MINUTES);
- }
- return chain.filter(exchange);
- }
-
- @Override
- public int getOrder() {
- return 0;
- }
-}
+//package com.bwie.gateway.filter;
+//
+//import cn.hutool.core.date.DateUnit;
+//import cn.hutool.core.date.DateUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.bwie.common.constants.TokenConstants;
+//import com.bwie.common.domain.User;
+//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 jdk.management.resource.ResourceId;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
+//import org.springframework.cloud.gateway.filter.GlobalFilter;
+//import org.springframework.core.Ordered;
+//import org.springframework.data.redis.core.RedisTemplate;
+//import org.springframework.http.server.reactive.ServerHttpRequest;
+//import org.springframework.stereotype.Component;
+//import org.springframework.web.server.ServerWebExchange;
+//import reactor.core.publisher.Mono;
+//
+//import java.util.Date;
+//import java.util.List;
+//import java.util.concurrent.TimeUnit;
+//
+///**
+// * @ClassName AuthFilter
+// * @Description
+// * @Author
+// * @Date 2023/11/5 11:40
+// */
+//@Component
+//public class AuthFilter implements GlobalFilter, Ordered {
+// @Autowired
+// private IgnoreWhiteConfig ignoreWhiteConfig;
+// @Autowired
+// private RedisTemplate redisTemplate;
+// @Override
+// public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
+// List whites = ignoreWhiteConfig.getWhites();
+// ServerHttpRequest request = exchange.getRequest();
+// String path = request.getURI().getPath();
+// if (StringUtils.matches(path,whites)){
+// return chain.filter(exchange);
+// }
+// String token = request.getHeaders().getFirst(TokenConstants.TOKEN);
+// if (StringUtils.isAllBlank(token)){
+// return GatewayUtils.errorResponse(exchange,"token不能为空");
+// }
+// String userKey = "";
+// try {
+// userKey = JwtUtils.getUserKey(token);
+// } catch (Exception e) {
+// GatewayUtils.errorResponse(exchange,"token不合法");
+// e.printStackTrace();
+// }
+// if (redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY+userKey)){
+// return GatewayUtils.errorResponse(exchange,"token过期");
+// }
+// String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
+// User user = JSON.parseObject(s, User.class);
+// long between = DateUtil.between(user.getTime(), new Date(), DateUnit.MINUTE);
+// if (between<=10){
+// redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY+userKey,30, TimeUnit.MINUTES);
+// }
+// return chain.filter(exchange);
+// }
+//
+// @Override
+// public int getOrder() {
+// return 0;
+// }
+//}
diff --git a/bwie-models/bwie-system/src/main/java/com/bwie/system/SystemApp.java b/bwie-models/bwie-system/src/main/java/com/bwie/system/SystemApp.java
new file mode 100644
index 0000000..93227d2
--- /dev/null
+++ b/bwie-models/bwie-system/src/main/java/com/bwie/system/SystemApp.java
@@ -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);
+ }
+}
diff --git a/bwie-models/bwie-system/src/main/java/com/bwie/system/controller/SystemController.java b/bwie-models/bwie-system/src/main/java/com/bwie/system/controller/SystemController.java
index 417bc3e..c239526 100644
--- a/bwie-models/bwie-system/src/main/java/com/bwie/system/controller/SystemController.java
+++ b/bwie-models/bwie-system/src/main/java/com/bwie/system/controller/SystemController.java
@@ -1,10 +1,16 @@
package com.bwie.system.controller;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -21,4 +27,34 @@ public class SystemController {
public Emp findByPhone(@PathVariable String phone){
return systemService.findByPhone(phone);
}
+ @PostMapping("empAllShow")
+ public Result> 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;
+ }
}
diff --git a/bwie-models/bwie-system/src/main/java/com/bwie/system/mapper/SystemMapper.java b/bwie-models/bwie-system/src/main/java/com/bwie/system/mapper/SystemMapper.java
index 2f0b072..fe6379c 100644
--- a/bwie-models/bwie-system/src/main/java/com/bwie/system/mapper/SystemMapper.java
+++ b/bwie-models/bwie-system/src/main/java/com/bwie/system/mapper/SystemMapper.java
@@ -1,9 +1,13 @@
package com.bwie.system.mapper;
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.Param;
+import java.util.List;
+
/**
* @ClassName SystemMapper
* @Description 描述
@@ -13,4 +17,20 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface SystemMapper {
Emp findByPhone(@Param("phone") String phone);
+
+ List 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);
}
diff --git a/bwie-models/bwie-system/src/main/java/com/bwie/system/service/SystemService.java b/bwie-models/bwie-system/src/main/java/com/bwie/system/service/SystemService.java
index 1e78cd4..0fe4687 100644
--- a/bwie-models/bwie-system/src/main/java/com/bwie/system/service/SystemService.java
+++ b/bwie-models/bwie-system/src/main/java/com/bwie/system/service/SystemService.java
@@ -1,6 +1,10 @@
package com.bwie.system.service;
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
@@ -10,4 +14,17 @@ import com.bwie.common.domain.Emp;
*/
public interface SystemService {
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);
}
diff --git a/bwie-models/bwie-system/src/main/java/com/bwie/system/service/impl/SystemServiceImpl.java b/bwie-models/bwie-system/src/main/java/com/bwie/system/service/impl/SystemServiceImpl.java
index 24f6862..038b2de 100644
--- a/bwie-models/bwie-system/src/main/java/com/bwie/system/service/impl/SystemServiceImpl.java
+++ b/bwie-models/bwie-system/src/main/java/com/bwie/system/service/impl/SystemServiceImpl.java
@@ -1,11 +1,25 @@
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.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.service.SystemService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
/**
* @ClassName SystemServiceimpl
* @Description 描述
@@ -16,8 +30,64 @@ import org.springframework.stereotype.Service;
public class SystemServiceImpl implements SystemService {
@Autowired
private SystemMapper systemMapper;
+ @Autowired
+ private HttpServletRequest httpServletRequest;
+ @Autowired
+ private RedisTemplate redisTemplate;
@Override
public Emp findByPhone(String phone) {
return systemMapper.findByPhone(phone);
}
+
+ @Override
+ public Result empAllShow(PageDTO pageDTO) {
+ PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
+ List list = systemMapper.empAllShow();
+ PageInfo 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();
+ }
+
+
}
diff --git a/bwie-models/bwie-system/src/main/resources/mapper/SystemMapper.xml b/bwie-models/bwie-system/src/main/resources/mapper/SystemMapper.xml
index cc7d918..d57e899 100644
--- a/bwie-models/bwie-system/src/main/resources/mapper/SystemMapper.xml
+++ b/bwie-models/bwie-system/src/main/resources/mapper/SystemMapper.xml
@@ -2,15 +2,60 @@
-
+
+ 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 into t_manager
+ (manager_pwd,
+ manager_power_level,
+ emp_id)
+ values
+ (#{managerPwd},
+ #{managerPowerLevel},
+ #{empId})
+
+
+
+
+ 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 t_manager set
+ manager_power_level = #{managerPowerLevel} where manager_id = #{empId}
+
+
+
+
+ delete from t_emp where emp_id = #{empId}
+
+
+ delete from t_manager where emp_id = #{empId}
+
-
\ No newline at end of file
+
+
+