laowo пре 4 година
комит
4a3315c410

+ 102 - 0
pom.xml

@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+    <groupId>com.usky</groupId>
+    <artifactId>118webjdbc</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <!--添加父工程坐标-->
+    <parent>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <groupId>org.springframework.boot</groupId>
+        <version>2.1.4.RELEASE</version>
+    </parent>
+    <dependencies>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.35</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+        </dependency>
+        <!-- 添加JPA依赖,官网描述支持spring data JPA 和hibernate-->
+
+        <!--导入连接MySQL的依赖 -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!-- 导入测试包 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+        </dependency>
+        <!--thymeleaf启动器-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>1.1.22</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.4</version>
+            <classifier>jdk15</classifier>
+        </dependency>
+
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <compilerArguments>
+                        <bootclasspath>${env.JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
+                    </compilerArguments>
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+
+
+</project>

+ 20 - 0
src/main/java/com/usky/Application.java

@@ -0,0 +1,20 @@
+package com.usky;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/11/2 11:27
+ * @description TODO
+ **/
+@SpringBootApplication
+
+@EnableScheduling
+public class Application {
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+    }
+}

+ 13 - 0
src/main/java/com/usky/annotion/SysLog.java

@@ -0,0 +1,13 @@
+package com.usky.annotion;
+
+import java.lang.annotation.*;
+
+/**
+ * 自定义日志注解
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface SysLog {
+    String value() default "";
+}

+ 91 - 0
src/main/java/com/usky/config/DataSourceConfig.java

@@ -0,0 +1,91 @@
+package com.usky.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.support.http.StatViewServlet;
+import com.alibaba.druid.support.http.WebStatFilter;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+
+/**
+ * 多数据源配置
+ */
+@Configuration
+public class DataSourceConfig {
+
+    /*@Primary
+    @Bean(name = "dataSourceProperties187")
+    @ConfigurationProperties(prefix = "spring.datasource.db187")
+    public DataSourceProperties DataSourceProperties187() {
+        return new DataSourceProperties();
+    }
+
+
+    @Primary
+    @Bean(name = "dataSource187")
+    public DataSource ds1DataSource(@Qualifier("dataSourceProperties187") DataSourceProperties dataSourceProperties) {
+        return dataSourceProperties.initializeDataSourceBuilder().build();
+    }
+
+    @Bean(name = "dataSourceProperties118")
+    @ConfigurationProperties(prefix = "spring.datasource.db118")
+    public DataSourceProperties DataSourceProperties118() {
+        return new DataSourceProperties();
+    }
+
+
+    @Bean("dataSource118")
+    public DataSource ds2DataSource(@Qualifier("dataSourceProperties118") DataSourceProperties dataSourceProperties) {
+        return dataSourceProperties.initializeDataSourceBuilder().build();
+    }*/
+    @ConfigurationProperties(prefix = "spring.datasource.first187")
+    @Bean(name = "dataSource187")
+    @Primary
+    public DataSource dataSource187() {
+        return new DruidDataSource();
+    }
+    @ConfigurationProperties(prefix = "spring.datasource.second118")
+    @Bean(name = "dataSource118")
+    public DataSource dataSource118() {
+        return new DruidDataSource();
+    }
+
+
+
+    @Bean
+    public ServletRegistrationBean statViewServlet() {
+        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
+        // 添加IP白名单
+        //   servletRegistrationBean.addInitParameter("allow", "127.0.0.1");
+        // 添加IP黑名单,当白名单和黑名单重复时,黑名单优先级更高
+        //   servletRegistrationBean.addInitParameter("deny", "127.0.0.1");
+        // 添加控制台管理用户
+        servletRegistrationBean.addInitParameter("loginUsername", "admin");
+        servletRegistrationBean.addInitParameter("loginPassword", "admin");
+        // 是否能够重置数据
+        servletRegistrationBean.addInitParameter("resetEnable", "true");
+        return servletRegistrationBean;
+    }
+
+    /**
+     * 配置服务过滤器
+     *
+     * @return 返回过滤器配置对象
+     */
+    @Bean
+    public FilterRegistrationBean statFilter() {
+        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter());
+        // 添加过滤规则
+        filterRegistrationBean.addUrlPatterns("/*");
+        // 忽略过滤格式
+        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*,");
+        return filterRegistrationBean;
+    }
+}

+ 23 - 0
src/main/java/com/usky/config/JdbcTemplateDataSourceConfig.java

@@ -0,0 +1,23 @@
+package com.usky.config;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.sql.DataSource;
+
+
+@Configuration
+public class JdbcTemplateDataSourceConfig {
+
+    @Primary
+    @Bean(name = "jdbcTemplate187")
+    public JdbcTemplate jdbcTemplate187(@Qualifier("dataSource187") DataSource dataSource) {
+        return new JdbcTemplate(dataSource);
+    }
+    @Bean(name = "jdbcTemplate118")
+    public JdbcTemplate jdbcTemplate118(@Qualifier("dataSource118") DataSource dataSource) {
+        return new JdbcTemplate(dataSource);
+    }
+}

