Merge branch 'master' of http://git.picaiba.com/why/ym
Conflicts: ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java
This commit is contained in:
commit
88d29c0260
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.idea/
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
*/**/target/
|
||||||
|
**/*.iml
|
||||||
|
*.md
|
||||||
|
.drone.yml
|
||||||
|
LICENSE
|
||||||
|
.dockerignore
|
||||||
|
Dockerfile
|
39
.drone.yml
Normal file
39
.drone.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: docker:dind
|
||||||
|
volumes:
|
||||||
|
- name: dockersock
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
- name: dockerconfig
|
||||||
|
path: /root/.docker
|
||||||
|
commands:
|
||||||
|
- docker build -t harbor.picaiba.com/kszny/mes-api:1.0.0-india ./ && docker push harbor.picaiba.com/kszny/mes-api:1.0.0-india
|
||||||
|
|
||||||
|
- name: deploy
|
||||||
|
image: harbor.picaiba.com/tools/kubectl
|
||||||
|
commands:
|
||||||
|
- echo "172.27.0.20 lb.kubesphere.local" >> /etc/hosts
|
||||||
|
- sleep 1
|
||||||
|
- kubectl scale --replicas=0 deployment/mes-api -n mes-india
|
||||||
|
- sleep 3
|
||||||
|
- kubectl scale --replicas=1 deployment/mes-api -n mes-india
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: dockersock
|
||||||
|
host:
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
- name: dockerconfig
|
||||||
|
host:
|
||||||
|
path: /root/.docker
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- porject/yd-monitor
|
||||||
|
event:
|
||||||
|
- push
|
56
Dockerfile
Normal file
56
Dockerfile
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#FROM maven:3-jdk-8-alpine as builder
|
||||||
|
#WORKDIR /app
|
||||||
|
#COPY settings.xml /usr/share/maven/ref/repository/settings.xml
|
||||||
|
#COPY pom.xml .
|
||||||
|
#COPY gateway/pom.xml gateway/
|
||||||
|
#COPY core/pom.xml core/
|
||||||
|
#COPY common/pom.xml common/
|
||||||
|
#COPY passport/pom.xml passport/
|
||||||
|
#COPY upms/pom.xml upms/
|
||||||
|
#COPY empty/pom.xml empty/
|
||||||
|
#COPY material/pom.xml material/
|
||||||
|
#COPY order/pom.xml order/
|
||||||
|
#COPY monitor/pom.xml monitor/
|
||||||
|
#COPY equipment/pom.xml equipment/
|
||||||
|
#COPY basic/pom.xml basic/
|
||||||
|
## COPY report/pom.xml report/
|
||||||
|
#
|
||||||
|
#RUN mvn -B -s /usr/share/maven/ref/repository/settings.xml dependency:resolve-plugins dependency:resolve clean package
|
||||||
|
#
|
||||||
|
#COPY ./ ./
|
||||||
|
#
|
||||||
|
#RUN mvn -B -s /usr/share/maven/ref/repository/settings.xml -Dmaven.test.skip=true -Ptest clean package
|
||||||
|
FROM maven:3-jdk-8-alpine as builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./ ./
|
||||||
|
RUN mvn -s settings.xml clean package -Dmaven.test.skip=true
|
||||||
|
|
||||||
|
FROM anapsix/alpine-java:8_server-jre_unlimited as layers
|
||||||
|
LABEL mantainer=shihairong@zimonet.com
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=builder app/ym-gateway/target/ym-gateway.jar /app/app.jar
|
||||||
|
#ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom","-jar","app.jar", "--spring.profiles.active=dev"]
|
||||||
|
|
||||||
|
# 通过工具spring-boot-jarmode-layertools从application.jar中提取拆分后的构建结果
|
||||||
|
RUN java -Djarmode=layertools -jar app.jar extract
|
||||||
|
|
||||||
|
# 正式构建镜像
|
||||||
|
FROM anapsix/alpine-java:8_server-jre_unlimited
|
||||||
|
# 指定工作目录,目录不存在会自动创建
|
||||||
|
WORKDIR /app
|
||||||
|
# 前一阶段从jar中提取除了多个文件,这里分别执行COPY命令复制到镜像空间中,每次COPY都是一个layer
|
||||||
|
COPY --from=layers app/dependencies ./
|
||||||
|
COPY --from=layers app/spring-boot-loader ./
|
||||||
|
COPY --from=layers app/snapshot-dependencies ./
|
||||||
|
COPY --from=layers app/company-dependencies ./
|
||||||
|
COPY --from=layers app/application ./
|
||||||
|
# 指定时区
|
||||||
|
ENV TZ="Asia/Shanghai"
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
# 定义一些环境变量,方便环境变量传参
|
||||||
|
ENV JVM_OPTS=""
|
||||||
|
ENV JAVA_OPTS="-Dspring.profiles.active=dev"
|
||||||
|
# 指定暴露的端口,起到说明的作用,不指定也会暴露对应端口
|
||||||
|
EXPOSE 8080
|
||||||
|
# 启动 jar 的命令
|
||||||
|
ENTRYPOINT ["sh","-c","java $JVM_OPTS $JAVA_OPTS org.springframework.boot.loader.JarLauncher"]
|
15
pom.xml
15
pom.xml
@ -34,7 +34,7 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<junit.version>4.13.2</junit.version>
|
<junit.version>4.13.2</junit.version>
|
||||||
<jedis.version>4.2.2</jedis.version>
|
<jedis.version>4.2.2</jedis.version>
|
||||||
<!-- <druid.version>1.2.9</druid.version>-->
|
<druid.version>1.2.9</druid.version>
|
||||||
<mybatisplus.version>3.5.1</mybatisplus.version>
|
<mybatisplus.version>3.5.1</mybatisplus.version>
|
||||||
<sqlserver.version>4.0</sqlserver.version>
|
<sqlserver.version>4.0</sqlserver.version>
|
||||||
<oracle.version>11.2.0.3</oracle.version>
|
<oracle.version>11.2.0.3</oracle.version>
|
||||||
@ -119,9 +119,14 @@
|
|||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jdbc</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>${druid.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-data-jdbc</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.afterturn</groupId>
|
<groupId>cn.afterturn</groupId>
|
||||||
@ -205,6 +210,10 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 阿里云maven仓库 -->
|
<!-- 阿里云maven仓库 -->
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
|
19
settings.xml
Normal file
19
settings.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
|
||||||
|
<localRepository>/usr/share/maven/ref/repository</localRepository>
|
||||||
|
|
||||||
|
<pluginGroups>
|
||||||
|
<pluginGroup>com.spotify</pluginGroup>
|
||||||
|
</pluginGroups>
|
||||||
|
|
||||||
|
<mirrors>
|
||||||
|
<mirror>
|
||||||
|
<id>central</id>
|
||||||
|
<mirrorOf>*</mirrorOf>
|
||||||
|
<name>aliyun</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
</mirror>
|
||||||
|
</mirrors>
|
||||||
|
</settings>
|
@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author weihongyang
|
* @Author weihongyang
|
||||||
@ -78,6 +79,7 @@ public class LogOperationAspect {
|
|||||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||||
if(loginUser != null){
|
if(loginUser != null){
|
||||||
log.setCreatorName(loginUser.getUsername());
|
log.setCreatorName(loginUser.getUsername());
|
||||||
|
log.setCreator(loginUser.getSysUserEntity().getCreator());
|
||||||
}
|
}
|
||||||
|
|
||||||
log.setStatus(status);
|
log.setStatus(status);
|
||||||
@ -89,6 +91,7 @@ public class LogOperationAspect {
|
|||||||
log.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
|
log.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
|
||||||
log.setRequestUri(request.getRequestURI());
|
log.setRequestUri(request.getRequestURI());
|
||||||
log.setRequestMethod(request.getMethod());
|
log.setRequestMethod(request.getMethod());
|
||||||
|
log.setCreateDate(new Date());
|
||||||
|
|
||||||
//请求参数
|
//请求参数
|
||||||
Object[] args = joinPoint.getArgs();
|
Object[] args = joinPoint.getArgs();
|
||||||
|
@ -41,6 +41,7 @@ public class CorsConfig implements WebMvcConfigurer {
|
|||||||
.allowedMethods("GET", "POST", "DELETE", "PUT")
|
.allowedMethods("GET", "POST", "DELETE", "PUT")
|
||||||
// 设置允许的header属性
|
// 设置允许的header属性
|
||||||
.allowedHeaders("*")
|
.allowedHeaders("*")
|
||||||
|
.exposedHeaders("*")
|
||||||
// 跨域允许时间
|
// 跨域允许时间
|
||||||
.maxAge(3600);
|
.maxAge(3600);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.cnbm.admin.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import com.cnbm.common.interceptor.DataFilterInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
|
||||||
|
// 数据权限
|
||||||
|
mybatisPlusInterceptor.addInnerInterceptor(new DataFilterInterceptor());
|
||||||
|
// 分页插件
|
||||||
|
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||||
|
// 乐观锁
|
||||||
|
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||||
|
// 防止全表更新与删除
|
||||||
|
mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
|
||||||
|
|
||||||
|
return mybatisPlusInterceptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -72,7 +72,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
"/swagger-ui/**",
|
"/swagger-ui/**",
|
||||||
"/webjars/**",
|
"/webjars/**",
|
||||||
"/websocket/**",
|
"/websocket/**",
|
||||||
"/captcha").anonymous()
|
"/captcha",
|
||||||
|
"druid/**").anonymous()
|
||||||
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
|
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
.anyRequest()
|
.anyRequest()
|
||||||
|
@ -6,6 +6,7 @@ import com.cnbm.admin.service.CaptchaService;
|
|||||||
import com.cnbm.admin.service.LoginService;
|
import com.cnbm.admin.service.LoginService;
|
||||||
import com.cnbm.admin.utils.ResponseResult;
|
import com.cnbm.admin.utils.ResponseResult;
|
||||||
import com.cnbm.common.exception.ErrorCode;
|
import com.cnbm.common.exception.ErrorCode;
|
||||||
|
import com.cnbm.common.utils.Result;
|
||||||
import com.cnbm.common.validator.AssertUtils;
|
import com.cnbm.common.validator.AssertUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
@ -52,13 +53,16 @@ public class LoginController {
|
|||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@ApiOperation(value = "登录")
|
@ApiOperation(value = "登录")
|
||||||
public ResponseResult login(HttpServletRequest request, @RequestBody LoginParam loginParam) {
|
public Result login(HttpServletRequest request, @RequestBody LoginParam loginParam) {
|
||||||
return loginService.login(request,loginParam);
|
return loginService.login(request,loginParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/doLogout")
|
@PostMapping("logout")
|
||||||
@ApiOperation(value = "退出")
|
@ApiOperation(value = "退出")
|
||||||
public void logout(){
|
public Result logout(HttpServletRequest request){
|
||||||
|
loginService.logout(request);
|
||||||
|
return new Result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
package com.cnbm.admin.controller;
|
||||||
|
|
||||||
|
import com.cnbm.admin.annotation.LogOperation;
|
||||||
|
import com.cnbm.admin.dto.SysLogLoginDTO;
|
||||||
|
import com.cnbm.admin.execl.SysLogLoginExcel;
|
||||||
|
import com.cnbm.admin.service.SysLogLoginService;
|
||||||
|
import com.cnbm.common.constant.Constant;
|
||||||
|
import com.cnbm.common.page.PageData;
|
||||||
|
import com.cnbm.common.utils.ExcelUtils;
|
||||||
|
import com.cnbm.common.utils.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("sys/log/login")
|
||||||
|
@Api(tags="登录日志")
|
||||||
|
@Log4j2
|
||||||
|
public class SysLogLoginController {
|
||||||
|
@Autowired
|
||||||
|
private SysLogLoginService sysLogLoginService;
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@ApiOperation("分页")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) ,
|
||||||
|
@ApiImplicitParam(name = "status", value = "状态 0:失败 1:成功 2:账号已锁定", paramType = "query", dataTypeClass=Integer.class),
|
||||||
|
@ApiImplicitParam(name = "creatorName", value = "用户名", paramType = "query", dataTypeClass=String.class)
|
||||||
|
})
|
||||||
|
@PreAuthorize("@ex.hasAuthority('sys:log:login')")
|
||||||
|
public Result<PageData<SysLogLoginDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
|
PageData<SysLogLoginDTO> page = sysLogLoginService.page(params);
|
||||||
|
|
||||||
|
return new Result<PageData<SysLogLoginDTO>>().ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("export")
|
||||||
|
@ApiOperation("导出")
|
||||||
|
@LogOperation("导出")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "status", value = "状态 0:失败 1:成功 2:账号已锁定", paramType = "query", dataTypeClass=Integer.class),
|
||||||
|
@ApiImplicitParam(name = "creatorName", value = "用户名", paramType = "query", dataTypeClass=String.class)
|
||||||
|
})
|
||||||
|
@PreAuthorize("@ex.hasAuthority('sys:log:login')")
|
||||||
|
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||||
|
List<SysLogLoginDTO> list = sysLogLoginService.list(params);
|
||||||
|
|
||||||
|
ExcelUtils.exportExcelToTarget(response, null, list, SysLogLoginExcel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.cnbm.admin.dao;
|
||||||
|
|
||||||
|
import com.cnbm.admin.entity.SysLogLoginEntity;
|
||||||
|
import com.cnbm.common.dao.BaseDao;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface SysLogLoginDao extends BaseDao<SysLogLoginEntity> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.cnbm.admin.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "登录日志")
|
||||||
|
public class SysLogLoginDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户操作 0:用户登录 1:用户退出")
|
||||||
|
private Integer operation;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态 0:失败 1:成功 2:账号已锁定")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户代理")
|
||||||
|
private String userAgent;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "操作IP")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户名")
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,9 @@ import java.util.stream.Collectors;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class LoginUser implements UserDetails {
|
public class LoginUser implements UserDetails{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private SysUserEntity sysUserEntity;
|
private SysUserEntity sysUserEntity;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -51,5 +52,10 @@ public class SysDeptEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -49,4 +50,9 @@ public class SysDictDataEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -45,4 +46,9 @@ public class SysDictTypeEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.cnbm.admin.entity;
|
package com.cnbm.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -40,5 +41,10 @@ public class SysLogErrorEntity extends BaseEntity {
|
|||||||
* 异常信息
|
* 异常信息
|
||||||
*/
|
*/
|
||||||
private String errorInfo;
|
private String errorInfo;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.cnbm.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@TableName("sys_log_login")
|
||||||
|
public class SysLogLoginEntity extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户操作 0:用户登录 1:用户退出
|
||||||
|
*/
|
||||||
|
private Integer operation;
|
||||||
|
/**
|
||||||
|
* 状态 0:失败 1:成功 2:账号已锁定
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 用户代理
|
||||||
|
*/
|
||||||
|
private String userAgent;
|
||||||
|
/**
|
||||||
|
* 操作IP
|
||||||
|
*/
|
||||||
|
private String ip;
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String creatorName;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.cnbm.admin.entity;
|
package com.cnbm.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -52,4 +53,9 @@ public class SysLogOperationEntity extends BaseEntity {
|
|||||||
* 用户名
|
* 用户名
|
||||||
*/
|
*/
|
||||||
private String creatorName;
|
private String creatorName;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -63,5 +64,10 @@ public class SysMenuEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -46,5 +47,10 @@ public class SysParamsEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.cnbm.admin.entity;
|
package com.cnbm.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -24,5 +25,10 @@ public class SysRoleDataScopeEntity extends BaseEntity {
|
|||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -43,4 +44,9 @@ public class SysRoleEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.cnbm.admin.entity;
|
package com.cnbm.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -23,5 +24,10 @@ public class SysRoleMenuEntity extends BaseEntity {
|
|||||||
* 菜单ID
|
* 菜单ID
|
||||||
*/
|
*/
|
||||||
private Long menuId;
|
private Long menuId;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.cnbm.admin.entity;
|
package com.cnbm.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -24,6 +25,11 @@ public class SysRoleUserEntity extends BaseEntity {
|
|||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cnbm.common.entity.BaseEntity;
|
import com.cnbm.common.entity.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -76,5 +77,10 @@ public class SysUserEntity extends BaseEntity implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField(exist=false)
|
@TableField(exist=false)
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
/**
|
||||||
|
* 删除标识,是否有效:1可用 0不可用
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.cnbm.admin.enums;
|
||||||
|
|
||||||
|
public enum LoginOperationEnum {
|
||||||
|
/**
|
||||||
|
* 用户登录
|
||||||
|
*/
|
||||||
|
LOGIN(0),
|
||||||
|
/**
|
||||||
|
* 用户退出
|
||||||
|
*/
|
||||||
|
LOGOUT(1);
|
||||||
|
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
LoginOperationEnum(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int value() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.cnbm.admin.enums;
|
||||||
|
|
||||||
|
public enum LoginStatusEnum {
|
||||||
|
/**
|
||||||
|
* 失败
|
||||||
|
*/
|
||||||
|
FAIL(0),
|
||||||
|
/**
|
||||||
|
* 成功
|
||||||
|
*/
|
||||||
|
SUCCESS(1),
|
||||||
|
/**
|
||||||
|
* 账号已锁定
|
||||||
|
*/
|
||||||
|
LOCK(2);
|
||||||
|
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
LoginStatusEnum(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int value() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.cnbm.admin.execl;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SysLogLoginExcel {
|
||||||
|
@Excel(name = "用户操作")
|
||||||
|
private String operation;
|
||||||
|
@Excel(name = "状态", replace = {"失败_0", "成功_1", "账号已锁定_1"})
|
||||||
|
private Integer status;
|
||||||
|
@Excel(name = "User-Agent")
|
||||||
|
private String userAgent;
|
||||||
|
@Excel(name = "操作IP")
|
||||||
|
private String ip;
|
||||||
|
@Excel(name = "用户名")
|
||||||
|
private String creatorName;
|
||||||
|
@Excel(name = "创建时间", format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -55,7 +55,6 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
|||||||
throw new RuntimeException("用户未登录");
|
throw new RuntimeException("用户未登录");
|
||||||
}
|
}
|
||||||
//存入SecurityContextHolder
|
//存入SecurityContextHolder
|
||||||
//TODO 获取权限信息封装到Authentication中
|
|
||||||
UsernamePasswordAuthenticationToken authenticationToken =
|
UsernamePasswordAuthenticationToken authenticationToken =
|
||||||
new UsernamePasswordAuthenticationToken(loginUser,null,loginUser.getAuthorities());
|
new UsernamePasswordAuthenticationToken(loginUser,null,loginUser.getAuthorities());
|
||||||
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.cnbm.admin.service;
|
package com.cnbm.admin.service;
|
||||||
|
|
||||||
import com.cnbm.admin.params.LoginParam;
|
import com.cnbm.admin.params.LoginParam;
|
||||||
import com.cnbm.admin.utils.ResponseResult;
|
import com.cnbm.common.utils.Result;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@ -12,6 +12,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
*/
|
*/
|
||||||
public interface LoginService {
|
public interface LoginService {
|
||||||
|
|
||||||
ResponseResult login(HttpServletRequest request, LoginParam loginParam);
|
Result login(HttpServletRequest request, LoginParam loginParam);
|
||||||
|
|
||||||
|
void logout(HttpServletRequest request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.cnbm.admin.service;
|
||||||
|
|
||||||
|
import com.cnbm.admin.dto.SysLogLoginDTO;
|
||||||
|
import com.cnbm.admin.entity.SysLogLoginEntity;
|
||||||
|
import com.cnbm.common.page.PageData;
|
||||||
|
import com.cnbm.common.service.BaseService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface SysLogLoginService extends BaseService<SysLogLoginEntity> {
|
||||||
|
|
||||||
|
PageData<SysLogLoginDTO> page(Map<String, Object> params);
|
||||||
|
|
||||||
|
List<SysLogLoginDTO> list(Map<String, Object> params);
|
||||||
|
|
||||||
|
void save(SysLogLoginEntity entity);
|
||||||
|
}
|
@ -1,14 +1,22 @@
|
|||||||
package com.cnbm.admin.service.impl;
|
package com.cnbm.admin.service.impl;
|
||||||
|
|
||||||
import com.cnbm.admin.entity.LoginUser;
|
import com.cnbm.admin.entity.LoginUser;
|
||||||
|
import com.cnbm.admin.entity.SysLogLoginEntity;
|
||||||
|
import com.cnbm.admin.enums.LoginOperationEnum;
|
||||||
|
import com.cnbm.admin.enums.LoginStatusEnum;
|
||||||
import com.cnbm.admin.params.LoginParam;
|
import com.cnbm.admin.params.LoginParam;
|
||||||
import com.cnbm.admin.service.CaptchaService;
|
import com.cnbm.admin.service.CaptchaService;
|
||||||
|
import com.cnbm.admin.service.SysLogLoginService;
|
||||||
import com.cnbm.admin.utils.JwtUtil;
|
import com.cnbm.admin.utils.JwtUtil;
|
||||||
import com.cnbm.admin.service.LoginService;
|
import com.cnbm.admin.service.LoginService;
|
||||||
import com.cnbm.admin.utils.ResponseResult;
|
import com.cnbm.admin.utils.ResponseResult;
|
||||||
import com.cnbm.common.exception.ErrorCode;
|
import com.cnbm.common.exception.ErrorCode;
|
||||||
|
import com.cnbm.common.utils.IpUtils;
|
||||||
|
import com.cnbm.common.utils.Result;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
@ -16,9 +24,11 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author weihongyang
|
* @Author weihongyang
|
||||||
@ -37,16 +47,30 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CaptchaService captchaService;
|
private CaptchaService captchaService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysLogLoginService sysLogLoginService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseResult login(HttpServletRequest request, LoginParam loginParam) {
|
public Result login(HttpServletRequest request, LoginParam loginParam) {
|
||||||
//验证码是否正确
|
//验证码是否正确
|
||||||
boolean flag = captchaService.validate(loginParam.getUuid(), loginParam.getCaptcha());
|
boolean flag = captchaService.validate(loginParam.getUuid(), loginParam.getCaptcha());
|
||||||
if(!flag){
|
if(!flag){
|
||||||
return new ResponseResult(ErrorCode.CAPTCHA_ERROR,"验证码错误");
|
return new Result<>().error(ErrorCode.CAPTCHA_ERROR, "验证码错误");
|
||||||
}
|
}
|
||||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginParam.getUsername(),loginParam.getPassword());
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginParam.getUsername(),loginParam.getPassword());
|
||||||
Authentication authenticate = authenticationManager.authenticate(authenticationToken);
|
Authentication authenticate = authenticationManager.authenticate(authenticationToken);
|
||||||
|
//登录日志
|
||||||
|
SysLogLoginEntity log = new SysLogLoginEntity();
|
||||||
|
log.setOperation(LoginOperationEnum.LOGIN.value());
|
||||||
|
log.setCreateDate(new Date());
|
||||||
|
log.setIp(IpUtils.getIpAddr(request));
|
||||||
|
log.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
|
||||||
|
log.setCreatorName(loginParam.getUsername());
|
||||||
|
|
||||||
if (Objects.isNull(authenticate)) {
|
if (Objects.isNull(authenticate)) {
|
||||||
|
log.setStatus(LoginStatusEnum.FAIL.value());
|
||||||
|
log.setCreatorName(loginParam.getUsername());
|
||||||
|
sysLogLoginService.save(log);
|
||||||
throw new RuntimeException("登录失败");
|
throw new RuntimeException("登录失败");
|
||||||
}
|
}
|
||||||
//如果认证通过了,使用userid生成一个jwt jwt存入ResponseResult返回
|
//如果认证通过了,使用userid生成一个jwt jwt存入ResponseResult返回
|
||||||
@ -56,8 +80,34 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
Map<String,String> map = new HashMap<>();
|
Map<String,String> map = new HashMap<>();
|
||||||
map.put("token",jwt);
|
map.put("token",jwt);
|
||||||
//把完整的用户信息存入redis userid作为key
|
//把完整的用户信息存入redis userid作为key
|
||||||
redisTemplate.opsForValue().set("login:"+userid,loginUser);
|
redisTemplate.opsForValue().set("login:"+userid,loginUser,1, TimeUnit.DAYS);
|
||||||
return new ResponseResult(200,"登录成功",map);
|
//登录成功
|
||||||
|
log.setStatus(LoginStatusEnum.SUCCESS.value());
|
||||||
|
log.setCreator(loginUser.getSysUserEntity().getId());
|
||||||
|
log.setCreatorName(loginUser.getUsername());
|
||||||
|
sysLogLoginService.save(log);
|
||||||
|
return new Result<>().ok(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logout(HttpServletRequest request) {
|
||||||
|
//获取SecurityContextHolder中的用户id
|
||||||
|
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||||
|
Long userid = loginUser.getSysUserEntity().getId();
|
||||||
|
//日志
|
||||||
|
SysLogLoginEntity log = new SysLogLoginEntity();
|
||||||
|
log.setOperation(LoginOperationEnum.LOGOUT.value());
|
||||||
|
log.setIp(IpUtils.getIpAddr(request));
|
||||||
|
log.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
|
||||||
|
log.setIp(IpUtils.getIpAddr(request));
|
||||||
|
log.setStatus(LoginStatusEnum.SUCCESS.value());
|
||||||
|
log.setCreator(userid);
|
||||||
|
log.setCreatorName(loginUser.getUsername());
|
||||||
|
log.setCreateDate(new Date());
|
||||||
|
sysLogLoginService.save(log);
|
||||||
|
//删除redis中的值
|
||||||
|
redisTemplate.delete("login:"+userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package com.cnbm.admin.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.cnbm.admin.dao.SysLogLoginDao;
|
||||||
|
import com.cnbm.admin.dto.SysLogLoginDTO;
|
||||||
|
import com.cnbm.admin.entity.SysLogLoginEntity;
|
||||||
|
import com.cnbm.admin.service.SysLogLoginService;
|
||||||
|
import com.cnbm.common.constant.Constant;
|
||||||
|
import com.cnbm.common.page.PageData;
|
||||||
|
import com.cnbm.common.service.impl.BaseServiceImpl;
|
||||||
|
import com.cnbm.common.utils.ConvertUtils;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
public class SysLogLoginServiceImpl extends BaseServiceImpl<SysLogLoginDao, SysLogLoginEntity> implements SysLogLoginService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageData<SysLogLoginDTO> page(Map<String, Object> params) {
|
||||||
|
IPage<SysLogLoginEntity> page = baseDao.selectPage(
|
||||||
|
getPage(params, Constant.CREATE_DATE, false),
|
||||||
|
getWrapper(params)
|
||||||
|
);
|
||||||
|
|
||||||
|
return getPageData(page, SysLogLoginDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysLogLoginDTO> list(Map<String, Object> params) {
|
||||||
|
List<SysLogLoginEntity> entityList = baseDao.selectList(getWrapper(params));
|
||||||
|
|
||||||
|
return ConvertUtils.sourceToTarget(entityList, SysLogLoginDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueryWrapper<SysLogLoginEntity> getWrapper(Map<String, Object> params){
|
||||||
|
String status = (String) params.get("status");
|
||||||
|
String creatorName = (String) params.get("creatorName");
|
||||||
|
|
||||||
|
QueryWrapper<SysLogLoginEntity> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq(StringUtils.isNotBlank(status), "status", status);
|
||||||
|
wrapper.like(StringUtils.isNotBlank(creatorName), "creator_name", creatorName);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void save(SysLogLoginEntity entity) {
|
||||||
|
insert(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,23 +5,24 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.cnbm.admin.dto.SysMenuDTO;
|
import com.cnbm.admin.dto.SysMenuDTO;
|
||||||
import com.cnbm.admin.dto.SysUserDTO;
|
import com.cnbm.admin.dto.SysUserDTO;
|
||||||
import com.cnbm.admin.entity.LoginUser;
|
import com.cnbm.admin.entity.LoginUser;
|
||||||
|
import com.cnbm.admin.entity.SysLogLoginEntity;
|
||||||
import com.cnbm.admin.entity.SysMenuEntity;
|
import com.cnbm.admin.entity.SysMenuEntity;
|
||||||
import com.cnbm.admin.entity.SysUserEntity;
|
import com.cnbm.admin.entity.SysUserEntity;
|
||||||
|
import com.cnbm.admin.enums.LoginOperationEnum;
|
||||||
import com.cnbm.admin.exception.LoginStatusException;
|
import com.cnbm.admin.exception.LoginStatusException;
|
||||||
import com.cnbm.admin.service.SysMenuService;
|
import com.cnbm.admin.service.SysMenuService;
|
||||||
import com.cnbm.common.utils.ConvertUtils;
|
import com.cnbm.common.utils.ConvertUtils;
|
||||||
|
import com.cnbm.common.utils.IpUtils;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.security.authentication.DisabledException;
|
import org.springframework.security.authentication.DisabledException;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,6 +46,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||||||
LambdaQueryWrapper<SysUserEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysUserEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(SysUserEntity::getUsername,username);
|
lambdaQueryWrapper.eq(SysUserEntity::getUsername,username);
|
||||||
SysUserEntity sysUserEntity = userDao.selectOne(lambdaQueryWrapper);
|
SysUserEntity sysUserEntity = userDao.selectOne(lambdaQueryWrapper);
|
||||||
|
|
||||||
if (Objects.isNull(sysUserEntity)) {
|
if (Objects.isNull(sysUserEntity)) {
|
||||||
throw new UsernameNotFoundException("用户名不存在");
|
throw new UsernameNotFoundException("用户名不存在");
|
||||||
}
|
}
|
||||||
|
6
ym-admin/src/main/resources/mapper/SysLogLoginDao.xml
Normal file
6
ym-admin/src/main/resources/mapper/SysLogLoginDao.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.cnbm.admin.dao.SysLogLoginDao">
|
||||||
|
|
||||||
|
</mapper>
|
@ -3,6 +3,8 @@ package com.cnbm.common.entity;
|
|||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -30,4 +32,5 @@ public abstract class BaseEntity implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Date createDate;
|
private Date createDate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.cnbm.common.interceptor;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
|
||||||
|
import net.sf.jsqlparser.JSQLParserException;
|
||||||
|
import net.sf.jsqlparser.expression.Expression;
|
||||||
|
import net.sf.jsqlparser.expression.StringValue;
|
||||||
|
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
|
||||||
|
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
||||||
|
import net.sf.jsqlparser.statement.select.PlainSelect;
|
||||||
|
import net.sf.jsqlparser.statement.select.Select;
|
||||||
|
import org.apache.ibatis.executor.Executor;
|
||||||
|
import org.apache.ibatis.mapping.BoundSql;
|
||||||
|
import org.apache.ibatis.mapping.MappedStatement;
|
||||||
|
import org.apache.ibatis.session.ResultHandler;
|
||||||
|
import org.apache.ibatis.session.RowBounds;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DataFilterInterceptor implements InnerInterceptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
|
||||||
|
DataScope scope = getDataScope(parameter);
|
||||||
|
// 不进行数据过滤
|
||||||
|
if(scope == null || StrUtil.isBlank(scope.getSqlFilter())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼接新SQL
|
||||||
|
String buildSql = getSelect(boundSql.getSql(), scope);
|
||||||
|
|
||||||
|
// 重写SQL
|
||||||
|
PluginUtils.mpBoundSql(boundSql).sql(buildSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataScope getDataScope(Object parameter){
|
||||||
|
if (parameter == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断参数里是否有DataScope对象
|
||||||
|
if (parameter instanceof Map) {
|
||||||
|
Map<?, ?> parameterMap = (Map<?, ?>) parameter;
|
||||||
|
for (Map.Entry entry : parameterMap.entrySet()) {
|
||||||
|
if (entry.getValue() != null && entry.getValue() instanceof DataScope) {
|
||||||
|
return (DataScope) entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (parameter instanceof DataScope) {
|
||||||
|
return (DataScope) parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSelect(String buildSql, DataScope scope){
|
||||||
|
try {
|
||||||
|
Select select = (Select) CCJSqlParserUtil.parse(buildSql);
|
||||||
|
PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
|
||||||
|
|
||||||
|
Expression expression = plainSelect.getWhere();
|
||||||
|
if(expression == null){
|
||||||
|
plainSelect.setWhere(new StringValue(scope.getSqlFilter()));
|
||||||
|
}else{
|
||||||
|
AndExpression andExpression = new AndExpression(expression, new StringValue(scope.getSqlFilter()));
|
||||||
|
plainSelect.setWhere(andExpression);
|
||||||
|
}
|
||||||
|
|
||||||
|
return select.toString().replaceAll("'", "");
|
||||||
|
}catch (JSQLParserException e){
|
||||||
|
return buildSql;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.cnbm.common.interceptor;
|
||||||
|
|
||||||
|
public class DataScope {
|
||||||
|
private String sqlFilter;
|
||||||
|
|
||||||
|
public DataScope(String sqlFilter) {
|
||||||
|
this.sqlFilter = sqlFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSqlFilter() {
|
||||||
|
return sqlFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSqlFilter(String sqlFilter) {
|
||||||
|
this.sqlFilter = sqlFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.sqlFilter;
|
||||||
|
}
|
||||||
|
}
|
160
ym-common/src/main/java/com/cnbm/common/utils/CountUtils.java
Normal file
160
ym-common/src/main/java/com/cnbm/common/utils/CountUtils.java
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
package com.cnbm.common.utils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.math.BigDecimal.ROUND_HALF_UP;
|
||||||
|
|
||||||
|
public class CountUtils {
|
||||||
|
|
||||||
|
// private static final BigDecimal TWO = BigDecimal.valueOf(2);
|
||||||
|
//
|
||||||
|
// public static BigDecimal Mean(List<BigDecimal> data){
|
||||||
|
// BigDecimal sum = new BigDecimal("0");
|
||||||
|
// for (BigDecimal datum : data) {
|
||||||
|
// sum = sum.add(datum);
|
||||||
|
// }
|
||||||
|
// BigDecimal divide = sum.divide(BigDecimal.valueOf(data.size()));
|
||||||
|
// return divide;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // population variance 总体方差
|
||||||
|
// public static BigDecimal POP_Variance(List<BigDecimal> data) {
|
||||||
|
// BigDecimal variance = new BigDecimal("0");
|
||||||
|
// for (BigDecimal datum : data) {
|
||||||
|
// variance = variance.add(datum.subtract(Mean(data)).pow(2));
|
||||||
|
// }
|
||||||
|
// variance = variance.divide(BigDecimal.valueOf(data.size()));
|
||||||
|
// return variance;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // population standard deviation 总体标准差
|
||||||
|
// public static BigDecimal POP_STD_dev(List<BigDecimal> data) {
|
||||||
|
// BigDecimal sqrt = sqrt(POP_Variance(data), 4);
|
||||||
|
// return sqrt;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //sample variance 样本方差
|
||||||
|
// public static BigDecimal Sample_Variance(List<BigDecimal> data) {
|
||||||
|
// BigDecimal variance = new BigDecimal("0");
|
||||||
|
// for (BigDecimal datum : data) {
|
||||||
|
// variance = variance.add(datum.subtract(Mean(data)).pow(2));
|
||||||
|
// }
|
||||||
|
// variance = variance.divide(BigDecimal.valueOf(data.size() - 1),4);
|
||||||
|
// return variance;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // sample standard deviation 样本标准差
|
||||||
|
// public static BigDecimal Sample_STD_dev(List<BigDecimal> data) {
|
||||||
|
// BigDecimal sqrt = sqrt(Sample_Variance(data), 4);
|
||||||
|
// return sqrt;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static BigDecimal sqrt(BigDecimal A, final int SCALE) {
|
||||||
|
// BigDecimal x0 = new BigDecimal("0");
|
||||||
|
// BigDecimal x1 = new BigDecimal(Math.sqrt(A.doubleValue()));
|
||||||
|
// while (!x0.equals(x1)) {
|
||||||
|
// x0 = x1;
|
||||||
|
// x1 = A.divide(x0, SCALE, ROUND_HALF_UP);
|
||||||
|
// x1 = x1.add(x0);
|
||||||
|
// x1 = x1.divide(TWO, SCALE, ROUND_HALF_UP);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// return x1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
double Sum(double[] data) {
|
||||||
|
double sum = 0;
|
||||||
|
for (int i = 0; i < data.length; i++)
|
||||||
|
sum = sum + data[i];
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Mean(double[] data) {
|
||||||
|
double mean = 0;
|
||||||
|
mean = Sum(data) / data.length;
|
||||||
|
return mean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// population variance 总体方差
|
||||||
|
double POP_Variance(double[] data) {
|
||||||
|
double variance = 0;
|
||||||
|
for (int i = 0; i < data.length; i++) {
|
||||||
|
variance = variance + (Math.pow((data[i] - Mean(data)), 2));
|
||||||
|
}
|
||||||
|
variance = variance / data.length;
|
||||||
|
return variance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// population standard deviation 总体标准差
|
||||||
|
double POP_STD_dev(double[] data) {
|
||||||
|
double std_dev;
|
||||||
|
std_dev = Math.sqrt(POP_Variance(data));
|
||||||
|
return std_dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
//sample variance 样本方差
|
||||||
|
double Sample_Variance(double[] data) {
|
||||||
|
double variance = 0;
|
||||||
|
for (int i = 0; i < data.length; i++) {
|
||||||
|
variance = variance + (Math.pow((data[i] - Mean(data)), 2));
|
||||||
|
}
|
||||||
|
variance = variance / (data.length-1);
|
||||||
|
return variance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sample standard deviation 样本标准差
|
||||||
|
double Sample_STD_dev(double[] data) {
|
||||||
|
double std_dev;
|
||||||
|
std_dev = Math.sqrt(Sample_Variance(data));
|
||||||
|
return std_dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// List<BigDecimal> data = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// data.add(new BigDecimal("10.023"));
|
||||||
|
// data.add(new BigDecimal("11.02"));
|
||||||
|
// data.add(new BigDecimal("9.99"));
|
||||||
|
// data.add(new BigDecimal("9.81"));
|
||||||
|
// data.add(new BigDecimal("10.12"));
|
||||||
|
// data.add(new BigDecimal("10.9"));
|
||||||
|
// data.add(new BigDecimal("9.99"));
|
||||||
|
// data.add(new BigDecimal("10.03"));
|
||||||
|
// data.add(new BigDecimal("9.99"));
|
||||||
|
// data.add(new BigDecimal("12.02"));
|
||||||
|
// CountUtils countUtils = new CountUtils();
|
||||||
|
//
|
||||||
|
// BigDecimal mean = countUtils.Mean(data);
|
||||||
|
// System.out.println(mean.toString());
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// BigDecimal bigDecimal1 = POP_STD_dev(data);
|
||||||
|
// System.out.println(bigDecimal1.toString());
|
||||||
|
//
|
||||||
|
// System.out.println(Sample_STD_dev(data).toString());
|
||||||
|
//
|
||||||
|
// BigDecimal bigDecimal = POP_Variance(data);
|
||||||
|
// System.out.println(bigDecimal.toString());
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// System.out.println(Sample_Variance(data));
|
||||||
|
|
||||||
|
double[] data = new double[]{10.023,11.02,9.99,9.81,10.12,10.9,9.99,10.03,9.99,12.02};
|
||||||
|
CountUtils countUtils = new CountUtils();
|
||||||
|
|
||||||
|
System.out.println(countUtils.Mean(data));
|
||||||
|
System.out.println(countUtils.POP_STD_dev(data));
|
||||||
|
System.out.println(countUtils.Sample_STD_dev(data));
|
||||||
|
|
||||||
|
System.out.println(countUtils.POP_Variance(data));
|
||||||
|
System.out.println(countUtils.Sample_Variance(data));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -41,6 +41,7 @@ public class ExcelUtils {
|
|||||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), pojoClass, list);
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), pojoClass, list);
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
response.setHeader("content-Type", "application/vnd.ms-excel");
|
response.setHeader("content-Type", "application/vnd.ms-excel");
|
||||||
|
response.setHeader("Access-Control-Expose-Headers","Content-Disposition");
|
||||||
response.setHeader("Content-Disposition",
|
response.setHeader("Content-Disposition",
|
||||||
"attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xls");
|
"attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xls");
|
||||||
ServletOutputStream out = response.getOutputStream();
|
ServletOutputStream out = response.getOutputStream();
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
package com.cnbm.common.utils;
|
||||||
|
|
||||||
|
public class LeastSquares
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 杜航 功能:返回估计的y值
|
||||||
|
*/
|
||||||
|
public static float estimate(float[] x, float[] y, float input)
|
||||||
|
{
|
||||||
|
float a = getA(x, y);
|
||||||
|
float b = getB(x, y);
|
||||||
|
System.out.println("线性回归系数a值:\t" + a + "\n" + "线性回归系数b值:\t" + b);
|
||||||
|
return (a * input + b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 杜航 功能:返回x的系数a 公式:a = ( n sum( xy ) - sum( x ) sum( y ) ) / ( n sum( x^2 )
|
||||||
|
* - sum(x) ^ 2 )
|
||||||
|
*/
|
||||||
|
public static float getA(float[] x, float[] y)
|
||||||
|
{
|
||||||
|
int n = x.length;
|
||||||
|
return (float) ((n * pSum(x, y) - sum(x) * sum(y)) / (n * sqSum(x) - Math
|
||||||
|
.pow(sum(x), 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 杜航 功能:返回常量系数系数b 公式:b = sum( y ) / n - a sum( x ) / n
|
||||||
|
*/
|
||||||
|
public static float getB(float[] x, float[] y)
|
||||||
|
{
|
||||||
|
int n = x.length;
|
||||||
|
float a = getA(x, y);
|
||||||
|
return sum(y) / n - a * sum(x) / n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 杜航 功能:求和
|
||||||
|
*/
|
||||||
|
private static float sum(float[] ds)
|
||||||
|
{
|
||||||
|
float s = 0;
|
||||||
|
for (float d : ds)
|
||||||
|
{
|
||||||
|
s = s + d;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 杜航 功能:求平方和
|
||||||
|
*/
|
||||||
|
private static float sqSum(float[] ds)
|
||||||
|
{
|
||||||
|
float s = 0;
|
||||||
|
for (float d : ds)
|
||||||
|
{
|
||||||
|
s = (float) (s + Math.pow(d, 2));
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 杜航 功能:返回对应项相乘后的和
|
||||||
|
*/
|
||||||
|
private static float pSum(float[] x, float[] y)
|
||||||
|
{
|
||||||
|
float s = 0;
|
||||||
|
for (int i = 0; i < x.length; i++)
|
||||||
|
{
|
||||||
|
s = s + x[i] * y[i];
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 杜航 功能:main()测试线性回归的最小二乘法java实现函数
|
||||||
|
*/
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
float[] x =
|
||||||
|
// { 540, 360, 240, 480, 420 };
|
||||||
|
{ 0.501F, 0.482F, 0.482F, 0.51F, 0.492F, 0.54F, 0.5F, 0.492F, 0.51F, 0.489F};
|
||||||
|
float[] y =
|
||||||
|
// { 520, 475, 430, 386, 500 };
|
||||||
|
{10.023F, 11.02F, 9.99F, 9.81F, 10.12F,10.9F, 9.99F, 10.03F, 9.99F, 12.02F };
|
||||||
|
System.out.println("经线性回归后的y值:\t" + estimate(x, y,240));
|
||||||
|
}
|
||||||
|
}
|
@ -65,4 +65,60 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>2.5.12</version>
|
||||||
|
<configuration>
|
||||||
|
<!--指定运行main函数的包-->
|
||||||
|
<mainClass>com.cnbm.YmApplication</mainClass>
|
||||||
|
<!--开启分层编译支持-->
|
||||||
|
<layers>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<configuration>${project.basedir}/src/main/resources/layers.xml</configuration>
|
||||||
|
</layers>
|
||||||
|
<excludes>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>${docker.plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>ym-pass/${project.artifactId}</imageName>
|
||||||
|
<dockerDirectory>${project.basedir}/</dockerDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -20,10 +20,36 @@ spring:
|
|||||||
# url: jdbc:postgresql://192.168.10.10:5432/postgres
|
# url: jdbc:postgresql://192.168.10.10:5432/postgres
|
||||||
# username: postgres
|
# username: postgres
|
||||||
# password: 123456
|
# password: 123456
|
||||||
hikari:
|
initial-size: 10
|
||||||
pool-name: GrowUpHikariCP
|
max-active: 100
|
||||||
minimum-idle: 1
|
min-idle: 10
|
||||||
maximum-pool-size: 10
|
max-wait: 60000
|
||||||
|
pool-prepared-statements: true
|
||||||
|
max-pool-prepared-statement-per-connection-size: 20
|
||||||
|
time-between-eviction-runs-millis: 60000
|
||||||
|
min-evictable-idle-time-millis: 300000
|
||||||
|
#Oracle需要打开注释
|
||||||
|
#validation-query: SELECT 1 FROM DUAL
|
||||||
|
test-while-idle: true
|
||||||
|
test-on-borrow: false
|
||||||
|
test-on-return: false
|
||||||
|
stat-view-servlet:
|
||||||
|
enabled: true
|
||||||
|
url-pattern: /druid/*
|
||||||
|
#login-username: admin
|
||||||
|
#login-password: admin
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
log-slow-sql: true
|
||||||
|
slow-sql-millis: 1000
|
||||||
|
merge-sql: false
|
||||||
|
wall:
|
||||||
|
config:
|
||||||
|
multi-statement-allow: true
|
||||||
|
# hikari:
|
||||||
|
# pool-name: GrowUpHikariCP
|
||||||
|
# minimum-idle: 1
|
||||||
|
# maximum-pool-size: 10
|
||||||
|
|
||||||
##多数据源的配置,需要引用renren-dynamic-datasource
|
##多数据源的配置,需要引用renren-dynamic-datasource
|
||||||
#dynamic:
|
#dynamic:
|
||||||
|
@ -32,7 +32,7 @@ spring:
|
|||||||
max-request-size: 100MB
|
max-request-size: 100MB
|
||||||
enabled: true
|
enabled: true
|
||||||
redis:
|
redis:
|
||||||
database: 2
|
database: 6
|
||||||
host: redis.picaiba.com
|
host: redis.picaiba.com
|
||||||
port: 6380
|
port: 6380
|
||||||
password: '@WSXcde3' # 密码(默认为空)
|
password: '@WSXcde3' # 密码(默认为空)
|
||||||
@ -69,12 +69,12 @@ mybatis-plus:
|
|||||||
cache-enabled: false
|
cache-enabled: false
|
||||||
call-setters-on-nulls: true
|
call-setters-on-nulls: true
|
||||||
jdbc-type-for-null: 'null'
|
jdbc-type-for-null: 'null'
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
configuration-properties:
|
configuration-properties:
|
||||||
prefix:
|
prefix:
|
||||||
blobType: BLOB
|
blobType: BLOB
|
||||||
boolValue: TRUE
|
boolValue: TRUE
|
||||||
|
|
||||||
logging:
|
#logging:
|
||||||
level:
|
# level:
|
||||||
com.cnbm.admin.dao: DEBUG
|
# com.cnbm.admin.dao: DEBUG
|
27
ym-gateway/src/main/resources/layers.xml
Normal file
27
ym-gateway/src/main/resources/layers.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<layers xmlns="http://www.springframework.org/schema/boot/layers"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/boot/layers
|
||||||
|
https://www.springframework.org/schema/boot/layers/layers.xsd">
|
||||||
|
<application>
|
||||||
|
<into layer="spring-boot-loader">
|
||||||
|
<include>org/springframework/boot/loader/**</include>
|
||||||
|
</into>
|
||||||
|
<into layer="application" />
|
||||||
|
</application>
|
||||||
|
<dependencies>
|
||||||
|
<into layer="snapshot-dependencies">
|
||||||
|
<include>*:*:*SNAPSHOT</include>
|
||||||
|
</into>
|
||||||
|
<into layer="company-dependencies">
|
||||||
|
<include>com.cnbm:*</include>
|
||||||
|
</into>
|
||||||
|
<into layer="dependencies"/>
|
||||||
|
</dependencies>
|
||||||
|
<layerOrder>
|
||||||
|
<layer>dependencies</layer>
|
||||||
|
<layer>spring-boot-loader</layer>
|
||||||
|
<layer>snapshot-dependencies</layer>
|
||||||
|
<layer>company-dependencies</layer>
|
||||||
|
<layer>application</layer>
|
||||||
|
</layerOrder>
|
||||||
|
</layers>
|
21
ym-gateway/src/main/resources/logback-spring.xml
Normal file
21
ym-gateway/src/main/resources/logback-spring.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||||
|
<logger name="org.springframework.web" level="INFO"/>
|
||||||
|
<logger name="org.springboot.sample" level="TRACE" />
|
||||||
|
|
||||||
|
<!-- 开发、测试环境 -->
|
||||||
|
<springProfile name="dev,test">
|
||||||
|
<logger name="org.springframework.web" level="INFO"/>
|
||||||
|
<logger name="org.springboot.sample" level="INFO" />
|
||||||
|
<logger name="com.cnbm" level="DEBUG" />
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<!-- 生产环境 -->
|
||||||
|
<springProfile name="prod">
|
||||||
|
<logger name="org.springframework.web" level="ERROR"/>
|
||||||
|
<logger name="org.springboot.sample" level="ERROR" />
|
||||||
|
<logger name="com.cnbm" level="ERROR" />
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
@ -0,0 +1,116 @@
|
|||||||
|
package com.cnbm.generator.code.controller;
|
||||||
|
|
||||||
|
import com.cnbm.admin.annotation.LogOperation;
|
||||||
|
import com.cnbm.common.constant.Constant;
|
||||||
|
import com.cnbm.common.page.PageData;
|
||||||
|
import com.cnbm.common.utils.ExcelUtils;
|
||||||
|
import com.cnbm.common.utils.Result;
|
||||||
|
import com.cnbm.common.validator.AssertUtils;
|
||||||
|
import com.cnbm.common.validator.ValidatorUtils;
|
||||||
|
import com.cnbm.common.validator.group.AddGroup;
|
||||||
|
import com.cnbm.common.validator.group.DefaultGroup;
|
||||||
|
import com.cnbm.common.validator.group.UpdateGroup;
|
||||||
|
import com.cnbm.generator.code.dto.UserDTO;
|
||||||
|
import com.cnbm.generator.code.excel.UserExcel;
|
||||||
|
import com.cnbm.generator.code.service.IUserService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户 前端控制器
|
||||||
|
*
|
||||||
|
* @author why
|
||||||
|
* @since 2022-08-23
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/code/user")
|
||||||
|
@Api(tags="系统用户")
|
||||||
|
public class UserController {
|
||||||
|
@Autowired
|
||||||
|
private IUserService userService;
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@ApiOperation("分页")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class)
|
||||||
|
})
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:user:page')")
|
||||||
|
public Result<PageData<UserDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
|
PageData<UserDTO> page = userService.page(params);
|
||||||
|
|
||||||
|
return new Result<PageData<UserDTO>>().ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@ApiOperation("信息")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:user:info')")
|
||||||
|
public Result<UserDTO> get(@PathVariable("id") Long id){
|
||||||
|
UserDTO data = userService.get(id);
|
||||||
|
|
||||||
|
return new Result<UserDTO>().ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("保存")
|
||||||
|
@LogOperation("保存")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:user:save')")
|
||||||
|
public Result<Long> save(@RequestBody UserDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
|
userService.save(dto);
|
||||||
|
|
||||||
|
return new Result<Long>().ok(dto.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@ApiOperation("修改")
|
||||||
|
@LogOperation("修改")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:user:update')")
|
||||||
|
public Result<Long> update(@RequestBody UserDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
|
userService.update(dto);
|
||||||
|
|
||||||
|
return new Result<Long>().ok(dto.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@ApiOperation("删除")
|
||||||
|
@LogOperation("删除")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:user:delete')")
|
||||||
|
public Result delete(@RequestBody Long[] ids){
|
||||||
|
//效验数据
|
||||||
|
AssertUtils.isArrayEmpty(ids, "id");
|
||||||
|
|
||||||
|
userService.delete(ids);
|
||||||
|
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("export")
|
||||||
|
@ApiOperation("导出")
|
||||||
|
@LogOperation("导出")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:user:export')")
|
||||||
|
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||||
|
List<UserDTO> list = userService.list(params);
|
||||||
|
|
||||||
|
ExcelUtils.exportExcelToTarget(response, null, list, UserExcel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package com.cnbm.generator.code.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户
|
||||||
|
*
|
||||||
|
* @author why
|
||||||
|
* @since 2022-08-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "系统用户DTO对象")
|
||||||
|
public class UserDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户名")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "姓名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "头像")
|
||||||
|
private String headUrl;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "性别 0:男 1:女 2:保密")
|
||||||
|
private Integer gender;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "邮箱")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "部门ID")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "超级管理员 0:否 1:是")
|
||||||
|
private Integer superAdmin;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态 0:停用 1:正常")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建者")
|
||||||
|
private Long creator;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private LocalDateTime createDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新者")
|
||||||
|
private Long updater;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private LocalDateTime updateDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "删除标识,是否有效:1可用 0不可用")
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.cnbm.generator.code.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统用户
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author why
|
||||||
|
* @since 2022-08-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("sys_user")
|
||||||
|
@ApiModel(value = "User对象", description = "系统用户")
|
||||||
|
public class User implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户名")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@ApiModelProperty("密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("头像")
|
||||||
|
private String headUrl;
|
||||||
|
|
||||||
|
@ApiModelProperty("性别 0:男 1:女 2:保密")
|
||||||
|
private Integer gender;
|
||||||
|
|
||||||
|
@ApiModelProperty("邮箱")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@ApiModelProperty("部门ID")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@ApiModelProperty("超级管理员 0:否 1:是")
|
||||||
|
private Integer superAdmin;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态 0:停用 1:正常")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建者")
|
||||||
|
private Long creator;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新者")
|
||||||
|
private Long updater;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标识,是否有效:1可用 0不可用")
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.cnbm.generator.code.excel;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户
|
||||||
|
*
|
||||||
|
* @author why
|
||||||
|
* @since 2022-08-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserExcel {
|
||||||
|
@Excel(name = "id")
|
||||||
|
private Long id;
|
||||||
|
@Excel(name = "用户名")
|
||||||
|
private String username;
|
||||||
|
@Excel(name = "密码")
|
||||||
|
private String password;
|
||||||
|
@Excel(name = "姓名")
|
||||||
|
private String realName;
|
||||||
|
@Excel(name = "头像")
|
||||||
|
private String headUrl;
|
||||||
|
@Excel(name = "性别 0:男 1:女 2:保密")
|
||||||
|
private Integer gender;
|
||||||
|
@Excel(name = "邮箱")
|
||||||
|
private String email;
|
||||||
|
@Excel(name = "手机号")
|
||||||
|
private String mobile;
|
||||||
|
@Excel(name = "部门ID")
|
||||||
|
private Long deptId;
|
||||||
|
@Excel(name = "超级管理员 0:否 1:是")
|
||||||
|
private Integer superAdmin;
|
||||||
|
@Excel(name = "状态 0:停用 1:正常")
|
||||||
|
private Integer status;
|
||||||
|
@Excel(name = "创建者")
|
||||||
|
private Long creator;
|
||||||
|
@Excel(name = "创建时间")
|
||||||
|
private LocalDateTime createDate;
|
||||||
|
@Excel(name = "更新者")
|
||||||
|
private Long updater;
|
||||||
|
@Excel(name = "更新时间")
|
||||||
|
private LocalDateTime updateDate;
|
||||||
|
@Excel(name = "删除标识,是否有效:1可用 0不可用")
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.cnbm.generator.code.mapper;
|
||||||
|
|
||||||
|
import com.cnbm.common.dao.BaseDao;
|
||||||
|
import com.cnbm.generator.code.entity.User;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户
|
||||||
|
*
|
||||||
|
* @author why
|
||||||
|
* @since 2022-08-23
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface UserMapper extends BaseDao<User> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cnbm.generator.code.mapper.UserMapper">
|
||||||
|
<resultMap type="com.cnbm.generator.code.entity.User" id="UserMap">
|
||||||
|
<id column="id" property="id" />
|
||||||
|
<id column="username" property="username" />
|
||||||
|
<id column="password" property="password" />
|
||||||
|
<id column="real_name" property="realName" />
|
||||||
|
<id column="head_url" property="headUrl" />
|
||||||
|
<id column="gender" property="gender" />
|
||||||
|
<id column="email" property="email" />
|
||||||
|
<id column="mobile" property="mobile" />
|
||||||
|
<id column="dept_id" property="deptId" />
|
||||||
|
<id column="super_admin" property="superAdmin" />
|
||||||
|
<id column="status" property="status" />
|
||||||
|
<id column="creator" property="creator" />
|
||||||
|
<id column="create_date" property="createDate" />
|
||||||
|
<id column="updater" property="updater" />
|
||||||
|
<id column="update_date" property="updateDate" />
|
||||||
|
<id column="valid" property="valid" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,7 @@
|
|||||||
|
-- 菜单初始SQL
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date)VALUES (1561967314641956865, 1067246875800000035, '系统用户', 'code/user', NULL, 0, 'icon-desktop', 0, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623361, 1561967314641956865, '查看', NULL, 'code:user:page,code:user:info', 1, NULL, 0, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623362, 1561967314641956865, '新增', NULL, 'code:user:save', 1, NULL, 1, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623363, 1561967314641956865, '修改', NULL, 'code:user:update', 1, NULL, 2, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623364, 1561967314641956865, '删除', NULL, 'code:user:delete', 1, NULL, 3, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623365, 1561967314641956865, '导出', NULL, 'code:user:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now());
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.cnbm.generator.code.service;
|
||||||
|
|
||||||
|
import com.cnbm.common.service.CrudService;
|
||||||
|
import com.cnbm.generator.code.dto.UserDTO;
|
||||||
|
import com.cnbm.generator.code.entity.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户
|
||||||
|
*
|
||||||
|
* @author why
|
||||||
|
* @since 2022-08-23
|
||||||
|
*/
|
||||||
|
public interface IUserService extends CrudService<User, UserDTO> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.cnbm.generator.code.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.cnbm.common.service.impl.CrudServiceImpl;
|
||||||
|
import com.cnbm.generator.code.dto.UserDTO;
|
||||||
|
import com.cnbm.generator.code.mapper.UserMapper;
|
||||||
|
import com.cnbm.generator.code.entity.User;
|
||||||
|
import com.cnbm.generator.code.service.IUserService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户
|
||||||
|
*
|
||||||
|
* @author why
|
||||||
|
* @since 2022-08-23
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserServiceImpl extends CrudServiceImpl<UserMapper, User, UserDTO> implements IUserService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper<User> getWrapper(Map<String, Object> params){
|
||||||
|
String id = (String)params.get("id");
|
||||||
|
|
||||||
|
QueryWrapper<User> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -9,8 +9,6 @@ import java.io.IOException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author weihongyang
|
* @Author weihongyang
|
||||||
* @Date 2022/6/29 2:01 PM
|
* @Date 2022/6/29 2:01 PM
|
||||||
|
Loading…
Reference in New Issue
Block a user