1
This commit is contained in:
135
common-log-base-starter/common-log-base-starter.iml
Normal file
135
common-log-base-starter/common-log-base-starter.iml
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<webroots />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.3.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.3.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.3.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.3.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.3.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.8.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.8.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.3.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.3.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.37" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.glassfish:jakarta.el:3.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.37" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.8.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.8.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.8.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.8.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.8.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.5.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.3.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.3.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.8.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.83" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:29.0-jre" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.11.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||
<orderEntry type="module" module-name="common-token-starter" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:transmittable-thread-local:2.11.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.auth0:java-jwt:3.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.vividsolutions:jts:1.13" level="project" />
|
||||
<orderEntry type="module" module-name="common-base-starter" />
|
||||
<orderEntry type="library" name="Maven: org.apache.velocity:velocity-engine-core:2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.7.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.caspar-chen:swagger-ui-layer:1.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.7.20" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.belerweb:pinyin4j:2.5.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.4.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.06" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
|
||||
<orderEntry type="module" module-name="common-redis-starter" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.3.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.3.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.3.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.3.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:5.3.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.49.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.49.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.49.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.49.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.49.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.49.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.3.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
|
||||
</component>
|
||||
</module>
|
98
common-log-base-starter/pom.xml
Normal file
98
common-log-base-starter/pom.xml
Normal file
@ -0,0 +1,98 @@
|
||||
<?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">
|
||||
<parent>
|
||||
<groupId>com.mosty</groupId>
|
||||
<artifactId>mosty-common</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-log-base-starter</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring-boot-dependencies.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
<version>${spring-boot-dependencies.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>29.0-jre</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mosty</groupId>
|
||||
<artifactId>common-token-starter</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mosty</groupId>
|
||||
<artifactId>common-base-starter</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.kafka</groupId>-->
|
||||
<!-- <artifactId>kafka-clients</artifactId>-->
|
||||
<!-- <version>2.6.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.kafka</groupId>-->
|
||||
<!-- <artifactId>spring-kafka</artifactId>-->
|
||||
<!-- <version>2.6.6</version>-->
|
||||
<!-- <scope>compile</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>mosty-nexus-releases</id>
|
||||
<name>release version</name>
|
||||
<url>http://47.108.232.77:8181/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>mosty-nexus-snapshots</id>
|
||||
<name>snapshots version</name>
|
||||
<url>http://47.108.232.77:8181/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,219 @@
|
||||
package com.mosty.operation.log;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
//import com.github.pagehelper.PageHelper;
|
||||
//import com.github.pagehelper.PageInfo;
|
||||
//import com.ruoyi.common.core.domain.AjaxResult;
|
||||
//import com.ruoyi.common.core.domain.AjaxResult.Type;
|
||||
//import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
//import com.ruoyi.common.core.page.PageDomain;
|
||||
//import com.ruoyi.common.core.page.TableDataInfo;
|
||||
//import com.ruoyi.common.core.page.TableSupport;
|
||||
//import com.ruoyi.common.utils.DateUtils;
|
||||
//import com.ruoyi.common.utils.PageUtils;
|
||||
//import com.ruoyi.common.utils.ServletUtils;
|
||||
//import com.ruoyi.common.utils.ShiroUtils;
|
||||
//import com.ruoyi.common.utils.StringUtils;
|
||||
//import com.ruoyi.common.utils.sql.SqlUtil;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Slf4j
|
||||
public class BaseController {
|
||||
|
||||
/**
|
||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
// Date 类型转换
|
||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
try {
|
||||
setValue(DateUtils.parseDate(text));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
// protected void startPage()
|
||||
// {
|
||||
// PageUtils.startPage();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 设置请求排序数据
|
||||
// */
|
||||
// protected void startOrderBy()
|
||||
// {
|
||||
// PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
// if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
||||
// {
|
||||
// String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
// PageHelper.orderBy(orderBy);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取request
|
||||
// */
|
||||
// public HttpServletRequest getRequest()
|
||||
// {
|
||||
// return ServletUtils.getRequest();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取response
|
||||
// */
|
||||
// public HttpServletResponse getResponse()
|
||||
// {
|
||||
// return ServletUtils.getResponse();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取session
|
||||
// */
|
||||
// public HttpSession getSession()
|
||||
// {
|
||||
// return getRequest().getSession();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 响应请求分页数据
|
||||
// */
|
||||
// @SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
// protected TableDataInfo getDataTable(List<?> list)
|
||||
// {
|
||||
// TableDataInfo rspData = new TableDataInfo();
|
||||
// rspData.setCode(0);
|
||||
// rspData.setRows(list);
|
||||
// rspData.setTotal(new PageInfo(list).getTotal());
|
||||
// return rspData;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 响应返回结果
|
||||
// *
|
||||
// * @param rows 影响行数
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// protected AjaxResult toAjax(int rows)
|
||||
// {
|
||||
// return rows > 0 ? success() : error();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 响应返回结果
|
||||
// *
|
||||
// * @param result 结果
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// protected AjaxResult toAjax(boolean result)
|
||||
// {
|
||||
// return result ? success() : error();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 返回成功
|
||||
// */
|
||||
// public AjaxResult success()
|
||||
// {
|
||||
// return AjaxResult.success();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 返回失败消息
|
||||
// */
|
||||
// public AjaxResult error()
|
||||
// {
|
||||
// return AjaxResult.error();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 返回成功消息
|
||||
// */
|
||||
// public AjaxResult success(String message)
|
||||
// {
|
||||
// return AjaxResult.success(message);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 返回成功数据
|
||||
// */
|
||||
// public static AjaxResult success(Object data)
|
||||
// {
|
||||
// return AjaxResult.success("操作成功", data);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 返回失败消息
|
||||
// */
|
||||
// public AjaxResult error(String message)
|
||||
// {
|
||||
// return AjaxResult.error(message);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 返回错误码消息
|
||||
// */
|
||||
// public AjaxResult error(Type type, String message)
|
||||
// {
|
||||
// return new AjaxResult(type, message);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 页面跳转
|
||||
// */
|
||||
// public String redirect(String url)
|
||||
// {
|
||||
// return StringUtils.format("redirect:{}", url);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取用户缓存信息
|
||||
// */
|
||||
// public SysUser getSysUser()
|
||||
// {
|
||||
// return ShiroUtils.getSysUser();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 设置用户缓存信息
|
||||
// */
|
||||
// public void setSysUser(SysUser user)
|
||||
// {
|
||||
// ShiroUtils.setSysUser(user);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取登录用户id
|
||||
// */
|
||||
// public Long getUserId()
|
||||
// {
|
||||
// return getSysUser().getUserId();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取登录用户名
|
||||
// */
|
||||
// public String getLoginName()
|
||||
// {
|
||||
// return getSysUser().getLoginName();
|
||||
// }
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.mosty.operation.log;
|
||||
|
||||
/**
|
||||
* 操作状态
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public enum BusinessStatus {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS,
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAIL,
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
package com.mosty.operation.log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.support.spring.PropertyPreFilters;
|
||||
import com.mosty.common.base.entity.log.Log;
|
||||
import com.mosty.common.base.entity.log.SysOperLog;
|
||||
import com.mosty.common.base.threadpool.SimpleThreadPool;
|
||||
import com.mosty.common.base.util.IpUtil;
|
||||
import com.mosty.common.base.util.ServletUtils;
|
||||
import com.mosty.common.base.util.SpringIocContext;
|
||||
import com.mosty.common.base.util.StringUtils;
|
||||
import com.mosty.common.token.JWTUtil;
|
||||
import com.mosty.common.token.UserInfo;
|
||||
import com.mosty.operation.log.service.SysOperLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.AfterThrowing;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mosty.common.base.constant.SystemConfigConstants.TOKEN_HEADER;
|
||||
import static com.mosty.common.base.entity.log.LogConst.LOG_THREAD_POOL;
|
||||
|
||||
|
||||
/**
|
||||
* 操作日志记录处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Slf4j
|
||||
@Aspect
|
||||
@Component
|
||||
public class LogAspect extends LogSaveStrategy {
|
||||
|
||||
// 排除敏感属性字段
|
||||
public static final String[] EXCLUDE_PROPERTIES = {"password", "oldPassword", "newPassword", "confirmPassword"};
|
||||
|
||||
// 配置织入点
|
||||
@Pointcut("@annotation(com.mosty.common.base.entity.log.Log)")
|
||||
public void logPointCut() {
|
||||
}
|
||||
|
||||
// 处理完请求后执行
|
||||
@AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
|
||||
public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) {
|
||||
handleLog(joinPoint, controllerLog, null, jsonResult);
|
||||
}
|
||||
|
||||
// 拦截异常操作
|
||||
@AfterThrowing(value = "@annotation(controllerLog)", throwing = "e")
|
||||
public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) {
|
||||
handleLog(joinPoint, controllerLog, e, null);
|
||||
}
|
||||
|
||||
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
|
||||
try {
|
||||
String token = ServletUtils.getRequest().getHeader(TOKEN_HEADER);
|
||||
// 获取当前的用户 从header中获取
|
||||
UserInfo userInfo = JWTUtil.getUserInfo(token);
|
||||
String ipAddress = IpUtil.getIpAddress(ServletUtils.getRequest());
|
||||
// *========数据库日志=========*//
|
||||
SysOperLog operLog = new SysOperLog();
|
||||
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
||||
// 请求的地址
|
||||
operLog.setOperIp(ipAddress);
|
||||
String url = ServletUtils.getRequest().getRequestURI();
|
||||
operLog.setOperUrl(url);
|
||||
// 添加服务名称
|
||||
if (url != null && url.length() >= 11) {
|
||||
String[] s = url.split("/");
|
||||
if (s.length >= 2 && s[1].contains("mosty-")) {
|
||||
operLog.setMkmc(s[1]);
|
||||
}
|
||||
}
|
||||
if (userInfo != null) {
|
||||
operLog.setOperName(userInfo.getUserLoginName());
|
||||
operLog.setOperUserId(String.valueOf(userInfo.getUserId()));
|
||||
operLog.setOperSfzh(userInfo.getIdEntityCard());
|
||||
if (StringUtils.isNotNull(userInfo.getDeptId())
|
||||
&& StringUtils.isNotEmpty(userInfo.getDeptName())) {
|
||||
operLog.setSsbm(userInfo.getDeptName());
|
||||
operLog.setSsbmid(String.valueOf(userInfo.getDeptId()));
|
||||
operLog.setSsbmdm(userInfo.getDeptCode());
|
||||
}
|
||||
}
|
||||
if (e != null) {
|
||||
operLog.setStatus(BusinessStatus.FAIL.ordinal());
|
||||
operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
|
||||
}
|
||||
// 设置方法名称
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = joinPoint.getSignature().getName();
|
||||
operLog.setMethod(className + "." + methodName + "()");
|
||||
// 设置请求方式
|
||||
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
||||
// 处理设置注解上的参数
|
||||
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
||||
// 保存数据库
|
||||
SimpleThreadPool.execute(LOG_THREAD_POOL, () ->
|
||||
SpringIocContext.getBean(SysOperLogService.class).insertOperlog(operLog));
|
||||
} catch (Exception exp) {
|
||||
// 记录本地异常日志
|
||||
log.error("==前置通知异常==");
|
||||
log.error("异常信息:{}", exp.getMessage());
|
||||
exp.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注解中对方法的描述信息 用于Controller层注解
|
||||
*
|
||||
* @param log 日志
|
||||
* @param operLog 操作日志
|
||||
* @throws Exception
|
||||
*/
|
||||
public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception {
|
||||
// 设置action动作
|
||||
operLog.setBusinessType(log.businessType().ordinal());
|
||||
// 设置标题
|
||||
operLog.setTitle(log.title());
|
||||
// 设置操作人类别
|
||||
operLog.setOperatorType(log.operatorType().ordinal());
|
||||
// 是否需要保存request,参数和值
|
||||
if (log.isSaveRequestData()) {
|
||||
// 获取参数的信息,传入到数据库中。
|
||||
setRequestValue(joinPoint, operLog);
|
||||
}
|
||||
// 是否需要保存response,参数和值
|
||||
if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) {
|
||||
operLog.setJsonResult(StringUtils.substring(JSONObject.toJSONString(jsonResult), 0, 2000));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求的参数,放到log中
|
||||
*
|
||||
* @param operLog 操作日志
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception {
|
||||
Map<String, String[]> map = ServletUtils.getRequest().getParameterMap();
|
||||
if (StringUtils.isNotEmpty(map)) {
|
||||
String params = JSONObject.toJSONString(map, excludePropertyPreFilter());
|
||||
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
||||
} else {
|
||||
Object args = joinPoint.getArgs();
|
||||
if (StringUtils.isNotNull(args)) {
|
||||
String params = argsArrayToString(joinPoint.getArgs());
|
||||
operLog.setOperParam(StringUtils.substring(params, 0, 2000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略敏感属性
|
||||
*/
|
||||
public PropertyPreFilters.MySimplePropertyPreFilter excludePropertyPreFilter() {
|
||||
return new PropertyPreFilters().addFilter().addExcludes(EXCLUDE_PROPERTIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数拼装
|
||||
*/
|
||||
private String argsArrayToString(Object[] paramsArray) {
|
||||
StringBuilder params = new StringBuilder();
|
||||
if (paramsArray != null && paramsArray.length > 0) {
|
||||
for (Object o : paramsArray) {
|
||||
if (StringUtils.isNotNull(o) && !isFilterObject(o)) {
|
||||
try {
|
||||
Object jsonObj = JSONObject.toJSONString(o, excludePropertyPreFilter());
|
||||
params.append(jsonObj.toString()).append(" ");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return params.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否需要过滤的对象。
|
||||
*
|
||||
* @param o 对象信息。
|
||||
* @return 如果是需要过滤的对象,则返回true;否则返回false。
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public boolean isFilterObject(final Object o) {
|
||||
Class<?> clazz = o.getClass();
|
||||
if (clazz.isArray()) {
|
||||
return clazz.getComponentType().isAssignableFrom(MultipartFile.class);
|
||||
} else if (Collection.class.isAssignableFrom(clazz)) {
|
||||
Collection collection = (Collection) o;
|
||||
for (Object value : collection) {
|
||||
return value instanceof MultipartFile;
|
||||
}
|
||||
} else if (Map.class.isAssignableFrom(clazz)) {
|
||||
Map map = (Map) o;
|
||||
for (Object value : map.entrySet()) {
|
||||
Map.Entry entry = (Map.Entry) value;
|
||||
return entry.getValue() instanceof MultipartFile;
|
||||
}
|
||||
}
|
||||
return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
|
||||
|| o instanceof BindingResult;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.mosty.operation.log;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class LogSaveStrategy implements ApplicationContextAware {
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String applicationName;
|
||||
|
||||
/** ioc 容器 */
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
private static final Set<String> NATIVE_APP_NAME = Collections.unmodifiableSet(Sets.newHashSet("mosty", "mosty-base"));
|
||||
|
||||
// private final FeignClient;
|
||||
|
||||
|
||||
private Boolean nativeInvoke() {
|
||||
return NATIVE_APP_NAME.contains(applicationName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
|
||||
LogSaveStrategy.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
protected void saveOperationLog() {
|
||||
if (nativeInvoke()) {
|
||||
|
||||
}
|
||||
// remoteFeign();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.mosty.operation.log;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 代码生成自动装配
|
||||
* @author kevin
|
||||
* @date 2022/2/3 3:34 PM
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = "com.mosty.operation")
|
||||
@MapperScan("com.mosty.operation.log.mapper")
|
||||
public class OperationLogBaseAutoConfiguration {
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package com.mosty.operation.log.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.entity.log.BusinessType;
|
||||
import com.mosty.common.base.entity.log.Log;
|
||||
import com.mosty.common.base.entity.log.SysOperLog;
|
||||
import com.mosty.common.token.JwtSysUser;
|
||||
import com.mosty.operation.log.BaseController;
|
||||
import com.mosty.operation.log.entity.DeleteListVO;
|
||||
import com.mosty.operation.log.entity.VO.OperlogPage;
|
||||
import com.mosty.operation.log.service.SysOperLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@Api(tags = "操作日志")
|
||||
@RequestMapping("/monitor/operlog")
|
||||
public class SysOperlogController {
|
||||
|
||||
|
||||
private final SysOperLogService operLogService;
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("查询操作日志列表")
|
||||
@Log(title = "查询操作日志详情", businessType = BusinessType.OTHER)
|
||||
public ResponseResult<IPage<SysOperLog>> list(@RequestBody OperlogPage operLog) {
|
||||
IPage<SysOperLog> sysOperLogPage = operLogService.selectByPage(operLog);
|
||||
return ResponseResult.success(sysOperLogPage);
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "删除操作日志", businessType = BusinessType.DELETE)
|
||||
@ApiOperation("查询操作日志详情")
|
||||
@PostMapping("/remove")
|
||||
public ResponseResult<Boolean> remove(@RequestBody DeleteListVO deleteListVO) {
|
||||
operLogService.deleteOperLogByIds(deleteListVO.getIds());
|
||||
return ResponseResult.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@ApiOperation("查询操作日志详情")
|
||||
@Log(title = "查询操作日志详情", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/detail/{id}")
|
||||
public ResponseResult<SysOperLog> detail(@PathVariable("id") Long id) {
|
||||
SysOperLog log = operLogService.getOne(new LambdaQueryWrapper<SysOperLog>()
|
||||
.eq(SysOperLog::getOperId, id));
|
||||
return ResponseResult.success(log);
|
||||
}
|
||||
|
||||
@Log(title = "清空操作日志", businessType = BusinessType.CLEAN)
|
||||
@ApiOperation("清空操作日志")
|
||||
@PostMapping("/clean")
|
||||
public ResponseResult<Boolean> clean() {
|
||||
operLogService.cleanOperLog();
|
||||
return ResponseResult.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Log(title = "系统使用情况统计数字", businessType = BusinessType.OTHER)
|
||||
@ApiOperation("系统使用情况统计数字")
|
||||
@JwtSysUser
|
||||
@PostMapping("/statistics")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "1.今天 2.7天 3.30天 4.90天", required = true, dataType = "String"),
|
||||
})
|
||||
public ResponseResult<Map<String,Object>> statistics(String type) {
|
||||
return ResponseResult.success(operLogService.statistics(type));
|
||||
}
|
||||
|
||||
@Log(title = "部门排名统计TOP10", businessType = BusinessType.OTHER)
|
||||
@ApiOperation("部门排名统计TOP10")
|
||||
@JwtSysUser
|
||||
@PostMapping("/bmStatistics")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "1.今天 2.7天 3.30天 4.90天", required = true, dataType = "String"),
|
||||
})
|
||||
public ResponseResult<List<Map<String,Object>>> bmStatistics(String type) {
|
||||
return ResponseResult.success(operLogService.bmStatistics(type));
|
||||
}
|
||||
|
||||
@Log(title = "人员排名统计TOP10", businessType = BusinessType.OTHER)
|
||||
@ApiOperation("人员排名统计TOP10")
|
||||
@JwtSysUser
|
||||
@PostMapping("/ryStatistics")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "1.今天 2.7天 3.30天 4.90天", required = true, dataType = "String"),
|
||||
})
|
||||
public ResponseResult<List<Map<String,Object>>> ryStatistics(String type) {
|
||||
return ResponseResult.success(operLogService.ryStatistics(type));
|
||||
}
|
||||
|
||||
@Log(title = "模块排名统计", businessType = BusinessType.OTHER)
|
||||
@ApiOperation("模块排名统计")
|
||||
@JwtSysUser
|
||||
@PostMapping("/mkStatistics")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "1.今天 2.7天 3.30天 4.90天", required = true, dataType = "String"),
|
||||
})
|
||||
public ResponseResult<List<Map<String,Object>>> mkStatistics(String type) {
|
||||
return ResponseResult.success(operLogService.mkStatistics(type));
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.mosty.operation.log.controller.provider;
|
||||
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.entity.log.SysOperLog;
|
||||
import com.mosty.operation.log.BaseController;
|
||||
import com.mosty.operation.log.service.SysOperLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "操作日志 for Feign调用")
|
||||
@RequestMapping("/provider/monitor/operateLog")
|
||||
public class SysOperlogProviderController extends BaseController {
|
||||
|
||||
private String prefix = "monitor/operlog";
|
||||
|
||||
@Autowired
|
||||
private SysOperLogService operLogService;
|
||||
|
||||
// 添加操作日志
|
||||
@PostMapping("/save")
|
||||
public ResponseResult<Boolean> save(@RequestBody SysOperLog sysOperLog) {
|
||||
operLogService.insertOperlog(sysOperLog);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String operlog(){
|
||||
return prefix + "/operlog";
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
package com.mosty.operation.log.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class BaseEntity implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 搜索值 */
|
||||
private String searchValue;
|
||||
|
||||
/** 创建者 */
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 请求参数 */
|
||||
private Map<String, Object> params;
|
||||
|
||||
public String getSearchValue()
|
||||
{
|
||||
return searchValue;
|
||||
}
|
||||
|
||||
public void setSearchValue(String searchValue)
|
||||
{
|
||||
this.searchValue = searchValue;
|
||||
}
|
||||
|
||||
public String getCreateBy()
|
||||
{
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy)
|
||||
{
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy()
|
||||
{
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy)
|
||||
{
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime()
|
||||
{
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime)
|
||||
{
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getRemark()
|
||||
{
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark)
|
||||
{
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParams()
|
||||
{
|
||||
if (params == null)
|
||||
{
|
||||
params = new HashMap<>();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Object> params)
|
||||
{
|
||||
this.params = params;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.mosty.operation.log.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="DeleteListVO", description="DeleteList批量")
|
||||
public class DeleteListVO {
|
||||
/**
|
||||
* ID集合
|
||||
*/
|
||||
private List<Long> ids;
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
package com.mosty.operation.log.entity;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 自定义导出Excel数据注解
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Excel
|
||||
{
|
||||
/**
|
||||
* 导出时在excel中排序
|
||||
*/
|
||||
public int sort() default Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* 导出到Excel中的名字.
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 日期格式, 如: yyyy-MM-dd
|
||||
*/
|
||||
public String dateFormat() default "";
|
||||
|
||||
/**
|
||||
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||
*/
|
||||
public String dictType() default "";
|
||||
|
||||
/**
|
||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||
*/
|
||||
public String readConverterExp() default "";
|
||||
|
||||
/**
|
||||
* 分隔符,读取字符串组内容
|
||||
*/
|
||||
public String separator() default ",";
|
||||
|
||||
/**
|
||||
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||
*/
|
||||
public int scale() default -1;
|
||||
|
||||
/**
|
||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||
*/
|
||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||
|
||||
/**
|
||||
* 导出类型(0数字 1字符串)
|
||||
*/
|
||||
public ColumnType cellType() default ColumnType.STRING;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的高度 单位为字符
|
||||
*/
|
||||
public double height() default 14;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的宽 单位为字符
|
||||
*/
|
||||
public double width() default 16;
|
||||
|
||||
/**
|
||||
* 文字后缀,如% 90 变成90%
|
||||
*/
|
||||
public String suffix() default "";
|
||||
|
||||
/**
|
||||
* 当值为空时,字段的默认值
|
||||
*/
|
||||
public String defaultValue() default "";
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
public String prompt() default "";
|
||||
|
||||
/**
|
||||
* 设置只能选择不能输入的列内容.
|
||||
*/
|
||||
public String[] combo() default {};
|
||||
|
||||
/**
|
||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||
*/
|
||||
public boolean isExport() default true;
|
||||
|
||||
/**
|
||||
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
||||
*/
|
||||
public String targetAttr() default "";
|
||||
|
||||
/**
|
||||
* 是否自动统计数据,在最后追加一行统计数据总和
|
||||
*/
|
||||
public boolean isStatistics() default false;
|
||||
|
||||
/**
|
||||
* 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
|
||||
*/
|
||||
public Align align() default Align.AUTO;
|
||||
|
||||
/**
|
||||
* 自定义数据处理器
|
||||
*/
|
||||
public Class<?> handler() default ExcelHandlerAdapter.class;
|
||||
|
||||
/**
|
||||
* 自定义数据处理器参数
|
||||
*/
|
||||
public String[] args() default {};
|
||||
|
||||
public enum Align
|
||||
{
|
||||
AUTO(0), LEFT(1), CENTER(2), RIGHT(3);
|
||||
private final int value;
|
||||
|
||||
Align(int value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||
*/
|
||||
Type type() default Type.ALL;
|
||||
|
||||
public enum Type
|
||||
{
|
||||
ALL(0), EXPORT(1), IMPORT(2);
|
||||
private final int value;
|
||||
|
||||
Type(int value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ColumnType
|
||||
{
|
||||
NUMERIC(0), STRING(1), IMAGE(2);
|
||||
private final int value;
|
||||
|
||||
ColumnType(int value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.mosty.operation.log.entity;
|
||||
|
||||
/**
|
||||
* Excel数据格式处理适配器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ExcelHandlerAdapter
|
||||
{
|
||||
/**
|
||||
* 格式化
|
||||
*
|
||||
* @param value 单元格数据值
|
||||
* @param args excel注解args参数组
|
||||
*
|
||||
* @return 处理后的值
|
||||
*/
|
||||
Object format(Object value, String[] args);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.mosty.operation.log.entity;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Excel注解集
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Excels
|
||||
{
|
||||
Excel[] value();
|
||||
}
|
@ -0,0 +1,377 @@
|
||||
package com.mosty.operation.log.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户对象 sys_user
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysUser extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用户ID */
|
||||
@Excel(name = "用户序号", cellType = Excel.ColumnType.NUMERIC, prompt = "用户编号")
|
||||
private Long userId;
|
||||
|
||||
/** 部门ID */
|
||||
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
|
||||
private Long deptId;
|
||||
|
||||
/** 部门父ID */
|
||||
private Long parentId;
|
||||
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
/** 登录名称 */
|
||||
@Excel(name = "登录名称")
|
||||
private String loginName;
|
||||
|
||||
/** 用户名称 */
|
||||
@Excel(name = "用户名称")
|
||||
private String userName;
|
||||
|
||||
/** 用户类型 */
|
||||
private String userType;
|
||||
|
||||
/** 用户邮箱 */
|
||||
@Excel(name = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
/** 手机号码 */
|
||||
@Excel(name = "手机号码")
|
||||
private String phonenumber;
|
||||
|
||||
/** 用户性别 */
|
||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||
private String sex;
|
||||
|
||||
/** 用户头像 */
|
||||
private String avatar;
|
||||
|
||||
/** 密码 */
|
||||
private String password;
|
||||
|
||||
/** 盐加密 */
|
||||
private String salt;
|
||||
|
||||
/** 帐号状态(0正常 1停用) */
|
||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
/** 最后登录IP */
|
||||
@Excel(name = "最后登录IP", type = Excel.Type.EXPORT)
|
||||
private String loginIp;
|
||||
|
||||
/** 最后登录时间 */
|
||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
|
||||
private Date loginDate;
|
||||
|
||||
/** 密码最后更新时间 */
|
||||
private Date pwdUpdateDate;
|
||||
|
||||
/** 部门对象 */
|
||||
@Excels({
|
||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Excel.Type.EXPORT),
|
||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT)
|
||||
})
|
||||
// private SysDept dept;
|
||||
//
|
||||
// private List<SysRole> roles;
|
||||
|
||||
/** 角色组 */
|
||||
private Long[] roleIds;
|
||||
|
||||
/** 岗位组 */
|
||||
private Long[] postIds;
|
||||
|
||||
public SysUser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SysUser(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public boolean isAdmin()
|
||||
{
|
||||
return isAdmin(this.userId);
|
||||
}
|
||||
|
||||
public static boolean isAdmin(Long userId)
|
||||
{
|
||||
return userId != null && 1L == userId;
|
||||
}
|
||||
|
||||
public Long getDeptId()
|
||||
{
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId)
|
||||
{
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getRoleId()
|
||||
{
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId)
|
||||
{
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
// @Xss(message = "登录账号不能包含脚本字符")
|
||||
// @NotBlank(message = "登录账号不能为空")
|
||||
// @Size(min = 0, max = 30, message = "登录账号长度不能超过30个字符")
|
||||
public String getLoginName()
|
||||
{
|
||||
return loginName;
|
||||
}
|
||||
|
||||
public void setLoginName(String loginName)
|
||||
{
|
||||
this.loginName = loginName;
|
||||
}
|
||||
|
||||
// @Xss(message = "用户昵称不能包含脚本字符")
|
||||
// @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
public String getUserName()
|
||||
{
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName)
|
||||
{
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserType()
|
||||
{
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(String userType)
|
||||
{
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
// @Email(message = "邮箱格式不正确")
|
||||
// @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
// @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
|
||||
public String getPhonenumber()
|
||||
{
|
||||
return phonenumber;
|
||||
}
|
||||
|
||||
public void setPhonenumber(String phonenumber)
|
||||
{
|
||||
this.phonenumber = phonenumber;
|
||||
}
|
||||
|
||||
public String getSex()
|
||||
{
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex)
|
||||
{
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getAvatar()
|
||||
{
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar)
|
||||
{
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSalt()
|
||||
{
|
||||
return salt;
|
||||
}
|
||||
|
||||
public void setSalt(String salt)
|
||||
{
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getLoginIp()
|
||||
{
|
||||
return loginIp;
|
||||
}
|
||||
|
||||
public void setLoginIp(String loginIp)
|
||||
{
|
||||
this.loginIp = loginIp;
|
||||
}
|
||||
|
||||
public Date getLoginDate()
|
||||
{
|
||||
return loginDate;
|
||||
}
|
||||
|
||||
public void setLoginDate(Date loginDate)
|
||||
{
|
||||
this.loginDate = loginDate;
|
||||
}
|
||||
|
||||
public Date getPwdUpdateDate()
|
||||
{
|
||||
return pwdUpdateDate;
|
||||
}
|
||||
|
||||
public void setPwdUpdateDate(Date pwdUpdateDate)
|
||||
{
|
||||
this.pwdUpdateDate = pwdUpdateDate;
|
||||
}
|
||||
|
||||
// public SysDept getDept()
|
||||
// {
|
||||
// if (dept == null)
|
||||
// {
|
||||
// dept = new SysDept();
|
||||
// }
|
||||
// return dept;
|
||||
// }
|
||||
//
|
||||
// public void setDept(SysDept dept)
|
||||
// {
|
||||
// this.dept = dept;
|
||||
// }
|
||||
//
|
||||
// public List<SysRole> getRoles()
|
||||
// {
|
||||
// return roles;
|
||||
// }
|
||||
//
|
||||
// public void setRoles(List<SysRole> roles)
|
||||
// {
|
||||
// this.roles = roles;
|
||||
// }
|
||||
|
||||
public Long[] getRoleIds()
|
||||
{
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
public void setRoleIds(Long[] roleIds)
|
||||
{
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
|
||||
public Long[] getPostIds()
|
||||
{
|
||||
return postIds;
|
||||
}
|
||||
|
||||
public void setPostIds(Long[] postIds)
|
||||
{
|
||||
this.postIds = postIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("userId", getUserId())
|
||||
.append("deptId", getDeptId())
|
||||
.append("loginName", getLoginName())
|
||||
.append("userName", getUserName())
|
||||
.append("userType", getUserType())
|
||||
.append("email", getEmail())
|
||||
.append("phonenumber", getPhonenumber())
|
||||
.append("sex", getSex())
|
||||
.append("avatar", getAvatar())
|
||||
.append("password", getPassword())
|
||||
.append("salt", getSalt())
|
||||
.append("status", getStatus())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("loginIp", getLoginIp())
|
||||
.append("loginDate", getLoginDate())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
// .append("dept", getDept())
|
||||
// .append("roles", getRoles())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.mosty.operation.log.entity.VO;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mosty.common.base.entity.log.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OperlogPage extends Page {
|
||||
|
||||
/**
|
||||
* 操作模块
|
||||
*/
|
||||
@ApiModelProperty(value = "操作模块")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 操作人员
|
||||
*/
|
||||
@ApiModelProperty(value = "操作人员")
|
||||
private String operName;
|
||||
|
||||
/**
|
||||
* 业务类型(0其它 1新增 2修改 3删除)
|
||||
*/
|
||||
@ApiModelProperty(value = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据")
|
||||
private Integer businessType;
|
||||
|
||||
/**
|
||||
* 操作状态(0正常 1异常)
|
||||
*/
|
||||
@ApiModelProperty(value = "状态 0=正常,1=异常")
|
||||
private Integer status;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
package com.mosty.operation.log.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.common.base.entity.log.SysOperLog;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 操作日志 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysOperLogMapper extends BaseMapper<SysOperLog> {
|
||||
|
||||
// 新增操作日志
|
||||
void insertOperlog(SysOperLog operLog);
|
||||
|
||||
// 查询系统操作日志集合
|
||||
List<SysOperLog> selectOperLogList(SysOperLog operLog);
|
||||
|
||||
// 批量删除系统操作日志
|
||||
int deleteOperLogByIds(String[] ids);
|
||||
|
||||
// 查询操作日志详细
|
||||
SysOperLog selectOperLogById(Long operId);
|
||||
|
||||
// 清空操作日志
|
||||
void cleanOperLog();
|
||||
|
||||
// 查询使用次数
|
||||
int getSycs(@Param("kssj") String kssj,
|
||||
@Param("jssj") String jssj,
|
||||
@Param("useSql") String useSql,
|
||||
@Param("status") String status);
|
||||
|
||||
// 查询访问人数
|
||||
int getFwrs(@Param("kssj") String kssj,
|
||||
@Param("jssj") String jssj,
|
||||
@Param("useSql") String useSql);
|
||||
|
||||
// 部门排名统计
|
||||
List<Map<String, Object>> bmStatistics(@Param("kssj") String kssj,
|
||||
@Param("jssj") String jssj,
|
||||
@Param("aUseSql") String aUseSql,
|
||||
@Param("bUseSql") String bUseSql);
|
||||
|
||||
// 人员排名统计
|
||||
List<Map<String, Object>> ryStatistics(@Param("kssj") String kssj,
|
||||
@Param("jssj") String jssj,
|
||||
@Param("aUseSql") String aUseSql,
|
||||
@Param("bUseSql") String bUseSql);
|
||||
|
||||
// 模块排名统计
|
||||
List<Map<String, Object>> mkStatistics(@Param("kssj") String kssj,
|
||||
@Param("jssj") String jssj,
|
||||
@Param("aUseSql") String aUseSql,
|
||||
@Param("bUseSql") String bUseSql);
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.mosty.operation.log.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mosty.common.base.entity.log.SysOperLog;
|
||||
import com.mosty.operation.log.entity.VO.OperlogPage;
|
||||
import com.mosty.operation.log.mapper.SysOperLogMapper;
|
||||
import com.mosty.operation.log.util.Convert;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 操作日志 服务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public interface SysOperLogService extends IService<SysOperLog> {
|
||||
|
||||
// 新增操作日志
|
||||
void insertOperlog(SysOperLog operLog);
|
||||
|
||||
// 查询系统操作日志集合
|
||||
List<SysOperLog> selectOperLogList(SysOperLog operLog);
|
||||
|
||||
// 批量删除系统操作日志
|
||||
void deleteOperLogByIds(List<Long> ids);
|
||||
|
||||
// 查询操作日志详细
|
||||
SysOperLog selectOperLogById(Long operId);
|
||||
|
||||
// 清空操作日志
|
||||
void cleanOperLog();
|
||||
|
||||
//分页查询
|
||||
IPage<SysOperLog> selectByPage(OperlogPage operLog);
|
||||
|
||||
// 系统使用情况统计数字
|
||||
Map<String, Object> statistics(String type);
|
||||
|
||||
// 部门排名统计TOP10
|
||||
List<Map<String, Object>> bmStatistics(String type);
|
||||
|
||||
// 人员排名统计TOP10
|
||||
List<Map<String, Object>> ryStatistics(String type);
|
||||
|
||||
// 模块排名统计
|
||||
List<Map<String, Object>> mkStatistics(String type);
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
package com.mosty.operation.log.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.common.base.entity.log.SysOperLog;
|
||||
import com.mosty.common.base.util.DateUtils;
|
||||
import com.mosty.common.token.UserInfo;
|
||||
import com.mosty.common.token.UserInfoManager;
|
||||
import com.mosty.common.util.PermissionsUtil;
|
||||
import com.mosty.operation.log.entity.VO.OperlogPage;
|
||||
import com.mosty.operation.log.mapper.SysOperLogMapper;
|
||||
import com.mosty.operation.log.service.SysOperLogService;
|
||||
import com.mosty.operation.log.util.Convert;
|
||||
import org.apache.catalina.User;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 操作日志 服务层处理
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog>
|
||||
implements SysOperLogService {
|
||||
|
||||
@Resource
|
||||
private SysOperLogMapper operLogMapper;
|
||||
|
||||
// 新增操作日志
|
||||
@Override
|
||||
public void insertOperlog(SysOperLog operLog) {
|
||||
if (operLog.getOperTime() == null) {
|
||||
operLog.setOperTime(new Date());
|
||||
}
|
||||
operLogMapper.insertOperlog(operLog);
|
||||
}
|
||||
|
||||
// 查询系统操作日志集合
|
||||
@Override
|
||||
public List<SysOperLog> selectOperLogList(SysOperLog operLog) {
|
||||
return operLogMapper.selectOperLogList(operLog);
|
||||
}
|
||||
|
||||
// 批量删除系统操作日志
|
||||
@Override
|
||||
public void deleteOperLogByIds(List<Long> ids) {
|
||||
operLogMapper.delete(new LambdaQueryWrapper<SysOperLog>()
|
||||
.in(SysOperLog::getOperId, ids));
|
||||
}
|
||||
|
||||
// 查询操作日志详细
|
||||
@Override
|
||||
public SysOperLog selectOperLogById(Long operId) {
|
||||
return operLogMapper.selectOperLogById(operId);
|
||||
}
|
||||
|
||||
// 清空操作日志
|
||||
@Override
|
||||
public void cleanOperLog() {
|
||||
operLogMapper.cleanOperLog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysOperLog> selectByPage(OperlogPage dto) {
|
||||
LambdaQueryWrapper<SysOperLog> qw = new LambdaQueryWrapper<>();
|
||||
qw.like(StringUtils.isNotBlank(dto.getTitle()), SysOperLog::getTitle, dto.getTitle())
|
||||
.like(StringUtils.isNotBlank(dto.getOperName()), SysOperLog::getOperName, dto.getOperName())
|
||||
.eq(Objects.nonNull(dto.getBusinessType()), SysOperLog::getBusinessType, dto.getBusinessType())
|
||||
.eq(Objects.nonNull(dto.getStatus()), SysOperLog::getStatus, dto.getStatus())
|
||||
.orderByDesc(SysOperLog::getOperId);
|
||||
return operLogMapper.selectPage(dto, qw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> statistics(String type) {
|
||||
UserInfo user = UserInfoManager.get();
|
||||
String useSql = PermissionsUtil.createSql("", user);
|
||||
String kssj = null, jssj;
|
||||
jssj = DateUtils.getTime();
|
||||
if ("1".equals(type)) {
|
||||
kssj = DateUtils.getDate() + " 00:00:00";
|
||||
} else if ("2".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -8));
|
||||
} else if ("3".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -31));
|
||||
} else if ("4".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -90));
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 请求成功次数
|
||||
map.put("qqcgcs", this.operLogMapper.getSycs(kssj, jssj, useSql, "0"));
|
||||
// 请求失败次数
|
||||
map.put("qqsbcs", this.operLogMapper.getSycs(kssj, jssj, useSql, "1"));
|
||||
// 访问人数
|
||||
map.put("fwrs", this.operLogMapper.getFwrs(kssj, jssj, useSql));
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> bmStatistics(String type) {
|
||||
UserInfo user = UserInfoManager.get();
|
||||
String aUseSql = PermissionsUtil.createSql("a", user);
|
||||
String bUseSql = PermissionsUtil.createSql("b", user);
|
||||
String kssj = null, jssj;
|
||||
jssj = DateUtils.getTime();
|
||||
if ("1".equals(type)) {
|
||||
kssj = DateUtils.getDate() + " 00:00:00";
|
||||
} else if ("2".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -8));
|
||||
} else if ("3".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -31));
|
||||
} else if ("4".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -90));
|
||||
}
|
||||
return this.baseMapper.bmStatistics(kssj, jssj, aUseSql, bUseSql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> ryStatistics(String type) {
|
||||
UserInfo user = UserInfoManager.get();
|
||||
String aUseSql = PermissionsUtil.createSql("a", user);
|
||||
String bUseSql = PermissionsUtil.createSql("b", user);
|
||||
String kssj = null, jssj;
|
||||
jssj = DateUtils.getTime();
|
||||
if ("1".equals(type)) {
|
||||
kssj = DateUtils.getDate() + " 00:00:00";
|
||||
} else if ("2".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -8));
|
||||
} else if ("3".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -31));
|
||||
} else if ("4".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -90));
|
||||
}
|
||||
return this.baseMapper.ryStatistics(kssj, jssj, aUseSql, bUseSql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> mkStatistics(String type) {
|
||||
UserInfo user = UserInfoManager.get();
|
||||
String aUseSql = PermissionsUtil.createSql("a", user);
|
||||
String bUseSql = PermissionsUtil.createSql("b", user);
|
||||
String kssj = null, jssj;
|
||||
jssj = DateUtils.getTime();
|
||||
if ("1".equals(type)) {
|
||||
kssj = DateUtils.getDate() + " 00:00:00";
|
||||
} else if ("2".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -8));
|
||||
} else if ("3".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -31));
|
||||
} else if ("4".equals(type)) {
|
||||
kssj = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",
|
||||
DateUtils.getNextDate(new Date(), "D", -90));
|
||||
}
|
||||
return this.baseMapper.mkStatistics(kssj, jssj, aUseSql, bUseSql);
|
||||
}
|
||||
}
|
@ -0,0 +1,854 @@
|
||||
package com.mosty.operation.log.util;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 类型转换器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class Convert {
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value, String defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value) {
|
||||
return toStr(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value, Character defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
return (Character) value;
|
||||
}
|
||||
|
||||
final String valueStr = toStr(value, null);
|
||||
return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value) {
|
||||
return toChar(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value, Byte defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
return (Byte) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).byteValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Byte.parseByte(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value) {
|
||||
return toByte(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value, Short defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
return (Short) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).shortValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Short.parseShort(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value) {
|
||||
return toShort(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value, Number defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return (Number) value;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return NumberFormat.getInstance().parse(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value) {
|
||||
return toNumber(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value, Integer defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value) {
|
||||
return toInt(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String str) {
|
||||
return toIntArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String str) {
|
||||
return toLongArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String split, String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return new Integer[]{};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Integer[] ints = new Integer[arr.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Integer v = toInt(arr[i], 0);
|
||||
ints[i] = v;
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String split, String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return new Long[]{};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Long[] longs = new Long[arr.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Long v = toLong(arr[i], null);
|
||||
longs[i] = v;
|
||||
}
|
||||
return longs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String str) {
|
||||
return toStrArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String split, String str) {
|
||||
return str.split(split);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value, Long defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return (Long) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).longValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value) {
|
||||
return toLong(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value, Double defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
return (Double) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).doubleValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).doubleValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value) {
|
||||
return toDouble(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value, Float defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
return (Float) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).floatValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Float.parseFloat(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value) {
|
||||
return toFloat(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value, Boolean defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
}
|
||||
String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
valueStr = valueStr.trim().toLowerCase();
|
||||
switch (valueStr) {
|
||||
case "true":
|
||||
return true;
|
||||
case "false":
|
||||
return false;
|
||||
case "yes":
|
||||
return true;
|
||||
case "ok":
|
||||
return true;
|
||||
case "no":
|
||||
return false;
|
||||
case "1":
|
||||
return true;
|
||||
case "0":
|
||||
return false;
|
||||
default:
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value) {
|
||||
return toBool(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @param defaultValue 默认值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (clazz.isAssignableFrom(value.getClass())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E myE = (E) value;
|
||||
return myE;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Enum.valueOf(clazz, valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
|
||||
return toEnum(clazz, value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof BigInteger) {
|
||||
return (BigInteger) value;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return BigInteger.valueOf((Long) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigInteger(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value) {
|
||||
return toBigInteger(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof BigDecimal) {
|
||||
return (BigDecimal) value;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return new BigDecimal((Long) value);
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
return new BigDecimal((Double) value);
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
return new BigDecimal((Integer) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value) {
|
||||
return toBigDecimal(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @return 字符串
|
||||
*/
|
||||
// public static String utf8Str(Object obj)
|
||||
// {
|
||||
// return str(obj, CharsetKit.CHARSET_UTF_8);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charsetName 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(Object obj, String charsetName) {
|
||||
return str(obj, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(Object obj, Charset charset) {
|
||||
if (null == obj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (obj instanceof String) {
|
||||
return (String) obj;
|
||||
} else if (obj instanceof byte[]) {
|
||||
return str((byte[]) obj, charset);
|
||||
} else if (obj instanceof Byte[]) {
|
||||
byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj);
|
||||
return str(bytes, charset);
|
||||
} else if (obj instanceof ByteBuffer) {
|
||||
return str((ByteBuffer) obj, charset);
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte数组转为字符串
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(byte[] bytes, String charset) {
|
||||
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码字节码
|
||||
*
|
||||
* @param data 字符串
|
||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||
* @return 解码后的字符串
|
||||
*/
|
||||
public static String str(byte[] data, Charset charset) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (null == charset) {
|
||||
return new String(data);
|
||||
}
|
||||
return new String(data, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(ByteBuffer data, String charset) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return str(data, Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(ByteBuffer data, Charset charset) {
|
||||
if (null == charset) {
|
||||
charset = Charset.defaultCharset();
|
||||
}
|
||||
return charset.decode(data).toString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- 全角半角转换
|
||||
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
* @param input String.
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC(String input) {
|
||||
return toSBC(input, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
* @param input String
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC(String input, Set<Character> notConvertSet) {
|
||||
char c[] = input.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c[i] == ' ') {
|
||||
c[i] = '\u3000';
|
||||
} else if (c[i] < '\177') {
|
||||
c[i] = (char) (c[i] + 65248);
|
||||
|
||||
}
|
||||
}
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全角转半角
|
||||
*
|
||||
* @param input String.
|
||||
* @return 半角字符串
|
||||
*/
|
||||
public static String toDBC(String input) {
|
||||
return toDBC(input, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换全角为半角
|
||||
*
|
||||
* @param text 文本
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 替换后的字符
|
||||
*/
|
||||
public static String toDBC(String text, Set<Character> notConvertSet) {
|
||||
char c[] = text.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c[i] == '\u3000') {
|
||||
c[i] = ' ';
|
||||
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||
c[i] = (char) (c[i] - 65248);
|
||||
}
|
||||
}
|
||||
String returnString = new String(c);
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||
*
|
||||
* @param n 数字
|
||||
* @return 中文大写数字
|
||||
*/
|
||||
public static String digitUppercase(double n) {
|
||||
String[] fraction = {"角", "分"};
|
||||
String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
|
||||
String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}};
|
||||
|
||||
String head = n < 0 ? "负" : "";
|
||||
n = Math.abs(n);
|
||||
|
||||
String s = "";
|
||||
for (int i = 0; i < fraction.length; i++) {
|
||||
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
||||
}
|
||||
if (s.length() < 1) {
|
||||
s = "整";
|
||||
}
|
||||
int integerPart = (int) Math.floor(n);
|
||||
|
||||
for (int i = 0; i < unit[0].length && integerPart > 0; i++) {
|
||||
String p = "";
|
||||
for (int j = 0; j < unit[1].length && n > 0; j++) {
|
||||
p = digit[integerPart % 10] + unit[1][j] + p;
|
||||
integerPart = integerPart / 10;
|
||||
}
|
||||
s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s;
|
||||
}
|
||||
return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整");
|
||||
}
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
package com.mosty.operation.log.util;
|
||||
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 客户端工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class ServletUtils {
|
||||
/**
|
||||
* 定义移动端请求的所有可能类型
|
||||
*/
|
||||
private final static String[] agent = {"Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser"};
|
||||
|
||||
/**
|
||||
* 获取String参数
|
||||
*/
|
||||
public static String getParameter(String name) {
|
||||
return getRequest().getParameter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取String参数
|
||||
*/
|
||||
public static String getParameter(String name, String defaultValue) {
|
||||
return Convert.toStr(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Integer参数
|
||||
*/
|
||||
public static Integer getParameterToInt(String name) {
|
||||
return Convert.toInt(getRequest().getParameter(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Integer参数
|
||||
*/
|
||||
public static Integer getParameterToInt(String name, Integer defaultValue) {
|
||||
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Boolean参数
|
||||
*/
|
||||
public static Boolean getParameterToBool(String name) {
|
||||
return Convert.toBool(getRequest().getParameter(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Boolean参数
|
||||
*/
|
||||
public static Boolean getParameterToBool(String name, Boolean defaultValue) {
|
||||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取request
|
||||
*/
|
||||
public static HttpServletRequest getRequest() {
|
||||
return getRequestAttributes().getRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取response
|
||||
*/
|
||||
public static HttpServletResponse getResponse() {
|
||||
return getRequestAttributes().getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取session
|
||||
*/
|
||||
public static HttpSession getSession() {
|
||||
return getRequest().getSession();
|
||||
}
|
||||
|
||||
public static ServletRequestAttributes getRequestAttributes() {
|
||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||
return (ServletRequestAttributes) attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串渲染到客户端
|
||||
*
|
||||
* @param response 渲染对象
|
||||
* @param string 待渲染的字符串
|
||||
* @return null
|
||||
*/
|
||||
public static String renderString(HttpServletResponse response, String string) {
|
||||
try {
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.getWriter().print(string);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是Ajax异步请求
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
public static boolean isAjaxRequest(HttpServletRequest request) {
|
||||
String accept = request.getHeader("accept");
|
||||
if (accept != null && accept.indexOf("application/json") != -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String uri = request.getRequestURI();
|
||||
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String ajax = request.getParameter("__ajax");
|
||||
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断User-Agent 是不是来自于手机
|
||||
*/
|
||||
public static boolean checkAgentIsMobile(String ua) {
|
||||
boolean flag = false;
|
||||
if (!ua.contains("Windows NT") || (ua.contains("Windows NT") && ua.contains("compatible; MSIE 9.0;"))) {
|
||||
// 排除 苹果桌面系统
|
||||
if (!ua.contains("Windows NT") && !ua.contains("Macintosh")) {
|
||||
for (String item : agent) {
|
||||
if (ua.contains(item)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
@ -0,0 +1,478 @@
|
||||
package com.mosty.operation.log.util;
|
||||
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 字符串工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
/**
|
||||
* 空字符串
|
||||
*/
|
||||
private static final String NULLSTR = "";
|
||||
|
||||
/**
|
||||
* 下划线
|
||||
*/
|
||||
private static final char SEPARATOR = '_';
|
||||
|
||||
/**
|
||||
* 获取参数不为空值
|
||||
*
|
||||
* @param value defaultValue 要判断的value
|
||||
* @return value 返回值
|
||||
*/
|
||||
public static <T> T nvl(T value, T defaultValue) {
|
||||
return value != null ? value : defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(Collection<?> coll) {
|
||||
return isNull(coll) || coll.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Collection是否非空,包含List,Set,Queue
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty(Collection<?> coll) {
|
||||
return !isEmpty(coll);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象数组是否为空
|
||||
*
|
||||
* @param objects 要判断的对象数组
|
||||
* * @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(Object[] objects) {
|
||||
return isNull(objects) || (objects.length == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象数组是否非空
|
||||
*
|
||||
* @param objects 要判断的对象数组
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty(Object[] objects) {
|
||||
return !isEmpty(objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Map是否为空
|
||||
*
|
||||
* @param map 要判断的Map
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(Map<?, ?> map) {
|
||||
return isNull(map) || map.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Map是否为空
|
||||
*
|
||||
* @param map 要判断的Map
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty(Map<?, ?> map) {
|
||||
return !isEmpty(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个字符串是否为空串
|
||||
*
|
||||
* @param str String
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(String str) {
|
||||
return isNull(str) || NULLSTR.equals(str.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个字符串是否为非空串
|
||||
*
|
||||
* @param str String
|
||||
* @return true:非空串 false:空串
|
||||
*/
|
||||
public static boolean isNotEmpty(String str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否为空
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isNull(Object object) {
|
||||
return object == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否非空
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotNull(Object object) {
|
||||
return !isNull(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
||||
*
|
||||
* @param object 对象
|
||||
* @return true:是数组 false:不是数组
|
||||
*/
|
||||
public static boolean isArray(Object object) {
|
||||
return isNotNull(object) && object.getClass().isArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 去空格
|
||||
*/
|
||||
public static String trim(String str) {
|
||||
return (str == null ? "" : str.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取字符串
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param start 开始
|
||||
* @return 结果
|
||||
*/
|
||||
public static String substring(final String str, int start) {
|
||||
if (str == null) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
start = str.length() + start;
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (start > str.length()) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
||||
return str.substring(start);
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取字符串
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param start 开始
|
||||
* @param end 结束
|
||||
* @return 结果
|
||||
*/
|
||||
public static String substring(final String str, int start, int end) {
|
||||
if (str == null) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
||||
if (end < 0) {
|
||||
end = str.length() + end;
|
||||
}
|
||||
if (start < 0) {
|
||||
start = str.length() + start;
|
||||
}
|
||||
|
||||
if (end > str.length()) {
|
||||
end = str.length();
|
||||
}
|
||||
|
||||
if (start > end) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (end < 0) {
|
||||
end = 0;
|
||||
}
|
||||
|
||||
return str.substring(start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化文本, {} 表示占位符<br>
|
||||
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
||||
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
||||
* 例:<br>
|
||||
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
||||
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
||||
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
||||
*
|
||||
* @param template 文本模板,被替换的部分用 {} 表示
|
||||
* @param params 参数值
|
||||
* @return 格式化后的文本
|
||||
*/
|
||||
// public static String format(String template, Object... params)
|
||||
// {
|
||||
// if (isEmpty(params) || isEmpty(template))
|
||||
// {
|
||||
// return template;
|
||||
// }
|
||||
// return StrFormatter.format(template, params);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 是否为http(s)://开头
|
||||
*
|
||||
* @param link 链接
|
||||
* @return 结果
|
||||
*/
|
||||
// public static boolean ishttp(String link)
|
||||
// {
|
||||
// return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 字符串转set
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param sep 分隔符
|
||||
* @return set集合
|
||||
*/
|
||||
public static final Set<String> str2Set(String str, String sep) {
|
||||
return new HashSet<String>(str2List(str, sep, true, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转list
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param sep 分隔符
|
||||
* @param filterBlank 过滤纯空白
|
||||
* @param trim 去掉首尾空白
|
||||
* @return list集合
|
||||
*/
|
||||
public static final List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return list;
|
||||
}
|
||||
|
||||
// 过滤空白字符串
|
||||
if (filterBlank && StringUtils.isBlank(str)) {
|
||||
return list;
|
||||
}
|
||||
String[] split = str.split(sep);
|
||||
for (String string : split) {
|
||||
if (filterBlank && StringUtils.isBlank(string)) {
|
||||
continue;
|
||||
}
|
||||
if (trim) {
|
||||
string = string.trim();
|
||||
}
|
||||
list.add(string);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
|
||||
*
|
||||
* @param cs 指定字符串
|
||||
* @param searchCharSequences 需要检查的字符串数组
|
||||
* @return 是否包含任意一个字符串
|
||||
*/
|
||||
public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) {
|
||||
if (isEmpty(cs) || isEmpty(searchCharSequences)) {
|
||||
return false;
|
||||
}
|
||||
for (CharSequence testStr : searchCharSequences) {
|
||||
if (containsIgnoreCase(cs, testStr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 驼峰转下划线命名
|
||||
*/
|
||||
public static String toUnderScoreCase(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// 前置字符是否大写
|
||||
boolean preCharIsUpperCase = true;
|
||||
// 当前字符是否大写
|
||||
boolean curreCharIsUpperCase = true;
|
||||
// 下一字符是否大写
|
||||
boolean nexteCharIsUpperCase = true;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
if (i > 0) {
|
||||
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
|
||||
} else {
|
||||
preCharIsUpperCase = false;
|
||||
}
|
||||
|
||||
curreCharIsUpperCase = Character.isUpperCase(c);
|
||||
|
||||
if (i < (str.length() - 1)) {
|
||||
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
|
||||
}
|
||||
|
||||
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) {
|
||||
sb.append(SEPARATOR);
|
||||
} else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) {
|
||||
sb.append(SEPARATOR);
|
||||
}
|
||||
sb.append(Character.toLowerCase(c));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含字符串
|
||||
*
|
||||
* @param str 验证字符串
|
||||
* @param strs 字符串组
|
||||
* @return 包含返回true
|
||||
*/
|
||||
public static boolean inStringIgnoreCase(String str, String... strs) {
|
||||
if (str != null && strs != null) {
|
||||
for (String s : strs) {
|
||||
if (str.equalsIgnoreCase(trim(s))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除最后一个字符串
|
||||
*
|
||||
* @param str 输入字符串
|
||||
* @param spit 以什么类型结尾的
|
||||
* @return 截取后的字符串
|
||||
*/
|
||||
public static String lastStringDel(String str, String spit) {
|
||||
if (!StringUtils.isEmpty(str) && str.endsWith(spit)) {
|
||||
return str.subSequence(0, str.length() - 1).toString();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
|
||||
*
|
||||
* @param name 转换前的下划线大写方式命名的字符串
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
public static String convertToCamelCase(String name) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
// 快速检查
|
||||
if (name == null || name.isEmpty()) {
|
||||
// 没必要转换
|
||||
return "";
|
||||
} else if (!name.contains("_")) {
|
||||
// 不含下划线,仅将首字母大写
|
||||
return name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
}
|
||||
// 用下划线将原始字符串分割
|
||||
String[] camels = name.split("_");
|
||||
for (String camel : camels) {
|
||||
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
||||
if (camel.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 首字母大写
|
||||
result.append(camel.substring(0, 1).toUpperCase());
|
||||
result.append(camel.substring(1).toLowerCase());
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 驼峰式命名法
|
||||
* 例如:user_name->userName
|
||||
*/
|
||||
public static String toCamelCase(String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
if (s.indexOf(SEPARATOR) == -1) {
|
||||
return s;
|
||||
}
|
||||
s = s.toLowerCase();
|
||||
StringBuilder sb = new StringBuilder(s.length());
|
||||
boolean upperCase = false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
if (c == SEPARATOR) {
|
||||
upperCase = true;
|
||||
} else if (upperCase) {
|
||||
sb.append(Character.toUpperCase(c));
|
||||
upperCase = false;
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
|
||||
*
|
||||
* @param str 指定字符串
|
||||
* @param strs 需要检查的字符串数组
|
||||
* @return 是否匹配
|
||||
*/
|
||||
public static boolean matches(String str, List<String> strs) {
|
||||
if (isEmpty(str) || isEmpty(strs)) {
|
||||
return false;
|
||||
}
|
||||
for (String pattern : strs) {
|
||||
if (isMatch(pattern, str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断url是否与规则配置:
|
||||
* ? 表示单个字符;
|
||||
* * 表示一层路径内的任意字符串,不可跨层级;
|
||||
* ** 表示任意层路径;
|
||||
*
|
||||
* @param pattern 匹配规则
|
||||
* @param url 需要匹配的url
|
||||
* @return
|
||||
*/
|
||||
public static boolean isMatch(String pattern, String url) {
|
||||
AntPathMatcher matcher = new AntPathMatcher();
|
||||
return matcher.match(pattern, url);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T cast(Object obj) {
|
||||
return (T) obj;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.mosty.operation.log.OperationLogBaseAutoConfiguration
|
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.mosty.operation.log.OperationLogBaseAutoConfiguration
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Thu Apr 18 12:45:11 CST 2024
|
||||
version=1.0.0-SNAPSHOT
|
||||
groupId=com.mosty
|
||||
artifactId=common-log-base-starter
|
@ -0,0 +1,24 @@
|
||||
com\mosty\operation\log\BusinessStatus.class
|
||||
com\mosty\operation\log\mapper\SysOperLogMapper.class
|
||||
com\mosty\operation\log\util\StringUtils.class
|
||||
com\mosty\operation\log\entity\DeleteListVO.class
|
||||
com\mosty\operation\log\util\ServletUtils.class
|
||||
com\mosty\operation\log\entity\Excels.class
|
||||
com\mosty\operation\log\entity\VO\OperlogPage.class
|
||||
com\mosty\operation\log\entity\SysUser.class
|
||||
com\mosty\operation\log\entity\Excel$Type.class
|
||||
com\mosty\operation\log\entity\Excel$ColumnType.class
|
||||
com\mosty\operation\log\entity\BaseEntity.class
|
||||
com\mosty\operation\log\controller\SysOperlogController.class
|
||||
com\mosty\operation\log\entity\ExcelHandlerAdapter.class
|
||||
com\mosty\operation\log\entity\Excel$Align.class
|
||||
com\mosty\operation\log\controller\provider\SysOperlogProviderController.class
|
||||
com\mosty\operation\log\OperationLogBaseAutoConfiguration.class
|
||||
com\mosty\operation\log\BaseController.class
|
||||
com\mosty\operation\log\service\impl\SysOperLogServiceImpl.class
|
||||
com\mosty\operation\log\BaseController$1.class
|
||||
com\mosty\operation\log\service\SysOperLogService.class
|
||||
com\mosty\operation\log\LogAspect.class
|
||||
com\mosty\operation\log\util\Convert.class
|
||||
com\mosty\operation\log\entity\Excel.class
|
||||
com\mosty\operation\log\LogSaveStrategy.class
|
@ -0,0 +1,20 @@
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\service\impl\SysOperLogServiceImpl.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\LogSaveStrategy.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\util\ServletUtils.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\util\StringUtils.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\LogAspect.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\OperationLogBaseAutoConfiguration.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\entity\BaseEntity.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\entity\SysUser.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\entity\DeleteListVO.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\entity\Excel.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\entity\Excels.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\entity\VO\OperlogPage.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\BusinessStatus.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\util\Convert.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\entity\ExcelHandlerAdapter.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\mapper\SysOperLogMapper.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\controller\SysOperlogController.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\service\SysOperLogService.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\BaseController.java
|
||||
C:\tools\dy外网\mosty-common\common-log-base-starter\src\main\java\com\mosty\operation\log\controller\provider\SysOperlogProviderController.java
|
Reference in New Issue
Block a user