+ 70 - 0
src/main/java/com/usky/config/RemoveDruidAdConfig.java

@@ -0,0 +1,70 @@
+package com.usky.config;
+
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
+import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
+import com.alibaba.druid.util.Utils;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.servlet.*;
+import java.io.IOException;
+
+@Configuration
+@ConditionalOnWebApplication
+@AutoConfigureAfter(DruidDataSourceAutoConfigure.class)
+@ConditionalOnProperty(name = "spring.datasource.druid.stat-view-servlet.enabled",
+        havingValue = "true", matchIfMissing = true)
+public class RemoveDruidAdConfig {
+ 
+    /**
+     * 方法名: removeDruidAdFilterRegistrationBean
+     * 方法描述:  除去页面底部的广告
+     * @param properties
+     * @return org.springframework.boot.web.servlet.FilterRegistrationBean
+     * @throws
+     */
+    @Bean
+    public FilterRegistrationBean removeDruidAdFilterRegistrationBean(DruidStatProperties properties)
+    {
+        // 获取web监控页面的参数
+        DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
+        // 提取common.js的配置路径
+        String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
+        String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
+ 
+        final String filePath = "support/http/resources/js/common.js";
+ 
+        //创建filter进行过滤
+        Filter filter = new Filter() {
+            @Override
+            public void init(FilterConfig filterConfig) throws ServletException {
+            }
+ 
+            @Override
+            public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+                    throws IOException, ServletException {
+                chain.doFilter(request, response);
+                // 重置缓冲区,响应头不会被重置
+                response.resetBuffer();
+                // 获取common.js
+                String text = Utils.readFromResource(filePath);
+                // 正则替换banner, 除去底部的广告信息
+                text = text.replaceAll("<a.*?banner\"></a><br/>", "");
+                text = text.replaceAll("powered.*?shrek.wang</a>", "");
+                response.getWriter().write(text);
+            }
+ 
+            @Override
+            public void destroy() {
+            }
+        };
+        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
+        registrationBean.setFilter(filter);
+        registrationBean.addUrlPatterns(commonJsPattern);
+        return registrationBean;
+    }
+}

+ 27 - 0
src/main/java/com/usky/controller/Statr.java

@@ -0,0 +1,27 @@
+package com.usky.controller;
+
+import com.usky.service.StartService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * @author laowo
+ * @version 1.0.0
+ * @ClassName Test.java
+ * @Description TODO
+ * @createTime 2021/03/13/ 14:23:00
+ */
+@Controller
+public class Statr {
+    @Autowired
+    private StartService startService;
+    @RequestMapping("start")
+    @ResponseBody
+    public String start(String tableName){
+        startService.start(tableName);
+        return "操作成功!";
+    }
+}

+ 12 - 0
src/main/java/com/usky/service/StartService.java

@@ -0,0 +1,12 @@
+package com.usky.service;
+
+/**
+ * @author laowo
+ * @version 1.0.0
+ * @ClassName TestService.java
+ * @Description TODO
+ * @createTime 2021/03/13/ 14:24:00
+ */
+public interface StartService {
+    void start(String tableName);
+}

+ 129 - 0
src/main/java/com/usky/service/StartServiceImpl.java

