hlf 1 год назад
Родитель
Сommit
07cb8a6bda
21 измененных файлов с 255 добавлено и 297 удалено
  1. 0 3
      build.gradle.kts
  2. 11 4
      src/main/java/com/gyee/table/controller/ComponentInformationController.java
  3. 6 3
      src/main/java/com/gyee/table/controller/LoginController.java
  4. 5 1
      src/main/java/com/gyee/table/controller/SysUserController.java
  5. 1 0
      src/main/java/com/gyee/table/controller/TerminalController.java
  6. 1 1
      src/main/java/com/gyee/table/entity/Configurationinfo.java
  7. 17 0
      src/main/java/com/gyee/table/jwt/annotation/PassToken.java
  8. 17 0
      src/main/java/com/gyee/table/jwt/annotation/UserLoginToken.java
  9. 0 19
      src/main/java/com/gyee/table/jwt/auth/AllowAllCredentialsMatcher.java
  10. 0 45
      src/main/java/com/gyee/table/jwt/auth/JwtToken.java
  11. 36 0
      src/main/java/com/gyee/table/jwt/config/InterceptorConfig.java
  12. 0 136
      src/main/java/com/gyee/table/jwt/filter/JwtFilter.java
  13. 91 0
      src/main/java/com/gyee/table/jwt/interceptor/AuthenticationInterceptor.java
  14. 12 25
      src/main/java/com/gyee/table/jwt/utils/JwtUtils.java
  15. 2 2
      src/main/java/com/gyee/table/alarm/JpaElectricalTestingPointAIDao.java
  16. 2 2
      src/main/java/com/gyee/table/alarm/JpaElectricalTestingPointDIDao.java
  17. 1 1
      src/main/java/com/gyee/table/alarm/repository/ElectricalTestingPointAIRepository.java
  18. 1 1
      src/main/java/com/gyee/table/alarm/repository/ElectricalTestingPointDIRepository.java
  19. 21 20
      src/main/java/com/gyee/table/service/impl/ObjectServiceImpl.java
  20. 30 33
      src/main/java/com/gyee/table/vo/TableDataInfo.java
  21. 1 1
      src/main/resources/mappers/Configurationinfo.xml

+ 0 - 3
build.gradle.kts

