mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
发布 2.3.0
This commit is contained in:
@ -8,7 +8,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 数据权限过滤注解
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@ -25,4 +25,9 @@ public @interface DataScope
|
||||
* 用户表的别名
|
||||
*/
|
||||
public String userAlias() default "";
|
||||
|
||||
/**
|
||||
* 是否过滤用户权限
|
||||
*/
|
||||
public boolean isUser() default false;
|
||||
}
|
||||
|
@ -1,234 +1,219 @@
|
||||
package com.ruoyi.common.core.redis;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.redisson.api.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* spring redis 工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
* @author shenxinquan
|
||||
**/
|
||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||
@Component
|
||||
public class RedisCache
|
||||
{
|
||||
@Autowired
|
||||
public RedisTemplate redisTemplate;
|
||||
public class RedisCache {
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value)
|
||||
{
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
* @param timeout 时间
|
||||
* @param timeUnit 时间颗粒度
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
|
||||
{
|
||||
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||
}
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value) {
|
||||
redissonClient.getBucket(key).set(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout)
|
||||
{
|
||||
return expire(key, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
* @param timeout 时间
|
||||
* @param timeUnit 时间颗粒度
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
|
||||
RBucket<T> result = redissonClient.getBucket(key);
|
||||
result.set(value);
|
||||
result.expire(timeout, timeUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @param unit 时间单位
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout, final TimeUnit unit)
|
||||
{
|
||||
return redisTemplate.expire(key, timeout, unit);
|
||||
}
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout) {
|
||||
return expire(key, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象。
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> T getCacheObject(final String key)
|
||||
{
|
||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||
return operation.get(key);
|
||||
}
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @param unit 时间单位
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
||||
RBucket rBucket = redissonClient.getBucket(key);
|
||||
return rBucket.expire(timeout, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个对象
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public boolean deleteObject(final String key)
|
||||
{
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
/**
|
||||
* 获得缓存的基本对象。
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> T getCacheObject(final String key) {
|
||||
RBucket<T> rBucket = redissonClient.getBucket(key);
|
||||
return rBucket.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除集合对象
|
||||
*
|
||||
* @param collection 多个对象
|
||||
* @return
|
||||
*/
|
||||
public long deleteObject(final Collection collection)
|
||||
{
|
||||
return redisTemplate.delete(collection);
|
||||
}
|
||||
/**
|
||||
* 删除单个对象
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public boolean deleteObject(final String key) {
|
||||
return redissonClient.getBucket(key).delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存List数据
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param dataList 待缓存的List数据
|
||||
* @return 缓存的对象
|
||||
*/
|
||||
public <T> long setCacheList(final String key, final List<T> dataList)
|
||||
{
|
||||
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
/* */
|
||||
|
||||
/**
|
||||
* 获得缓存的list对象
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> List<T> getCacheList(final String key)
|
||||
{
|
||||
return redisTemplate.opsForList().range(key, 0, -1);
|
||||
}
|
||||
/**
|
||||
* 删除集合对象
|
||||
*
|
||||
* @param collection 多个对象
|
||||
* @return
|
||||
*/
|
||||
public long deleteObject(final Collection collection) {
|
||||
return redissonClient.getKeys().delete(Arrays.toString(collection.toArray()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param dataSet 缓存的数据
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
|
||||
{
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
Iterator<T> it = dataSet.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
setOperation.add(it.next());
|
||||
}
|
||||
return setOperation;
|
||||
}
|
||||
/**
|
||||
* 缓存List数据
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param dataList 待缓存的List数据
|
||||
* @return 缓存的对象
|
||||
*/
|
||||
public <T> boolean setCacheList(final String key, final List<T> dataList) {
|
||||
RList<T> rList = redissonClient.getList(key);
|
||||
return rList.addAll(dataList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的set
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Set<T> getCacheSet(final String key)
|
||||
{
|
||||
return redisTemplate.opsForSet().members(key);
|
||||
}
|
||||
/**
|
||||
* 获得缓存的list对象
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> List<T> getCacheList(final String key) {
|
||||
RList<T> rList = redissonClient.getList(key);
|
||||
return rList.readAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存Map
|
||||
*
|
||||
* @param key
|
||||
* @param dataMap
|
||||
*/
|
||||
public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
|
||||
{
|
||||
if (dataMap != null) {
|
||||
redisTemplate.opsForHash().putAll(key, dataMap);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param dataSet 缓存的数据
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> boolean setCacheSet(final String key, final Set<T> dataSet) {
|
||||
RSet<T> rSet = redissonClient.getSet(key);
|
||||
return rSet.addAll(dataSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的Map
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Map<String, T> getCacheMap(final String key)
|
||||
{
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
/**
|
||||
* 获得缓存的set
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Set<T> getCacheSet(final String key) {
|
||||
RSet<T> rSet = redissonClient.getSet(key);
|
||||
return rSet.readAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 往Hash中存入数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @param value 值
|
||||
*/
|
||||
public <T> void setCacheMapValue(final String key, final String hKey, final T value)
|
||||
{
|
||||
redisTemplate.opsForHash().put(key, hKey, value);
|
||||
}
|
||||
/**
|
||||
* 缓存Map
|
||||
*
|
||||
* @param key
|
||||
* @param dataMap
|
||||
*/
|
||||
public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
|
||||
if (dataMap != null) {
|
||||
RMap<String, T> rMap = redissonClient.getMap(key);
|
||||
rMap.putAll(dataMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @return Hash中的对象
|
||||
*/
|
||||
public <T> T getCacheMapValue(final String key, final String hKey)
|
||||
{
|
||||
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
||||
return opsForHash.get(key, hKey);
|
||||
}
|
||||
/**
|
||||
* 获得缓存的Map
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Map<String, T> getCacheMap(final String key) {
|
||||
RMap<String, T> rMap = redissonClient.getMap(key);
|
||||
return rMap.getAll(rMap.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKeys Hash键集合
|
||||
* @return Hash对象集合
|
||||
*/
|
||||
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
|
||||
{
|
||||
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||
}
|
||||
/**
|
||||
* 往Hash中存入数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @param value 值
|
||||
*/
|
||||
public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
|
||||
RMap<String, T> rMap = redissonClient.getMap(key);
|
||||
rMap.put(hKey, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象列表
|
||||
*
|
||||
* @param pattern 字符串前缀
|
||||
* @return 对象列表
|
||||
*/
|
||||
public Collection<String> keys(final String pattern)
|
||||
{
|
||||
return redisTemplate.keys(pattern);
|
||||
}
|
||||
/**
|
||||
* 获取Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @return Hash中的对象
|
||||
*/
|
||||
public <T> T getCacheMapValue(final String key, final String hKey) {
|
||||
RMap<String, T> rMap = redissonClient.getMap(key);
|
||||
return rMap.get(hKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKeys Hash键集合
|
||||
* @return Hash对象集合
|
||||
*/
|
||||
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
|
||||
RListMultimap rListMultimap = redissonClient.getListMultimap(key);
|
||||
return rListMultimap.getAll(hKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象列表
|
||||
*
|
||||
* @param pattern 字符串前缀
|
||||
* @return 对象列表
|
||||
*/
|
||||
public Collection<String> keys(final String pattern) {
|
||||
Iterable<String> iterable = redissonClient.getKeys().getKeysByPattern(pattern);
|
||||
return Lists.newArrayList(iterable);
|
||||
}
|
||||
}
|
||||
|
50
ruoyi/src/main/java/com/ruoyi/demo/bo/ChkjTestAddBo.java
Normal file
50
ruoyi/src/main/java/com/ruoyi/demo/bo/ChkjTestAddBo.java
Normal file
@ -0,0 +1,50 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试添加对象 chkj_test
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试添加对象")
|
||||
public class ChkjTestAddBo {
|
||||
|
||||
/** key键 */
|
||||
@ApiModelProperty("key键")
|
||||
@NotBlank(message = "key键不能为空")
|
||||
private String testKey;
|
||||
/** 值 */
|
||||
@ApiModelProperty("值")
|
||||
@NotBlank(message = "值不能为空")
|
||||
private String value;
|
||||
/** 版本 */
|
||||
@ApiModelProperty("版本")
|
||||
private Long version;
|
||||
/** 创建时间 */
|
||||
@ApiModelProperty("创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/** 删除标志 */
|
||||
@ApiModelProperty("删除标志")
|
||||
private Long deleted;
|
||||
/** 父id */
|
||||
@ApiModelProperty("父id")
|
||||
@NotNull(message = "父id不能为空")
|
||||
private Long parentId;
|
||||
/** 排序号 */
|
||||
@ApiModelProperty("排序号")
|
||||
@NotNull(message = "排序号不能为空")
|
||||
private Long orderNum;
|
||||
}
|
61
ruoyi/src/main/java/com/ruoyi/demo/bo/ChkjTestEditBo.java
Normal file
61
ruoyi/src/main/java/com/ruoyi/demo/bo/ChkjTestEditBo.java
Normal file
@ -0,0 +1,61 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 测试编辑对象 chkj_test
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试编辑对象")
|
||||
public class ChkjTestEditBo {
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@ApiModelProperty("主键")
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
/** key键 */
|
||||
@ApiModelProperty("key键")
|
||||
@NotBlank(message = "key键不能为空")
|
||||
private String testKey;
|
||||
|
||||
/** 值 */
|
||||
@ApiModelProperty("值")
|
||||
@NotBlank(message = "值不能为空")
|
||||
private String value;
|
||||
|
||||
/** 版本 */
|
||||
@ApiModelProperty("版本")
|
||||
private Long version;
|
||||
|
||||
/** 创建时间 */
|
||||
@ApiModelProperty("创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 删除标志 */
|
||||
@ApiModelProperty("删除标志")
|
||||
private Long deleted;
|
||||
|
||||
/** 父id */
|
||||
@ApiModelProperty("父id")
|
||||
@NotNull(message = "父id不能为空")
|
||||
private Long parentId;
|
||||
|
||||
/** 排序号 */
|
||||
@ApiModelProperty("排序号")
|
||||
@NotNull(message = "排序号不能为空")
|
||||
private Long orderNum;
|
||||
}
|
53
ruoyi/src/main/java/com/ruoyi/demo/bo/ChkjTestQueryBo.java
Normal file
53
ruoyi/src/main/java/com/ruoyi/demo/bo/ChkjTestQueryBo.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 测试分页查询对象 chkj_test
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("测试分页查询对象")
|
||||
public class ChkjTestQueryBo extends BaseEntity {
|
||||
|
||||
/** 分页大小 */
|
||||
@ApiModelProperty("分页大小")
|
||||
private Integer pageSize;
|
||||
/** 当前页数 */
|
||||
@ApiModelProperty("当前页数")
|
||||
private Integer pageNum;
|
||||
/** 排序列 */
|
||||
@ApiModelProperty("排序列")
|
||||
private String orderByColumn;
|
||||
/** 排序的方向desc或者asc */
|
||||
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
|
||||
private String isAsc;
|
||||
|
||||
|
||||
/** key键 */
|
||||
@ApiModelProperty("key键")
|
||||
private String testKey;
|
||||
/** 值 */
|
||||
@ApiModelProperty("值")
|
||||
private String value;
|
||||
/** 版本 */
|
||||
@ApiModelProperty("版本")
|
||||
private Long version;
|
||||
/** 删除标志 */
|
||||
@ApiModelProperty("删除标志")
|
||||
private Long deleted;
|
||||
/** 父id */
|
||||
@ApiModelProperty("父id")
|
||||
private Long parentId;
|
||||
/** 排序号 */
|
||||
@ApiModelProperty("排序号")
|
||||
private Long orderNum;
|
||||
|
||||
}
|
43
ruoyi/src/main/java/com/ruoyi/demo/bo/TestDemoAddBo.java
Normal file
43
ruoyi/src/main/java/com/ruoyi/demo/bo/TestDemoAddBo.java
Normal file
@ -0,0 +1,43 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试单表添加对象 test_demo
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试单表添加对象")
|
||||
public class TestDemoAddBo {
|
||||
|
||||
/** 部门id */
|
||||
@ApiModelProperty("部门id")
|
||||
private Long deptId;
|
||||
|
||||
/** 用户id */
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/** 排序号 */
|
||||
@ApiModelProperty("排序号")
|
||||
private Long orderNum;
|
||||
|
||||
/** key键 */
|
||||
@ApiModelProperty("key键")
|
||||
@NotBlank(message = "key键不能为空")
|
||||
private String testKey;
|
||||
|
||||
/** 值 */
|
||||
@ApiModelProperty("值")
|
||||
@NotBlank(message = "值不能为空")
|
||||
private String value;
|
||||
|
||||
}
|
52
ruoyi/src/main/java/com/ruoyi/demo/bo/TestDemoEditBo.java
Normal file
52
ruoyi/src/main/java/com/ruoyi/demo/bo/TestDemoEditBo.java
Normal file
@ -0,0 +1,52 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
|
||||
/**
|
||||
* 测试单表编辑对象 test_demo
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试单表编辑对象")
|
||||
public class TestDemoEditBo {
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
|
||||
/** 部门id */
|
||||
@ApiModelProperty("部门id")
|
||||
private Long deptId;
|
||||
|
||||
|
||||
/** 用户id */
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
/** 排序号 */
|
||||
@ApiModelProperty("排序号")
|
||||
private Long orderNum;
|
||||
|
||||
|
||||
/** key键 */
|
||||
@ApiModelProperty("key键")
|
||||
@NotBlank(message = "key键不能为空")
|
||||
private String testKey;
|
||||
|
||||
|
||||
/** 值 */
|
||||
@ApiModelProperty("值")
|
||||
@NotBlank(message = "值不能为空")
|
||||
private String value;
|
||||
|
||||
}
|
42
ruoyi/src/main/java/com/ruoyi/demo/bo/TestDemoQueryBo.java
Normal file
42
ruoyi/src/main/java/com/ruoyi/demo/bo/TestDemoQueryBo.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 测试单表分页查询对象 test_demo
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("测试单表分页查询对象")
|
||||
public class TestDemoQueryBo extends BaseEntity {
|
||||
|
||||
/** 分页大小 */
|
||||
@ApiModelProperty("分页大小")
|
||||
private Integer pageSize;
|
||||
/** 当前页数 */
|
||||
@ApiModelProperty("当前页数")
|
||||
private Integer pageNum;
|
||||
/** 排序列 */
|
||||
@ApiModelProperty("排序列")
|
||||
private String orderByColumn;
|
||||
/** 排序的方向desc或者asc */
|
||||
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
|
||||
private String isAsc;
|
||||
|
||||
|
||||
/** key键 */
|
||||
@ApiModelProperty("key键")
|
||||
private String testKey;
|
||||
/** 值 */
|
||||
@ApiModelProperty("值")
|
||||
private String value;
|
||||
|
||||
}
|
39
ruoyi/src/main/java/com/ruoyi/demo/bo/TestTreeAddBo.java
Normal file
39
ruoyi/src/main/java/com/ruoyi/demo/bo/TestTreeAddBo.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试树表添加对象 test_tree
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试树表添加对象")
|
||||
public class TestTreeAddBo {
|
||||
|
||||
/** 父id */
|
||||
@ApiModelProperty("父id")
|
||||
private Long parentId;
|
||||
|
||||
/** 部门id */
|
||||
@ApiModelProperty("部门id")
|
||||
private Long deptId;
|
||||
|
||||
/** 用户id */
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/** 树节点名 */
|
||||
@ApiModelProperty("树节点名")
|
||||
@NotBlank(message = "树节点名不能为空")
|
||||
private String treeName;
|
||||
|
||||
}
|
47
ruoyi/src/main/java/com/ruoyi/demo/bo/TestTreeEditBo.java
Normal file
47
ruoyi/src/main/java/com/ruoyi/demo/bo/TestTreeEditBo.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
|
||||
/**
|
||||
* 测试树表编辑对象 test_tree
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试树表编辑对象")
|
||||
public class TestTreeEditBo {
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
|
||||
/** 父id */
|
||||
@ApiModelProperty("父id")
|
||||
private Long parentId;
|
||||
|
||||
|
||||
/** 部门id */
|
||||
@ApiModelProperty("部门id")
|
||||
private Long deptId;
|
||||
|
||||
|
||||
/** 用户id */
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
/** 树节点名 */
|
||||
@ApiModelProperty("树节点名")
|
||||
@NotBlank(message = "树节点名不能为空")
|
||||
private String treeName;
|
||||
|
||||
}
|
42
ruoyi/src/main/java/com/ruoyi/demo/bo/TestTreeQueryBo.java
Normal file
42
ruoyi/src/main/java/com/ruoyi/demo/bo/TestTreeQueryBo.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.ruoyi.demo.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 测试树表分页查询对象 test_tree
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("测试树表分页查询对象")
|
||||
public class TestTreeQueryBo extends BaseEntity {
|
||||
|
||||
/** 分页大小 */
|
||||
@ApiModelProperty("分页大小")
|
||||
private Integer pageSize;
|
||||
/** 当前页数 */
|
||||
@ApiModelProperty("当前页数")
|
||||
private Integer pageNum;
|
||||
/** 排序列 */
|
||||
@ApiModelProperty("排序列")
|
||||
private String orderByColumn;
|
||||
/** 排序的方向desc或者asc */
|
||||
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
|
||||
private String isAsc;
|
||||
|
||||
|
||||
/** 树节点名 */
|
||||
@ApiModelProperty("树节点名")
|
||||
private String treeName;
|
||||
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package com.ruoyi.demo.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.demo.bo.ChkjTestAddBo;
|
||||
import com.ruoyi.demo.bo.ChkjTestEditBo;
|
||||
import com.ruoyi.demo.bo.ChkjTestQueryBo;
|
||||
import com.ruoyi.demo.service.IChkjTestService;
|
||||
import com.ruoyi.demo.vo.ChkjTestVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试Controller
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
@Api(value = "测试控制器", tags = {"测试管理"})
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RestController
|
||||
@RequestMapping("/demo/test")
|
||||
public class ChkjTestController extends BaseController {
|
||||
|
||||
private final IChkjTestService iChkjTestService;
|
||||
|
||||
/**
|
||||
* 查询测试列表
|
||||
*/
|
||||
@ApiOperation("查询测试列表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:test:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ChkjTestVo> list(@Validated ChkjTestQueryBo bo) {
|
||||
return iChkjTestService.queryPageList(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出测试列表
|
||||
*/
|
||||
@ApiOperation("导出测试列表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:test:export')")
|
||||
@Log(title = "测试", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult<ChkjTestVo> export(@Validated ChkjTestQueryBo bo) {
|
||||
List<ChkjTestVo> list = iChkjTestService.queryList(bo);
|
||||
ExcelUtil<ChkjTestVo> util = new ExcelUtil<ChkjTestVo>(ChkjTestVo.class);
|
||||
return util.exportExcel(list, "测试");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取测试详细信息
|
||||
*/
|
||||
@ApiOperation("获取测试详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('demo:test:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult<ChkjTestVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(iChkjTestService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增测试
|
||||
*/
|
||||
@ApiOperation("新增测试")
|
||||
@PreAuthorize("@ss.hasPermi('demo:test:add')")
|
||||
@Log(title = "测试", businessType = BusinessType.INSERT)
|
||||
@PostMapping()
|
||||
public AjaxResult<Void> add(@Validated @RequestBody ChkjTestAddBo bo) {
|
||||
return toAjax(iChkjTestService.insertByAddBo(bo) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改测试
|
||||
*/
|
||||
@ApiOperation("修改测试")
|
||||
@PreAuthorize("@ss.hasPermi('demo:test:edit')")
|
||||
@Log(title = "测试", businessType = BusinessType.UPDATE)
|
||||
@PutMapping()
|
||||
public AjaxResult<Void> edit(@Validated @RequestBody ChkjTestEditBo bo) {
|
||||
return toAjax(iChkjTestService.updateByEditBo(bo) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除测试
|
||||
*/
|
||||
@ApiOperation("删除测试")
|
||||
@PreAuthorize("@ss.hasPermi('demo:test:remove')")
|
||||
@Log(title = "测试" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iChkjTestService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package com.ruoyi.demo.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.demo.bo.TestDemoAddBo;
|
||||
import com.ruoyi.demo.bo.TestDemoEditBo;
|
||||
import com.ruoyi.demo.bo.TestDemoQueryBo;
|
||||
import com.ruoyi.demo.service.ITestDemoService;
|
||||
import com.ruoyi.demo.vo.TestDemoVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试单表Controller
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Api(value = "测试单表控制器", tags = {"测试单表管理"})
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RestController
|
||||
@RequestMapping("/demo/demo")
|
||||
public class TestDemoController extends BaseController {
|
||||
|
||||
private final ITestDemoService iTestDemoService;
|
||||
|
||||
/**
|
||||
* 查询测试单表列表
|
||||
*/
|
||||
@ApiOperation("查询测试单表列表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:demo:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<TestDemoVo> list(@Validated TestDemoQueryBo bo) {
|
||||
return iTestDemoService.queryPageList(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出测试单表列表
|
||||
*/
|
||||
@ApiOperation("导出测试单表列表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:demo:export')")
|
||||
@Log(title = "测试单表", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult<TestDemoVo> export(@Validated TestDemoQueryBo bo) {
|
||||
List<TestDemoVo> list = iTestDemoService.queryList(bo);
|
||||
ExcelUtil<TestDemoVo> util = new ExcelUtil<TestDemoVo>(TestDemoVo.class);
|
||||
return util.exportExcel(list, "测试单表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取测试单表详细信息
|
||||
*/
|
||||
@ApiOperation("获取测试单表详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('demo:demo:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult<TestDemoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(iTestDemoService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增测试单表
|
||||
*/
|
||||
@ApiOperation("新增测试单表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:demo:add')")
|
||||
@Log(title = "测试单表", businessType = BusinessType.INSERT)
|
||||
@PostMapping()
|
||||
public AjaxResult<Void> add(@Validated @RequestBody TestDemoAddBo bo) {
|
||||
return toAjax(iTestDemoService.insertByAddBo(bo) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改测试单表
|
||||
*/
|
||||
@ApiOperation("修改测试单表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:demo:edit')")
|
||||
@Log(title = "测试单表", businessType = BusinessType.UPDATE)
|
||||
@PutMapping()
|
||||
public AjaxResult<Void> edit(@Validated @RequestBody TestDemoEditBo bo) {
|
||||
return toAjax(iTestDemoService.updateByEditBo(bo) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除测试单表
|
||||
*/
|
||||
@ApiOperation("删除测试单表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:demo:remove')")
|
||||
@Log(title = "测试单表" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.ruoyi.demo.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.demo.bo.TestTreeAddBo;
|
||||
import com.ruoyi.demo.bo.TestTreeEditBo;
|
||||
import com.ruoyi.demo.bo.TestTreeQueryBo;
|
||||
import com.ruoyi.demo.service.ITestTreeService;
|
||||
import com.ruoyi.demo.vo.TestTreeVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试树表Controller
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Api(value = "测试树表控制器", tags = {"测试树表管理"})
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RestController
|
||||
@RequestMapping("/demo/tree")
|
||||
public class TestTreeController extends BaseController {
|
||||
|
||||
private final ITestTreeService iTestTreeService;
|
||||
|
||||
/**
|
||||
* 查询测试树表列表
|
||||
*/
|
||||
@ApiOperation("查询测试树表列表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:tree:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult<List<TestTreeVo>> list(@Validated TestTreeQueryBo bo) {
|
||||
return AjaxResult.success(iTestTreeService.queryList(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出测试树表列表
|
||||
*/
|
||||
@ApiOperation("导出测试树表列表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:tree:export')")
|
||||
@Log(title = "测试树表", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult<TestTreeVo> export(@Validated TestTreeQueryBo bo) {
|
||||
List<TestTreeVo> list = iTestTreeService.queryList(bo);
|
||||
ExcelUtil<TestTreeVo> util = new ExcelUtil<TestTreeVo>(TestTreeVo.class);
|
||||
return util.exportExcel(list, "测试树表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取测试树表详细信息
|
||||
*/
|
||||
@ApiOperation("获取测试树表详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('demo:tree:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult<TestTreeVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(iTestTreeService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增测试树表
|
||||
*/
|
||||
@ApiOperation("新增测试树表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:tree:add')")
|
||||
@Log(title = "测试树表", businessType = BusinessType.INSERT)
|
||||
@PostMapping()
|
||||
public AjaxResult<Void> add(@Validated @RequestBody TestTreeAddBo bo) {
|
||||
return toAjax(iTestTreeService.insertByAddBo(bo) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改测试树表
|
||||
*/
|
||||
@ApiOperation("修改测试树表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:tree:edit')")
|
||||
@Log(title = "测试树表", businessType = BusinessType.UPDATE)
|
||||
@PutMapping()
|
||||
public AjaxResult<Void> edit(@Validated @RequestBody TestTreeEditBo bo) {
|
||||
return toAjax(iTestTreeService.updateByEditBo(bo) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除测试树表
|
||||
*/
|
||||
@ApiOperation("删除测试树表")
|
||||
@PreAuthorize("@ss.hasPermi('demo:tree:remove')")
|
||||
@Log(title = "测试树表" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
||||
}
|
||||
}
|
55
ruoyi/src/main/java/com/ruoyi/demo/domain/ChkjTest.java
Normal file
55
ruoyi/src/main/java/com/ruoyi/demo/domain/ChkjTest.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.ruoyi.demo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 测试对象 chkj_test
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@TableName("chkj_test")
|
||||
public class ChkjTest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/** key键 */
|
||||
private String testKey;
|
||||
|
||||
/** 值 */
|
||||
private String value;
|
||||
|
||||
/** 版本 */
|
||||
private Long version;
|
||||
|
||||
/** 创建时间 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/** 删除标志 */
|
||||
private Long deleted;
|
||||
|
||||
/** 父id */
|
||||
private Long parentId;
|
||||
|
||||
/** 排序号 */
|
||||
private Long orderNum;
|
||||
|
||||
}
|
70
ruoyi/src/main/java/com/ruoyi/demo/domain/TestDemo.java
Normal file
70
ruoyi/src/main/java/com/ruoyi/demo/domain/TestDemo.java
Normal file
@ -0,0 +1,70 @@
|
||||
package com.ruoyi.demo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 测试单表对象 test_demo
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@TableName("test_demo")
|
||||
public class TestDemo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/** 部门id */
|
||||
private Long deptId;
|
||||
|
||||
/** 用户id */
|
||||
private Long userId;
|
||||
|
||||
/** 排序号 */
|
||||
@OrderBy(isDesc = false, sort = 1)
|
||||
private Long orderNum;
|
||||
|
||||
/** key键 */
|
||||
private String testKey;
|
||||
|
||||
/** 值 */
|
||||
private String value;
|
||||
|
||||
/** 版本 */
|
||||
@Version
|
||||
private Long version;
|
||||
|
||||
/** 创建时间 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/** 创建人 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/** 更新人 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
|
||||
/** 删除标志 */
|
||||
@TableLogic
|
||||
private Long delFlag;
|
||||
|
||||
}
|
67
ruoyi/src/main/java/com/ruoyi/demo/domain/TestTree.java
Normal file
67
ruoyi/src/main/java/com/ruoyi/demo/domain/TestTree.java
Normal file
@ -0,0 +1,67 @@
|
||||
package com.ruoyi.demo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 测试树表对象 test_tree
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@TableName("test_tree")
|
||||
public class TestTree implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/** 父id */
|
||||
private Long parentId;
|
||||
|
||||
/** 部门id */
|
||||
private Long deptId;
|
||||
|
||||
/** 用户id */
|
||||
private Long userId;
|
||||
|
||||
/** 树节点名 */
|
||||
private String treeName;
|
||||
|
||||
/** 版本 */
|
||||
@Version
|
||||
private Long version;
|
||||
|
||||
/** 创建时间 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/** 创建人 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/** 更新人 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
|
||||
/** 删除标志 */
|
||||
@TableLogic
|
||||
private Long delFlag;
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.demo.mapper;
|
||||
|
||||
import com.ruoyi.demo.domain.ChkjTest;
|
||||
import com.ruoyi.common.core.page.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 测试Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
public interface ChkjTestMapper extends BaseMapperPlus<ChkjTest> {
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.demo.mapper;
|
||||
|
||||
import com.ruoyi.demo.domain.TestDemo;
|
||||
import com.ruoyi.common.core.page.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 测试单表Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
public interface TestDemoMapper extends BaseMapperPlus<TestDemo> {
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.demo.mapper;
|
||||
|
||||
import com.ruoyi.demo.domain.TestTree;
|
||||
import com.ruoyi.common.core.page.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 测试树表Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
public interface TestTreeMapper extends BaseMapperPlus<TestTree> {
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.ruoyi.demo.service;
|
||||
|
||||
import com.ruoyi.demo.domain.ChkjTest;
|
||||
import com.ruoyi.demo.vo.ChkjTestVo;
|
||||
import com.ruoyi.demo.bo.ChkjTestQueryBo;
|
||||
import com.ruoyi.demo.bo.ChkjTestAddBo;
|
||||
import com.ruoyi.demo.bo.ChkjTestEditBo;
|
||||
import com.ruoyi.common.core.page.IServicePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
public interface IChkjTestService extends IServicePlus<ChkjTest> {
|
||||
/**
|
||||
* 查询单个
|
||||
* @return
|
||||
*/
|
||||
ChkjTestVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
TableDataInfo<ChkjTestVo> queryPageList(ChkjTestQueryBo bo);
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
List<ChkjTestVo> queryList(ChkjTestQueryBo bo);
|
||||
|
||||
/**
|
||||
* 根据新增业务对象插入测试
|
||||
* @param bo 测试新增业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean insertByAddBo(ChkjTestAddBo bo);
|
||||
|
||||
/**
|
||||
* 根据编辑业务对象修改测试
|
||||
* @param bo 测试编辑业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean updateByEditBo(ChkjTestEditBo bo);
|
||||
|
||||
/**
|
||||
* 校验并删除数据
|
||||
* @param ids 主键集合
|
||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.ruoyi.demo.service;
|
||||
|
||||
import com.ruoyi.demo.domain.TestDemo;
|
||||
import com.ruoyi.demo.vo.TestDemoVo;
|
||||
import com.ruoyi.demo.bo.TestDemoQueryBo;
|
||||
import com.ruoyi.demo.bo.TestDemoAddBo;
|
||||
import com.ruoyi.demo.bo.TestDemoEditBo;
|
||||
import com.ruoyi.common.core.page.IServicePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试单表Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
public interface ITestDemoService extends IServicePlus<TestDemo> {
|
||||
/**
|
||||
* 查询单个
|
||||
* @return
|
||||
*/
|
||||
TestDemoVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
TableDataInfo<TestDemoVo> queryPageList(TestDemoQueryBo bo);
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
List<TestDemoVo> queryList(TestDemoQueryBo bo);
|
||||
|
||||
/**
|
||||
* 根据新增业务对象插入测试单表
|
||||
* @param bo 测试单表新增业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean insertByAddBo(TestDemoAddBo bo);
|
||||
|
||||
/**
|
||||
* 根据编辑业务对象修改测试单表
|
||||
* @param bo 测试单表编辑业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean updateByEditBo(TestDemoEditBo bo);
|
||||
|
||||
/**
|
||||
* 校验并删除数据
|
||||
* @param ids 主键集合
|
||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.ruoyi.demo.service;
|
||||
|
||||
import com.ruoyi.common.core.page.IServicePlus;
|
||||
import com.ruoyi.demo.bo.TestTreeAddBo;
|
||||
import com.ruoyi.demo.bo.TestTreeEditBo;
|
||||
import com.ruoyi.demo.bo.TestTreeQueryBo;
|
||||
import com.ruoyi.demo.domain.TestTree;
|
||||
import com.ruoyi.demo.vo.TestTreeVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试树表Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
public interface ITestTreeService extends IServicePlus<TestTree> {
|
||||
/**
|
||||
* 查询单个
|
||||
* @return
|
||||
*/
|
||||
TestTreeVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
List<TestTreeVo> queryList(TestTreeQueryBo bo);
|
||||
|
||||
/**
|
||||
* 根据新增业务对象插入测试树表
|
||||
* @param bo 测试树表新增业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean insertByAddBo(TestTreeAddBo bo);
|
||||
|
||||
/**
|
||||
* 根据编辑业务对象修改测试树表
|
||||
* @param bo 测试树表编辑业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean updateByEditBo(TestTreeEditBo bo);
|
||||
|
||||
/**
|
||||
* 校验并删除数据
|
||||
* @param ids 主键集合
|
||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.ruoyi.demo.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.page.PagePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.demo.bo.ChkjTestAddBo;
|
||||
import com.ruoyi.demo.bo.ChkjTestEditBo;
|
||||
import com.ruoyi.demo.bo.ChkjTestQueryBo;
|
||||
import com.ruoyi.demo.domain.ChkjTest;
|
||||
import com.ruoyi.demo.mapper.ChkjTestMapper;
|
||||
import com.ruoyi.demo.service.IChkjTestService;
|
||||
import com.ruoyi.demo.vo.ChkjTestVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 测试Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
@Service
|
||||
public class ChkjTestServiceImpl extends ServiceImpl<ChkjTestMapper, ChkjTest> implements IChkjTestService {
|
||||
|
||||
@Override
|
||||
public ChkjTestVo queryById(Long id){
|
||||
return getVoById(id, obj -> BeanUtil.toBean(obj, ChkjTestVo.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<ChkjTestVo> queryPageList(ChkjTestQueryBo bo) {
|
||||
PagePlus<ChkjTest, ChkjTestVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ChkjTestVo.class);
|
||||
return PageUtils.buildDataInfo(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChkjTestVo> queryList(ChkjTestQueryBo bo) {
|
||||
return listVo(buildQueryWrapper(bo), ChkjTestVo.class);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<ChkjTest> buildQueryWrapper(ChkjTestQueryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ChkjTest> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StrUtil.isNotBlank(bo.getTestKey()), ChkjTest::getTestKey, bo.getTestKey());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getValue()), ChkjTest::getValue, bo.getValue());
|
||||
lqw.eq(bo.getVersion() != null, ChkjTest::getVersion, bo.getVersion());
|
||||
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
||||
ChkjTest::getCreateTime ,params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
lqw.eq(bo.getDeleted() != null, ChkjTest::getDeleted, bo.getDeleted());
|
||||
lqw.eq(bo.getParentId() != null, ChkjTest::getParentId, bo.getParentId());
|
||||
lqw.eq(bo.getOrderNum() != null, ChkjTest::getOrderNum, bo.getOrderNum());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByAddBo(ChkjTestAddBo bo) {
|
||||
ChkjTest add = BeanUtil.toBean(bo, ChkjTest.class);
|
||||
validEntityBeforeSave(add);
|
||||
return save(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByEditBo(ChkjTestEditBo bo) {
|
||||
ChkjTest update = BeanUtil.toBean(bo, ChkjTest.class);
|
||||
validEntityBeforeSave(update);
|
||||
return updateById(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*
|
||||
* @param entity 实体类数据
|
||||
*/
|
||||
private void validEntityBeforeSave(ChkjTest entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return removeByIds(ids);
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.ruoyi.demo.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.core.page.PagePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.demo.bo.TestDemoAddBo;
|
||||
import com.ruoyi.demo.bo.TestDemoEditBo;
|
||||
import com.ruoyi.demo.bo.TestDemoQueryBo;
|
||||
import com.ruoyi.demo.domain.TestDemo;
|
||||
import com.ruoyi.demo.mapper.TestDemoMapper;
|
||||
import com.ruoyi.demo.service.ITestDemoService;
|
||||
import com.ruoyi.demo.vo.TestDemoVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 测试单表Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Service
|
||||
public class TestDemoServiceImpl extends ServiceImpl<TestDemoMapper, TestDemo> implements ITestDemoService {
|
||||
|
||||
@Override
|
||||
public TestDemoVo queryById(Long id) {
|
||||
return getVoById(id, TestDemoVo.class);
|
||||
}
|
||||
|
||||
@DataScope(isUser = true)
|
||||
@Override
|
||||
public TableDataInfo<TestDemoVo> queryPageList(TestDemoQueryBo bo) {
|
||||
PagePlus<TestDemo, TestDemoVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), TestDemoVo.class);
|
||||
return PageUtils.buildDataInfo(result);
|
||||
}
|
||||
|
||||
@DataScope(isUser = true)
|
||||
@Override
|
||||
public List<TestDemoVo> queryList(TestDemoQueryBo bo) {
|
||||
return listVo(buildQueryWrapper(bo), TestDemoVo.class);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoQueryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
Object dataScope = params.get("dataScope");
|
||||
LambdaQueryWrapper<TestDemo> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StrUtil.isNotBlank(bo.getTestKey()), TestDemo::getTestKey, bo.getTestKey());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getValue()), TestDemo::getValue, bo.getValue());
|
||||
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
||||
TestDemo::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
lqw.apply(dataScope != null && StrUtil.isNotBlank(dataScope.toString()),
|
||||
dataScope != null ? dataScope.toString() : null);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByAddBo(TestDemoAddBo bo) {
|
||||
TestDemo add = BeanUtil.toBean(bo, TestDemo.class);
|
||||
validEntityBeforeSave(add);
|
||||
return save(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByEditBo(TestDemoEditBo bo) {
|
||||
TestDemo update = BeanUtil.toBean(bo, TestDemo.class);
|
||||
validEntityBeforeSave(update);
|
||||
return updateById(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*
|
||||
* @param entity 实体类数据
|
||||
*/
|
||||
private void validEntityBeforeSave(TestDemo entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return removeByIds(ids);
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.ruoyi.demo.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.demo.bo.TestTreeAddBo;
|
||||
import com.ruoyi.demo.bo.TestTreeEditBo;
|
||||
import com.ruoyi.demo.bo.TestTreeQueryBo;
|
||||
import com.ruoyi.demo.domain.TestTree;
|
||||
import com.ruoyi.demo.mapper.TestTreeMapper;
|
||||
import com.ruoyi.demo.service.ITestTreeService;
|
||||
import com.ruoyi.demo.vo.TestTreeVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 测试树表Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Service
|
||||
public class TestTreeServiceImpl extends ServiceImpl<TestTreeMapper, TestTree> implements ITestTreeService {
|
||||
|
||||
@Override
|
||||
public TestTreeVo queryById(Long id) {
|
||||
return getVoById(id, TestTreeVo.class);
|
||||
}
|
||||
|
||||
@DataScope(isUser = true)
|
||||
@Override
|
||||
public List<TestTreeVo> queryList(TestTreeQueryBo bo) {
|
||||
return listVo(buildQueryWrapper(bo), TestTreeVo.class);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeQueryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
Object dataScope = params.get("dataScope");
|
||||
LambdaQueryWrapper<TestTree> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StrUtil.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName());
|
||||
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
||||
TestTree::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
lqw.apply(dataScope != null && StrUtil.isNotBlank(dataScope.toString()),
|
||||
dataScope != null ? dataScope.toString() : null);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByAddBo(TestTreeAddBo bo) {
|
||||
TestTree add = BeanUtil.toBean(bo, TestTree.class);
|
||||
validEntityBeforeSave(add);
|
||||
return save(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByEditBo(TestTreeEditBo bo) {
|
||||
TestTree update = BeanUtil.toBean(bo, TestTree.class);
|
||||
validEntityBeforeSave(update);
|
||||
return updateById(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*
|
||||
* @param entity 实体类数据
|
||||
*/
|
||||
private void validEntityBeforeSave(TestTree entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return removeByIds(ids);
|
||||
}
|
||||
}
|
57
ruoyi/src/main/java/com/ruoyi/demo/vo/ChkjTestVo.java
Normal file
57
ruoyi/src/main/java/com/ruoyi/demo/vo/ChkjTestVo.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.ruoyi.demo.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试视图对象 mall_package
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试视图对象")
|
||||
public class ChkjTestVo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
/** key键 */
|
||||
@Excel(name = "key键")
|
||||
@ApiModelProperty("key键")
|
||||
private String testKey;
|
||||
/** 值 */
|
||||
@Excel(name = "值")
|
||||
@ApiModelProperty("值")
|
||||
private String value;
|
||||
/** 版本 */
|
||||
@Excel(name = "版本")
|
||||
@ApiModelProperty("版本")
|
||||
private Long version;
|
||||
/** 创建时间 */
|
||||
@Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
/** 删除标志 */
|
||||
@Excel(name = "删除标志")
|
||||
@ApiModelProperty("删除标志")
|
||||
private Long deleted;
|
||||
/** 父id */
|
||||
@Excel(name = "父id")
|
||||
@ApiModelProperty("父id")
|
||||
private Long parentId;
|
||||
/** 排序号 */
|
||||
@Excel(name = "排序号")
|
||||
@ApiModelProperty("排序号")
|
||||
private Long orderNum;
|
||||
|
||||
}
|
76
ruoyi/src/main/java/com/ruoyi/demo/vo/TestDemoVo.java
Normal file
76
ruoyi/src/main/java/com/ruoyi/demo/vo/TestDemoVo.java
Normal file
@ -0,0 +1,76 @@
|
||||
package com.ruoyi.demo.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试单表视图对象 test_demo
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试单表视图对象")
|
||||
public class TestDemoVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
/** 部门id */
|
||||
@Excel(name = "部门id")
|
||||
@ApiModelProperty("部门id")
|
||||
private Long deptId;
|
||||
|
||||
/** 用户id */
|
||||
@Excel(name = "用户id")
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/** 排序号 */
|
||||
@Excel(name = "排序号")
|
||||
@ApiModelProperty("排序号")
|
||||
private Long orderNum;
|
||||
|
||||
/** key键 */
|
||||
@Excel(name = "key键")
|
||||
@ApiModelProperty("key键")
|
||||
private String testKey;
|
||||
|
||||
/** 值 */
|
||||
@Excel(name = "值")
|
||||
@ApiModelProperty("值")
|
||||
private String value;
|
||||
|
||||
/** 创建时间 */
|
||||
@Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/** 创建人 */
|
||||
@Excel(name = "创建人")
|
||||
@ApiModelProperty("创建人")
|
||||
private String createBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@Excel(name = "更新时间" , width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/** 更新人 */
|
||||
@Excel(name = "更新人")
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateBy;
|
||||
|
||||
|
||||
}
|
55
ruoyi/src/main/java/com/ruoyi/demo/vo/TestTreeVo.java
Normal file
55
ruoyi/src/main/java/com/ruoyi/demo/vo/TestTreeVo.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.ruoyi.demo.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试树表视图对象 test_tree
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-05-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("测试树表视图对象")
|
||||
public class TestTreeVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
/** 父id */
|
||||
@Excel(name = "父id")
|
||||
@ApiModelProperty("父id")
|
||||
private Long parentId;
|
||||
|
||||
/** 部门id */
|
||||
@Excel(name = "部门id")
|
||||
@ApiModelProperty("部门id")
|
||||
private Long deptId;
|
||||
|
||||
/** 用户id */
|
||||
@Excel(name = "用户id")
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/** 树节点名 */
|
||||
@Excel(name = "树节点名")
|
||||
@ApiModelProperty("树节点名")
|
||||
private String treeName;
|
||||
|
||||
/** 创建时间 */
|
||||
@Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
@ -24,167 +24,147 @@ import java.util.Map;
|
||||
/**
|
||||
* 数据过滤处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class DataScopeAspect
|
||||
{
|
||||
/**
|
||||
* 全部数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_ALL = "1";
|
||||
public class DataScopeAspect {
|
||||
|
||||
/**
|
||||
* 自定数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_CUSTOM = "2";
|
||||
/**
|
||||
* 全部数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_ALL = "1";
|
||||
|
||||
/**
|
||||
* 部门数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT = "3";
|
||||
/**
|
||||
* 自定数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_CUSTOM = "2";
|
||||
|
||||
/**
|
||||
* 部门及以下数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
|
||||
/**
|
||||
* 部门数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT = "3";
|
||||
|
||||
/**
|
||||
* 仅本人数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_SELF = "5";
|
||||
/**
|
||||
* 部门及以下数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
|
||||
|
||||
/**
|
||||
* 数据权限过滤关键字
|
||||
*/
|
||||
public static final String DATA_SCOPE = "dataScope";
|
||||
/**
|
||||
* 仅本人数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_SELF = "5";
|
||||
|
||||
// 配置织入点
|
||||
@Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)")
|
||||
public void dataScopePointCut()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* 数据权限过滤关键字
|
||||
*/
|
||||
public static final String DATA_SCOPE = "dataScope";
|
||||
|
||||
@Before("dataScopePointCut()")
|
||||
public void doBefore(JoinPoint point) throws Throwable
|
||||
{
|
||||
// 配置织入点
|
||||
@Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)")
|
||||
public void dataScopePointCut() {
|
||||
}
|
||||
|
||||
@Before("dataScopePointCut()")
|
||||
public void doBefore(JoinPoint point) throws Throwable {
|
||||
clearDataScope(point);
|
||||
handleDataScope(point);
|
||||
}
|
||||
handleDataScope(point);
|
||||
}
|
||||
|
||||
protected void handleDataScope(final JoinPoint joinPoint)
|
||||
{
|
||||
// 获得注解
|
||||
DataScope controllerDataScope = getAnnotationLog(joinPoint);
|
||||
if (controllerDataScope == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 获取当前的用户
|
||||
LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
|
||||
if (Validator.isNotNull(loginUser))
|
||||
{
|
||||
SysUser currentUser = loginUser.getUser();
|
||||
// 如果是超级管理员,则不过滤数据
|
||||
if (Validator.isNotNull(currentUser) && !currentUser.isAdmin())
|
||||
{
|
||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
||||
controllerDataScope.userAlias());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据范围过滤
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param user 用户
|
||||
* @param userAlias 别名
|
||||
*/
|
||||
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias)
|
||||
{
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
|
||||
for (SysRole role : user.getRoles())
|
||||
{
|
||||
String dataScope = role.getDataScope();
|
||||
if (DATA_SCOPE_ALL.equals(dataScope))
|
||||
{
|
||||
sqlString = new StringBuilder();
|
||||
break;
|
||||
}
|
||||
else if (DATA_SCOPE_CUSTOM.equals(dataScope))
|
||||
{
|
||||
sqlString.append(StrUtil.format(
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
|
||||
role.getRoleId()));
|
||||
}
|
||||
else if (DATA_SCOPE_DEPT.equals(dataScope))
|
||||
{
|
||||
sqlString.append(StrUtil.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
|
||||
}
|
||||
else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
|
||||
{
|
||||
sqlString.append(StrUtil.format(
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
|
||||
deptAlias, user.getDeptId(), user.getDeptId()));
|
||||
}
|
||||
else if (DATA_SCOPE_SELF.equals(dataScope))
|
||||
{
|
||||
if (StrUtil.isNotBlank(userAlias))
|
||||
{
|
||||
sqlString.append(StrUtil.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 数据权限为仅本人且没有userAlias别名不查询任何数据
|
||||
sqlString.append(" OR 1=0 ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(sqlString.toString()))
|
||||
{
|
||||
putDataScope(joinPoint, "AND (" + sqlString.substring(4) + ")");
|
||||
protected void handleDataScope(final JoinPoint joinPoint) {
|
||||
// 获得注解
|
||||
DataScope controllerDataScope = getAnnotationLog(joinPoint);
|
||||
if (controllerDataScope == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 获取当前的用户
|
||||
LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
|
||||
if (Validator.isNotNull(loginUser)) {
|
||||
SysUser currentUser = loginUser.getUser();
|
||||
// 如果是超级管理员,则不过滤数据
|
||||
if (Validator.isNotNull(currentUser) && !currentUser.isAdmin()) {
|
||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
||||
controllerDataScope.userAlias(), controllerDataScope.isUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在注解,如果存在就获取
|
||||
*/
|
||||
private DataScope getAnnotationLog(JoinPoint joinPoint)
|
||||
{
|
||||
Signature signature = joinPoint.getSignature();
|
||||
MethodSignature methodSignature = (MethodSignature) signature;
|
||||
Method method = methodSignature.getMethod();
|
||||
/**
|
||||
* 数据范围过滤
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param user 用户
|
||||
* @param userAlias 别名
|
||||
*/
|
||||
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, boolean isUser) {
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
|
||||
if (method != null)
|
||||
{
|
||||
return method.getAnnotation(DataScope.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// 将 "." 提取出,不写别名为单表查询,写别名为多表查询
|
||||
deptAlias = StrUtil.isNotBlank(deptAlias) ? deptAlias + "." : "";
|
||||
userAlias = StrUtil.isNotBlank(userAlias) ? userAlias + "." : "";
|
||||
|
||||
for (SysRole role : user.getRoles()) {
|
||||
String dataScope = role.getDataScope();
|
||||
if (DATA_SCOPE_ALL.equals(dataScope)) {
|
||||
sqlString = new StringBuilder();
|
||||
break;
|
||||
} else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
|
||||
sqlString.append(StrUtil.format(
|
||||
" OR {}dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ",
|
||||
deptAlias, role.getRoleId()));
|
||||
} else if (DATA_SCOPE_DEPT.equals(dataScope)) {
|
||||
sqlString.append(StrUtil.format(" OR {}dept_id = {} ",
|
||||
deptAlias, user.getDeptId()));
|
||||
} else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
|
||||
sqlString.append(StrUtil.format(
|
||||
" OR {}dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
|
||||
deptAlias, user.getDeptId(), user.getDeptId()));
|
||||
} else if (DATA_SCOPE_SELF.equals(dataScope)) {
|
||||
if (isUser) {
|
||||
sqlString.append(StrUtil.format(" OR {}user_id = {} ",
|
||||
userAlias, user.getUserId()));
|
||||
} else {
|
||||
// 数据权限为仅本人且没有userAlias别名不查询任何数据
|
||||
sqlString.append(" OR 1=0 ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(sqlString.toString())) {
|
||||
putDataScope(joinPoint, sqlString.substring(4));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在注解,如果存在就获取
|
||||
*/
|
||||
private DataScope getAnnotationLog(JoinPoint joinPoint) {
|
||||
Signature signature = joinPoint.getSignature();
|
||||
MethodSignature methodSignature = (MethodSignature) signature;
|
||||
Method method = methodSignature.getMethod();
|
||||
|
||||
if (method != null) {
|
||||
return method.getAnnotation(DataScope.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接权限sql前先清空params.dataScope参数防止注入
|
||||
*/
|
||||
private void clearDataScope(final JoinPoint joinPoint)
|
||||
{
|
||||
private void clearDataScope(final JoinPoint joinPoint) {
|
||||
Object params = joinPoint.getArgs()[0];
|
||||
if (Validator.isNotNull(params))
|
||||
{
|
||||
if (Validator.isNotNull(params)) {
|
||||
putDataScope(joinPoint, "");
|
||||
}
|
||||
}
|
||||
|
||||
private static void putDataScope(JoinPoint joinPoint, String sql) {
|
||||
Object params = joinPoint.getArgs()[0];
|
||||
if (Validator.isNotNull(params))
|
||||
{
|
||||
if(params instanceof BaseEntity) {
|
||||
if (Validator.isNotNull(params)) {
|
||||
if (params instanceof BaseEntity) {
|
||||
BaseEntity baseEntity = (BaseEntity) params;
|
||||
baseEntity.getParams().put(DATA_SCOPE, "");
|
||||
baseEntity.getParams().put(DATA_SCOPE, sql);
|
||||
} else {
|
||||
try {
|
||||
Method getParams = params.getClass().getDeclaredMethod("getParams", null);
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.ruoyi.framework.config;
|
||||
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@EnableAsync
|
||||
@Configuration
|
||||
public class AsyncConfig extends AsyncConfigurerSupport {
|
||||
|
||||
/**
|
||||
* 异步执行需要使用权限框架自带的包装线程池 保证权限信息的传递
|
||||
*/
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
return new DelegatingSecurityContextExecutorService(
|
||||
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步执行异常处理
|
||||
*/
|
||||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return (throwable, method, objects) -> {
|
||||
throwable.printStackTrace();
|
||||
throw new CustomException(
|
||||
"Exception message - " + throwable.getMessage()
|
||||
+ ", Method name - " + method.getName()
|
||||
+ ", Parameter value - " + Arrays.toString(objects));
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +1,69 @@
|
||||
package com.ruoyi.framework.config;
|
||||
|
||||
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
||||
import com.ruoyi.framework.config.properties.RedissonProperties;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.codec.JsonJacksonCodec;
|
||||
import org.redisson.config.Config;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* redis配置
|
||||
*
|
||||
* @author ruoyi
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisConfig extends CachingConfigurerSupport
|
||||
{
|
||||
@Bean
|
||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
|
||||
{
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
|
||||
GenericFastJsonRedisSerializer serializer = new GenericFastJsonRedisSerializer();
|
||||
StringRedisSerializer keySerializer = new StringRedisSerializer();
|
||||
private static final String REDIS_PROTOCOL_PREFIX = "redis://";
|
||||
private static final String REDISS_PROTOCOL_PREFIX = "rediss://";
|
||||
|
||||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||
template.setKeySerializer(keySerializer);
|
||||
template.setValueSerializer(serializer);
|
||||
@Autowired
|
||||
private RedisProperties redisProperties;
|
||||
|
||||
// Hash的key也采用StringRedisSerializer的序列化方式
|
||||
template.setHashKeySerializer(keySerializer);
|
||||
template.setHashValueSerializer(serializer);
|
||||
@Autowired
|
||||
private RedissonProperties redissonProperties;
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
@ConditionalOnMissingBean(RedissonClient.class)
|
||||
public RedissonClient redisson() throws IOException {
|
||||
String prefix = REDIS_PROTOCOL_PREFIX;
|
||||
if (redisProperties.isSsl()) {
|
||||
prefix = REDISS_PROTOCOL_PREFIX;
|
||||
}
|
||||
Config config = new Config();
|
||||
config.setThreads(redissonProperties.getThreads())
|
||||
.setNettyThreads(redissonProperties.getNettyThreads())
|
||||
.setCodec(JsonJacksonCodec.INSTANCE)
|
||||
.setTransportMode(redissonProperties.getTransportMode());
|
||||
|
||||
RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig();
|
||||
// 使用单机模式
|
||||
config.useSingleServer()
|
||||
.setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort())
|
||||
.setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue())
|
||||
.setDatabase(redisProperties.getDatabase())
|
||||
.setPassword(redisProperties.getPassword())
|
||||
.setTimeout(singleServerConfig.getTimeout())
|
||||
.setRetryAttempts(singleServerConfig.getRetryAttempts())
|
||||
.setRetryInterval(singleServerConfig.getRetryInterval())
|
||||
.setSubscriptionsPerConnection(singleServerConfig.getSubscriptionsPerConnection())
|
||||
.setClientName(singleServerConfig.getClientName())
|
||||
.setIdleConnectionTimeout(singleServerConfig.getIdleConnectionTimeout())
|
||||
.setSubscriptionConnectionMinimumIdleSize(singleServerConfig.getSubscriptionConnectionMinimumIdleSize())
|
||||
.setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize())
|
||||
.setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize())
|
||||
.setConnectionPoolSize(singleServerConfig.getConnectionPoolSize())
|
||||
.setDnsMonitoringInterval(singleServerConfig.getDnsMonitoringInterval());
|
||||
return Redisson.create(config);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,101 @@
|
||||
package com.ruoyi.framework.config.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.redisson.client.codec.Codec;
|
||||
import org.redisson.config.TransportMode;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Redisson 配置属性
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "redisson")
|
||||
public class RedissonProperties {
|
||||
|
||||
/**
|
||||
* 线程池数量,默认值 = 当前处理核数量 * 2
|
||||
*/
|
||||
private int threads;
|
||||
|
||||
/**
|
||||
* Netty线程池数量,默认值 = 当前处理核数量 * 2
|
||||
*/
|
||||
private int nettyThreads;
|
||||
|
||||
/**
|
||||
* 传输模式
|
||||
*/
|
||||
private TransportMode transportMode;
|
||||
|
||||
/**
|
||||
* 单机服务配置
|
||||
*/
|
||||
private SingleServerConfig singleServerConfig;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class SingleServerConfig {
|
||||
|
||||
/**
|
||||
* 客户端名称
|
||||
*/
|
||||
private String clientName;
|
||||
|
||||
/**
|
||||
* 最小空闲连接数
|
||||
*/
|
||||
private int connectionMinimumIdleSize;
|
||||
|
||||
/**
|
||||
* 连接池大小
|
||||
*/
|
||||
private int connectionPoolSize;
|
||||
|
||||
/**
|
||||
* 连接空闲超时,单位:毫秒
|
||||
*/
|
||||
private int idleConnectionTimeout;
|
||||
|
||||
/**
|
||||
* 命令等待超时,单位:毫秒
|
||||
*/
|
||||
private int timeout;
|
||||
|
||||
/**
|
||||
* 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。
|
||||
*/
|
||||
private int retryAttempts;
|
||||
|
||||
/**
|
||||
* 命令重试发送时间间隔,单位:毫秒
|
||||
*/
|
||||
private int retryInterval;
|
||||
|
||||
/**
|
||||
* 发布和订阅连接的最小空闲连接数
|
||||
*/
|
||||
private int subscriptionConnectionMinimumIdleSize;
|
||||
|
||||
/**
|
||||
* 发布和订阅连接池大小
|
||||
*/
|
||||
private int subscriptionConnectionPoolSize;
|
||||
|
||||
/**
|
||||
* 单个连接最大订阅数量
|
||||
*/
|
||||
private int subscriptionsPerConnection;
|
||||
|
||||
/**
|
||||
* DNS监测时间间隔,单位:毫秒
|
||||
*/
|
||||
private int dnsMonitoringInterval;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -30,4 +30,12 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept> {
|
||||
*/
|
||||
public List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
|
||||
|
||||
/**
|
||||
* 修改子元素关系
|
||||
*
|
||||
* @param depts 子元素
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.ruoyi.system.mapper;
|
||||
import com.ruoyi.common.core.page.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysRoleDept;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色与部门关联表 数据层
|
||||
*
|
||||
@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysRoleDept;
|
||||
*/
|
||||
public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDept> {
|
||||
|
||||
/**
|
||||
* 批量新增角色部门信息
|
||||
*
|
||||
* @param roleDeptList 角色部门列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchRoleDept(List<SysRoleDept> roleDeptList);
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.ruoyi.system.mapper;
|
||||
import com.ruoyi.common.core.page.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysRoleMenu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色与菜单关联表 数据层
|
||||
*
|
||||
@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysRoleMenu;
|
||||
*/
|
||||
public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu> {
|
||||
|
||||
/**
|
||||
* 批量新增角色菜单信息
|
||||
*
|
||||
* @param roleMenuList 角色菜单列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchRoleMenu(List<SysRoleMenu> roleMenuList);
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.ruoyi.system.mapper;
|
||||
import com.ruoyi.common.core.page.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysUserPost;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户与岗位关联表 数据层
|
||||
*
|
||||
@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysUserPost;
|
||||
*/
|
||||
public interface SysUserPostMapper extends BaseMapperPlus<SysUserPost> {
|
||||
|
||||
/**
|
||||
* 批量新增用户岗位信息
|
||||
*
|
||||
* @param userPostList 用户角色列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchUserPost(List<SysUserPost> userPostList);
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.ruoyi.system.mapper;
|
||||
import com.ruoyi.common.core.page.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户与角色关联表 数据层
|
||||
*
|
||||
@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysUserRole;
|
||||
*/
|
||||
public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole> {
|
||||
|
||||
/**
|
||||
* 批量新增用户角色信息
|
||||
*
|
||||
* @param userRoleList 用户角色列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchUserRole(List<SysUserRole> userRoleList);
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -32,9 +33,6 @@ import java.util.Map;
|
||||
@Service
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService {
|
||||
|
||||
@Autowired
|
||||
private SysConfigMapper configMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@ -160,9 +158,9 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||
if (StrUtil.equals(UserConstants.YES, config.getConfigType())) {
|
||||
throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
||||
}
|
||||
configMapper.deleteById(configId);
|
||||
redisCache.deleteObject(getCacheKey(config.getConfigKey()));
|
||||
}
|
||||
baseMapper.deleteBatchIds(Arrays.asList(configIds));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,7 +244,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
||||
}
|
||||
if (children.size() > 0) {
|
||||
updateBatchById(children);
|
||||
baseMapper.updateDeptChildren(children);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -83,10 +84,10 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
public void deleteDictDataByIds(Long[] dictCodes) {
|
||||
for (Long dictCode : dictCodes) {
|
||||
SysDictData data = selectDictDataById(dictCode);
|
||||
baseMapper.deleteById(dictCode);
|
||||
List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
}
|
||||
baseMapper.deleteBatchIds(Arrays.asList(dictCodes));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -32,9 +33,6 @@ import java.util.Map;
|
||||
@Service
|
||||
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService {
|
||||
|
||||
@Autowired
|
||||
private SysDictTypeMapper dictTypeMapper;
|
||||
|
||||
@Autowired
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
@ -149,9 +147,9 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
||||
.eq(SysDictData::getDictType, dictType.getDictType())) > 0) {
|
||||
throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
dictTypeMapper.deleteById(dictId);
|
||||
DictUtils.removeDictCache(dictType.getDictType());
|
||||
}
|
||||
baseMapper.deleteBatchIds(Arrays.asList(dictIds));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -240,9 +240,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
list.add(rm);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
for (SysRoleMenu sysRoleMenu : list) {
|
||||
rows += roleMenuMapper.insert(sysRoleMenu);
|
||||
}
|
||||
rows = roleMenuMapper.batchRoleMenu(list);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
@ -263,9 +261,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
for (SysRoleDept sysRoleDept : list) {
|
||||
rows += roleDeptMapper.insert(sysRoleDept);
|
||||
}
|
||||
rows = roleDeptMapper.batchRoleDept(list);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
@DataScope(deptAlias = "d", userAlias = "u", isUser = true)
|
||||
public TableDataInfo<SysUser> selectPageUserList(SysUser user) {
|
||||
return PageUtils.buildDataInfo(baseMapper.selectPageUserList(PageUtils.buildPage(), user));
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
@DataScope(deptAlias = "d", userAlias = "u", isUser = true)
|
||||
public List<SysUser> selectUserList(SysUser user) {
|
||||
return baseMapper.selectUserList(user);
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Override
|
||||
public String selectUserRoleGroup(String userName) {
|
||||
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
||||
StringBuffer idsStr = new StringBuffer();
|
||||
StringBuilder idsStr = new StringBuilder();
|
||||
for (SysRole role : list) {
|
||||
idsStr.append(role.getRoleName()).append(",");
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Override
|
||||
public String selectUserPostGroup(String userName) {
|
||||
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
||||
StringBuffer idsStr = new StringBuffer();
|
||||
StringBuilder idsStr = new StringBuilder();
|
||||
for (SysPost post : list) {
|
||||
idsStr.append(post.getPostName()).append(",");
|
||||
}
|
||||
@ -311,9 +311,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
for (SysUserRole sysUserRole : list) {
|
||||
userRoleMapper.insert(sysUserRole);
|
||||
}
|
||||
userRoleMapper.batchUserRole(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -335,9 +333,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
list.add(up);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
for (SysUserPost sysUserPost : list) {
|
||||
userPostMapper.insert(sysUserPost);
|
||||
}
|
||||
userPostMapper.batchUserPost(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,13 +67,38 @@ spring:
|
||||
password:
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池中的最小空闲连接
|
||||
min-idle: 0
|
||||
# 连接池中的最大空闲连接
|
||||
max-idle: 8
|
||||
# 连接池的最大数据库连接数
|
||||
max-active: 8
|
||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
max-wait: -1ms
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
|
||||
--- # redisson 客户端配置
|
||||
redisson:
|
||||
# 线程池数量
|
||||
threads: 16
|
||||
# Netty线程池数量
|
||||
nettyThreads: 32
|
||||
# 传输模式
|
||||
transportMode: "NIO"
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
clientName: ${ruoyi-vue-plus.name}
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 32
|
||||
# 连接池大小
|
||||
connectionPoolSize: 64
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。
|
||||
retryAttempts: 3
|
||||
# 命令重试发送时间间隔,单位:毫秒
|
||||
retryInterval: 1500
|
||||
# 发布和订阅连接的最小空闲连接数
|
||||
subscriptionConnectionMinimumIdleSize: 1
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
# 单个连接最大订阅数量
|
||||
subscriptionsPerConnection: 5
|
||||
# DNS监测时间间隔,单位:毫秒
|
||||
dnsMonitoringInterval: 5000
|
||||
|
@ -67,13 +67,38 @@ spring:
|
||||
password:
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池中的最小空闲连接
|
||||
min-idle: 0
|
||||
# 连接池中的最大空闲连接
|
||||
max-idle: 8
|
||||
# 连接池的最大数据库连接数
|
||||
max-active: 8
|
||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
max-wait: -1ms
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
|
||||
--- # redisson 客户端配置
|
||||
redisson:
|
||||
# 线程池数量
|
||||
threads: 16
|
||||
# Netty线程池数量
|
||||
nettyThreads: 32
|
||||
# 传输模式
|
||||
transportMode: "NIO"
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
clientName: ${ruoyi-vue-plus.name}
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 32
|
||||
# 连接池大小
|
||||
connectionPoolSize: 64
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。
|
||||
retryAttempts: 3
|
||||
# 命令重试发送时间间隔,单位:毫秒
|
||||
retryInterval: 1500
|
||||
# 发布和订阅连接的最小空闲连接数
|
||||
subscriptionConnectionMinimumIdleSize: 1
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
# 单个连接最大订阅数量
|
||||
subscriptionsPerConnection: 5
|
||||
# DNS监测时间间隔,单位:毫秒
|
||||
dnsMonitoringInterval: 5000
|
||||
|
19
ruoyi/src/main/resources/mapper/demo/ChkjTestMapper.xml
Normal file
19
ruoyi/src/main/resources/mapper/demo/ChkjTestMapper.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?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.ruoyi.demo.mapper.ChkjTestMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.demo.domain.ChkjTest" id="ChkjTestResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="testKey" column="test_key"/>
|
||||
<result property="value" column="value"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="deleted" column="deleted"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="orderNum" column="order_num"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
23
ruoyi/src/main/resources/mapper/demo/TestDemoMapper.xml
Normal file
23
ruoyi/src/main/resources/mapper/demo/TestDemoMapper.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.demo.mapper.TestDemoMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.demo.domain.TestDemo" id="TestDemoResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="orderNum" column="order_num"/>
|
||||
<result property="testKey" column="test_key"/>
|
||||
<result property="value" column="value"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
22
ruoyi/src/main/resources/mapper/demo/TestTreeMapper.xml
Normal file
22
ruoyi/src/main/resources/mapper/demo/TestTreeMapper.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?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.ruoyi.demo.mapper.TestTreeMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.demo.domain.TestTree" id="TestTreeResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="treeName" column="tree_name"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
@ -40,7 +40,9 @@
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
<if test="params.dataScope != null and params.dataScope != ''">
|
||||
AND ( ${params.dataScope} )
|
||||
</if>
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
@ -55,4 +57,17 @@
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
<update id="updateDeptChildren" parameterType="java.util.List">
|
||||
update sys_dept set ancestors =
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator=" " open="case dept_id" close="end">
|
||||
when #{item.deptId} then #{item.ancestors}
|
||||
</foreach>
|
||||
where dept_id in
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{item.deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
@ -9,4 +9,11 @@
|
||||
<result property="deptId" column="dept_id"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
<insert id="batchRoleDept">
|
||||
insert into sys_role_dept(role_id, dept_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.roleId},#{item.deptId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
@ -58,7 +58,9 @@
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{role.params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${role.params.dataScope}
|
||||
<if test="role.params.dataScope != null and role.params.dataScope != ''">
|
||||
AND ( ${role.params.dataScope} )
|
||||
</if>
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
@ -81,7 +83,9 @@
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
<if test="params.dataScope != null and params.dataScope != ''">
|
||||
AND ( ${params.dataScope} )
|
||||
</if>
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
|
@ -9,4 +9,11 @@
|
||||
<result property="menuId" column="menu_id"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
<insert id="batchRoleMenu">
|
||||
insert into sys_role_menu(role_id, menu_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.roleId},#{item.menuId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
@ -106,7 +106,9 @@
|
||||
ancestors) ))
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${user.params.dataScope}
|
||||
<if test="user.params.dataScope != null and user.params.dataScope != ''">
|
||||
AND ( ${user.params.dataScope} )
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
@ -135,7 +137,9 @@
|
||||
ancestors) ))
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
<if test="params.dataScope != null and params.dataScope != ''">
|
||||
AND ( ${params.dataScope} )
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
|
@ -9,4 +9,11 @@
|
||||
<result property="postId" column="post_id"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
<insert id="batchUserPost">
|
||||
insert into sys_user_post(user_id, post_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.userId},#{item.postId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
@ -9,4 +9,11 @@
|
||||
<result property="roleId" column="role_id"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
<insert id="batchUserRole">
|
||||
insert into sys_user_role(user_id, role_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.userId},#{item.roleId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
@ -24,6 +24,7 @@ public class ${ClassName}AddBo {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isInsert && $column.isPk!=1)
|
||||
|
||||
/** $column.columnComment */
|
||||
@ApiModelProperty("$column.columnComment")
|
||||
#if($column.javaType == 'Date')
|
||||
|
@ -11,7 +11,7 @@ import com.ruoyi.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* ${functionName}对象 ${tableName}
|
||||
*
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@ -21,7 +21,7 @@ import com.ruoyi.common.annotation.Excel;
|
||||
@TableName("${tableName}")
|
||||
public class ${ClassName} implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
|
||||
@ -35,6 +35,9 @@ private static final long serialVersionUID=1L;
|
||||
#if($column.javaField=='delFlag')
|
||||
@TableLogic
|
||||
#end
|
||||
#if($column.javaField=='version')
|
||||
@Version
|
||||
#end
|
||||
#if($column.isPk==1)
|
||||
@TableId(value = "$column.columnName")
|
||||
#end
|
||||
|
@ -32,6 +32,7 @@ public interface I${ClassName}Service extends IServicePlus<${ClassName}> {
|
||||
*/
|
||||
TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo);
|
||||
#end
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
|
@ -13,7 +13,7 @@ import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* ${functionName}视图对象 mall_package
|
||||
* ${functionName}视图对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
@ -21,6 +21,7 @@ import java.util.Date;
|
||||
@Data
|
||||
@ApiModel("${functionName}视图对象")
|
||||
public class ${ClassName}Vo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $pkColumn.columnComment */
|
||||
@ -46,6 +47,7 @@ public class ${ClassName}Vo {
|
||||
#end
|
||||
@ApiModelProperty("$column.columnComment")
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
|
Reference in New Issue
Block a user