@@ -0,0 +1,129 @@
+package com.usky.service;
+
+import com.usky.utils.ListUtil;
+import com.usky.utils.MapUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author laowo
+ * @version 1.0.0
+ * @ClassName TestServiceImpl.java
+ * @Description TODO
+ * @createTime 2021/03/13/ 14:25:00
+ */
+@Service
+
+public class StartServiceImpl implements StartService {
+    private static Logger logger = LoggerFactory.getLogger(StartServiceImpl.class);
+    @Autowired
+    @Qualifier("jdbcTemplate118")
+    private JdbcTemplate jdbcTemplate118;
+    @Autowired
+    @Qualifier("jdbcTemplate187")
+    private JdbcTemplate jdbcTemplate187;
+
+    @Override
+    public void start(String tableName) {
+
+
+        List<Map<String, Object>> resList = query187Tables(tableName);
+        Boolean aBoolean = creatTable(resList);
+
+    }
+
+    public Boolean creatTable(List<Map<String, Object>> resList) {
+        if (ListUtil.isNotBlank(resList)) {
+            Map<String, Object> tablNameMap = resList.get(0);
+            String tableName = (String) tablNameMap.get("Table");
+            String tableSql = (String) tablNameMap.get("Create Table");
+            String sql = "show tables like '" + tableName + "'";
+            List<Map<String, Object>> maps = jdbcTemplate118.queryForList(sql);
+            if (ListUtil.isBlank(maps)) {
+                jdbcTemplate118.execute(tableSql);
+            }
+            String querySql = "select * from " + tableName + " as t where t.acquisition_time <(DATE_ADD(now(),INTERVAL -1 month))";
+            StringBuffer sb = new StringBuffer();
+            List<Map<String, Object>> data187 = jdbcTemplate187.queryForList(querySql);
+            for (Map<String, Object> objectMap : data187) {
+                for (String s : objectMap.keySet()) {
+                    if (s.equals("id")){
+                        sb.append(objectMap.get(s));
+                    }else {
+                        sb.append("'" + objectMap.get(s) + "'");
+                    }
+                    sb.append(",");
+                }
+                sb.deleteCharAt(sb.length() - 1);
+                String inSql = "INSERT INTO " + tableName + " VALUES (" + sb.toString() + ")";
+                int update = jdbcTemplate118.update(inSql);
+                String delSql="delete from "+tableName+" where id= "+objectMap.get("id")+"";
+                int update1 = jdbcTemplate187.update(delSql);
+                sb.setLength(0);
+                int i=0;
+                System.out.println("inSql = " + i++);
+            }
+        }
+       /* String tableName = resList.get(0);
+        String tableSql = resList.get(1);
+    List list = (List) hibernateTemplate118.execute(new HibernateCallback() {
+        @Override
+        public Object doInHibernate(Session session) throws HibernateException {
+           return session.createSQLQuery("show tables like '" + tableName + "'").list();
+        }
+    });
+        if (ListUtil.isBlank(list)) {
+            int i = getSession118().createSQLQuery(tableSql).executeUpdate();
+        }
+        List list1 = (List) hibernateTemplate187.execute(new HibernateCallback() {
+            @Override
+            public Object doInHibernate(Session session) throws HibernateException {
+                return session.createSQLQuery("select * from " + tableName + " as t where t.acquisition_time <(DATE_ADD(now(),INTERVAL -1 month)) ").list();
+            }
+        });
+
+        for (Object o : list1) {
+            Object[] d = (Object[]) o;
+            StringBuffer sb = new StringBuffer();
+            for (int i = 0; i < d.length; i++) {
+                sb.append("'" + d[i] + "'");
+                sb.append(",");
+            }
+            // sb.r
+            sb.deleteCharAt(sb.length() - 1);
+            String inSql = "INSERT INTO " + tableName + " VALUES (" + sb.toString() + ")";
+           // int i = getSession118().createSQLQuery(inSql).executeUpdate();
+
+            Integer i = (Integer) hibernateTemplate118.execute(new HibernateCallback() {
+                @Override
+                public Object doInHibernate(Session session) throws HibernateException {
+                    return session.createSQLQuery(inSql).executeUpdate();
+                }
+            });
+
+
+
+        }*/
+        return true;
+    }
+
+    public List<Map<String, Object>> query187Tables(String tableName) {
+
+
+        List<String> resList = new ArrayList<>();
+        String sql = "show create table  " + tableName + "";
+        return jdbcTemplate187.queryForList(sql);
+
+
+    }
+}

+ 52 - 0
src/main/java/com/usky/utils/BeanHelp.java

@@ -0,0 +1,52 @@
+package com.usky.utils;
+
+import org.springframework.beans.BeanUtils;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/3/9 12:49
+ * @description TODO
+ **/
+
+public class BeanHelp {
+
+    public static <T> T copyProperties(Object source, Class<T> target){
+        try {
+            T t = target.newInstance();
+            BeanUtils.copyProperties(source, t);
+            return t;
+        } catch (Exception e) {
+           /* logger.error("【数据转换】数据转换出错,目标对象{}构造函数异常", target.getName(), e);*/
+            //logger.error();
+            // throw new LyException(ExceptionEnum.DATA_TRANSFER_ERROR);
+        }
+        return null;
+    }
+
+    public static <T> List<T> copyWithCollection(List<?> sourceList, Class<T> target){
+        try {
+            return sourceList.stream().map(s -> copyProperties(s, target)).collect(Collectors.toList());
+        } catch (Exception e) {
+           // log.error("【数据转换】数据转换出错,目标对象{}构造函数异常", target.getName(), e);
+            // throw new LyException(ExceptionEnum.DATA_TRANSFER_ERROR);
+        }
+        return null;
+    }
+
+    public static <T> Set<T> copyWithCollection(Set<?> sourceList, Class<T> target){
+        try {
+            return sourceList.stream().map(s -> copyProperties(s, target)).collect(Collectors.toSet());
+        } catch (Exception e) {
+           // log.error("【数据转换】数据转换出错,目标对象{}构造函数异常", target.getName(), e);
+            // throw new LyException(ExceptionEnum.DATA_TRANSFER_ERROR);
+        }
+        return null;
+    }
+
+
+}

+ 28 - 0
src/main/java/com/usky/utils/ConfigUtil.java

