diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..75aac1a
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,10 @@
+.idea/
+.git/
+.gitignore
+*/**/target/
+**/*.iml
+*.md
+.drone.yml
+LICENSE
+.dockerignore
+Dockerfile
\ No newline at end of file
diff --git a/.drone.yml b/.drone.yml
new file mode 100644
index 0000000..3dca087
--- /dev/null
+++ b/.drone.yml
@@ -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
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..b764535
--- /dev/null
+++ b/Dockerfile
@@ -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"]
diff --git a/pom.xml b/pom.xml
index e30dc2c..0b6df18 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,7 @@
1.8
4.13.2
4.2.2
-
+ 1.2.9
3.5.1
4.0
11.2.0.3
@@ -119,9 +119,14 @@
postgresql
- org.springframework.boot
- spring-boot-starter-data-jdbc
+ com.alibaba
+ druid-spring-boot-starter
+ ${druid.version}
+
+
+
+
cn.afterturn
@@ -205,6 +210,10 @@
+
+
+
+
diff --git a/settings.xml b/settings.xml
new file mode 100644
index 0000000..b1c7d51
--- /dev/null
+++ b/settings.xml
@@ -0,0 +1,19 @@
+
+
+
+ /usr/share/maven/ref/repository
+
+
+ com.spotify
+
+
+
+
+ central
+ *
+ aliyun
+ https://maven.aliyun.com/repository/public
+
+
+
\ No newline at end of file
diff --git a/ym-admin/src/main/java/com/cnbm/admin/aspect/LogOperationAspect.java b/ym-admin/src/main/java/com/cnbm/admin/aspect/LogOperationAspect.java
index 619c43f..e55c8c5 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/aspect/LogOperationAspect.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/aspect/LogOperationAspect.java
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
+import java.util.Date;
/**
* @Author weihongyang
@@ -78,6 +79,7 @@ public class LogOperationAspect {
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
if(loginUser != null){
log.setCreatorName(loginUser.getUsername());
+ log.setCreator(loginUser.getSysUserEntity().getCreator());
}
log.setStatus(status);
@@ -89,6 +91,7 @@ public class LogOperationAspect {
log.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
log.setRequestUri(request.getRequestURI());
log.setRequestMethod(request.getMethod());
+ log.setCreateDate(new Date());
//请求参数
Object[] args = joinPoint.getArgs();
diff --git a/ym-admin/src/main/java/com/cnbm/admin/config/CorsConfig.java b/ym-admin/src/main/java/com/cnbm/admin/config/CorsConfig.java
index 19c79e7..aa8986e 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/config/CorsConfig.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/config/CorsConfig.java
@@ -41,6 +41,7 @@ public class CorsConfig implements WebMvcConfigurer {
.allowedMethods("GET", "POST", "DELETE", "PUT")
// 设置允许的header属性
.allowedHeaders("*")
+ .exposedHeaders("*")
// 跨域允许时间
.maxAge(3600);
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/config/MybatisPlusConfig.java b/ym-admin/src/main/java/com/cnbm/admin/config/MybatisPlusConfig.java
new file mode 100644
index 0000000..3f5b021
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/config/MybatisPlusConfig.java
@@ -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;
+ }
+
+}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java
index 2fff7b1..4c58b45 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java
@@ -72,7 +72,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/swagger-ui/**",
"/webjars/**",
"/websocket/**",
- "/captcha").anonymous()
+ "/captcha",
+ "druid/**").anonymous()
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
// 除上面外的所有请求全部需要鉴权认证
.anyRequest()
diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/LoginController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/LoginController.java
index 85abb6a..14d31ca 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/controller/LoginController.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/controller/LoginController.java
@@ -6,6 +6,7 @@ import com.cnbm.admin.service.CaptchaService;
import com.cnbm.admin.service.LoginService;
import com.cnbm.admin.utils.ResponseResult;
import com.cnbm.common.exception.ErrorCode;
+import com.cnbm.common.utils.Result;
import com.cnbm.common.validator.AssertUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -52,13 +53,16 @@ public class LoginController {
@PostMapping("/login")
@ApiOperation(value = "登录")
- public ResponseResult login(HttpServletRequest request, @RequestBody LoginParam loginParam) {
+ public Result login(HttpServletRequest request, @RequestBody LoginParam loginParam) {
return loginService.login(request,loginParam);
}
- @PostMapping("/doLogout")
+ @PostMapping("logout")
@ApiOperation(value = "退出")
- public void logout(){
+ public Result logout(HttpServletRequest request){
+ loginService.logout(request);
+ return new Result();
}
+
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogLoginController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogLoginController.java
new file mode 100644
index 0000000..882eca1
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogLoginController.java
@@ -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> page(@ApiIgnore @RequestParam Map params){
+ PageData page = sysLogLoginService.page(params);
+
+ return new Result>().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 params, HttpServletResponse response) throws Exception {
+ List list = sysLogLoginService.list(params);
+
+ ExcelUtils.exportExcelToTarget(response, null, list, SysLogLoginExcel.class);
+ }
+
+}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/dao/SysLogLoginDao.java b/ym-admin/src/main/java/com/cnbm/admin/dao/SysLogLoginDao.java
new file mode 100644
index 0000000..c4a9ddb
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/dao/SysLogLoginDao.java
@@ -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 {
+
+}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/dto/SysLogLoginDTO.java b/ym-admin/src/main/java/com/cnbm/admin/dto/SysLogLoginDTO.java
new file mode 100644
index 0000000..c52d0c4
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/dto/SysLogLoginDTO.java
@@ -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;
+
+}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/LoginUser.java b/ym-admin/src/main/java/com/cnbm/admin/entity/LoginUser.java
index 6729ecd..6d1b4f4 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/LoginUser.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/LoginUser.java
@@ -20,7 +20,9 @@ import java.util.stream.Collectors;
@Data
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
-public class LoginUser implements UserDetails {
+public class LoginUser implements UserDetails{
+
+ private static final long serialVersionUID = 1L;
private SysUserEntity sysUserEntity;
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysDeptEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysDeptEntity.java
index 436cbbf..8811473 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysDeptEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysDeptEntity.java
@@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnbm.common.entity.BaseEntity;
import lombok.Data;
@@ -51,5 +52,10 @@ public class SysDeptEntity extends BaseEntity {
*/
@TableField(exist = false)
private String parentName;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysDictDataEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysDictDataEntity.java
index 2726cce..b653807 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysDictDataEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysDictDataEntity.java
@@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnbm.common.entity.BaseEntity;
import lombok.Data;
@@ -49,4 +50,9 @@ public class SysDictDataEntity extends BaseEntity {
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysDictTypeEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysDictTypeEntity.java
index 103054e..87f0f7c 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysDictTypeEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysDictTypeEntity.java
@@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnbm.common.entity.BaseEntity;
import lombok.Data;
@@ -45,4 +46,9 @@ public class SysDictTypeEntity extends BaseEntity {
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogErrorEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogErrorEntity.java
index f2cbc59..a03a698 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogErrorEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogErrorEntity.java
@@ -1,5 +1,6 @@
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;
@@ -40,5 +41,10 @@ public class SysLogErrorEntity extends BaseEntity {
* 异常信息
*/
private String errorInfo;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
\ No newline at end of file
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogLoginEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogLoginEntity.java
new file mode 100644
index 0000000..83ec439
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogLoginEntity.java
@@ -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;
+
+}
\ No newline at end of file
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogOperationEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogOperationEntity.java
index 98cd9dc..9745f86 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogOperationEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysLogOperationEntity.java
@@ -1,5 +1,6 @@
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;
@@ -52,4 +53,9 @@ public class SysLogOperationEntity extends BaseEntity {
* 用户名
*/
private String creatorName;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysMenuEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysMenuEntity.java
index 3843d0a..8ef25aa 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysMenuEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysMenuEntity.java
@@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnbm.common.entity.BaseEntity;
import lombok.Data;
@@ -63,5 +64,10 @@ public class SysMenuEntity extends BaseEntity {
*/
@TableField(exist = false)
private String parentName;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysParamsEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysParamsEntity.java
index 67aafbc..e3c51f7 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysParamsEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysParamsEntity.java
@@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnbm.common.entity.BaseEntity;
import lombok.Data;
@@ -46,5 +47,10 @@ public class SysParamsEntity extends BaseEntity {
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleDataScopeEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleDataScopeEntity.java
index 7e73287..3693efe 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleDataScopeEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleDataScopeEntity.java
@@ -1,5 +1,6 @@
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;
@@ -24,5 +25,10 @@ public class SysRoleDataScopeEntity extends BaseEntity {
* 部门ID
*/
private Long deptId;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleEntity.java
index b96a570..2605a31 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleEntity.java
@@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnbm.common.entity.BaseEntity;
import lombok.Data;
@@ -43,4 +44,9 @@ public class SysRoleEntity extends BaseEntity {
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleMenuEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleMenuEntity.java
index caf8b8b..96484d1 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleMenuEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleMenuEntity.java
@@ -1,5 +1,6 @@
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;
@@ -23,5 +24,10 @@ public class SysRoleMenuEntity extends BaseEntity {
* 菜单ID
*/
private Long menuId;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleUserEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleUserEntity.java
index fd748f8..1103275 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleUserEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysRoleUserEntity.java
@@ -1,5 +1,6 @@
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;
@@ -24,6 +25,11 @@ public class SysRoleUserEntity extends BaseEntity {
* 用户ID
*/
private Long userId;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/entity/SysUserEntity.java b/ym-admin/src/main/java/com/cnbm/admin/entity/SysUserEntity.java
index 22d9eef..6c989ed 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/entity/SysUserEntity.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/entity/SysUserEntity.java
@@ -2,6 +2,7 @@ package com.cnbm.admin.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cnbm.common.entity.BaseEntity;
import lombok.Data;
@@ -76,5 +77,10 @@ public class SysUserEntity extends BaseEntity implements Serializable {
*/
@TableField(exist=false)
private String deptName;
+ /**
+ * 删除标识,是否有效:1可用 0不可用
+ */
+ @TableLogic
+ private Integer valid;
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/enums/LoginOperationEnum.java b/ym-admin/src/main/java/com/cnbm/admin/enums/LoginOperationEnum.java
new file mode 100644
index 0000000..dea9804
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/enums/LoginOperationEnum.java
@@ -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;
+ }
+}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/enums/LoginStatusEnum.java b/ym-admin/src/main/java/com/cnbm/admin/enums/LoginStatusEnum.java
new file mode 100644
index 0000000..e30d1b3
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/enums/LoginStatusEnum.java
@@ -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;
+ }
+}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/execl/SysLogLoginExcel.java b/ym-admin/src/main/java/com/cnbm/admin/execl/SysLogLoginExcel.java
new file mode 100644
index 0000000..8230aa2
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/execl/SysLogLoginExcel.java
@@ -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;
+
+}
+
diff --git a/ym-admin/src/main/java/com/cnbm/admin/filter/JwtAuthenticationTokenFilter.java b/ym-admin/src/main/java/com/cnbm/admin/filter/JwtAuthenticationTokenFilter.java
index 3730eb8..c5f77a1 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/filter/JwtAuthenticationTokenFilter.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/filter/JwtAuthenticationTokenFilter.java
@@ -55,7 +55,6 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
throw new RuntimeException("用户未登录");
}
//存入SecurityContextHolder
- //TODO 获取权限信息封装到Authentication中
UsernamePasswordAuthenticationToken authenticationToken =
new UsernamePasswordAuthenticationToken(loginUser,null,loginUser.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
diff --git a/ym-admin/src/main/java/com/cnbm/admin/service/LoginService.java b/ym-admin/src/main/java/com/cnbm/admin/service/LoginService.java
index 9f93524..c5bd308 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/service/LoginService.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/service/LoginService.java
@@ -1,7 +1,7 @@
package com.cnbm.admin.service;
import com.cnbm.admin.params.LoginParam;
-import com.cnbm.admin.utils.ResponseResult;
+import com.cnbm.common.utils.Result;
import javax.servlet.http.HttpServletRequest;
@@ -12,6 +12,8 @@ import javax.servlet.http.HttpServletRequest;
*/
public interface LoginService {
- ResponseResult login(HttpServletRequest request, LoginParam loginParam);
+ Result login(HttpServletRequest request, LoginParam loginParam);
+
+ void logout(HttpServletRequest request);
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/service/SysLogLoginService.java b/ym-admin/src/main/java/com/cnbm/admin/service/SysLogLoginService.java
new file mode 100644
index 0000000..2fec755
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/service/SysLogLoginService.java
@@ -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 {
+
+ PageData page(Map params);
+
+ List list(Map params);
+
+ void save(SysLogLoginEntity entity);
+}
\ No newline at end of file
diff --git a/ym-admin/src/main/java/com/cnbm/admin/service/impl/LoginServiceImpl.java b/ym-admin/src/main/java/com/cnbm/admin/service/impl/LoginServiceImpl.java
index ada95af..cdf977c 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/service/impl/LoginServiceImpl.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/service/impl/LoginServiceImpl.java
@@ -1,14 +1,22 @@
package com.cnbm.admin.service.impl;
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.service.CaptchaService;
+import com.cnbm.admin.service.SysLogLoginService;
import com.cnbm.admin.utils.JwtUtil;
import com.cnbm.admin.service.LoginService;
import com.cnbm.admin.utils.ResponseResult;
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.data.redis.core.RedisTemplate;
+import org.springframework.http.HttpHeaders;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -16,9 +24,11 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.concurrent.TimeUnit;
/**
* @Author weihongyang
@@ -37,16 +47,30 @@ public class LoginServiceImpl implements LoginService {
@Autowired
private CaptchaService captchaService;
+ @Autowired
+ private SysLogLoginService sysLogLoginService;
+
@Override
- public ResponseResult login(HttpServletRequest request, LoginParam loginParam) {
+ public Result login(HttpServletRequest request, LoginParam loginParam) {
//验证码是否正确
boolean flag = captchaService.validate(loginParam.getUuid(), loginParam.getCaptcha());
if(!flag){
- return new ResponseResult(ErrorCode.CAPTCHA_ERROR,"验证码错误");
+ return new Result<>().error(ErrorCode.CAPTCHA_ERROR, "验证码错误");
}
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginParam.getUsername(),loginParam.getPassword());
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)) {
+ log.setStatus(LoginStatusEnum.FAIL.value());
+ log.setCreatorName(loginParam.getUsername());
+ sysLogLoginService.save(log);
throw new RuntimeException("登录失败");
}
//如果认证通过了,使用userid生成一个jwt jwt存入ResponseResult返回
@@ -56,8 +80,34 @@ public class LoginServiceImpl implements LoginService {
Map map = new HashMap<>();
map.put("token",jwt);
//把完整的用户信息存入redis userid作为key
- redisTemplate.opsForValue().set("login:"+userid,loginUser);
- return new ResponseResult(200,"登录成功",map);
+ redisTemplate.opsForValue().set("login:"+userid,loginUser,1, TimeUnit.DAYS);
+ //登录成功
+ 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);
}
}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/service/impl/SysLogLoginServiceImpl.java b/ym-admin/src/main/java/com/cnbm/admin/service/impl/SysLogLoginServiceImpl.java
new file mode 100644
index 0000000..b3faa57
--- /dev/null
+++ b/ym-admin/src/main/java/com/cnbm/admin/service/impl/SysLogLoginServiceImpl.java
@@ -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 implements SysLogLoginService {
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, Constant.CREATE_DATE, false),
+ getWrapper(params)
+ );
+
+ return getPageData(page, SysLogLoginDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, SysLogLoginDTO.class);
+ }
+
+ private QueryWrapper getWrapper(Map params){
+ String status = (String) params.get("status");
+ String creatorName = (String) params.get("creatorName");
+
+ QueryWrapper 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);
+ }
+
+}
diff --git a/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java b/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java
index 389c4c9..0204aa6 100644
--- a/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java
+++ b/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java
@@ -5,23 +5,24 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cnbm.admin.dto.SysMenuDTO;
import com.cnbm.admin.dto.SysUserDTO;
import com.cnbm.admin.entity.LoginUser;
+import com.cnbm.admin.entity.SysLogLoginEntity;
import com.cnbm.admin.entity.SysMenuEntity;
import com.cnbm.admin.entity.SysUserEntity;
+import com.cnbm.admin.enums.LoginOperationEnum;
import com.cnbm.admin.exception.LoginStatusException;
import com.cnbm.admin.service.SysMenuService;
import com.cnbm.common.utils.ConvertUtils;
+import com.cnbm.common.utils.IpUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -45,6 +46,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SysUserEntity::getUsername,username);
SysUserEntity sysUserEntity = userDao.selectOne(lambdaQueryWrapper);
+
if (Objects.isNull(sysUserEntity)) {
throw new UsernameNotFoundException("用户名不存在");
}
diff --git a/ym-admin/src/main/resources/mapper/SysLogLoginDao.xml b/ym-admin/src/main/resources/mapper/SysLogLoginDao.xml
new file mode 100644
index 0000000..587044e
--- /dev/null
+++ b/ym-admin/src/main/resources/mapper/SysLogLoginDao.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ym-common/src/main/java/com/cnbm/common/entity/BaseEntity.java b/ym-common/src/main/java/com/cnbm/common/entity/BaseEntity.java
index 4190a44..2ad188f 100644
--- a/ym-common/src/main/java/com/cnbm/common/entity/BaseEntity.java
+++ b/ym-common/src/main/java/com/cnbm/common/entity/BaseEntity.java
@@ -3,6 +3,8 @@ package com.cnbm.common.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+
import lombok.Data;
import java.io.Serializable;
@@ -30,4 +32,5 @@ public abstract class BaseEntity implements Serializable {
*/
@TableField(fill = FieldFill.INSERT)
private Date createDate;
+
}
diff --git a/ym-common/src/main/java/com/cnbm/common/interceptor/DataFilterInterceptor.java b/ym-common/src/main/java/com/cnbm/common/interceptor/DataFilterInterceptor.java
new file mode 100644
index 0000000..9c8db8d
--- /dev/null
+++ b/ym-common/src/main/java/com/cnbm/common/interceptor/DataFilterInterceptor.java
@@ -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;
+ }
+ }
+}
diff --git a/ym-common/src/main/java/com/cnbm/common/interceptor/DataScope.java b/ym-common/src/main/java/com/cnbm/common/interceptor/DataScope.java
new file mode 100644
index 0000000..1f7f8a2
--- /dev/null
+++ b/ym-common/src/main/java/com/cnbm/common/interceptor/DataScope.java
@@ -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;
+ }
+}
diff --git a/ym-common/src/main/java/com/cnbm/common/utils/CountUtils.java b/ym-common/src/main/java/com/cnbm/common/utils/CountUtils.java
new file mode 100644
index 0000000..5b522e0
--- /dev/null
+++ b/ym-common/src/main/java/com/cnbm/common/utils/CountUtils.java
@@ -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 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 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 data) {
+// BigDecimal sqrt = sqrt(POP_Variance(data), 4);
+// return sqrt;
+// }
+//
+// //sample variance 样本方差
+// public static BigDecimal Sample_Variance(List 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 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 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));
+
+ }
+
+}
diff --git a/ym-common/src/main/java/com/cnbm/common/utils/ExcelUtils.java b/ym-common/src/main/java/com/cnbm/common/utils/ExcelUtils.java
index 54373d5..9f235b7 100644
--- a/ym-common/src/main/java/com/cnbm/common/utils/ExcelUtils.java
+++ b/ym-common/src/main/java/com/cnbm/common/utils/ExcelUtils.java
@@ -41,6 +41,7 @@ public class ExcelUtils {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), pojoClass, list);
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
+ response.setHeader("Access-Control-Expose-Headers","Content-Disposition");
response.setHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xls");
ServletOutputStream out = response.getOutputStream();
diff --git a/ym-common/src/main/java/com/cnbm/common/utils/LeastSquares.java b/ym-common/src/main/java/com/cnbm/common/utils/LeastSquares.java
new file mode 100644
index 0000000..5f63dd8
--- /dev/null
+++ b/ym-common/src/main/java/com/cnbm/common/utils/LeastSquares.java
@@ -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));
+ }
+}
diff --git a/ym-gateway/pom.xml b/ym-gateway/pom.xml
index a47ed6c..713f8da 100644
--- a/ym-gateway/pom.xml
+++ b/ym-gateway/pom.xml
@@ -65,4 +65,60 @@
-
\ No newline at end of file
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.5.12
+
+
+ com.cnbm.YmApplication
+
+
+ true
+ ${project.basedir}/src/main/resources/layers.xml
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+ repackage
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+ com.spotify
+ docker-maven-plugin
+ ${docker.plugin.version}
+
+ ym-pass/${project.artifactId}
+ ${project.basedir}/
+
+
+ /
+ ${project.build.directory}
+ ${project.build.finalName}.jar
+
+
+
+
+
+
+
+
diff --git a/ym-gateway/src/main/resources/application-dev.yml b/ym-gateway/src/main/resources/application-dev.yml
index 609c59e..2bdf131 100644
--- a/ym-gateway/src/main/resources/application-dev.yml
+++ b/ym-gateway/src/main/resources/application-dev.yml
@@ -20,10 +20,36 @@ spring:
# url: jdbc:postgresql://192.168.10.10:5432/postgres
# username: postgres
# password: 123456
- hikari:
- pool-name: GrowUpHikariCP
- minimum-idle: 1
- maximum-pool-size: 10
+ initial-size: 10
+ max-active: 100
+ min-idle: 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
#dynamic:
diff --git a/ym-gateway/src/main/resources/application.yml b/ym-gateway/src/main/resources/application.yml
index d3ab12d..dd83b23 100644
--- a/ym-gateway/src/main/resources/application.yml
+++ b/ym-gateway/src/main/resources/application.yml
@@ -32,7 +32,7 @@ spring:
max-request-size: 100MB
enabled: true
redis:
- database: 2
+ database: 6
host: redis.picaiba.com
port: 6380
password: '@WSXcde3' # 密码(默认为空)
@@ -69,12 +69,12 @@ mybatis-plus:
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
configuration-properties:
prefix:
blobType: BLOB
boolValue: TRUE
-logging:
- level:
- com.cnbm.admin.dao: DEBUG
\ No newline at end of file
+#logging:
+# level:
+# com.cnbm.admin.dao: DEBUG
\ No newline at end of file
diff --git a/ym-gateway/src/main/resources/layers.xml b/ym-gateway/src/main/resources/layers.xml
new file mode 100644
index 0000000..25736ee
--- /dev/null
+++ b/ym-gateway/src/main/resources/layers.xml
@@ -0,0 +1,27 @@
+
+
+
+ org/springframework/boot/loader/**
+
+
+
+
+
+ *:*:*SNAPSHOT
+
+
+ com.cnbm:*
+
+
+
+
+ dependencies
+ spring-boot-loader
+ snapshot-dependencies
+ company-dependencies
+ application
+
+
diff --git a/ym-gateway/src/main/resources/logback-spring.xml b/ym-gateway/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..7111d2f
--- /dev/null
+++ b/ym-gateway/src/main/resources/logback-spring.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/controller/UserController.java b/ym-generator/src/main/java/com/cnbm/generator/code/controller/UserController.java
new file mode 100644
index 0000000..aeb69f2
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/controller/UserController.java
@@ -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> page(@ApiIgnore @RequestParam Map params){
+ PageData page = userService.page(params);
+
+ return new Result>().ok(page);
+ }
+
+ @GetMapping("{id}")
+ @ApiOperation("信息")
+ @PreAuthorize("@ex.hasAuthority('code:user:info')")
+ public Result get(@PathVariable("id") Long id){
+ UserDTO data = userService.get(id);
+
+ return new Result().ok(data);
+ }
+
+ @PostMapping
+ @ApiOperation("保存")
+ @LogOperation("保存")
+ @PreAuthorize("@ex.hasAuthority('code:user:save')")
+ public Result save(@RequestBody UserDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+
+ userService.save(dto);
+
+ return new Result().ok(dto.getId());
+ }
+
+ @PutMapping
+ @ApiOperation("修改")
+ @LogOperation("修改")
+ @PreAuthorize("@ex.hasAuthority('code:user:update')")
+ public Result update(@RequestBody UserDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
+
+ userService.update(dto);
+
+ return new Result().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 params, HttpServletResponse response) throws Exception {
+ List list = userService.list(params);
+
+ ExcelUtils.exportExcelToTarget(response, null, list, UserExcel.class);
+ }
+
+}
\ No newline at end of file
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/dto/UserDTO.java b/ym-generator/src/main/java/com/cnbm/generator/code/dto/UserDTO.java
new file mode 100644
index 0000000..00b077e
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/dto/UserDTO.java
@@ -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;
+
+}
\ No newline at end of file
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/entity/User.java b/ym-generator/src/main/java/com/cnbm/generator/code/entity/User.java
new file mode 100644
index 0000000..c7ed12c
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/entity/User.java
@@ -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;
+
+/**
+ *
+ * 系统用户
+ *
+ *
+ * @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;
+
+
+}
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/excel/UserExcel.java b/ym-generator/src/main/java/com/cnbm/generator/code/excel/UserExcel.java
new file mode 100644
index 0000000..cf092ba
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/excel/UserExcel.java
@@ -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;
+
+}
\ No newline at end of file
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mapper/UserMapper.java b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/UserMapper.java
new file mode 100644
index 0000000..e938420
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/UserMapper.java
@@ -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 {
+
+}
\ No newline at end of file
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mapper/UserMapper.xml b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/UserMapper.xml
new file mode 100644
index 0000000..239fea5
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/mapper/UserMapper.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/mysql/Usermysql.sql b/ym-generator/src/main/java/com/cnbm/generator/code/mysql/Usermysql.sql
new file mode 100644
index 0000000..8b8a987
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/mysql/Usermysql.sql
@@ -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());
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/service/IUserService.java b/ym-generator/src/main/java/com/cnbm/generator/code/service/IUserService.java
new file mode 100644
index 0000000..06a8e20
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/service/IUserService.java
@@ -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 {
+
+}
\ No newline at end of file
diff --git a/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/UserServiceImpl.java b/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..6a8c4f7
--- /dev/null
+++ b/ym-generator/src/main/java/com/cnbm/generator/code/service/impl/UserServiceImpl.java
@@ -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 implements IUserService {
+
+ @Override
+ public QueryWrapper getWrapper(Map params){
+ String id = (String)params.get("id");
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq(StringUtils.isNotBlank(id), "id", id);
+
+ return wrapper;
+ }
+
+
+}
\ No newline at end of file
diff --git a/ym-websocket/src/main/java/com/cnbm/websocket/task/SendMessageTask.java b/ym-websocket/src/main/java/com/cnbm/websocket/task/SendMessageTask.java
index 0601de2..c7bdef0 100644
--- a/ym-websocket/src/main/java/com/cnbm/websocket/task/SendMessageTask.java
+++ b/ym-websocket/src/main/java/com/cnbm/websocket/task/SendMessageTask.java
@@ -9,8 +9,6 @@ import java.io.IOException;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
/**
* @Author weihongyang
* @Date 2022/6/29 2:01 PM