kaiyu
2021-05-28 f202fd9cf5ab399e8d34812ab44163af3ac78672
Merge branch 'dev' of http://blit.7drlb.com:8888/r/moral into dev
1 files renamed
5 files modified
142 ■■■■■ changed files
screen-api/src/main/java/com/moral/api/config/Interceptor/WebAppConfiguration.java 21 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/interceptor/WebInterceptor.java 3 ●●●● patch | view | raw | blame | history
screen-api/src/main/resources/application-dev.yml 56 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/controller/DeviceController.java 32 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/DeviceService.java 4 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java 26 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/config/Interceptor/WebAppConfiguration.java
@@ -1,18 +1,31 @@
package com.moral.api.config.Interceptor;
import org.springframework.boot.context.properties.ConfigurationProperties;
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;
import com.moral.api.interceptor.AuthenticationInterceptor;
import java.util.ArrayList;
import com.moral.api.interceptor.WebInterceptor;
@Configuration
public class WebAppConfiguration implements WebMvcConfigurer {
    //读取不需拦截路径
    @Bean
    @ConfigurationProperties("mvc.interceptor.exclude")
    public ArrayList<String> getExcludePath(){
        return new ArrayList<>();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthenticationInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/**/login/**", "/**/logout/**", "/swagger-ui.html/**", "/swagger-resources/**","/**/verificationCode/**","/**/user/**");
        InterceptorRegistration regisration = registry.addInterceptor(new WebInterceptor());
        ArrayList<String> excludePath = getExcludePath();
        regisration.addPathPatterns("/**/**");//设置拦截路径
        regisration.excludePathPatterns(excludePath);//设置不拦截路径
    }
}
screen-api/src/main/java/com/moral/api/interceptor/WebInterceptor.java
File was renamed from screen-api/src/main/java/com/moral/api/interceptor/AuthenticationInterceptor.java
@@ -7,11 +7,10 @@
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import com.moral.redis.RedisUtil;
import com.moral.util.TokenUtils;
@Component
public class AuthenticationInterceptor implements HandlerInterceptor {
public class WebInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
screen-api/src/main/resources/application-dev.yml
@@ -14,32 +14,28 @@
  profiles:
    active: dev
  application:
    name: screen-api
    name: screen-manage
  redis:
    #cluster:
    #nodes: 47.112.126.78:7001,47.112.126.78:7002,47.112.126.132:7003,47.112.126.132:7004,47.112.132.193:7005,47.112.132.193:7006
    #password: test
    #timeout: 500
      host: 39.97.177.149
      port: 6379
      password: chenkaiyu111
      timeout: 30000
      jedis:
        pool:
          max-active: 256
          max-wait: 30000
          max-idle: 64
          min-idle: 32
      lettuce:
        pool:
          max-active: 256
          max-idle: 64
          max-wait: 30000
          min-idle: 32
  tokenRedis:
    host: 39.97.177.149
    host: r-bp1xdlb9wfc6zt0msp.redis.rds.aliyuncs.com
    port: 6379
    password: chenkaiyu111
    password: moral_123456
    timeout: 30000
    jedis:
      pool:
        max-active: 256
        max-wait: 30000
        max-idle: 64
        min-idle: 32
    lettuce:
      pool:
        max-active: 256
        max-idle: 64
        max-wait: 30000
        min-idle: 32
  tokenRedis:
    host: r-bp1xdlb9wfc6zt0msp.redis.rds.aliyuncs.com
    port: 6379
    password: moral_123456
    timeout: 30000
    database: 15
    pool:
@@ -57,9 +53,9 @@
    filters: stat
    type: com.alibaba.druid.pool.DruidDataSource
    max-wait: 60000
    url: jdbc:mysql://39.97.177.149:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: chenkaiyu111
    password: moral_123456
    test-on-borrow: false
    sql-script-encoding: utf-8
    pool-prepared-statements: true
@@ -113,7 +109,13 @@
mvc:
  interceptor:
    exclude:
      - /account/login
      - /login
      - /swagger-ui.html
      - /swagger-resources/**
      - /swagger-ui.html/**
      - /webjars/**
      - /verificationCode/**
AES:
  KEY:
    AD42F7787B035B7580000EF93BE20BAD
screen-manage/src/main/java/com/moral/api/controller/DeviceController.java
@@ -148,21 +148,41 @@
    @ApiOperation(value = "根据组织查设备", notes = "根据组织查设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
            @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "order", value = "排序字段", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "orderType", value = "排序类型,升序:0,降序:1", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "organizationId", value = "组织id", required = false, paramType = "query", dataType = "int"),
    })
    @RequestMapping(value = "devicesByOrgId", method = RequestMethod.GET)
    public ResultMessage selectDevicesByOrg(Integer orgId) {
        List<Map<String, Object>> devices = deviceService.selectDevicesByOrgId(orgId);
    public ResultMessage selectDevicesByOrg(HttpServletRequest request) {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        if (parameters.get("organizationId") == null) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> devices = deviceService.selectDevicesByOrgId(parameters);
        return ResultMessage.ok(devices);
    }
    @ApiOperation(value = "根据站点查设备", notes = "根据站点查设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
            @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "order", value = "排序字段", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "orderType", value = "排序类型,升序:0,降序:1", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "monitorPointId", value = "站点id", required = false, paramType = "query", dataType = "int"),
    })
    @RequestMapping(value = "devicesByMpId", method = RequestMethod.GET)
    public ResultMessage selectDevicesByMp(Integer mpId) {
        List<Map<String, Object>> devices = deviceService.selectDevicesByMpId(mpId);
    public ResultMessage selectDevicesByMp(HttpServletRequest request) {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        if (parameters.get("monitorPointId") == null) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> devices = deviceService.selectDevicesByMpId(parameters);
        return ResultMessage.ok(devices);
    }
screen-manage/src/main/java/com/moral/api/service/DeviceService.java
@@ -41,10 +41,10 @@
    List<Map<String, Object>> selectMonitorsByOrgId(Integer orgId);
    //根据组织查询设备
    List<Map<String, Object>> selectDevicesByOrgId(Integer orgId);
    Map<String, Object> selectDevicesByOrgId(Map<String, Object> parameters);
    //根据站点查询设备
    List<Map<String, Object>> selectDevicesByMpId(Integer orgId);
    Map<String, Object> selectDevicesByMpId(Map<String, Object> parameters);
    //分页获取所有设备列表
    Map<String, Object> selectDevices(Map<String, Object> parameters);
screen-manage/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
@@ -177,17 +177,13 @@
    }
    @Override
    public List<Map<String, Object>> selectDevicesByOrgId(Integer orgId) {
        QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete", Constants.NOT_DELETE).eq("organization_id", orgId);
        return deviceMapper.selectMaps(queryWrapper);
    public Map<String, Object> selectDevicesByOrgId(Map<String, Object> parameters) {
        return selectDevices(parameters);
    }
    @Override
    public List<Map<String, Object>> selectDevicesByMpId(Integer mpId) {
        QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete", Constants.NOT_DELETE).eq("monitor_point_id", mpId);
        return deviceMapper.selectMaps(queryWrapper);
    public Map<String, Object> selectDevicesByMpId(Map<String, Object> parameters) {
        return selectDevices(parameters);
    }
    @Override
@@ -199,6 +195,19 @@
        Object orderType = parameters.get("orderType");
        Object name = parameters.get("name");
        Object mac = parameters.get("mac");
        Object orgId = parameters.get("organizationId");
        Object mpId = parameters.get("monitorPointId");
        //查询某组织下所有设备
        if (orgId != null) {
            queryWrapper.eq("organization_id", orgId);
        }
        //查询某站点下所有设备
        if (mpId != null) {
            queryWrapper.eq("monitor_point_id", mpId);
        }
        if (name != null) {
            queryWrapper.like("name", name);
        }
@@ -206,6 +215,7 @@
            queryWrapper.like("mac", mac);
        }
        //排序参数,默认create_time降序
        if (order != null && orderType != null) {
            if (Constants.ORDER_ASC.equals(orderType)) {