@@ -0,0 +1,28 @@
+package com.usky.utils;
+
+import java.util.ResourceBundle;
+
+/**
+ * @author 鲁班七号
+ * @version v1.0
+ * @date 2020/4/30 14:28
+ * @description TODO
+ **/
+public class ConfigUtil {
+    private static String BASE_URL;
+    static {
+        ResourceBundle bundle = ResourceBundle.getBundle("config");
+        BASE_URL = bundle.getString("BASE_URL");//系统路径
+
+    }
+
+    public ConfigUtil() {
+    }
+
+
+    public static String getSimBaseUrl() {
+        return BASE_URL;
+    }
+
+
+}

+ 26 - 0
src/main/java/com/usky/utils/DaoResult.java

@@ -0,0 +1,26 @@
+package com.usky.utils;
+
+public class DaoResult {
+	String result;
+	boolean success;
+	public DaoResult(String result, boolean success){
+		this.result = result;
+		this.success = success;
+	}
+	public DaoResult(){
+		this.result="";
+		this.success=false;
+	}
+	public String getResult() {
+		return result;
+	}
+	public void setResult(String result) {
+		this.result = result;
+	}
+	public boolean isSuccess() {
+		return success;
+	}
+	public void setSuccess(boolean success) {
+		this.success = success;
+	}
+}

+ 58 - 0
src/main/java/com/usky/utils/IPUtils.java

@@ -0,0 +1,58 @@
+
+package com.usky.utils;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * IP地址
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+public class IPUtils {
+    private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
+
+    /**
+     * 获取IP地址
+     * <p>
+     * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
+     * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
+     */
+    public static String getIpAddr(HttpServletRequest request) {
+        String ip = null;
+        try {
+            ip = request.getHeader("x-forwarded-for");
+            if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+                ip = request.getHeader("Proxy-Client-IP");
+            }
+            if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+                ip = request.getHeader("WL-Proxy-Client-IP");
+            }
+            if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+                ip = request.getHeader("HTTP_CLIENT_IP");
+            }
+            if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+                ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+            }
+            if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
+                ip = request.getRemoteAddr();
+            }
+        } catch (Exception e) {
+            logger.error("IPUtils ERROR ", e);
+        }
+
+        //使用代理,则获取第一个IP地址
+        if (StringUtils.isEmpty(ip) && ip.length() > 15) {
+            if (ip.indexOf(",") > 0) {
+                ip = ip.substring(0, ip.indexOf(","));
+            }
+        }
+
+        return ip;
+    }
+
+}

+ 53 - 0
src/main/java/com/usky/utils/JsonUtil.java

@@ -0,0 +1,53 @@
+package com.usky.utils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author 我去喂猪了
+ * @version v1.0
+ * @date 2020/9/12 14:35
+ * @description TODO
+ **/
+
+public class JsonUtil {
+
+    private static Pattern linePattern = Pattern.compile("_(\\w)");
+
+    /** 下划线转驼峰 */
+    public static String lineToHump(String str) {
+        str = str.toLowerCase();
+        Matcher matcher = linePattern.matcher(str);
+        StringBuffer sb = new StringBuffer();
+        while (matcher.find()) {
+            matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
+        }
+        matcher.appendTail(sb);
+        return sb.toString();
+    }
+
+    /** 驼峰转下划线(简单写法,效率低于{@link #humpToLine2(String)}) */
+    public static String humpToLine(String str) {
+        return str.replaceAll("[A-Z]", "_$0").toLowerCase();
+    }
+
+    private static Pattern humpPattern = Pattern.compile("[A-Z]");
+
+    /** 驼峰转下划线,效率比上面高 */
+    public static String humpToLine2(String str) {
+        Matcher matcher = humpPattern.matcher(str);
+        StringBuffer sb = new StringBuffer();
+        while (matcher.find()) {
+            matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
+        }
+        matcher.appendTail(sb);
+        return sb.toString();
+    }
+
+    public static void main(String[] args) {
+        String lineToHump = lineToHump("{\"device_code\":\"12321312332313\",\"company_code\":\"\",\"device_name\":\"1223\",\"transmission_mode\":\"1\",\"device_types\":\"3\",\"device_model\":\"6\",\"data\":\"1\",\"device_install\":\"1\",\"device_floor\":\"1\",\"sim\":\"11\",\"manufactor_name\":\"无锡蓝天\",\"installer\":\"1\",\"magnification\":\"\",\"model_corresponding_method\":\"\",\"ports\":\"0\",\"highest_floor\":\"1\",\"lowest_floor\":\"1\",\"top_level_label\":\"0\",\"ownerId\":\"0\",\"device_type\":\"Smoke\",\"is_secure\":\"0\",\"status\":\"1\",\"protocol_type\":\"CoPA\",\"location\":\"黄浦区\",\"model\":\"\",\"psk\":\"c78af7fe1406eaad0898cce15b6e15f1\",\"iot_id\":\"7662fe48-2cdb-467f-869e-dd6a6babf8c4\",\"ownerCode\":\"YT100036000010000001\",\"number\":\"10000001\"}");
+        System.out.println(lineToHump);// fParentNoLeader
+
+    }
+
+}