@@ -25,7 +25,6 @@ dependencies {
     annotationProcessor("org.projectlombok:lombok")
     testImplementation("org.springframework.boot:spring-boot-starter-test")
     implementation("org.springframework.boot:spring-boot-starter-websocket")
-
     implementation("com.baomidou:mybatis-plus-boot-starter:3.5.3.1")
     implementation("com.alibaba:druid-spring-boot-starter:1.2.15")
     //implementation("mysql:mysql-connector-java:8.0.31")
@@ -36,8 +35,6 @@ dependencies {
     implementation("cn.hutool:hutool-all:5.8.15")
     implementation("com.github.pagehelper:pagehelper-spring-boot-starter:1.4.1")
     implementation("com.auth0:java-jwt:3.4.0")
-    implementation("org.apache.shiro:shiro-core:1.7.1")
-    implementation("org.apache.shiro:shiro-spring:1.7.1")
 }
 
 tasks.withType<Test> {

+ 11 - 4
src/main/java/com/gyee/table/controller/ComponentInformationController.java

@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.gyee.table.entity.ComponentModificationRecord;
 import com.gyee.table.entity.Configurationinfo;
+import com.gyee.table.jwt.annotation.PassToken;
 import com.gyee.table.result.Result;
 import com.gyee.table.service.IComponentModificationRecordService;
 import com.gyee.table.service.IConfigurationinfoService;
@@ -17,9 +18,11 @@ import javax.annotation.Resource;
 import java.util.List;
 
 /**
+ * 组件管理操作接口
+ *
  * @author hlf
  * @date 2023/3/20 10:03
- * 文件说明:组件管理操作接口
+ * 文件说明:
  */
 @Slf4j
 @RestController
@@ -38,9 +41,10 @@ public class ComponentInformationController {
      * @param configurationinfo
      * @return
      */
-    @GetMapping("/componentList")
+    @PostMapping("/componentList")
+    @PassToken
     public TableDataInfo componentList(@RequestBody Configurationinfo configurationinfo) {
-        PageHelper.startPage(configurationinfo.getPageNum(), configurationinfo.getPageSize(), true);
+        PageHelper.startPage(configurationinfo.getPageNumber(), configurationinfo.getPageSize(), true);
         List<Configurationinfo> list = configurationinfoService.selectConfigurationinfoList(configurationinfo);
         return getDataTable(list);
     }
@@ -52,6 +56,7 @@ public class ComponentInformationController {
      * @return
      */
     @PostMapping("/addComponent")
+    @PassToken
     public JSONObject addComponent(@RequestBody Configurationinfo configurationinfo) {
         configurationinfo.setId(Long.toString(IdUtil.getSnowflake(1, 1).nextId()));
         configurationinfoService.save(configurationinfo);
@@ -65,6 +70,7 @@ public class ComponentInformationController {
      * @return
      */
     @PostMapping("/updateComponent")
+    @PassToken
     public JSONObject updateComponent(@RequestBody Configurationinfo configurationinfo) {
         configurationinfoService.updateById(configurationinfo);
         ComponentModificationRecord componentModificationRecord = new ComponentModificationRecord();
@@ -82,6 +88,7 @@ public class ComponentInformationController {
      * @return
      */
     @DeleteMapping("/deleteComponent/{id}")
+    @PassToken
     public JSONObject deleteComponent(@PathVariable String id) {
         configurationinfoService.removeById(id);
         return Result.success();
@@ -94,7 +101,7 @@ public class ComponentInformationController {
     protected TableDataInfo getDataTable(List<?> list) {
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(200);
-        rspData.setRows(list);
+        rspData.setData(list);
         rspData.setTotal(new PageInfo(list).getTotal());
         rspData.setMsg("成功");
         return rspData;

+ 6 - 3
src/main/java/com/gyee/table/controller/LoginController.java

@@ -2,6 +2,7 @@ package com.gyee.table.controller;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.gyee.table.entity.SysUser;
+import com.gyee.table.jwt.annotation.UserLoginToken;
 import com.gyee.table.jwt.utils.JwtUtils;
 import com.gyee.table.service.ISysUserService;
 import com.gyee.table.utils.StringUtil;
@@ -13,9 +14,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import javax.annotation.Resource;
 
 /**
+ * 用户登录操作接口
+ *
  * @author hlf
  * @date 2023/3/28 14:55
- * 文件说明:用户登录操作接口
+ * 文件说明:
  */
 @Controller
 public class LoginController {
@@ -25,12 +28,14 @@ public class LoginController {
 
     /**
      * 登录
+     *
      * @param username 用户名
      * @param password 密码
      * @return
      */
     @PostMapping("/toLogin")
     @ResponseBody
+    @UserLoginToken
     public AjaxResult jwtLogin(String username, String password) {
         if (StringUtil.isEmpty(username) || StringUtil.isEmpty(password)) {
             return AjaxResult.error("账号和密码不能为空!");
@@ -39,11 +44,9 @@ public class LoginController {
         if (user == null) {
             return AjaxResult.error("用户不存在/密码错误!");
         }
-
         if (ObjectUtil.isNull(userService.checkPassword(username, password))) {
             return AjaxResult.error("用户不存在/密码错误!");
         }
-
         String token = JwtUtils.createToken(username, user.getPassword());
         return AjaxResult.success("登录成功,请妥善保管您的token信息").put("token", token).put("id", user.getId()).put("loginName", user.getLoginName()).put("userName", user.getUserName()).put("userAuthority", user.getUserAuthority());
     }

+ 5 - 1
src/main/java/com/gyee/table/controller/SysUserController.java

@@ -2,6 +2,7 @@ package com.gyee.table.controller;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.gyee.table.entity.SysUser;
+import com.gyee.table.jwt.annotation.PassToken;
 import com.gyee.table.result.Result;
 import com.gyee.table.result.ResultCode;
 import com.gyee.table.service.ISysUserService;
@@ -12,9 +13,10 @@ import javax.annotation.Resource;
 import java.util.List;
 
 /**
+ * 用户管理操作接口
  * @author hlf
  * @date 2023/3/29 15:58
- * 文件说明:用户管理操作接口
+ * 文件说明:
  */
 @Slf4j
 @RestController
@@ -30,6 +32,7 @@ public class SysUserController {
      * @return
      */
     @GetMapping("/getUserList")
+    @PassToken
     public JSONObject getUserList() {
         List<SysUser> list = userService.list();
         return Result.successData(ResultCode.SUCCESS, list);
@@ -44,6 +47,7 @@ public class SysUserController {
      * @return
      */
     @PostMapping("/changePassword")
+    @PassToken
     public JSONObject changePassword(@RequestParam(value = "id") String id,
                                      @RequestParam(value = "originalPassword") String originalPassword,
                                      @RequestParam(value = "newPassword") String newPassword) {

+ 1 - 0
src/main/java/com/gyee/table/controller/TerminalController.java

@@ -21,6 +21,7 @@ import javax.annotation.Resource;
 import java.util.List;
 
 /**
+ * 场站基础信息
  * @author hlf
  * @date 2023/3/16 16:59
  * 文件说明:

+ 1 - 1
src/main/java/com/gyee/table/entity/Configurationinfo.java

@@ -51,7 +51,7 @@ public class Configurationinfo {
     //修改用户ID(筛选)
     private String changeUser;
     //页码
-    private Integer pageNum;
+    private Integer pageNumber;
     //每页显示数量
     private Integer pageSize;
     //上传用户昵称

+ 17 - 0
src/main/java/com/gyee/table/jwt/annotation/PassToken.java

@@ -0,0 +1,17 @@
+package com.gyee.table.jwt.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @author hlf
+ * @date 2023/4/1 16:29
+ * 文件说明:除登录外使用的注解
+ */
+@Target({ElementType.METHOD,ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface PassToken {
+
+    boolean required() default true;
+
+}

+ 17 - 0
src/main/java/com/gyee/table/jwt/annotation/UserLoginToken.java

@@ -0,0 +1,17 @@
+package com.gyee.table.jwt.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @author hlf
+ * @date 2023/4/1 16:30
+ * 文件说明:登录使用的注解
+ */
+@Target({ElementType.METHOD,ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface UserLoginToken {
+
+    boolean required() default true;
+
+}

+ 0 - 19
src/main/java/com/gyee/table/jwt/auth/AllowAllCredentialsMatcher.java

@@ -1,19 +0,0 @@
-package com.gyee.table.jwt.auth;
-
-import org.apache.shiro.authc.AuthenticationInfo;
-import org.apache.shiro.authc.AuthenticationToken;
-import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;
-
-/**
- * 无需验证密码
- * 
- * @author ruoyi
- */
-public class AllowAllCredentialsMatcher extends SimpleCredentialsMatcher
-{
-    @Override
-    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info)
-    {
-        return true;
-    }
-}

+ 0 - 45
src/main/java/com/gyee/table/jwt/auth/JwtToken.java

@@ -1,45 +0,0 @@
-package com.gyee.table.jwt.auth;
-
-import org.apache.shiro.authc.UsernamePasswordToken;
-
-/**
- * 自定义登录Token
- * 
- * @author ruoyi
- */
-public class JwtToken extends UsernamePasswordToken
-{
-    private static final long serialVersionUID = 1L;
-
-    private String token;
-
-    public JwtToken()
-    {
-    }
-
-    public JwtToken(String username, String password, boolean rememberMe)
-    {
-        super(username, password, rememberMe);
-    }
-
-    public JwtToken(String username, String password)
-    {
-        super(username, password, false);
-    }
-
-    public JwtToken(String token)
-    {
-        super("", "", false);
-        this.token = token;
-    }
-
-    public String getToken()
-    {
-        return token;
-    }
-
-    public void setToken(String token)
-    {
-        this.token = token;
-    }
-}

+ 36 - 0
src/main/java/com/gyee/table/jwt/config/InterceptorConfig.java

@@ -0,0 +1,36 @@
+package com.gyee.table.jwt.config;
+
+import com.gyee.table.jwt.interceptor.AuthenticationInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * @author hlf
+ * @date 2023/4/1 16:24
+ * 文件说明:jwt后台访问拦截
+ */
+@Configuration
+public class InterceptorConfig implements WebMvcConfigurer {
+
+    @Bean
+    public AuthenticationInterceptor authenticationInterceptor() {
+        return new AuthenticationInterceptor();
+    }
+
+    // 这个方法用来注册拦截器,我们自己写好的拦截器需要通过这里添加注册才能生效
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        //注册TestInterceptor拦截器
+        InterceptorRegistration registration = registry.addInterceptor(authenticationInterceptor());
+        registration.addPathPatterns("/**");//所有路径都被拦截
+        registration.excludePathPatterns("" +
+            "/assets/**",     //assets文件夹里文件不拦截
+            "/**/*.js",       //js静态资源不拦截
+            "/**/*.css"       //css静态资源不拦截
+        );
+    }
+
+}

+ 0 - 136
src/main/java/com/gyee/table/jwt/filter/JwtFilter.java

@@ -1,136 +0,0 @@
-package com.gyee.table.jwt.filter;
-
-import com.alibaba.fastjson.JSON;
-import com.auth0.jwt.exceptions.JWTVerificationException;
-import com.auth0.jwt.exceptions.TokenExpiredException;
-import com.gyee.table.jwt.auth.JwtToken;
-import com.gyee.table.utils.StringUtil;
-import com.gyee.table.vo.AjaxResult;
-import org.apache.shiro.authc.AuthenticationException;
-import org.apache.shiro.web.filter.AccessControlFilter;
-import org.apache.shiro.web.util.WebUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-/**
- * jwt 自定义拦截器
- *
- * @author ruoyi
- */
-public class JwtFilter extends AccessControlFilter
-{
-    private static final Logger LOGGER = LoggerFactory.getLogger(JwtFilter.class);
-
-    private static final String AUTHZ_HEADER = "token";
-
-    private final ThreadLocal<String> MSG_HOLDER = new ThreadLocal<>();
-
-    @Override
-    public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception
-    {
-        return super.onPreHandle(request, response, mappedValue);
-    }
-
-    @Override
-    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception
-    {
-        return this.executeLogin(request, response);
-    }
-
-    /**
-     * 执行登录方法(UserRealm判断,异常返回false)
-     */
-    protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception
-    {
-        String token = WebUtils.toHttp(request).getHeader(AUTHZ_HEADER);
-        if (StringUtil.isEmpty(token))
-        {
-            MSG_HOLDER.set("消息头不正确,header需要携带token参数");
-            return false;
-        }
-        try
-        {
-            // 断是否有权限
-            JwtToken jwtToken = new JwtToken(token);
-            this.getSubject(request, response).login(jwtToken);
-            return true;
-        }
-        catch (AuthenticationException e)
-        {
-            if (e.getCause() instanceof TokenExpiredException)
-            {
-                MSG_HOLDER.set("token已过期");
-            }
-            else if (e.getCause() instanceof JWTVerificationException)
-            {
-                MSG_HOLDER.set("用户密码错误");
-            }
-            else
-            {
-                MSG_HOLDER.set("用户信息验证失败:" + e.getMessage());
-            }
-            return false;
-        }
-    }
-
-    /**
-     * 请求前处理,处理跨域
-     */
-    @Override
-    protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception
-    {
-        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
-        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
-        httpServletResponse.setHeader("Access-control-Allow-Origin", httpServletRequest.getHeader("Origin"));
-        httpServletResponse.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,DELETE");
-        httpServletResponse.setHeader("Access-Control-Allow-Headers", httpServletRequest.getHeader("Access-Control-Request-Headers"));
-        // 跨域时,option请求直接返回正常状态
-        if (httpServletRequest.getMethod().equals(RequestMethod.OPTIONS.name()))
-        {
-            httpServletResponse.setStatus(HttpStatus.OK.value());
-            return false;
-        }
-        return super.preHandle(request, response);
-    }
-
-    /**
-     * 异常处理
-     */
-    @Override
-    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception
-    {
-        this.jwtFail(request, response, 401, "对不起,您无权限进行操作!");
-        return false;
-    }
-
-    /**
-     * 认证失败,异常返回
-     */
-    protected void jwtFail(ServletRequest request, ServletResponse response, int code, String message)
-    {
-        HttpServletResponse httpResponse = WebUtils.toHttp(response);
-        String contentType = "application/json;charset=UTF-8";
-        httpResponse.setStatus(401);
-        httpResponse.setContentType(contentType);
-        try
-        {
-            String msg = StringUtil.isNotEmpty(MSG_HOLDER.get()) ? MSG_HOLDER.get() : message;
-            AjaxResult ajaxResult = new AjaxResult().put(AjaxResult.CODE_TAG, code).put(AjaxResult.MSG_TAG, msg);
-            PrintWriter printWriter = httpResponse.getWriter();
-            printWriter.append(JSON.toJSONString(ajaxResult));
-        }
-        catch (IOException e)
-        {
-            LOGGER.error("sendChallenge error,can not resolve httpServletResponse");
-        }
-    }
-}

+ 91 - 0
src/main/java/com/gyee/table/jwt/interceptor/AuthenticationInterceptor.java

@@ -0,0 +1,91 @@
+package com.gyee.table.jwt.interceptor;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.auth0.jwt.exceptions.JWTDecodeException;
+import com.gyee.table.entity.SysUser;
+import com.gyee.table.jwt.annotation.PassToken;
+import com.gyee.table.jwt.annotation.UserLoginToken;
+import com.gyee.table.jwt.utils.JwtUtils;
+import com.gyee.table.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.Method;
+
+/**
+ * @author hlf
+ * @date 2023/4/1 16:26
+ * 文件说明:拦截器类
+ */
+public class AuthenticationInterceptor implements HandlerInterceptor {
+
+    @Autowired
+    private ISysUserService userService;
+
+    /*
+    controller执行之前
+     */
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) {
+        // 从http请求头中取出token
+        String token = request.getHeader("token");
+        // 如果不是映射到方法直接通过
+        if (!(object instanceof HandlerMethod)) {
+            return true;
+        }
+        HandlerMethod handlerMethod = (HandlerMethod) object;
+        Method method = handlerMethod.getMethod();
+        // 方法是否带有UserLoginToken注释
+        if (method.isAnnotationPresent(UserLoginToken.class)) {
+            UserLoginToken userLoginToken = method.getAnnotation(UserLoginToken.class);
+            if (userLoginToken.required()) {
+                return true;
+            }
+        }
+        // 方法是否带有PassToken注释
+        if (method.isAnnotationPresent(PassToken.class)) {
+            PassToken passToken = method.getDeclaredAnnotation(PassToken.class);
+            if (passToken.required()) {
+                // 执行认证
+                if (token == null) {
+                    throw new RuntimeException("无token,请重新登录!");
+                }
+                // 获取token中的username
+                String username;
+                try {
+                    username = JwtUtils.getUserName(token);
+                } catch (JWTDecodeException j) {
+                    throw new RuntimeException("访问异常!");
+                }
+                SysUser user = userService.selectUserByLoginName(username);
+                if (ObjectUtil.isNull(user)) {
+                    throw new RuntimeException("当前用户不存在,请重新登录!");
+                }
+                JwtUtils.verify(user.getLoginName(), user.getPassword(), token);
+                return true;
+            }
+        }
+        return true;
+    }
+
+    /*
+    controller执行后,页面渲染前
+     */
+    @Override
+    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
+
+    }
+
+    /*
+    页面渲染后
+     */
+    @Override
+    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
+
+    }
+
+}

+ 12 - 25
src/main/java/com/gyee/table/jwt/utils/JwtUtils.java

@@ -12,55 +12,42 @@ import java.util.Date;
 
 /**
  * jwt 工具类
- * 
- * @author ruoyi
+ *
+ * @author hlf
  */
-public class JwtUtils
-{
+public class JwtUtils {
     private static final long EXPIRE_TIME = 3 * 120 * 60 * 1000;
 
     private static final String CLAIM_NAME = "username";
 
-    public static String createToken(String username, String password)
-    {
+    public static String createToken(String username, String password) {
         return createToken(username, password, EXPIRE_TIME);
     }
 
-    public static String createToken(String username, String password, long expireTime)
-    {
+    public static String createToken(String username, String password, long expireTime) {
         Date date = new Date(System.currentTimeMillis() + expireTime);
         // 加密处理密码
         Algorithm algorithm = Algorithm.HMAC256(password);
         return JWT.create().withClaim(CLAIM_NAME, username).withExpiresAt(date).sign(algorithm);
     }
 
-    public static void verify(String username, String dbPwd, String token)
-    {
+    public static void verify(String username, String dbPwd, String token) {
         Algorithm algorithm = Algorithm.HMAC256(dbPwd);
         JWTVerifier jwtVerifier = JWT.require(algorithm).withClaim(CLAIM_NAME, username).build();
-        try
-        {
+        try {
             jwtVerifier.verify(token);
-        }
-        catch (TokenExpiredException e)
-        {
+        } catch (TokenExpiredException e) {
             throw new TokenExpiredException("token已过期");
-        }
-        catch (JWTVerificationException e)
-        {
+        } catch (JWTVerificationException e) {
             throw new JWTVerificationException("token验证失败");
         }
     }
 
-    public static String getUserName(String token)
-    {
-        try
-        {
+    public static String getUserName(String token) {
+        try {
             DecodedJWT jwt = JWT.decode(token);
             return jwt.getClaim(CLAIM_NAME).asString();
-        }
-        catch (JWTDecodeException e)
-        {
+        } catch (JWTDecodeException e) {
             return null;
         }
     }

+ 2 - 2
src/main/java/com/gyee/table/alarm/JpaElectricalTestingPointAIDao.java

@@ -1,8 +1,8 @@
-package com.gyee.table.alarm;
+package com.gyee.table.service.alarm;
 
 import com.gyee.table.entity.ElectricalTestingPointAI;
 import com.gyee.table.entity.ElectricalTestingPointAIEntity;
-import com.gyee.table.alarm.repository.ElectricalTestingPointAIRepository;
+import com.gyee.table.service.alarm.repository.ElectricalTestingPointAIRepository;
 import com.gyee.table.service.ElectricalTestingPointAIDao;
 import com.gyee.table.utils.DataUtil;
 import org.springframework.beans.factory.annotation.Autowired;

+ 2 - 2
src/main/java/com/gyee/table/alarm/JpaElectricalTestingPointDIDao.java

@@ -1,4 +1,4 @@
-package com.gyee.table.alarm;
+package com.gyee.table.service.alarm;
 
 import com.gyee.table.entity.ElectricalTestingPointDI;
 import com.gyee.table.entity.ElectricalTestingPointDIEntity;
@@ -18,7 +18,7 @@ import java.util.List;
 @Component
 public class JpaElectricalTestingPointDIDao implements ElectricalTestingPointDIDao {
     @Autowired
-    private com.gyee.table.alarm.repository.ElectricalTestingPointDIRepository ElectricalTestingPointDIRepository;
+    private com.gyee.table.service.alarm.repository.ElectricalTestingPointDIRepository ElectricalTestingPointDIRepository;
 
 
     @Override

+ 1 - 1
src/main/java/com/gyee/table/alarm/repository/ElectricalTestingPointAIRepository.java

@@ -1,4 +1,4 @@
-package com.gyee.table.alarm.repository;
+package com.gyee.table.service.alarm.repository;
 
 import com.gyee.table.entity.ElectricalTestingPointAIEntity;
 import org.springframework.data.jpa.repository.JpaRepository;

+ 1 - 1
src/main/java/com/gyee/table/alarm/repository/ElectricalTestingPointDIRepository.java

@@ -1,4 +1,4 @@
-package com.gyee.table.alarm.repository;
+package com.gyee.table.service.alarm.repository;
 
 
 import com.gyee.table.entity.ElectricalTestingPointDIEntity;

+ 21 - 20
src/main/java/com/gyee/table/service/impl/ObjectServiceImpl.java

@@ -1,7 +1,5 @@
 package com.gyee.table.service.impl;
 
-import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -25,7 +23,7 @@ import java.util.regex.Pattern;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author gfhd
@@ -36,6 +34,7 @@ public class ObjectServiceImpl implements IObjectService {
 
     private final static String regex = "#|/\\*|\\*/|--|\\buse\\b|\\binsert\\b|\\bdelete\\b|\\bupdate\\b|\\bcreate\\b|\\bdrop\\b|\\btruncate\\b|\\balter\\b|\\bgrant\\b|\\bexecute\\b|\\bexec\\b|\\bxp_cmdshell\\b|\\bcall\\b|\\bdeclare\\b|\\bsource\\b|\\bsql\\b|\\bchr\\b|\\bmid\\b|\\bmaster\\b|\\bchar\\b|\\bsitename\\b|\\bnet user\\b|;|-|\\+|\\btable\\b|\\bgroup_concat\\b|\\bcolumn_name\\b|\\binformation_schema.columns\\b|\\btable_schema\\b|//|/";
     private final Pattern compile;
+
     {
         compile = Pattern.compile(regex);
     }
@@ -49,6 +48,7 @@ public class ObjectServiceImpl implements IObjectService {
 
     /**
      * 根据表名查表头,根据sql查数据
+     *
      * @param map tablenae,sql
      * @return
      */
@@ -56,54 +56,54 @@ public class ObjectServiceImpl implements IObjectService {
     public JSONObject selectBySql(Map map) {
 
         String sql = (String) map.get("sql");
-        if(StringUtils.isBlank(sql)) return Result.error(ResultCode.PARAM_IS_BLANK);
+        if (StringUtils.isBlank(sql)) return Result.error(ResultCode.PARAM_IS_BLANK);
 
         Matcher matcher = compile.matcher(sql);
-        if(matcher.find()){
+        if (matcher.find()) {
             String group = matcher.group(0);
-            return Result.error(ResultCode.ERROR_UNSUPPORTED_SQL,"查看字符:"+group);
+            return Result.error(ResultCode.ERROR_UNSUPPORTED_SQL, "查看字符:" + group);
         }
 
         List<LinkedHashMap<String, Object>> lms = objectMapper.selectAll(sql);
 
         String tablename = (String) map.get("tablename");
-        if(StringUtils.isBlank(tablename))
+        if (StringUtils.isBlank(tablename))
             tablename = StringUtils.substringBetween("from ", " ");
-            //return Result.successData(ResultCode.SUCCESS,lms);
+        //return Result.successData(ResultCode.SUCCESS,lms);
 
         QueryWrapper<TableColumnHeader> wrapper = new QueryWrapper<>();
         wrapper.eq("name", tablename);
         boolean tableExist = tableColumnHeaderMapper.exists(wrapper);
 
         List<TableColumnHeader> tableColumnHeader;
-        if(!tableExist && lms.size()>0){
+        if (!tableExist && lms.size() > 0) {
             tableColumnHeader = createTableColumnHeader(tablename, lms.get(0));
-        }else {
+        } else {
             tableColumnHeader = tableColumnHeaderMapper.selectList(wrapper);
         }
         Table table = new Table();
         table.setTableHeader(tableColumnHeader);
         table.setTableData(lms);
         //截取sql
-        if (sql.contains("limit")||sql.contains("LIMIT")){
+        if (sql.contains("limit") || sql.contains("LIMIT")) {
 
             String newSql = "";
-            if(sql.contains("LIMIT"))
-                newSql=  sql.split("LIMIT")[0];
-            else if (sql.contains("limit")){
-                newSql=  sql.split("limit")[0];
+            if (sql.contains("LIMIT"))
+                newSql = sql.split("LIMIT")[0];
+            else if (sql.contains("limit")) {
+                newSql = sql.split("limit")[0];
             }
             List<LinkedHashMap<String, Object>> linkedHashMaps = objectMapper.selectAll(newSql);
             table.setCount(linkedHashMaps.size());
-        }else {
+        } else {
             table.setCount(lms.size());
         }
-        return Result.successData(ResultCode.SUCCESS,table);
+        return Result.successData(ResultCode.SUCCESS, table);
     }
 
     @Override
     public JSONObject selectBySqlToEchart(Map map) {
-        String sql = (String)map.get("sql");
+        String sql = (String) map.get("sql");
         if (StringUtils.isBlank(sql)) {
             return Result.error(ResultCode.PARAM_IS_BLANK);
         } else {
@@ -120,6 +120,7 @@ public class ObjectServiceImpl implements IObjectService {
 
     /**
      * 根据表头和数据生成默认表头
+     *
      * @param tablename
      * @param solhm
      * @return
@@ -127,10 +128,10 @@ public class ObjectServiceImpl implements IObjectService {
     private List<TableColumnHeader> createTableColumnHeader(String tablename, LinkedHashMap<String, Object> solhm) {
         List<TableColumnHeader> tableHeaderColumns = new ArrayList<>();
         long tableId = tableColumnHeaderMapper.selectCount(Wrappers.emptyWrapper()) + 1;
-        int id=0;
+        int id = 0;
         for (String s : solhm.keySet()) {
             TableColumnHeader tch = new TableColumnHeader();
-            id=id+1;
+            id = id + 1;
             tch.setId(String.valueOf(id));
             tch.setTid(tableId);
             tch.setName(tablename);

+ 30 - 33
src/main/java/com/gyee/table/vo/TableDataInfo.java

@@ -5,81 +5,78 @@ import java.util.List;
 
 /**
  * 表格分页数据对象
- * 
+ *
  * @author ruoyi
  */
-public class TableDataInfo implements Serializable
-{
+public class TableDataInfo implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    /** 总记录数 */
+    /**
+     * 总记录数
+     */
     private long total;
 
-    /** 列表数据 */
-    private List<?> rows;
+    /**
+     * 列表数据
+     */
+    private List<?> data;
 
-    /** 消息状态码 */
+    /**
+     * 消息状态码
+     */
     private int code;
 
-    /** 消息内容 */
+    /**
+     * 消息内容
+     */
     private String msg;
 
     /**
      * 表格数据对象
      */
-    public TableDataInfo()
-    {
+    public TableDataInfo() {
     }
 
     /**
      * 分页
-     * 
-     * @param list 列表数据
+     *
+     * @param list  列表数据
      * @param total 总记录数
      */
-    public TableDataInfo(List<?> list, int total)
-    {
-        this.rows = list;
+    public TableDataInfo(List<?> list, int total) {
+        this.data = list;
         this.total = total;
     }
 
-    public long getTotal()
-    {
+    public long getTotal() {
         return total;
     }
 
-    public void setTotal(long total)
-    {
+    public void setTotal(long total) {
         this.total = total;
     }
 
-    public List<?> getRows()
-    {
-        return rows;
+    public List<?> getData() {
+        return data;
     }
 
-    public void setRows(List<?> rows)
-    {
-        this.rows = rows;
+    public void setData(List<?> data) {
+        this.data = data;
     }
 
-    public int getCode()
-    {
+    public int getCode() {
         return code;
     }
 
-    public void setCode(int code)
-    {
+    public void setCode(int code) {
         this.code = code;
     }
 
-    public String getMsg()
-    {
+    public String getMsg() {
         return msg;
     }
 
-    public void setMsg(String msg)
-    {
+    public void setMsg(String msg) {
         this.msg = msg;
     }
 }

+ 1 - 1
src/main/resources/mappers/Configurationinfo.xml

@@ -32,7 +32,7 @@
         left join sys_user u1 on u1.id = c.upload_user
         left join sys_user u2 on u2.id = c.change_user
         <where>
-            <if test="name != null and name != ''">and c.name = #{name}</if>
+            <if test="name != null and name != ''">and c.name like concat(concat('%', #{name}), '%')</if>
             <if test="uploadUser != null and uploadUser != ''">and c.upload_user = #{uploadUser}</if>
             <if test="changeUser != null and changeUser != ''">and c.changeUser = #{changeUser}</if>
             <if test="needMapDone != null">and c.needMapDone = #{needMapDone}</if>