Commit 1f5f6de8 by wuchao

初始化

parent 684599b3
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
catalina.base_IS_UNDEFINED/logs/auth-master/
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
# springboot-jwt
SpringBoot集成JWT实现token验证
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.platform</groupId>
<artifactId>platform.server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>platform-server</name>
<description>project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<skipTests>true</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!-- fastjson-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.59</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.4.0</version>
</dependency>
<!-- Druid 数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.18</version>
</dependency>
<!--开发环境热部署插件-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-devtools</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!-- Swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- rabbitmq-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- 分页处理 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
<!--Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--mybatis自动生成代码插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<!-- 是否覆盖,true表示会替换生成的JAVA文件,false则不覆盖 -->
<overwrite>false</overwrite>
</configuration>
<dependencies>
<!--mysql驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
</dependency>
</dependencies>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-compiler-plugin</artifactId>-->
<!--<configuration>-->
<!--<source>8</source>-->
<!--<target>8</target>-->
<!--</configuration>-->
<!--</plugin>-->
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
package com.platform.springboot;
import com.platform.springboot.wxmessage.ApiConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication
@EnableCaching
@MapperScan("com.platform.springboot.mapper")
public class SpringbootApplication {
public static void main(String[] args) {
// SpringApplication.run(SpringbootApplication.class, args);
//初始化微信相关配置
ConfigurableApplicationContext context = SpringApplication.run(SpringbootApplication.class, args);
context.getBean(ApiConfig.class).ApiConfigInit(true);
}
}
package com.platform.springboot.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author zhouy
* @date 2018-07-08 20:38
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface PassToken {
boolean required() default true;
}
package com.platform.springboot.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author zhouy
* @date 2018-07-08 20:40
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface UserLoginToken {
boolean required() default true;
}
package com.platform.springboot.api;
/**
* .::::.
* .::::::::.
* ::::::::::: 佛主保佑、永无Bug
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* ``::::::::::::::::
* ::::``:::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ``::::.
* ...::: ::::::::::::' ``::.
* ```` ':. ':::::::::' ::::..
* '.:::::' ':'````..
*/
import com.platform.springboot.annotation.UserLoginToken;
import com.platform.springboot.domain.ResponseUserToken;
import com.platform.springboot.domain.ResultCode;
import com.platform.springboot.domain.ResultJson;
import com.platform.springboot.domain.entity.Applications;
import com.platform.springboot.domain.entity.User;
import com.platform.springboot.rabbitmq.AmqpService;
import com.platform.springboot.service.ApplicationsService;
import com.platform.springboot.service.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
* @ClassName: ApplicationsApi
* @Description: ${description}
* @Authror zhouy
* @Date 2019-08-27 17:48
*/
@Slf4j
@RestController
@Api(tags = "token调用接口类")
public class ApplicationsApi {
@Autowired
ApplicationsService applicationsService;
@Autowired
TokenService tokenService;
@Autowired
AmqpService amqpService;
@PostMapping(value = "/applicationsToken")
@ApiOperation(value = "获得token", notes = "调用成功返回token")
public ResultJson applicationsToken(
@Valid @RequestBody User user){
String token = "";
Applications application = applicationsService.getApplications(user.getAppid(),user.getSecret());
if (application!=null){
token =tokenService.getToken(application);
}else{
return ResultJson.failure(ResultCode.UNAUTHORIZED);
}
log.info("应用验证成功,appid:"+user.getAppid());
return ResultJson.ok(token);
}
@UserLoginToken
@GetMapping("/getMessage")
public String getMessage(){
return "你已通过验证";
}
}
package com.platform.springboot.config;
import com.platform.springboot.interceptor.AuthenticationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author zhouy
* @date 2018-07-08 22:33
*/
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 拦截所有请求,通过判断是否有 @LoginRequired 注解 决定是否需要登录
registry.addInterceptor(authenticationInterceptor())
.addPathPatterns("/**");
}
@Bean
public AuthenticationInterceptor authenticationInterceptor() {
return new AuthenticationInterceptor();
}
}
package com.platform.springboot.config;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import javax.annotation.Resource;
import static org.springframework.data.redis.cache.RedisCacheConfiguration.defaultCacheConfig;
/**
* @author
* 暂不启用,有特殊配置是启用
*/
//@Configuration
//@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {
@Resource
private RedisConnectionFactory factory;
/**
* 自定义生成redis-key
*
* @return
*/
@Override
@Bean
public KeyGenerator keyGenerator() {
return (o, method, objects) -> {
StringBuilder sb = new StringBuilder();
sb.append(o.getClass().getName()).append(".");
sb.append(method.getName()).append(".");
for (Object obj : objects) {
sb.append(obj.toString());
}
System.out.println("keyGenerator=" + sb.toString());
return sb.toString();
};
}
@Bean
public RedisTemplate<Object, Object> redisTemplate() {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(factory);
GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
redisTemplate.setKeySerializer(genericJackson2JsonRedisSerializer);
redisTemplate.setValueSerializer(genericJackson2JsonRedisSerializer);
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(genericJackson2JsonRedisSerializer);
return redisTemplate;
}
@Bean
@Override
public CacheResolver cacheResolver() {
return new SimpleCacheResolver(cacheManager());
}
@Bean
@Override
public CacheErrorHandler errorHandler() {
// 用于捕获从Cache中进行CRUD时的异常的回调处理器。
return new SimpleCacheErrorHandler();
}
@Bean
@Override
public CacheManager cacheManager() {
RedisCacheConfiguration cacheConfiguration =
defaultCacheConfig()
.disableCachingNullValues()
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()));
return RedisCacheManager.builder(factory).cacheDefaults(cacheConfiguration).build();
}
}
\ No newline at end of file
package com.platform.springboot.config;
import com.google.common.base.Predicates;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author zhouy
* swagger相关配置类
*/
//@EnableSwagger2
//@Configuration
public class SwaggerConfig {
private Contact contact = new Contact("zhouy","/doc.html", "zhouyang@palacesun.com");
//@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("api")// 定义组
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(Predicates.not(PathSelectors.regex("/error.*")))
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("基础平台接口 v1.0")
.description("基础平台接口")
.contact(contact)
.version("1.0")
.build();
}
}
package com.platform.springboot.controller;
import com.platform.springboot.annotation.UserLoginToken;
import com.platform.springboot.domain.ResultJson;
import com.platform.springboot.domain.dto.DepartmentPersonneDTO;
import com.platform.springboot.domain.entity.Department;
import com.platform.springboot.service.DepartmentService;
import com.platform.springboot.service.PersonnelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@Api(tags = "平台部门机构信息")
@RequestMapping("/api/dt")
public class DepartmentController {
@Resource
private DepartmentService departmentService;
@Resource
private PersonnelService personnelService;
@GetMapping(value = "/dept")
@ApiOperation(value = "获取部门列表", notes = "获取部门列表不分页 http://ditie.wbb.aizhuanxing.com/index/jiekou/dept")
@ApiImplicitParams({@ApiImplicitParam(name = "Authorization", value = "参数格式 token", required = true, dataType = "string", paramType = "header")})
@UserLoginToken(required = true)
public ResultJson<List<Department>> getDeptList(HttpServletRequest request){
List<Department> platformDepartment = departmentService.getDeptList();
return ResultJson.ok(platformDepartment);
}
@GetMapping(value = "/deptByPid/{pid}")
@ApiOperation(value = "根据部门id获取子部门列表", notes = "根据部门id获取子部门列表")
@ApiImplicitParams({@ApiImplicitParam(name = "Authorization", value = "参数格式 token", required = true, dataType = "string", paramType = "header"),
@ApiImplicitParam(name="pid",value="部门id",required=true,paramType="path"),})
@UserLoginToken(required = true)
public ResultJson<List<Department>> getDeptListByPid(@PathVariable String pid, boolean deep){
List<Department> list = null;
if(deep){
list = departmentService.getDeptListByPidWithDeep(pid);
}else{
list = departmentService.getDeptListByPid(pid);
}
return ResultJson.ok(list);
}
@GetMapping(value = "/deptByids")
@ApiOperation(value = "通过部门id查询部门", notes = "通过部门id查询部门")
@ApiImplicitParams({@ApiImplicitParam(name = "Authorization", value = "参数格式 token", required = true, dataType = "string", paramType = "header"),
@ApiImplicitParam(name="id",value="部门id (单一部门id或以,分割的部门id字符串))",required=true,paramType="query"),
})
@UserLoginToken(required = true)
public ResultJson<List<Department>> getDeptListByIds(@RequestParam(required=true,value="id",defaultValue="")String id ){
List<Department> list = departmentService.getDeptListByids(id);
return ResultJson.ok(list);
}
@GetMapping(value = "/departmentTree")
@ApiOperation(value = "部门级的树", notes = "部门级的树")
@ApiImplicitParams({@ApiImplicitParam(name = "Authorization", value = "参数格式 token", required = true, dataType = "string", paramType = "header"),
})
@UserLoginToken(required = true)
public ResultJson<DepartmentPersonneDTO> getDepartmentTree(){
DepartmentPersonneDTO entity = personnelService.getDepartmentTree();
return ResultJson.ok(entity);
}
}
package com.platform.springboot.controller;
import com.platform.springboot.domain.ResultCode;
import com.platform.springboot.domain.ResultJson;
import com.platform.springboot.domain.entity.Todo;
import com.platform.springboot.rabbitmq.AmqpService;
import com.platform.springboot.utils.JSONUtil;
import com.platform.springboot.utils.SpringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @author zhf
*/
@Slf4j
@RestController
@Api(tags = "平台待办信息")
@RequestMapping("/api/interface")
public class InterfaceController {
@PostMapping(value = "/todo/add")
@ApiOperation(value = "接收待办信息", notes = "接收待办信息")
@ApiImplicitParams({@ApiImplicitParam(name = "Authorization", value = "参数格式token", required = true, dataType = "string", paramType = "header"),
@ApiImplicitParam(name="todo",value="待办信息",required=true,dataType = "Todo",paramType="body"),})
public ResultJson addtodo(@RequestBody Todo todo){
String json = JSONUtil.toJson(todo);
log.info("加入队列消息: "+json);
SpringUtil.getBean(AmqpService.class).convertAndSend(json);//加入队列
return ResultJson.ok();
}
@GetMapping(value = "/todo/update/{buid}")
@ApiOperation(value = "更新待办已处理", notes = "更新待办已处理")
@ApiImplicitParams({@ApiImplicitParam(name = "Authorization", value = "参数格式token", required = true, dataType = "string", paramType = "header"),
@ApiImplicitParam(name="buid",value="业务id",required=true,dataType = "String",paramType="path"),})
public ResultJson updatetodo(@PathVariable String buid){
SpringUtil.getBean(AmqpService.class).convertAndSendUpdate(buid);//加入队列
return ResultJson.ok();
}
}
package com.platform.springboot.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 分页结果DO
* @author zhouy
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PageResult<T> {
private int current_page;//当前页码
private int last_page;//最后页码
private String per_page;//每页条数
private long total;//总数
private T data;
}
\ No newline at end of file
package com.platform.springboot.domain;
import com.platform.springboot.domain.entity.Applications;
import com.platform.springboot.domain.entity.Personnel;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* @author zhouy
* createAt: 2019/8/1
*/
@Data
@AllArgsConstructor
public class ResponseUserToken {
private String token;
private Applications userDetail;
}
package com.platform.springboot.domain;
/**
* @author zhouy
* 状态码
* Created by jt on 2019/8/1.
*/
public enum ResultCode {
/*
请求返回状态码和说明信息
*/
//原请求状态为200
SUCCESS(1, "获取成功"),
BAD_REQUEST(400, "参数或者语法不对"),
UNAUTHORIZED(401, "Token失效,认证失败"),
LOGIN_ERROR(401, "登陆失败,用户名或密码无效"),
FORBIDDEN(403, "禁止访问"),
NOT_FOUND(404, "请求的资源不存在"),
OPERATE_ERROR(405, "操作失败,请求操作的资源不存在"),
TIME_OUT(408, "请求超时"),
SERVER_ERROR(500, "服务器内部错误");
private int code;
private String msg;
ResultCode(int code, String msg) {
this.code = code;
this.msg = msg;
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
package com.platform.springboot.domain;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhouy
* RESTful API 返回类型
* Created at 2019/8/1.
*/
@Data
public class ResultJson<T> implements Serializable{
private static final long serialVersionUID = 783015033603078674L;
private int code;
private String msg;
private T data;
public static ResultJson ok() {
return ok("");
}
public static ResultJson ok(Object o) {
return new ResultJson(ResultCode.SUCCESS, o);
}
public static ResultJson failure(ResultCode code) {
return failure(code, "");
}
public static ResultJson failure(ResultCode code, Object o) {
return new ResultJson(code, o);
}
public ResultJson(ResultCode resultCode) {
setResultCode(resultCode);
}
public ResultJson(ResultCode resultCode, T data) {
setResultCode(resultCode);
this.data = data;
}
public void setResultCode(ResultCode resultCode) {
this.code = resultCode.getCode();
this.msg = resultCode.getMsg();
}
@Override
public String toString() {
return "{" +
"\"code\":" + code +
", \"msg\":\"" + msg + '\"' +
", \"data\":\"" + data + '\"'+
'}';
}
}
package com.platform.springboot.domain;
import lombok.Data;
@Data
public class WebUserToken {
private String username;
private String realName;
private String phoneNumber;
private String profilePhoto;
private String accessToken;
private String userId;
private Long expiredTime;
private String type;//用户类别
private String platformUsernum;//员工工号
private String status;
private String role;//角色
private String centercode;//中心编码
private String centername;//中心名称
private String deptcode;//部门编码
private String deptname;//部门名称
private String stationcode;//中心站编码
private String stationname;//中心站名称
private String groupcode;//班组编码
private String groupname;//班组名称
private String position;//岗位名称
}
package com.platform.springboot.domain.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.platform.springboot.domain.entity.Department;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel(description= "具体参数描述")
public class DepartmentDTO {
@ApiModelProperty(value = "展开标识")
private boolean expand;
@ApiModelProperty(value = "是否懒加载")
private boolean lazy;
@ApiModelProperty(value = "是否已加载")
private boolean loading;
@ApiModelProperty(value = "待办描述")
private Integer id;
@ApiModelProperty(value = "部门id")
private String title;
@ApiModelProperty(value = "部门名")
private String pid;
@ApiModelProperty(value = "上级部门id")
private String label;
@ApiModelProperty(value = "子列表")
private List<Object> children;
@ApiModelProperty(value = "人员子列表")
private List<Object> people;
public DepartmentDTO(){
}
public DepartmentDTO(Department department,boolean expand,boolean lazy,boolean loading){
this.expand=expand;
this.lazy = lazy;
this.loading = loading;
this.id = department.getId();
this.title = department.getName();
this.pid = department.getPid();
this.label = department.getName();
this.children = new ArrayList<>();
}
public DepartmentDTO(DepartmentPersonneDTO department,boolean expand,boolean lazy,boolean loading){
this.expand=expand;
this.lazy = lazy;
this.loading = loading;
this.id = department.getId();
this.title = department.getTitle();
this.pid = department.getPid();
this.label = department.getLabel();
this.children = new ArrayList<>();
}
}
package com.platform.springboot.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel(description= "具体参数描述")
public class DepartmentPersonneDTO implements Serializable {
@ApiModelProperty(value = "部门或员工id")
private Integer id;
@ApiModelProperty(value = "部门或员工名")
private String title;
@ApiModelProperty(value = "上级id")
private String pid;
@ApiModelProperty(value = "部门或员工名")
private String label;
@ApiModelProperty(value = "部门或员工id")
private Integer key;
@ApiModelProperty(value = "子列表")
private List<Object> children;
@ApiModelProperty(value = "人员子列表")
private List<Object> people;
}
package com.platform.springboot.domain.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(description= "具体参数描述")
@JsonInclude(value= JsonInclude.Include.NON_NULL)
public class PersonneBaseDTO implements Serializable {
@ApiModelProperty(value = "部门或员工id")
private Integer id;
@ApiModelProperty(value = "部门或员工名")
private String title;
@ApiModelProperty(value = "上级id")
private String pid;
@ApiModelProperty(value = "部门或员工名")
private String label;
@ApiModelProperty(value = "部门或员工id")
private Integer key;
@ApiModelProperty(value = "工号")
private String no;
@ApiModelProperty(value = "头像")
private String avatar;
public PersonneBaseDTO(PersonneDTO dto){
this.pid= dto.getPid();
this.id=dto.getId();
this.title=dto.getTitle();
this.label=dto.getLabel();
this.key=dto.getKey();
this.no= dto.getNo();
this.avatar = dto.getAvatar();
}
}
package com.platform.springboot.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description= "具体参数描述")
public class PersonneDTO{
@ApiModelProperty(value = "部门或员工id")
private Integer id;
@ApiModelProperty(value = "部门或员工名")
private String title;
@ApiModelProperty(value = "上级id")
private String pid;
@ApiModelProperty(value = "部门或员工名")
private String label;
@ApiModelProperty(value = "部门或员工id")
private Integer key;
@ApiModelProperty(value = "工号")
private String no;
@ApiModelProperty(value = "头像")
private String avatar;
}
package com.platform.springboot.domain.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@JsonInclude(value= JsonInclude.Include.NON_NULL)
@ApiModel(description= "具体参数描述")
public class PersonnelPageDTO {
@ApiModelProperty(value = "员工id")
private Integer id;
@ApiModelProperty(value = "姓名")
private String username;
@ApiModelProperty(value = "部门id")
private String department;
@ApiModelProperty(value = "派驻标识")
private String paizhu;
@ApiModelProperty(value = "职位")
private String position;
@ApiModelProperty(value = "工号")
private String number;
@ApiModelProperty(value = "部门名称")
private String bmmc;
@ApiModelProperty(value = "头像")
private String avatar;
@ApiModelProperty(value = "性别 1男 2女")
private Integer sex;
@ApiModelProperty(value = "生日")
private String birthday;
@ApiModelProperty(value = "工号")
private String account;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "手机号码")
private String phoneNumber;
@ApiModelProperty(value = "座机号码")
private String telNumber;
@ApiModelProperty(value = "邮箱地址")
private String email;
@ApiModelProperty(value = "微信昵称")
private String nickname;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "移动小号")
private String mobile;
@ApiModelProperty(value = "电信小号")
private String telecom;
@ApiModelProperty(value = "办公地点")
private String office;
@ApiModelProperty(value = "身份")
private String identity;
@ApiModelProperty(value = "角色")
private String role;
@ApiModelProperty(value = "角色")
private String addtime;
@ApiModelProperty(value = "信用分")
private String credit;
@ApiModelProperty(value = "政治面貌")
private String political;
@ApiModelProperty(value = "负责")
private String fuze;
@ApiModelProperty(value = "角色权限")
private String auth;
@ApiModelProperty(value = "应用权限")
private String appId;
@ApiModelProperty(value = "所属中心id")
private String centerid;
@ApiModelProperty(value = "所属中心")
private String centername;
@ApiModelProperty(value = "中心id")
private String metrocenterid;
@ApiModelProperty(value = "中心名")
private String metrocentername;
@ApiModelProperty(value = "1微信不存在0正常")
private String delstatus;
@ApiModelProperty(value = "启用状态0未启用1启用")
private String status;
@ApiModelProperty(value = "分公司ID")
private String branchCompanyId;
}
package com.platform.springboot.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description= "具体参数描述")
public class PersonnewxDTO {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "工号")
private String account;
@ApiModelProperty(value = "类型")
private String type;
@ApiModelProperty(value = "创建时间")
private String updatetime;
}
package com.platform.springboot.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description= "具体参数描述")
public class SearchDTO {
@ApiModelProperty(value = "页码")
private Integer pageNum;
@ApiModelProperty(value = "每页条数")
private Integer pageSize;
@ApiModelProperty(value = "派驻")
private String paizhu;
@ApiModelProperty(value = "姓名/工号")
private String key;
@ApiModelProperty(value = "字段限制,为1不限制")
private String state;
}
package com.platform.springboot.domain.entity;
import java.io.Serializable;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table platform_applications
*
* @mbg.generated do_not_delete_during_merge
*/
public class Applications implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.id
*
* @mbg.generated
*/
private Integer id;
/**
* Database Column Remarks:
* 名称
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.title
*
* @mbg.generated
*/
private String title;
/**
* Database Column Remarks:
* 图标
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.img
*
* @mbg.generated
*/
private String img;
/**
* Database Column Remarks:
* 连接
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.href
*
* @mbg.generated
*/
private String href;
/**
* Database Column Remarks:
* 添加时间
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.addtime
*
* @mbg.generated
*/
private String addtime;
/**
* Database Column Remarks:
* 是否提示
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.tishi
*
* @mbg.generated
*/
private Integer tishi;
/**
* Database Column Remarks:
* 应以唯一标识
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.appid
*
* @mbg.generated
*/
private String appid;
/**
* Database Column Remarks:
* 用户的密钥信息
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications.secret
*
* @mbg.generated
*/
private String secret;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table platform_applications
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications.id
*
* @return the value of platform_applications.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications.id
*
* @param id the value for platform_applications.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications.title
*
* @return the value of platform_applications.title
*
* @mbg.generated
*/
public String getTitle() {
return title;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications.title
*
* @param title the value for platform_applications.title
*
* @mbg.generated
*/
public void setTitle(String title) {
this.title = title;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications.img
*
* @return the value of platform_applications.img
*
* @mbg.generated
*/
public String getImg() {
return img;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications.img
*
* @param img the value for platform_applications.img
*
* @mbg.generated
*/
public void setImg(String img) {
this.img = img;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications.href
*
* @return the value of platform_applications.href
*
* @mbg.generated
*/
public String getHref() {
return href;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications.href
*
* @param href the value for platform_applications.href
*
* @mbg.generated
*/
public void setHref(String href) {
this.href = href;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications.addtime
*
* @return the value of platform_applications.addtime
*
* @mbg.generated
*/
public String getAddtime() {
return addtime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications.addtime
*
* @param addtime the value for platform_applications.addtime
*
* @mbg.generated
*/
public void setAddtime(String addtime) {
this.addtime = addtime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications.tishi
*
* @return the value of platform_applications.tishi
*
* @mbg.generated
*/
public Integer getTishi() {
return tishi;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications.tishi
*
* @param tishi the value for platform_applications.tishi
*
* @mbg.generated
*/
public void setTishi(Integer tishi) {
this.tishi = tishi;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications.appid
*
* @return the value of platform_applications.appid
*
* @mbg.generated
*/
public String getAppid() {
return appid;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications.appid
*
* @param appid the value for platform_applications.appid
*
* @mbg.generated
*/
public void setAppid(String appid) {
this.appid = appid;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications.secret
*
* @return the value of platform_applications.secret
*
* @mbg.generated
*/
public String getSecret() {
return secret;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications.secret
*
* @param secret the value for platform_applications.secret
*
* @mbg.generated
*/
public void setSecret(String secret) {
this.secret = secret;
}
}
\ No newline at end of file
package com.platform.springboot.domain.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
@Data
@AllArgsConstructor
@ApiModel(description= "具体参数描述")
public class Department implements Serializable {
@ApiModelProperty(value = "部门id")
private Integer id;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "上级id")
private String pid;
@ApiModelProperty(value = "添加时间")
private String addtime;
@ApiModelProperty(value = "状态")
private String status;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.platform.springboot.domain.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(description= "具体参数描述")
public class Personnel implements Serializable {
@ApiModelProperty(value = "员工id")
private Integer id;
@ApiModelProperty(value = "姓名")
private String username;
@ApiModelProperty(value = "部门id")
private String department;
@ApiModelProperty(value = "派驻标识")
private String paizhu;
@ApiModelProperty(value = "职位")
private String position;
@ApiModelProperty(value = "性别 1男 2女")
private Integer sex;
@ApiModelProperty(value = "生日")
private String birthday;
@ApiModelProperty(value = "工号")
private String account;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "手机号码")
private String phoneNumber;
@ApiModelProperty(value = "座机号码")
private String telNumber;
@ApiModelProperty(value = "邮箱地址")
private String email;
@ApiModelProperty(value = "微信昵称")
private String nickname;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "移动小号")
private String mobile;
@ApiModelProperty(value = "电信小号")
private String telecom;
@ApiModelProperty(value = "办公地点")
private String office;
@ApiModelProperty(value = "身份")
private String identity;
@ApiModelProperty(value = "角色")
private String role;
@ApiModelProperty(value = "角色")
private String addtime;
@ApiModelProperty(value = "信用分")
private String credit;
@ApiModelProperty(value = "政治面貌")
private String political;
@ApiModelProperty(value = "负责")
private String fuze;
@ApiModelProperty(value = "角色权限")
private String auth;
@ApiModelProperty(value = "应用权限")
private String appId;
@ApiModelProperty(value = "所属中心id")
private String centerid;
@ApiModelProperty(value = "头像")
private String avatar;
@ApiModelProperty(value = "部门")
private String departmentname;
@ApiModelProperty(value = "中心id")
private String metrocenterid;
@ApiModelProperty(value = "中心名")
private String metrocentername;
@ApiModelProperty(value = "状态")
private String status;
@ApiModelProperty(value = "所属分公司id")
private String branchCompanyId;
}
\ No newline at end of file
package com.platform.springboot.domain.entity;
import java.io.Serializable;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table platform_sys_role
*
* @mbg.generated do_not_delete_during_merge
*/
public class SysRole implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_role.id
*
* @mbg.generated
*/
private Integer id;
/**
* Database Column Remarks:
* 角色名称:管理员;用户
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_role.nameZh
*
* @mbg.generated
*/
private String namezh;
/**
* Database Column Remarks:
* 角色:ROLE_ADMIN;ROLE_USER
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_role.name
*
* @mbg.generated
*/
private String name;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_role.id
*
* @return the value of platform_sys_role.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_role.id
*
* @param id the value for platform_sys_role.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_role.nameZh
*
* @return the value of platform_sys_role.nameZh
*
* @mbg.generated
*/
public String getNamezh() {
return namezh;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_role.nameZh
*
* @param namezh the value for platform_sys_role.nameZh
*
* @mbg.generated
*/
public void setNamezh(String namezh) {
this.namezh = namezh;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_role.name
*
* @return the value of platform_sys_role.name
*
* @mbg.generated
*/
public String getName() {
return name;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_role.name
*
* @param name the value for platform_sys_role.name
*
* @mbg.generated
*/
public void setName(String name) {
this.name = name;
}
}
\ No newline at end of file
package com.platform.springboot.domain.entity;
import java.io.Serializable;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table platform_sys_user
*
* @mbg.generated do_not_delete_during_merge
*/
public class SysUser implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_user.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_user.name
*
* @mbg.generated
*/
private String name;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_user.nickname
*
* @mbg.generated
*/
private String nickname;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_user.password
*
* @mbg.generated
*/
private String password;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_user.id
*
* @return the value of platform_sys_user.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_user.id
*
* @param id the value for platform_sys_user.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_user.name
*
* @return the value of platform_sys_user.name
*
* @mbg.generated
*/
public String getName() {
return name;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_user.name
*
* @param name the value for platform_sys_user.name
*
* @mbg.generated
*/
public void setName(String name) {
this.name = name;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_user.nickname
*
* @return the value of platform_sys_user.nickname
*
* @mbg.generated
*/
public String getNickname() {
return nickname;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_user.nickname
*
* @param nickname the value for platform_sys_user.nickname
*
* @mbg.generated
*/
public void setNickname(String nickname) {
this.nickname = nickname;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_user.password
*
* @return the value of platform_sys_user.password
*
* @mbg.generated
*/
public String getPassword() {
return password;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_user.password
*
* @param password the value for platform_sys_user.password
*
* @mbg.generated
*/
public void setPassword(String password) {
this.password = password;
}
}
\ No newline at end of file
package com.platform.springboot.domain.entity;
import java.io.Serializable;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table platform_sys_user_role
*
* @mbg.generated do_not_delete_during_merge
*/
public class SysUserRole implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_user_role.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_user_role.user_id
*
* @mbg.generated
*/
private Integer userId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_sys_user_role.role_id
*
* @mbg.generated
*/
private Integer roleId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_user_role.id
*
* @return the value of platform_sys_user_role.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_user_role.id
*
* @param id the value for platform_sys_user_role.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_user_role.user_id
*
* @return the value of platform_sys_user_role.user_id
*
* @mbg.generated
*/
public Integer getUserId() {
return userId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_user_role.user_id
*
* @param userId the value for platform_sys_user_role.user_id
*
* @mbg.generated
*/
public void setUserId(Integer userId) {
this.userId = userId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_sys_user_role.role_id
*
* @return the value of platform_sys_user_role.role_id
*
* @mbg.generated
*/
public Integer getRoleId() {
return roleId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_sys_user_role.role_id
*
* @param roleId the value for platform_sys_user_role.role_id
*
* @mbg.generated
*/
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
}
\ No newline at end of file
package com.platform.springboot.domain.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(description= "具体参数描述")
public class Todo implements Serializable {
/**
* 待办描述
*/
@ApiModelProperty(value = "待办描述",required=true)
private String memo;
/**
* 业务类型
*/
@ApiModelProperty(value = "业务类型(接受值为1,2,3,4 [1=会议系统,2 =日报系统,3 =安全生产管理系统,4= 考勤系统])",required=true)
private String type;
/**
* 业务id
*/
@ApiModelProperty(value = "业务id",required=true)
private String buid;
/**
* 待办人工号
*/
@ApiModelProperty(value = "待办人工号",required=true)
private String account;
/**
* 跳转路由
*/
@ApiModelProperty(value = "跳转路由",required=true)
private String rounter;
}
\ No newline at end of file
package com.platform.springboot.domain.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zhouy
* @date 2018-07-08 20:43
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
String appid;
String secret;
}
package com.platform.springboot.http;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
@Component
public class HttpAPIService {
@Autowired
private CloseableHttpClient httpClient;
@Autowired
private RequestConfig config;
/**
* 不带参数的get请求,如果状态码为200,则返回body,如果不为200,则返回null
* @param url
* @return
* @throws Exception
*/
public String doGet(String url) throws Exception {
// 声明 http get 请求
HttpGet httpGet = new HttpGet(url);
// 装载配置信息
httpGet.setConfig(config);
// 发起请求
CloseableHttpResponse response = this.httpClient.execute(httpGet);
// 判断状态码是否为200
if (response.getStatusLine().getStatusCode() == 200) {
// 返回响应体的内容
return EntityUtils.toString(response.getEntity(), "UTF-8");
}
return null;
}
/**
* 带参数的get请求,如果状态码为200,则返回body,如果不为200,则返回null
*
* @param url
* @return
* @throws Exception
*/
public String doGet(String url, Map<String, Object> map) throws Exception {
URIBuilder uriBuilder = new URIBuilder(url);
if (map != null) {
// 遍历map,拼接请求参数
for (Map.Entry<String, Object> entry : map.entrySet()) {
uriBuilder.setParameter(entry.getKey(), entry.getValue().toString());
}
}
// 调用不带参数的get请求
return this.doGet(uriBuilder.build().toString());
}
/**
* 带参数的post请求
*
* @param url
* @param map
* @return
* @throws Exception
*/
public HttpResult doPost(String url, Map<String, Object> map) throws Exception {
// 声明httpPost请求
HttpPost httpPost = new HttpPost(url);
// 加入配置信息
httpPost.setConfig(config);
// 判断map是否为空,不为空则进行遍历,封装from表单对象
if (map != null) {
List<NameValuePair> list = new ArrayList<NameValuePair>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
list.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
}
// 构造from表单对象
UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(list, "UTF-8");
// 把表单放到post里
httpPost.setEntity(urlEncodedFormEntity);
}
// 发起请求
CloseableHttpResponse response = this.httpClient.execute(httpPost);
return new HttpResult(response.getStatusLine().getStatusCode(), EntityUtils.toString(
response.getEntity(), "UTF-8"));
}
/**
* post请求
* @param url
* @param json
* @return
*/
public JSONObject doPost(String url, String json){
CloseableHttpClient httpclient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
// 加入配置信息
post.setConfig(config);
JSONObject response = null;
try {
StringEntity s = new StringEntity(json,Charset.forName("UTF-8"));
s.setContentType("application/json");//发送json数据需要设置contentType
s.setContentEncoding("UTF-8");
post.setEntity(s);
CloseableHttpResponse res = httpclient.execute(post);
if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
String result = EntityUtils.toString(res.getEntity());// 返回json格式:
response = JSONObject.parseObject(result);
log.info("请求返回信息: "+response.toJSONString());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return response;
}
}
\ No newline at end of file
package com.platform.springboot.http;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* zhouy
* @Date
*/
@Configuration
public class HttpClient {
@Value("${http.maxTotal}")
private Integer maxTotal;
@Value("${http.defaultMaxPerRoute}")
private Integer defaultMaxPerRoute;
@Value("${http.connectTimeout}")
private Integer connectTimeout;
@Value("${http.connectionRequestTimeout}")
private Integer connectionRequestTimeout;
@Value("${http.socketTimeout}")
private Integer socketTimeout;
@Value("${http.staleConnectionCheckEnabled}")
private boolean staleConnectionCheckEnabled;
/**
* 首先实例化一个连接池管理器,设置最大连接数、并发连接数
* @return
*/
@Bean(name = "httpClientConnectionManager")
public PoolingHttpClientConnectionManager getHttpClientConnectionManager(){
PoolingHttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager();
//最大连接数
httpClientConnectionManager.setMaxTotal(maxTotal);
//并发数
httpClientConnectionManager.setDefaultMaxPerRoute(defaultMaxPerRoute);
return httpClientConnectionManager;
}
/**
* 实例化连接池,设置连接池管理器。
* 这里需要以参数形式注入上面实例化的连接池管理器
* @param httpClientConnectionManager
* @return
*/
@Bean(name = "httpClientBuilder")
public HttpClientBuilder getHttpClientBuilder(@Qualifier("httpClientConnectionManager") PoolingHttpClientConnectionManager httpClientConnectionManager){
//HttpClientBuilder中的构造方法被protected修饰,所以这里不能直接使用new来实例化一个HttpClientBuilder,可以使用HttpClientBuilder提供的静态方法create()来获取HttpClientBuilder对象
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
httpClientBuilder.setConnectionManager(httpClientConnectionManager);
return httpClientBuilder;
}
/**
* 注入连接池,用于获取httpClient
* @param httpClientBuilder
* @return
*/
@Bean
public CloseableHttpClient getCloseableHttpClient(@Qualifier("httpClientBuilder") HttpClientBuilder httpClientBuilder){
return httpClientBuilder.build();
}
/**
* Builder是RequestConfig的一个内部类
* 通过RequestConfig的custom方法来获取到一个Builder对象
* 设置builder的连接信息
* 这里还可以设置proxy,cookieSpec等属性。有需要的话可以在此设置
* @return
*/
@Bean(name = "builder")
public RequestConfig.Builder getBuilder(){
RequestConfig.Builder builder = RequestConfig.custom();
return builder.setConnectTimeout(connectTimeout)
.setConnectionRequestTimeout(connectionRequestTimeout)
.setSocketTimeout(socketTimeout)
.setStaleConnectionCheckEnabled(staleConnectionCheckEnabled);
}
/**
* 使用builder构建一个RequestConfig对象
* @param builder
* @return
*/
@Bean
public RequestConfig getRequestConfig(@Qualifier("builder") RequestConfig.Builder builder){
return builder.build();
}
}
package com.platform.springboot.http;
public class HttpResult {
// 响应码
private Integer code;
// 响应体
private String body;
public HttpResult() {
super();
}
public HttpResult(Integer code, String body) {
super();
this.code = code;
this.body = body;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
}
\ No newline at end of file
package com.platform.springboot.http;
import org.apache.http.conn.HttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class IdleConnectionEvictor extends Thread {
@Autowired
private HttpClientConnectionManager connMgr;
private volatile boolean shutdown;
public IdleConnectionEvictor() {
super();
super.start();
}
@Override
public void run() {
try {
while (!shutdown) {
synchronized (this) {
wait(5000);
// 关闭失效的连接
connMgr.closeExpiredConnections();
}
}
} catch (InterruptedException ex) {
// 结束
}
}
//关闭清理无效连接的线程
public void shutdown() {
shutdown = true;
synchronized (this) {
notifyAll();
}
}
}
\ No newline at end of file
package com.platform.springboot.interceptor;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.platform.springboot.annotation.PassToken;
import com.platform.springboot.annotation.UserLoginToken;
import com.platform.springboot.domain.ResultCode;
import com.platform.springboot.domain.entity.Applications;
import com.platform.springboot.service.ApplicationsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
/**
* @author zhouy
* @date 2018-07-08 20:41
*/
@Slf4j
public class AuthenticationInterceptor implements HandlerInterceptor {
@Autowired
ApplicationsService applicationsService;
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) throws Exception {
// 从 http 请求头中取出 token
String token = httpServletRequest.getHeader("Authorization");
if(token==null) {
token = httpServletRequest.getParameter("token");
}
// 如果不是映射到方法直接通过
if(!(object instanceof HandlerMethod)){
return true;
}
HandlerMethod handlerMethod=(HandlerMethod)object;
Method method=handlerMethod.getMethod();
//检查是否有passtoken注释,有则跳过认证
if (method.isAnnotationPresent(PassToken.class)) {
PassToken passToken = method.getAnnotation(PassToken.class);
if (passToken.required()) {
return true;
}
}
//检查有没有需要用户权限的注解
if (method.isAnnotationPresent(UserLoginToken.class)) {
UserLoginToken userLoginToken = method.getAnnotation(UserLoginToken.class);
if (userLoginToken.required()) {
// 执行认证
if (token == null) {
log.info("token 为空!");
throw new RuntimeException(ResultCode.UNAUTHORIZED.getMsg());
}
// 获取 token 中的 user id
String appid="";
try {
appid = JWT.decode(token).getAudience().get(0);
} catch (JWTDecodeException j) {
throw new RuntimeException(ResultCode.UNAUTHORIZED.getMsg());
}
//可以升级在redis中获取
Applications applications = applicationsService.findApplication(appid);
if (applications == null) {
throw new RuntimeException(ResultCode.UNAUTHORIZED.getMsg());
}
// 验证 token
JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(applications.getSecret())).build();
try {
jwtVerifier.verify(token);
} catch (JWTVerificationException e) {
log.info(e.getLocalizedMessage());
throw new RuntimeException(ResultCode.UNAUTHORIZED.getMsg());
}
return true;
}
}
return true;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
}
}
package com.platform.springboot.interceptor;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author zhouy
* @date 2018-07-08 22:37
*/
@ControllerAdvice
public class GloablExceptionHandler {
@ResponseBody
@ExceptionHandler(Exception.class)
public Object handleException(Exception e) {
String msg = e.getMessage();
if (msg == null || msg.equals("")) {
msg = "服务器出错";
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", msg);
jsonObject.put("code", "0");
return jsonObject;
}
}
package com.platform.springboot.mapper;
import com.platform.springboot.domain.entity.Applications;
import com.platform.springboot.domain.entity.ApplicationsExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ApplicationsMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
long countByExample(ApplicationsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
int deleteByExample(ApplicationsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
int insert(Applications record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
int insertSelective(Applications record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
List<Applications> selectByExample(ApplicationsExample example);
/**
* 功能描述: <br>
* 〈〉
* @Param: [example]
* @Return: [example]
* @Author: zhouy
* @Date: 2019-08-27 19:43
*/
Applications selectByExampleForObject (ApplicationsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
Applications selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") Applications record, @Param("example") ApplicationsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
int updateByExample(@Param("record") Applications record, @Param("example") ApplicationsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(Applications record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications
*
* @mbg.generated
*/
int updateByPrimaryKey(Applications record);
}
\ No newline at end of file
package com.platform.springboot.mapper;
import com.platform.springboot.domain.dto.DepartmentPersonneDTO;
import com.platform.springboot.domain.entity.Department;
import com.platform.springboot.domain.entity.DepartmentExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface DepartmentMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
long countByExample(DepartmentExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
int deleteByExample(DepartmentExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
int insert(Department record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
int insertSelective(Department record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
List<Department> selectByExample(DepartmentExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
Department selectByPrimaryKey(Integer id);
DepartmentPersonneDTO selectByPrimaryKey2(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") Department record, @Param("example") DepartmentExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
int updateByExample(@Param("record") Department record, @Param("example") DepartmentExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(Department record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_department
*
* @mbg.generated
*/
int updateByPrimaryKey(Department record);
List<DepartmentPersonneDTO> getDepartmentPersonneDTOList(DepartmentExample example);
}
\ No newline at end of file
<?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.platform.springboot.mapper.DepartmentMapper">
<resultMap id="BaseResultMap" type="com.platform.springboot.domain.entity.Department">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="pid" jdbcType="VARCHAR" property="pid" />
<result column="addtime" jdbcType="VARCHAR" property="addtime" />
</resultMap>
<resultMap id="PersonneldtoResultMap" type="com.platform.springboot.domain.dto.DepartmentPersonneDTO">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="title" />
<result column="name" jdbcType="VARCHAR" property="label" />
<result column="pid" jdbcType="VARCHAR" property="pid" />
<result column="key" jdbcType="VARCHAR" property="key" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, name, pid, addtime,status
</sql>
<select id="selectByExample" parameterType="com.platform.springboot.domain.entity.DepartmentExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from platform_department
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<!--获取所有部门以dto返回-->
<select id="getDepartmentPersonneDTOList" parameterType="com.platform.springboot.domain.entity.DepartmentExample" resultMap="PersonneldtoResultMap">
select
<if test="distinct">
distinct
</if>
id,name,pid,id+1000000 as 'key'
from platform_department
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey2" parameterType="java.lang.Integer" resultMap="PersonneldtoResultMap">
select
id,name,pid,id+1000000 as 'key'
from platform_department
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from platform_department
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from platform_department
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.platform.springboot.domain.entity.DepartmentExample">
delete from platform_department
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.platform.springboot.domain.entity.Department">
insert into platform_department (id, name, pid,
addtime)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR},
#{addtime,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.platform.springboot.domain.entity.Department">
insert into platform_department
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
name,
</if>
<if test="pid != null">
pid,
</if>
<if test="addtime != null">
addtime,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="pid != null">
#{pid,jdbcType=VARCHAR},
</if>
<if test="addtime != null">
#{addtime,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.platform.springboot.domain.entity.DepartmentExample" resultType="java.lang.Long">
select count(*) from platform_department
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update platform_department
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.pid != null">
pid = #{record.pid,jdbcType=VARCHAR},
</if>
<if test="record.addtime != null">
addtime = #{record.addtime,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update platform_department
set id = #{record.id,jdbcType=INTEGER},
name = #{record.name,jdbcType=VARCHAR},
pid = #{record.pid,jdbcType=VARCHAR},
addtime = #{record.addtime,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.platform.springboot.domain.entity.Department">
update platform_department
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="pid != null">
pid = #{pid,jdbcType=VARCHAR},
</if>
<if test="addtime != null">
addtime = #{addtime,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.platform.springboot.domain.entity.Department">
update platform_department
set name = #{name,jdbcType=VARCHAR},
pid = #{pid,jdbcType=VARCHAR},
addtime = #{addtime,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
package com.platform.springboot.mapper;
import com.platform.springboot.domain.dto.DepartmentPersonneDTO;
import com.platform.springboot.domain.dto.PersonneDTO;
import com.platform.springboot.domain.dto.PersonnelPageDTO;
import com.platform.springboot.domain.dto.PersonnewxDTO;
import com.platform.springboot.domain.entity.Personnel;
import com.platform.springboot.domain.entity.PersonnelExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
public interface PersonnelMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
long countByExample(PersonnelExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int deleteByExample(PersonnelExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int insert(Personnel record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int insertSelective(Personnel record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
List<Personnel> selectByExampleWithBLOBs(PersonnelExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
List<Personnel> selectByExample(PersonnelExample example);
List<PersonnelPageDTO> selectByExample2(PersonnelExample example);
List<PersonnelPageDTO> selectByExample3(PersonnelExample example);
List<PersonnelPageDTO> selectByExample4(PersonnelExample example);
List<PersonnewxDTO> selectByExample5(PersonnelExample personnewxDTO);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
Personnel selectByPrimaryKey(Integer id);
PersonnelPageDTO selectByPrimaryKey2(Integer id);
PersonnelPageDTO selectByPrimaryKey3(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") Personnel record, @Param("example") PersonnelExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int updateByExampleWithBLOBs(@Param("record") Personnel record, @Param("example") PersonnelExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int updateByExample(@Param("record") Personnel record, @Param("example") PersonnelExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(Personnel record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int updateByPrimaryKeyWithBLOBs(Personnel record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_personnel
*
* @mbg.generated
*/
int updateByPrimaryKey(Personnel record);
Personnel selectByAccount(String account);
// List<Personnel> getPersonListByAccount(String account);
List<PersonneDTO> getDepartmentPersonneDTOList(PersonnelExample example);
Map getCompanyIdByUserId(String userId);
}
\ No newline at end of file
package com.platform.springboot.mapper;
import com.platform.springboot.domain.entity.SysRole;
import com.platform.springboot.domain.entity.SysRoleExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysRoleMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
long countByExample(SysRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
int deleteByExample(SysRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
int insert(SysRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
int insertSelective(SysRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
List<SysRole> selectByExample(SysRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
SysRole selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") SysRole record, @Param("example") SysRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
int updateByExample(@Param("record") SysRole record, @Param("example") SysRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(SysRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_role
*
* @mbg.generated
*/
int updateByPrimaryKey(SysRole record);
}
\ No newline at end of file
<?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.platform.springboot.mapper.SysRoleMapper">
<resultMap id="BaseResultMap" type="com.platform.springboot.domain.entity.SysRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="nameZh" jdbcType="VARCHAR" property="namezh" />
<result column="name" jdbcType="VARCHAR" property="name" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, nameZh, name
</sql>
<select id="selectByExample" parameterType="com.platform.springboot.domain.entity.SysRoleExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from platform_sys_role
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from platform_sys_role
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from platform_sys_role
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.platform.springboot.domain.entity.SysRoleExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from platform_sys_role
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.platform.springboot.domain.entity.SysRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into platform_sys_role (id, nameZh, name
)
values (#{id,jdbcType=INTEGER}, #{namezh,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.platform.springboot.domain.entity.SysRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into platform_sys_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="namezh != null">
nameZh,
</if>
<if test="name != null">
name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="namezh != null">
#{namezh,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.platform.springboot.domain.entity.SysRoleExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from platform_sys_role
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_role
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.namezh != null">
nameZh = #{record.namezh,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_role
set id = #{record.id,jdbcType=INTEGER},
nameZh = #{record.namezh,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.platform.springboot.domain.entity.SysRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_role
<set>
<if test="namezh != null">
nameZh = #{namezh,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.platform.springboot.domain.entity.SysRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_role
set nameZh = #{namezh,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
package com.platform.springboot.mapper;
import com.platform.springboot.domain.entity.SysUser;
import com.platform.springboot.domain.entity.SysUserExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysUserMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
long countByExample(SysUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
int deleteByExample(SysUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
int insert(SysUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
int insertSelective(SysUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
List<SysUser> selectByExample(SysUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
SysUser selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") SysUser record, @Param("example") SysUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
int updateByExample(@Param("record") SysUser record, @Param("example") SysUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(SysUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user
*
* @mbg.generated
*/
int updateByPrimaryKey(SysUser record);
}
\ No newline at end of file
<?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.platform.springboot.mapper.SysUserMapper">
<resultMap id="BaseResultMap" type="com.platform.springboot.domain.entity.SysUser">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="password" jdbcType="VARCHAR" property="password" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, name, nickname, password
</sql>
<select id="selectByExample" parameterType="com.platform.springboot.domain.entity.SysUserExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from platform_sys_user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from platform_sys_user
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from platform_sys_user
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.platform.springboot.domain.entity.SysUserExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from platform_sys_user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.platform.springboot.domain.entity.SysUser">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into platform_sys_user (id, name, nickname,
password)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.platform.springboot.domain.entity.SysUser">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into platform_sys_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
name,
</if>
<if test="nickname != null">
nickname,
</if>
<if test="password != null">
password,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
#{nickname,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.platform.springboot.domain.entity.SysUserExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from platform_sys_user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_user
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.nickname != null">
nickname = #{record.nickname,jdbcType=VARCHAR},
</if>
<if test="record.password != null">
password = #{record.password,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_user
set id = #{record.id,jdbcType=INTEGER},
name = #{record.name,jdbcType=VARCHAR},
nickname = #{record.nickname,jdbcType=VARCHAR},
password = #{record.password,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.platform.springboot.domain.entity.SysUser">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_user
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.platform.springboot.domain.entity.SysUser">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_user
set name = #{name,jdbcType=VARCHAR},
nickname = #{nickname,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
package com.platform.springboot.mapper;
import com.platform.springboot.domain.entity.SysUserRole;
import com.platform.springboot.domain.entity.SysUserRoleExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysUserRoleMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
long countByExample(SysUserRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
int deleteByExample(SysUserRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
int insert(SysUserRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
int insertSelective(SysUserRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
List<SysUserRole> selectByExample(SysUserRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
SysUserRole selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") SysUserRole record, @Param("example") SysUserRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
int updateByExample(@Param("record") SysUserRole record, @Param("example") SysUserRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(SysUserRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_sys_user_role
*
* @mbg.generated
*/
int updateByPrimaryKey(SysUserRole record);
}
\ No newline at end of file
<?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.platform.springboot.mapper.SysUserRoleMapper">
<resultMap id="BaseResultMap" type="com.platform.springboot.domain.entity.SysUserRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="role_id" jdbcType="INTEGER" property="roleId" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, user_id, role_id
</sql>
<select id="selectByExample" parameterType="com.platform.springboot.domain.entity.SysUserRoleExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from platform_sys_user_role
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from platform_sys_user_role
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from platform_sys_user_role
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.platform.springboot.domain.entity.SysUserRoleExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from platform_sys_user_role
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.platform.springboot.domain.entity.SysUserRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into platform_sys_user_role (id, user_id, role_id
)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.platform.springboot.domain.entity.SysUserRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into platform_sys_user_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="roleId != null">
role_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="roleId != null">
#{roleId,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.platform.springboot.domain.entity.SysUserRoleExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from platform_sys_user_role
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_user_role
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=INTEGER},
</if>
<if test="record.roleId != null">
role_id = #{record.roleId,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_user_role
set id = #{record.id,jdbcType=INTEGER},
user_id = #{record.userId,jdbcType=INTEGER},
role_id = #{record.roleId,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.platform.springboot.domain.entity.SysUserRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_user_role
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="roleId != null">
role_id = #{roleId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.platform.springboot.domain.entity.SysUserRole">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update platform_sys_user_role
set user_id = #{userId,jdbcType=INTEGER},
role_id = #{roleId,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
package com.platform.springboot.mapper;
import com.platform.springboot.domain.entity.User;
import org.apache.ibatis.annotations.Param;
/**
* @author zhouy
* @date 2018-07-08 20:44
*/
public interface UserMapper {
User findByUsername(@Param("username") String username);
User findUserById(@Param("Id") String Id);
}
package com.platform.springboot.rabbitmq;
/**
* .::::.
* .::::::::.
* ::::::::::: 佛主保佑、永无Bug
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* ``::::::::::::::::
* ::::``:::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ``::::.
* ...::: ::::::::::::' ``::.
* ```` ':. ':::::::::' ::::..
* '.:::::' ':'````..
*/
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @ClassName: AmqpService
* @Description: ${description}
* @Authror zhouy
* @Date 2019-08-28 22:22
*/
@Service
public class AmqpService {
@Autowired
private AmqpTemplate amqpTemplate;
public void convertAndSend(String message) {
amqpTemplate.convertAndSend("com.exchange.direct","CalonDirectRouting", message);
}
public void convertAndSendUpdate(String message) {
amqpTemplate.convertAndSend("com.exchange.direct","CalonDirectRoutingUpdate", message);
}
}
package com.platform.springboot.rabbitmq;
/**
* .::::.
* .::::::::.
* ::::::::::: 佛主保佑、永无Bug
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* ``::::::::::::::::
* ::::``:::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ``::::.
* ...::: ::::::::::::' ``::.
* ```` ':. ':::::::::' ::::..
* '.:::::' ':'````..
*/
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.stereotype.Component;
//
///**
// * @ClassName: AmqpServiceConsumer
// * @Description: ${description}
// * @Authror zhouy
// * @Date 2019-08-28 22:24
// */
//@Slf4j
//@Component
//public class AmqpServiceConsumer {
// @RabbitListener(queues = {"com.queue.notify.hello"})
// public void receiveSmsCodeQueue(String message) {
// log.info("------hello:消费者处理消息------");
// log.info(message);
// }
//}
package com.platform.springboot.rabbitmq;
/**
* .::::.
* .::::::::.
* ::::::::::: 佛主保佑、永无Bug
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* ``::::::::::::::::
* ::::``:::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ``::::.
* ...::: ::::::::::::' ``::.
* ```` ':. ':::::::::' ::::..
* '.:::::' ':'````..
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @ClassName: RabbitConfig
* @Description: ${description}
* @Authror zhouy
* @Date 2019-08-28 21:00
*
*/
@Configuration
public class RabbitConfig {
@Value("${spring.rabbitmq.host}")
private String addresses;
@Value("${spring.rabbitmq.port}")
private Integer port;
@Value("${spring.rabbitmq.username}")
private String username;
@Value("${spring.rabbitmq.password}")
private String password;
@Value("${spring.rabbitmq.virtual-host}")
private String virtualHost;
@Value("${spring.rabbitmq.publisher-confirms}")
private boolean publisherConfirms;
public RabbitConfig() {
}
@Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setAddresses(this.addresses);
connectionFactory.setPort(this.port);
connectionFactory.setUsername(this.username);
connectionFactory.setPassword(this.password);
connectionFactory.setVirtualHost(this.virtualHost);
connectionFactory.setPublisherConfirms(this.publisherConfirms);
return connectionFactory;
}
@Bean
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
return new RabbitAdmin(connectionFactory);
}
@Bean
public RabbitTemplate rabbitTemplate() {
RabbitTemplate rabbitTemplate = new RabbitTemplate(this.connectionFactory());
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
return rabbitTemplate;
}
}
package com.platform.springboot.rabbitmq;
/**
* .::::.
* .::::::::.
* ::::::::::: 佛主保佑、永无Bug
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* ``::::::::::::::::
* ::::``:::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ``::::.
* ...::: ::::::::::::' ``::.
* ```` ':. ':::::::::' ::::..
* '.:::::' ':'````..
*/
/**
* @ClassName: RabbitExchangeConfig
* @Description: ${description}
* @Authror zhouy
* @Date 2019-08-28 21:56
*/
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitExchangeConfig {
@Autowired
private RabbitAdmin rabbitAdmin;
public RabbitExchangeConfig() {
}
//广播模式
@Bean
FanoutExchange contractFanoutExchange() {
FanoutExchange fanoutExchange = new FanoutExchange("com.exchange.fanout");
this.rabbitAdmin.declareExchange(fanoutExchange);
return fanoutExchange;
}
@Bean
TopicExchange contractTopicExchangeDurable() {
TopicExchange contractTopicExchange = new TopicExchange("com.exchange.topic");
this.rabbitAdmin.declareExchange(contractTopicExchange);
return contractTopicExchange;
}
@Bean
DirectExchange contractDirectExchange() {
DirectExchange contractDirectExchange = new DirectExchange("com.exchange.direct");
this.rabbitAdmin.declareExchange(contractDirectExchange);
return contractDirectExchange;
}
//创建新增代办信息队列
@Bean
Queue queueAddTodo() {
Queue queue = new Queue("com.queue.notify.addtodo", true);
this.rabbitAdmin.declareQueue(queue);
return queue;
}
//创建更新代办信息队列
@Bean
Queue queueUpdateTodo() {
Queue queue = new Queue("com.queue.notify.updatetodo", true);
this.rabbitAdmin.declareQueue(queue);
return queue;
}
//创建更新代办信息队列
@Bean
Queue queueHello() {
Queue queue = new Queue("com.queue.notify.hello", true);
this.rabbitAdmin.declareQueue(queue);
return queue;
}
//队列交换机绑定
@Bean
Binding bindingAddDirect() {
return BindingBuilder.bind(queueAddTodo()).to(contractDirectExchange()).with("CalonDirectRouting");
}
//队列交换机绑定
@Bean
Binding bindingUpdateDirect() {
return BindingBuilder.bind(queueUpdateTodo()).to(contractDirectExchange()).with("CalonDirectRoutingUpdate");
}
//队列交换机绑定
@Bean
Binding bindingHelloDirect() {
return BindingBuilder.bind(queueHello()).to(contractFanoutExchange());//.with("CalonDirectRouting");
}
}
package com.platform.springboot.rabbitmq;
/**
* .::::.
* .::::::::.
* ::::::::::: 佛主保佑、永无Bug
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* ``::::::::::::::::
* ::::``:::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ``::::.
* ...::: ::::::::::::' ``::.
* ```` ':. ':::::::::' ::::..
* '.:::::' ':'````..
*/
/**
* @ClassName: RabbitListenerConfig
* @Description: ${description}
* @Authror zhouy
* @Date 2019-08-28 21:57
*/
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory;
@Configuration
@EnableRabbit
public class RabbitListenerConfig implements RabbitListenerConfigurer {
@Autowired
private ConnectionFactory connectionFactory;
public RabbitListenerConfig() {
}
@Bean
public DefaultMessageHandlerMethodFactory handlerMethodFactory() {
DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
factory.setMessageConverter(new MappingJackson2MessageConverter());
return factory;
}
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(this.connectionFactory);
factory.setAcknowledgeMode(AcknowledgeMode.AUTO);
return factory;
}
@Override
public void configureRabbitListeners(RabbitListenerEndpointRegistrar rabbitListenerEndpointRegistrar) {
rabbitListenerEndpointRegistrar.setMessageHandlerMethodFactory(this.handlerMethodFactory());
}
}
package com.platform.springboot.redis;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.cache.RedisCacheWriter;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import java.lang.reflect.Method;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private int port;
@Value("${spring.redis.timeout}")
private int timeout;
@Value("${spring.redis.password}")
private String password;
@Value("${spring.redis.jedis.pool.max-active}")
private int maxActive;
@Value("${spring.redis.jedis.pool.max-wait}")
private int maxWait;
@Value("${spring.redis.jedis.pool.max-idle}")
private int maxIdle;
@Value("${spring.redis.jedis.pool.min-idle}")
private int minIdle;
@Bean
public KeyGenerator wiselyKeyGenerator(){
return new KeyGenerator() {
@Override
public Object generate(Object target, Method method, Object... params) {
StringBuilder sb = new StringBuilder();
sb.append(target.getClass().getName());
sb.append(method.getName());
for (Object obj : params) {
sb.append(obj.toString());
}
return sb.toString();
}
};
}
@Bean
public JedisConnectionFactory redisConnectionFactory() {
JedisConnectionFactory factory = new JedisConnectionFactory();
factory.setHostName(host);
factory.setPort(port);
factory.setTimeout(timeout); //设置连接超时时间
factory.setPassword(password);
factory.getPoolConfig().setMaxIdle(maxIdle);
factory.getPoolConfig().setMinIdle(minIdle);
factory.getPoolConfig().setMaxTotal(maxActive);
factory.getPoolConfig().setMaxWaitMillis(maxWait);
return factory;
}
@Bean
CacheManager cacheManager(RedisConnectionFactory connectionFactory) {
//user信息缓存配置
// RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(30)).disableCachingNullValues().prefixKeysWith("user");
//product信息缓存配置
// RedisCacheConfiguration productCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(10)).disableCachingNullValues().prefixKeysWith("product");
//viewDeptall信息缓存配置,组织树
RedisCacheConfiguration viewDeptallCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofDays(30)).disableCachingNullValues().prefixKeysWith("viewDeptall");
Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
// redisCacheConfigurationMap.put("user", userCacheConfiguration);
// redisCacheConfigurationMap.put("product", productCacheConfiguration);
redisCacheConfigurationMap.put("viewDeptall", viewDeptallCacheConfiguration);
//初始化一个RedisCacheWriter
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory);
//设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现
//ClassLoader loader = this.getClass().getClassLoader();
//JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader);
//RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer);
//RedisCacheConfiguration defaultCacheConfig=RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair);
RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig();
//设置默认超过期时间是24小时
defaultCacheConfig.entryTtl(Duration.ofHours(24));
//初始化RedisCacheManager
RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap);
return cacheManager;
}
@Bean
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
StringRedisTemplate template = new StringRedisTemplate(factory);
setSerializer(template); //设置序列化工具,这样ReportBean不需要实现Serializable接口
template.afterPropertiesSet();
return template;
}
private void setSerializer(StringRedisTemplate template) {
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
template.setValueSerializer(jackson2JsonRedisSerializer);
}
}
package com.platform.springboot.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Service
public class RedisUtils {
@Autowired
private RedisTemplate redisTemplate;
/**
* 写入缓存
*
* @param key
* @param value
* @return
*/
public boolean set(final String key, Object value) {
boolean result = false;
try {
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
operations.set(key, value);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* 写入缓存设置时效时间
*
* @param key
* @param value
* @return
*/
public boolean set(final String key, Object value, Long expireTime, TimeUnit timeUnit) {
boolean result = false;
try {
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
operations.set(key, value);
redisTemplate.expire(key, expireTime, timeUnit);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* 批量删除对应的value
*
* @param keys
*/
public void remove(final String... keys) {
for (String key : keys) {
remove(key);
}
}
/**
* 批量删除key
*
* @param pattern
*/
public void removePattern(final String pattern) {
Set<Serializable> keys = redisTemplate.keys(pattern);
if (keys.size() > 0) {
redisTemplate.delete(keys);
}
}
/**
* 删除对应的value
*
* @param key
*/
public void remove(final String key) {
if (exists(key)) {
redisTemplate.delete(key);
}
}
/**
* 判断缓存中是否有对应的value
*
* @param key
* @return
*/
public boolean exists(final String key) {
return redisTemplate.hasKey(key);
}
/**
* 读取缓存
*
* @param key
* @return
*/
public Object get(final String key) {
Object result = null;
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
result = operations.get(key);
return result;
}
/**
* 哈希 添加
*
* @param key
* @param hashKey
* @param value
*/
public void hmSet(String key, Object hashKey, Object value) {
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
hash.put(key, hashKey, value);
}
/**
* 哈希获取数据
*
* @param key
* @param hashKey
* @return
*/
public Object hmGet(String key, Object hashKey) {
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
return hash.get(key, hashKey);
}
/**
* 列表添加
*
* @param k
* @param v
*/
public void lPush(String k, Object v) {
ListOperations<String, Object> list = redisTemplate.opsForList();
list.rightPush(k, v);
}
/**
* 列表获取
*
* @param k
* @param l
* @param l1
* @return
*/
public List<Object> lRange(String k, long l, long l1) {
ListOperations<String, Object> list = redisTemplate.opsForList();
return list.range(k, l, l1);
}
/**
* 集合添加
*
* @param key
* @param value
*/
public void add(String key, Object value) {
SetOperations<String, Object> set = redisTemplate.opsForSet();
set.add(key, value);
}
/**
* 集合获取
*
* @param key
* @return
*/
public Set<Object> setMembers(String key) {
SetOperations<String, Object> set = redisTemplate.opsForSet();
return set.members(key);
}
/**
* 有序集合添加
*
* @param key
* @param value
* @param scoure
*/
public void zAdd(String key, Object value, double scoure) {
ZSetOperations<String, Object> zset = redisTemplate.opsForZSet();
zset.add(key, value, scoure);
}
/**
* 有序集合获取
*
* @param key
* @param scoure
* @param scoure1
* @return
*/
public Set<Object> rangeByScore(String key, double scoure, double scoure1) {
ZSetOperations<String, Object> zset = redisTemplate.opsForZSet();
return zset.rangeByScore(key, scoure, scoure1);
}
}
package com.platform.springboot.service;
/**
* .::::.
* .::::::::.
* ::::::::::: 佛主保佑、永无Bug
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* ``::::::::::::::::
* ::::``:::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ``::::.
* ...::: ::::::::::::' ``::.
* ```` ':. ':::::::::' ::::..
* '.:::::' ':'````..
*/
import com.platform.springboot.domain.entity.Applications;
import com.platform.springboot.domain.entity.ApplicationsExample;
import com.platform.springboot.mapper.ApplicationsMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @ClassName: ApplicationsService
* @Description: ${description}
* @Authror zhouy
* @Date 2019-08-27 17:54
*/
@Service
public class ApplicationsService {
@Resource
ApplicationsMapper applicationsMapper;
/**
* 功能描述: <br>
* @Param: [applications]
* @Return: [applications]
* @Author: zhouy
* @Date: 2019-08-27 18:06
*/
public Applications getApplications(String appid,String secret){
ApplicationsExample example = new ApplicationsExample();
ApplicationsExample.Criteria criteria = example.createCriteria();
criteria.andAppidEqualTo(appid);
criteria.andSecretEqualTo(secret);
return applicationsMapper.selectByExampleForObject(example);
}
/**
* 功能描述: <br>根据appid查询Applications--拦截器调用
* @Param: [id]
* @Return: [id]
* @Author: zhouy
* @Date: 2019-08-27 19:29
*/
public Applications findApplication(String appid){
ApplicationsExample example = new ApplicationsExample();
ApplicationsExample.Criteria criteria = example.createCriteria();
criteria.andAppidEqualTo(appid);
return applicationsMapper.selectByExampleForObject(example);
}
}
package com.platform.springboot.service;
import com.platform.springboot.domain.dto.DepartmentPersonneDTO;
import com.platform.springboot.domain.entity.Department;
import java.util.List;
public interface DepartmentService {
/**
* 获得所有部门 http://ditie.wbb.aizhuanxing.com/index/jiekou/dept
* @return
*/
List<Department> getDeptList();
List<Department> getDeptListByPid(String pid);
List<Department> getDeptListByPidWithDeep(String pid);
List<Department> getDeptListByids(String id);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论