+ 37 - 0
src/main/java/com/usky/utils/ListUtil.java

@@ -0,0 +1,37 @@
+package com.usky.utils;
+
+import java.util.List;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/2/22 15:41
+ * @description 集合判断工具类
+ **/
+public class ListUtil {
+    /**
+     * 判断集合是否为空
+     * @param list
+     * @return
+     */
+    public static boolean isNotBlank(List list) {
+        if (list == null || list.isEmpty()) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     *
+     * @param list
+     * @return
+     */
+    public static boolean isBlank(List list) {
+        if (list == null || list.isEmpty()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+}

+ 30 - 0
src/main/java/com/usky/utils/LoginResult.java

@@ -0,0 +1,30 @@
+package com.usky.utils;
+
+public class LoginResult {
+	private String V_LOGINNAME;
+	private String V_PASSWORD;
+	private String Result;
+	public LoginResult() {
+		this.Result="";
+		this.V_LOGINNAME="";
+		this.V_PASSWORD= "";
+	}
+	public String getV_LOGINNAME() {
+		return V_LOGINNAME;
+	}
+	public void setV_LOGINNAME(String v_LOGINNAME) {
+		V_LOGINNAME = v_LOGINNAME;
+	}
+	public String getV_PASSWORD() {
+		return V_PASSWORD;
+	}
+	public void setV_PASSWORD(String v_PASSWORD) {
+		V_PASSWORD = v_PASSWORD;
+	}
+	public String getResult() {
+		return Result;
+	}
+	public void setResult(String result) {
+		Result = result;
+	}
+}

+ 39 - 0
src/main/java/com/usky/utils/MD5Util.java

@@ -0,0 +1,39 @@
+package com.usky.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class MD5Util {
+	public final static String MD5(String s){
+		char hexDigits[] ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+		try{
+			byte[] btInput = s.getBytes();
+			MessageDigest mdInst = MessageDigest.getInstance("MD5");
+			mdInst.update(btInput);
+			byte[] md = mdInst.digest();
+			int j = md.length;
+			char str[] = new char[j*2];
+			int k = 0;
+			for(int i=0;i<j;i++){
+				byte byte0 = md[i];
+				str[k++] = hexDigits[byte0 >>> 4 & 0xf];
+				str[k++] = hexDigits[byte0 & 0xf];
+			}
+			return new String(str);
+		} catch (Exception e){
+			return null;
+		}
+	}
+	public static String EncoderByMd5(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException{
+		byte[] secretBytes = null; 
+		MessageDigest md5=MessageDigest.getInstance("MD5");
+		 md5.update(str.getBytes());
+		 secretBytes = md5.digest();
+		 String newstr = new BigInteger(1,secretBytes).toString(16);
+		 for(int i=0;i<32-newstr.length();i++)
+			 newstr = "0"+newstr;
+		 return newstr;
+	}
+}

+ 99 - 0
src/main/java/com/usky/utils/MD5Utils.java

@@ -0,0 +1,99 @@
+package com.usky.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class MD5Utils {
+ 
+    /**
+     * MD5加密字符串(32位大写)
+     *
+     * @param string 需要进行MD5加密的字符串
+     * @return 加密后的字符串(大写)
+     */
+    public static String md5Encrypt32Upper(String string) {
+        byte[] hash;
+        try {
+            //创建一个MD5算法对象,并获得MD5字节数组,16*8=128位
+            hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("Huh, MD5 should be supported?", e);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("Huh, UTF-8 should be supported?", e);
+        }
+ 
+        //转换为十六进制字符串
+        StringBuilder hex = new StringBuilder(hash.length * 2);
+        for (byte b : hash) {
+            if ((b & 0xFF) < 0x10) {hex.append("0");}
+            hex.append(Integer.toHexString(b & 0xFF));
+        }
+        return hex.toString().toUpperCase();
+    }
+ 
+    /**
+     * MD5加密字符串(32位小写)
+     *
+     * @param string 需要进行MD5加密的字符串
+     * @return 加密后的字符串(小写)
+     */
+    public static String md5Encrypt32Lower(String string) {
+        byte[] hash;
+        try {
+            //创建一个MD5算法对象,并获得MD5字节数组,16*8=128位
+            hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("Huh, MD5 should be supported?", e);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("Huh, UTF-8 should be supported?", e);
+        }
+ 
+        //转换为十六进制字符串
+        StringBuilder hex = new StringBuilder(hash.length * 2);
+        for (byte b : hash) {
+            if ((b & 0xFF) < 0x10) {hex.append("0");}
+            hex.append(Integer.toHexString(b & 0xFF));
+        }
+        return hex.toString().toLowerCase();
+    }
+ 
+    /**
+     * 将二进制字节数组转换为十六进制字符串
+     *
+     * @param bytes 二进制字节数组
+     * @return 十六进制字符串
+     */
+    public static String bytesToHex(byte[] bytes) {
+        StringBuffer hexStr = new StringBuffer();
+        int num;
+        for (int i = 0; i < bytes.length; i++) {
+            num = bytes[i];
+            if (num < 0) {
+                num += 256;
+            }
+            if (num < 16) {
+                hexStr.append("0");
+            }
+            hexStr.append(Integer.toHexString(num));
+        }
+        return hexStr.toString().toUpperCase();
+    }
+ 
+    /**
+     * Unicode中文编码转换成字符串
+     */
+    public static String unicodeToString(String str) {
+        Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
+        Matcher matcher = pattern.matcher(str);
+        char ch;
+        while (matcher.find()) {
+            ch = (char) Integer.parseInt(matcher.group(2), 16);
+            str = str.replace(matcher.group(1), ch + "");
+        }
+        return str;
+    }
+
+}

+ 88 - 0
src/main/java/com/usky/utils/MapUtils.java

@@ -0,0 +1,88 @@
+package com.usky.utils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+/**
+ * @author   辅助类
+ **/
+public final class MapUtils {
+
+	/**
+	 * @author
+	 * @para
+	 * @return string
+	 **/
+	public static String getStr(Object obj) {
+		if (obj == null) {
+			return null;
+		} else {
+			return StringUtils.trimToEmpty(obj.toString());
+		}
+	}
+
+	/**
+	 * @author   验证map设定非空字段是否为空
+	 * @param params
+	 *            :目标map,args:校验数组
+	 * @return boolean
+	 **/
+	public static boolean isEmptyMap(Map<String, ?> params, String[] args) {
+		if (params == null || args == null || params.isEmpty() || args.length == 0) {
+			return true;
+		}
+
+		boolean bool = false;
+		for (String arg : args) {
+			if (StringUtils.isBlank(getStr(params.get(arg)))) {
+				bool = true;
+				break;
+			}
+		}
+		return bool;
+	}
+	
+	/**
+	 * @author   判断Map是否为非NULL或者非Empty
+	 * @param map
+	 * @return boolean
+	 * **/
+	public static boolean isNotBlank(Map<String,?> map) {
+		if (map != null && !map.isEmpty()) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	
+	/**
+	 * @author   判断Map是否为NULL或者Empty
+	 * @param map
+	 * @return boolean
+	 * **/
+	public static boolean isBlank(Map<String,?> map) {
+		return !isNotBlank(map);
+	}
+	
+	/**
+	 * @author   验证map设定的value是否全是整形数值
+	 * @param params
+	 *            :目标map,args:校验数组
+	 * @return boolean true 是, false 不是
+	 **/
+	public static boolean isNumericMap(Map<String, ?> params, String[] args) {
+		if (params == null || args == null || params.isEmpty() || args.length == 0) {
+			return false;
+		}
+
+		boolean bool = true;
+		for (String arg : args) {
+			if (!StringUtils.isNumeric(getStr(params.get(arg)))) {
+				bool = false;
+				break;
+			}
+		}
+		return bool;
+	}
+}

+ 164 - 0
src/main/java/com/usky/utils/Page1.java

@@ -0,0 +1,164 @@
+package com.usky.utils;
+
+import java.util.List;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/2/24 9:01
+ * @description TODO
+ **/
+public class Page1<T> {
+    private int pageSize; //每页显示条数
+    private int totalCount; //总条数
+    private int start; //开始条数
+    private int pageNo;//当前页
+    private int totalPages; //总页数
+    private int peopleTotalCount; //人总数
+    private int completeTotalCount; //已完成总数
+    private int failedTotalCount; //审核未通过总数
+    private int notReviewedTotalCount; //未审核总数
+    private int unprocessedTotalCount; //未处理总数
+
+    private List<T> pageList;//数据
+
+    public Page1(int totalCount, Integer pageSize) {
+        if (pageSize == null) {
+            this.pageSize = 20;
+        } else {
+            this.pageSize = pageSize;
+        }
+        this.totalCount = totalCount;
+    }
+
+    /**
+     * 获取下一条
+     *
+     * @return
+     */
+    public int getCurrentPageNo() {
+        return start / pageSize + 1;
+    }
+
+    /**
+     * 是否有下一条
+     *
+     * @return
+     */
+    public boolean getHasNextPage() {
+        return getCurrentPageNo() < totalPages;
+    }
+
+    /**
+     * 当前页是否大于一
+     *
+     * @return
+     */
+    public boolean getHasPavPage() {
+        return getCurrentPageNo() > 1;
+    }
+
+    /**
+     * 获取总页数
+     *
+     * @return
+     */
+    public int getTotalPages() {
+        totalPages = totalCount / pageSize;
+
+        if (totalCount % pageSize != 0) {
+            totalPages++;
+        }
+
+        return totalPages;
+    }
+
+    public int getStart(int pageNo) {
+        this.pageNo = pageNo;
+        if (pageNo < 1) {
+            pageNo = 1;
+        }
+        start = (pageNo - 1) * pageSize;
+        return start;
+    }
+
+    public int getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(int pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public int getTotalCount() {
+        return totalCount;
+    }
+
+    public void setTotalCount(int totalCount) {
+        this.totalCount = totalCount;
+    }
+
+    public void setStart(int start) {
+        this.start = start;
+    }
+
+    public List<T> getPageList() {
+        return pageList;
+    }
+
+    public void setPageList(List<T> pageList) {
+        this.pageList = pageList;
+    }
+
+    public void setTotalPages(int totalPages) {
+        this.totalPages = totalPages;
+    }
+
+    public int getPageNo() {
+        return pageNo;
+    }
+
+    public void setPageNo(int pageNo) {
+        this.pageNo = pageNo;
+    }
+
+    public int getPeopleTotalCount() {
+        return peopleTotalCount;
+    }
+
+    public void setPeopleTotalCount(int peopleTotalCount) {
+        this.peopleTotalCount = peopleTotalCount;
+    }
+
+    public int getCompleteTotalCount() {
+        return completeTotalCount;
+    }
+
+    public void setCompleteTotalCount(int completeTotalCount) {
+        this.completeTotalCount = completeTotalCount;
+    }
+
+    public int getFailedTotalCount() {
+        return failedTotalCount;
+    }
+
+    public void setFailedTotalCount(int failedTotalCount) {
+        this.failedTotalCount = failedTotalCount;
+    }
+
+    public int getNotReviewedTotalCount() {
+        return notReviewedTotalCount;
+    }
+
+    public void setNotReviewedTotalCount(int notReviewedTotalCount) {
+        this.notReviewedTotalCount = notReviewedTotalCount;
+    }
+
+    public int getUnprocessedTotalCount() {
+        return unprocessedTotalCount;
+    }
+
+    public void setUnprocessedTotalCount(int unprocessedTotalCount) {
+        this.unprocessedTotalCount = unprocessedTotalCount;
+    }
+}

+ 33 - 0
src/main/java/com/usky/utils/RequestUtils.java

@@ -0,0 +1,33 @@
+package com.usky.utils;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.context.request.ServletWebRequest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/11/26 9:36
+ * @description TODO
+ **/
+public class RequestUtils {
+
+    public static HttpServletRequest getRequest() {
+
+        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+    }
+    public static HttpServletResponse getResponse(){
+
+        HttpServletResponse resp = ((ServletWebRequest)RequestContextHolder.getRequestAttributes()).getResponse();
+
+
+
+        ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+     //   HttpServletResponse response = attrs.getResponse();
+        HttpServletRequest request = attrs.getRequest();
+
+        return resp;
+    }
+}

+ 16 - 0
src/main/java/com/usky/utils/UUIDUtils.java

@@ -0,0 +1,16 @@
+package com.usky.utils;
+
+import java.util.UUID;
+
+/**
+ * @author laowo
+ * @version v1.0
+ * @date 2020/11/26 9:09
+ * @description TODO
+ **/
+public class UUIDUtils {
+
+    public static String getUUID() {
+        return UUID.randomUUID().toString().replace("-", "").toLowerCase();
+    }
+}

+ 58 - 0
src/main/resources/application.yml

@@ -0,0 +1,58 @@
+server:
+  port: 8081
+spring:
+  datasource:
+    first187:
+      #driver-class-name: com.mysql.cj.jdbc.Driver
+      type: com.alibaba.druid.pool.DruidDataSource
+      initialSize: 2
+      minIdle: 2
+      maxActive: 5
+      maxWait: 60000
+      timeBetweenEvictionRunsMillis: 60000
+      minEvictableIdleTimeMillis: 300000
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      poolPreparedStatements: true
+      aopPatterns: com.usky.Bean.187
+      #   配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+      # filters: stat,wall,slf4j
+      filters: stat,slf4j
+      maxPoolPreparedStatementPerConnectionSize: 20
+      useGlobalDataSourceStat: true
+      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
+      db-type: com.alibaba.druid.pool.DruidDataSource
+      url: jdbc:mysql://192.168.81.131:3306/jdxf?useunicode=true&characterEncoding=utf8&serverTimezone=UTC
+      username: root
+      password: root
+    second118:
+      #driver-class-name: com.mysql.cj.jdbc.Driver
+      type: com.alibaba.druid.pool.DruidDataSource
+      initialSize: 2
+      minIdle: 2
+      maxActive: 5
+      maxWait: 60000
+      timeBetweenEvictionRunsMillis: 60000
+      minEvictableIdleTimeMillis: 300000
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      poolPreparedStatements: true
+      aopPatterns: com.usky.Bean.118
+      #   配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+      # filters: stat,wall,slf4j
+      filters: stat,slf4j
+      maxPoolPreparedStatementPerConnectionSize: 20
+      useGlobalDataSourceStat: true
+      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
+      db-type: com.alibaba.druid.pool.DruidDataSource
+      url: jdbc:mysql://127.0.0.1:3306/jdxf?useunicode=true&characterEncoding=utf8&serverTimezone=UTC
+      username: root
+      password: root
+
+logging:
+  level:
+    root: info

+ 196 - 0
src/main/resources/logback-spring.xml.bak

@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
+<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
+<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
+<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
+<configuration  scan="true" scanPeriod="10 seconds">
+
+    <!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
+
+    <contextName>logback</contextName>
+    <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
+    <property name="log.path" value="D:/nmyslog/nmys" />
+
+    <!-- 彩色日志 -->
+    <!-- 彩色日志依赖的渲染类 -->
+    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
+    <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
+    <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
+    <!-- 彩色日志格式 -->
+    <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
+
+
+    <!--输出到控制台-->
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>info</level>
+        </filter>
+        <encoder>
+            <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
+            <!-- 设置字符集 -->
+            <charset>UTF-8</charset>
+        </encoder>
+    </appender>
+
+
+    <!--输出到文件-->
+
+    <!-- 时间滚动输出 level为 DEBUG 日志 -->
+    <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文件的路径及文件名 -->
+        <file>${log.path}/log_debug.log</file>
+        <!--日志文件输出格式-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset> <!-- 设置字符集 -->
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志归档 -->
+            <fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文件保留天数-->
+            <maxHistory>15</maxHistory>
+        </rollingPolicy>
+        <!-- 此日志文件只记录debug级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>debug</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 时间滚动输出 level为 INFO 日志 -->
+    <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文件的路径及文件名 -->
+        <file>${log.path}/log_info.log</file>
+        <!--日志文件输出格式-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 每天日志归档路径以及格式 -->
+            <fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文件保留天数-->
+            <maxHistory>15</maxHistory>
+        </rollingPolicy>
+        <!-- 此日志文件只记录info级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>info</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 时间滚动输出 level为 WARN 日志 -->
+    <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文件的路径及文件名 -->
+        <file>${log.path}/log_warn.log</file>
+        <!--日志文件输出格式-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset> <!-- 此处设置字符集 -->
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文件保留天数-->
+            <maxHistory>15</maxHistory>
+        </rollingPolicy>
+        <!-- 此日志文件只记录warn级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>warn</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+
+    <!-- 时间滚动输出 level为 ERROR 日志 -->
+    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文件的路径及文件名 -->
+        <file>${log.path}/log_error.log</file>
+        <!--日志文件输出格式-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset> <!-- 此处设置字符集 -->
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文件保留天数-->
+            <maxHistory>15</maxHistory>
+        </rollingPolicy>
+        <!-- 此日志文件只记录ERROR级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!--
+        <logger>用来设置某一个包或者具体的某一个类的日志打印级别、
+        以及指定<appender>。<logger>仅有一个name属性,
+        一个可选的level和一个可选的addtivity属性。
+        name:用来指定受此logger约束的某一个包或者具体的某一个类。
+        level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
+              还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
+              如果未设置此属性,那么当前logger将会继承上级的级别。
+        addtivity:是否向上级logger传递打印信息。默认是true。
+    -->
+    <!--<logger name="org.springframework.web" level="info"/>-->
+    <!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>-->
+    <!--
+        使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
+        第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
+        第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别:
+     -->
+
+
+    <!--
+        root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
+        level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
+        不能设置为INHERITED或者同义词NULL。默认是DEBUG
+        可以包含零个或多个元素,标识这个appender将会添加到这个logger。
+    -->
+
+    <!--开发环境:打印控制台-->
+    <springProfile name="dev">
+        <logger name="com.usky" level="debug"/>
+    </springProfile>
+
+    <root level="debug">
+        <appender-ref ref="CONSOLE" />
+        <appender-ref ref="DEBUG_FILE" />
+        <appender-ref ref="INFO_FILE" />
+        <appender-ref ref="WARN_FILE" />
+        <appender-ref ref="ERROR_FILE" />
+    </root>
+
+    <!--生产环境:输出到文件-->
+    <!--<springProfile name="pro">-->
+    <!--<root level="info">-->
+    <!--<appender-ref ref="CONSOLE" />-->
+    <!--<appender-ref ref="DEBUG_FILE" />-->
+    <!--<appender-ref ref="INFO_FILE" />-->
+    <!--<appender-ref ref="ERROR_FILE" />-->
+    <!--<appender-ref ref="WARN_FILE" />-->
+    <!--</root>-->
+    <!--</springProfile>-->
+
+</configuration>

+ 10 - 0
src/main/resources/templates/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>hello world!</title>
+</head>
+<body>
+
+</body>
+</html>