diff --git a/pom.xml b/pom.xml index 1b0714e..e5da5f8 100644 --- a/pom.xml +++ b/pom.xml @@ -271,6 +271,12 @@ 2.3.28 compile + + org.springframework.boot + spring-boot-devtools + runtime + true + root diff --git a/src/main/java/com/yipin/liuwanr/config/AuthConfig.java b/src/main/java/com/yipin/liuwanr/config/AuthConfig.java new file mode 100644 index 0000000..376825b --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/config/AuthConfig.java @@ -0,0 +1,29 @@ +package com.yipin.liuwanr.config; + +/** + * @description + * @author: Mr.JK + * @create: 2021-06-03 16:24 + **/ + +import com.yipin.liuwanr.filter.AuthInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class AuthConfig implements WebMvcConfigurer { + + @Bean + public AuthInterceptor initAuthInterceptor(){ + return new AuthInterceptor(); + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/**") + .excludePathPatterns("/userInfo/adminLogins/**","/userInfo/loginSchoolClient/**","/userInfo/logins/**","/userInfo/updateLogInNumber/**"); + } + +} \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java b/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java index 0e170fd..9f685ff 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java @@ -1,6 +1,7 @@ package com.yipin.liuwanr.controller; import java.util.HashMap; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; @@ -103,11 +104,20 @@ public class StaffGradeController { Response deleteStaffGrade(@RequestBody StaffGrade staffGrade) { Response resp = new Response(); Integer staffGradeId = staffGrade.getStaffGradeId(); + HashMap ret = new HashMap<>(); + HashMap ret2 = new HashMap<>(); if (staffGradeId==null) { resp.setStatus(300); resp.setErrmessage("Parameter Invalid"); } else { - HashMap ret = staffGradeService.deleteStaffGrade(staffGradeId); + List userIds = staffGradeService.queryUserIdsByGradeId(staffGradeId); + if(userIds.size()>0){ + ret2 = staffGradeService.deleteStaffGrade(userIds); + ret = staffGradeService.deleteStaffGradePs(staffGradeId); + }else{//如果组织架构下面没有员工,则只删除组织架构 + ret = staffGradeService.deleteStaffGradePs(staffGradeId); + } + int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); diff --git a/src/main/java/com/yipin/liuwanr/entity/UserInfo.java b/src/main/java/com/yipin/liuwanr/entity/UserInfo.java index 6949a8c..b1c0922 100644 --- a/src/main/java/com/yipin/liuwanr/entity/UserInfo.java +++ b/src/main/java/com/yipin/liuwanr/entity/UserInfo.java @@ -101,4 +101,7 @@ public class UserInfo { private Integer organizationRelationshipId; //登陆时间 private String dataTime; + + //鉴权token + private String loginToken; } diff --git a/src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java b/src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java new file mode 100644 index 0000000..414a255 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java @@ -0,0 +1,58 @@ +package com.yipin.liuwanr.filter; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.util.StringUtils; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +/** + * @description + * @author: Mr.JK + * @create: 2021-06-03 16:19 + **/ +public class AuthInterceptor implements HandlerInterceptor { + + @Resource + StringRedisTemplate stringRedisTemplate; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + String token = request.getHeader("token"); + if (StringUtils.isEmpty(token)) { + response.getWriter().print("0");//用户未登录,请登录后操作! + return false; + } + + ValueOperations ops = stringRedisTemplate.opsForValue(); + Object loginStatus = ops.get(token); + + + if( Objects.isNull(loginStatus)){ + response.getWriter().print("1");//token错误 + return false; + } + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + + } + +} diff --git a/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java b/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java index 994d92c..cac1643 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java @@ -94,7 +94,7 @@ public interface CourseMapper { //删除课程 @Update({" "}) diff --git a/src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java b/src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java index 6df3a52..b71ef3a 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java @@ -54,7 +54,7 @@ public interface OrderMapper { " and o.cityId = #{cityId} ", " and o.orderType = #{orderType} ", " and o.orderStatus = #{orderStatus} ", - " and o.orderNumber like CONCAT('%',#{searchContent},'%') or c.customerName like CONCAT('%',#{searchContent},'%')", + " and (o.orderNumber like CONCAT('%',#{searchContent},'%') or c.customerName like CONCAT('%',#{searchContent},'%'))", "order by o.orderDate desc", " "}) List queryOrder(Order order); diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java index aaeef71..8cfc09e 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java @@ -2,10 +2,8 @@ package com.yipin.liuwanr.mapper; import java.util.List; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.annotations.Update; +import com.yipin.liuwanr.entity.Student; +import org.apache.ibatis.annotations.*; import com.yipin.liuwanr.entity.Staff; import com.yipin.liuwanr.entity.StaffGrade; @@ -20,9 +18,18 @@ public interface StaffGradeMapper { "SELECT staffGradeId,staffGradeName,staffProfessionalArchitectureId from staff_grade where isdel = 0 and staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}", " "}) List queryStaffGrade(Integer staffProfessionalArchitectureId); - + + @Update({""}) + void deleteStaffGrade(@Param("userIds") List userIds); + + @Update("UPDATE staff_grade SET isdel = 1 where staffGradeId = #{staffGradeId}") - void deleteStaffGrade(Integer staffGradeId); + void deleteStaffGradePs(Integer staffGradeId); @Select({"