mirror of https://github.com/elunez/eladmin
日志加入加入IP来源,支持多字段模糊搜索,升级七牛云存储版本
parent
1b574b5971
commit
e471a9dafd
|
@ -30,6 +30,12 @@ public @interface Query {
|
||||||
*/
|
*/
|
||||||
Join join() default Join.LEFT;
|
Join join() default Join.LEFT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多字段模糊搜索,仅支持String类型字段,多个用逗号隔开, 如@Query(blurry = "email,username")
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String blurry() default "";
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
/** jie 2019/6/4 相等 */
|
/** jie 2019/6/4 相等 */
|
||||||
EQUAL
|
EQUAL
|
||||||
|
|
|
@ -11,6 +11,11 @@ public class ElAdminConstant {
|
||||||
|
|
||||||
public static final String RESET_MAIL = "重置邮箱";
|
public static final String RESET_MAIL = "重置邮箱";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于IP定位转换
|
||||||
|
*/
|
||||||
|
public static final String REGION = "内网IP|内网IP";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常用接口
|
* 常用接口
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,8 +2,8 @@ package me.zhengjie.utils;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,4 +116,27 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||||
}
|
}
|
||||||
return resultSize;
|
return resultSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputStream 转 File
|
||||||
|
* @param ins
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static File inputStreamToFile(InputStream ins, String name) throws Exception{
|
||||||
|
File file = new File(System.getProperty("java.io.tmpdir") + name);
|
||||||
|
if (file.exists()) {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
OutputStream os = new FileOutputStream(file);
|
||||||
|
int bytesRead = 0;
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
os.close();
|
||||||
|
ins.close();
|
||||||
|
return file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class QueryHelp {
|
||||||
if (q != null) {
|
if (q != null) {
|
||||||
String propName = q.propName();
|
String propName = q.propName();
|
||||||
String joinName = q.joinName();
|
String joinName = q.joinName();
|
||||||
|
String blurry = q.blurry();
|
||||||
String attributeName = isBlank(propName) ? field.getName() : propName;
|
String attributeName = isBlank(propName) ? field.getName() : propName;
|
||||||
Class<?> fieldType = field.getType();
|
Class<?> fieldType = field.getType();
|
||||||
Object val = field.get(query);
|
Object val = field.get(query);
|
||||||
|
@ -44,6 +45,18 @@ public class QueryHelp {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Join join = null;
|
Join join = null;
|
||||||
|
// 模糊多字段
|
||||||
|
if (ObjectUtil.isNotEmpty(blurry)) {
|
||||||
|
String[] blurrys = blurry.split(",");
|
||||||
|
List<Predicate> orPredicate = new ArrayList<>();
|
||||||
|
for (String s : blurrys) {
|
||||||
|
orPredicate.add(cb.like(root.get(s)
|
||||||
|
.as(String.class), "%" + val.toString() + "%"));
|
||||||
|
}
|
||||||
|
Predicate[] p = new Predicate[orPredicate.size()];
|
||||||
|
list.add(cb.or(orPredicate.toArray(p)));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (ObjectUtil.isNotEmpty(joinName)) {
|
if (ObjectUtil.isNotEmpty(joinName)) {
|
||||||
switch (q.join()) {
|
switch (q.join()) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package me.zhengjie.utils;
|
package me.zhengjie.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.resource.ClassPathResource;
|
||||||
|
import org.lionsoul.ip2region.DataBlock;
|
||||||
|
import org.lionsoul.ip2region.DbConfig;
|
||||||
|
import org.lionsoul.ip2region.DbSearcher;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -132,7 +139,49 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||||
ip = request.getRemoteAddr();
|
ip = request.getRemoteAddr();
|
||||||
}
|
}
|
||||||
return "0:0:0:0:0:0:0:1".equals(ip)?"127.0.0.1":ip;
|
String[] ips = ip.split(",");
|
||||||
|
return "0:0:0:0:0:0:0:1".equals(ips[0])?"127.0.0.1":ips[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ip获取详细地址
|
||||||
|
* @param ip
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getCityInfo(String ip) {
|
||||||
|
try {
|
||||||
|
String path = "ip2region/ip2region.db";
|
||||||
|
String name = "ip2region.db";
|
||||||
|
int algorithm = DbSearcher.BTREE_ALGORITHM;
|
||||||
|
DbConfig config = new DbConfig();
|
||||||
|
File file = FileUtil.inputStreamToFile(new ClassPathResource(path).getStream(), name);
|
||||||
|
DbSearcher searcher = new DbSearcher(config, file.getPath());
|
||||||
|
Method method = null;
|
||||||
|
switch (algorithm) {
|
||||||
|
case DbSearcher.BTREE_ALGORITHM:
|
||||||
|
method = searcher.getClass().getMethod("btreeSearch", String.class);
|
||||||
|
break;
|
||||||
|
case DbSearcher.BINARY_ALGORITHM:
|
||||||
|
method = searcher.getClass().getMethod("binarySearch", String.class);
|
||||||
|
break;
|
||||||
|
case DbSearcher.MEMORY_ALGORITYM:
|
||||||
|
method = searcher.getClass().getMethod("memorySearch", String.class);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
method = searcher.getClass().getMethod("memorySearch", String.class);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DataBlock dataBlock = null;
|
||||||
|
dataBlock = (DataBlock) method.invoke(searcher, ip);
|
||||||
|
String address = dataBlock.getRegion().replace("0|","");
|
||||||
|
if(address.charAt(address.length()-1) == '|'){
|
||||||
|
address = address.substring(0,address.length() - 1);
|
||||||
|
}
|
||||||
|
return address.equals(ElAdminConstant.REGION)?"内网IP":address;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,6 +54,9 @@ public class Log implements Serializable {
|
||||||
@Column(name = "request_ip")
|
@Column(name = "request_ip")
|
||||||
private String requestIp;
|
private String requestIp;
|
||||||
|
|
||||||
|
@Column(name = "address")
|
||||||
|
private String address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求耗时
|
* 请求耗时
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class LogController {
|
||||||
@GetMapping(value = "/logs/user")
|
@GetMapping(value = "/logs/user")
|
||||||
public ResponseEntity getUserLogs(LogQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity getUserLogs(LogQueryCriteria criteria, Pageable pageable){
|
||||||
criteria.setLogType("INFO");
|
criteria.setLogType("INFO");
|
||||||
criteria.setUsername(SecurityUtils.getUsername());
|
criteria.setBlurry(SecurityUtils.getUsername());
|
||||||
return new ResponseEntity(logService.queryAllByUser(criteria,pageable), HttpStatus.OK);
|
return new ResponseEntity(logService.queryAllByUser(criteria,pageable), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ public class LogErrorDTO implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String requestIp;
|
private String requestIp;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建日期
|
* 创建日期
|
||||||
|
|
|
@ -11,12 +11,10 @@ import me.zhengjie.annotation.Query;
|
||||||
@Data
|
@Data
|
||||||
public class LogQueryCriteria {
|
public class LogQueryCriteria {
|
||||||
|
|
||||||
@Query(type = Query.Type.INNER_LIKE)
|
// 多字段模糊
|
||||||
private String username;
|
@Query(blurry = "username,description,address,requestIp,method,params")
|
||||||
|
private String blurry;
|
||||||
|
|
||||||
@Query
|
@Query
|
||||||
private String logType;
|
private String logType;
|
||||||
|
|
||||||
@Query(type = Query.Type.INNER_LIKE)
|
|
||||||
private String description;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class LogSmallDTO implements Serializable {
|
||||||
*/
|
*/
|
||||||
private Long time;
|
private Long time;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建日期
|
* 创建日期
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,6 +10,7 @@ import me.zhengjie.service.mapper.LogErrorMapper;
|
||||||
import me.zhengjie.service.mapper.LogSmallMapper;
|
import me.zhengjie.service.mapper.LogSmallMapper;
|
||||||
import me.zhengjie.utils.PageUtil;
|
import me.zhengjie.utils.PageUtil;
|
||||||
import me.zhengjie.utils.QueryHelp;
|
import me.zhengjie.utils.QueryHelp;
|
||||||
|
import me.zhengjie.utils.StringUtils;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -92,6 +93,7 @@ public class LogServiceImpl implements LogService {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.setAddress(StringUtils.getCityInfo(log.getRequestIp()));
|
||||||
log.setMethod(methodName);
|
log.setMethod(methodName);
|
||||||
log.setUsername(username);
|
log.setUsername(username);
|
||||||
log.setParams(params + " }");
|
log.setParams(params + " }");
|
||||||
|
|
|
@ -5,6 +5,7 @@ import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.system.domain.Dict;
|
import me.zhengjie.modules.system.domain.Dict;
|
||||||
import me.zhengjie.modules.system.service.DictService;
|
import me.zhengjie.modules.system.service.DictService;
|
||||||
import me.zhengjie.modules.system.service.dto.DictDTO;
|
import me.zhengjie.modules.system.service.dto.DictDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.DictQueryCriteria;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -29,7 +30,7 @@ public class DictController {
|
||||||
@Log("查询字典")
|
@Log("查询字典")
|
||||||
@GetMapping(value = "/dict")
|
@GetMapping(value = "/dict")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_SELECT')")
|
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_SELECT')")
|
||||||
public ResponseEntity getDicts(DictDTO resources, Pageable pageable){
|
public ResponseEntity getDicts(DictQueryCriteria resources, Pageable pageable){
|
||||||
return new ResponseEntity(dictService.queryAll(resources,pageable),HttpStatus.OK);
|
return new ResponseEntity(dictService.queryAll(resources,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.system.service.MenuService;
|
import me.zhengjie.modules.system.service.MenuService;
|
||||||
import me.zhengjie.modules.system.service.RoleService;
|
import me.zhengjie.modules.system.service.RoleService;
|
||||||
import me.zhengjie.modules.system.service.UserService;
|
import me.zhengjie.modules.system.service.UserService;
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
|
||||||
import me.zhengjie.modules.system.service.dto.MenuDTO;
|
import me.zhengjie.modules.system.service.dto.MenuDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
|
||||||
import me.zhengjie.modules.system.service.dto.UserDTO;
|
import me.zhengjie.modules.system.service.dto.UserDTO;
|
||||||
import me.zhengjie.utils.SecurityUtils;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -62,7 +62,7 @@ public class MenuController {
|
||||||
@Log("查询菜单")
|
@Log("查询菜单")
|
||||||
@GetMapping(value = "/menus")
|
@GetMapping(value = "/menus")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')")
|
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')")
|
||||||
public ResponseEntity getMenus(CommonQueryCriteria criteria){
|
public ResponseEntity getMenus(MenuQueryCriteria criteria){
|
||||||
List<MenuDTO> menuDTOList = menuService.queryAll(criteria);
|
List<MenuDTO> menuDTOList = menuService.queryAll(criteria);
|
||||||
return new ResponseEntity(menuService.buildTree(menuDTOList),HttpStatus.OK);
|
return new ResponseEntity(menuService.buildTree(menuDTOList),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import me.zhengjie.aop.log.Log;
|
||||||
import me.zhengjie.modules.system.domain.Permission;
|
import me.zhengjie.modules.system.domain.Permission;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.system.service.PermissionService;
|
import me.zhengjie.modules.system.service.PermissionService;
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
|
||||||
import me.zhengjie.modules.system.service.dto.PermissionDTO;
|
import me.zhengjie.modules.system.service.dto.PermissionDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.PermissionQueryCriteria;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -41,7 +41,7 @@ public class PermissionController {
|
||||||
@Log("查询权限")
|
@Log("查询权限")
|
||||||
@GetMapping(value = "/permissions")
|
@GetMapping(value = "/permissions")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')")
|
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')")
|
||||||
public ResponseEntity getPermissions(CommonQueryCriteria criteria){
|
public ResponseEntity getPermissions(PermissionQueryCriteria criteria){
|
||||||
List<PermissionDTO> permissionDTOS = permissionService.queryAll(criteria);
|
List<PermissionDTO> permissionDTOS = permissionService.queryAll(criteria);
|
||||||
return new ResponseEntity(permissionService.buildTree(permissionDTOS),HttpStatus.OK);
|
return new ResponseEntity(permissionService.buildTree(permissionDTOS),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ import me.zhengjie.aop.log.Log;
|
||||||
import me.zhengjie.modules.system.domain.Role;
|
import me.zhengjie.modules.system.domain.Role;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.system.service.RoleService;
|
import me.zhengjie.modules.system.service.RoleService;
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
|
||||||
|
import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
|
||||||
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||||
import me.zhengjie.utils.SecurityUtils;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -58,7 +59,7 @@ public class RoleController {
|
||||||
@Log("查询角色")
|
@Log("查询角色")
|
||||||
@GetMapping(value = "/roles")
|
@GetMapping(value = "/roles")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')")
|
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')")
|
||||||
public ResponseEntity getRoles(CommonQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity getRoles(RoleQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity(roleService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity(roleService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package me.zhengjie.modules.system.service;
|
||||||
|
|
||||||
import me.zhengjie.modules.system.domain.Dict;
|
import me.zhengjie.modules.system.domain.Dict;
|
||||||
import me.zhengjie.modules.system.service.dto.DictDTO;
|
import me.zhengjie.modules.system.service.dto.DictDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.DictQueryCriteria;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
@ -21,7 +22,7 @@ public interface DictService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Cacheable(keyGenerator = "keyGenerator")
|
@Cacheable(keyGenerator = "keyGenerator")
|
||||||
Object queryAll(DictDTO dict, Pageable pageable);
|
Object queryAll(DictQueryCriteria dict, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* findById
|
* findById
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
package me.zhengjie.modules.system.service;
|
package me.zhengjie.modules.system.service;
|
||||||
|
|
||||||
import me.zhengjie.modules.system.domain.Menu;
|
import me.zhengjie.modules.system.domain.Menu;
|
||||||
import me.zhengjie.modules.system.domain.Role;
|
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
|
||||||
import me.zhengjie.modules.system.service.dto.MenuDTO;
|
import me.zhengjie.modules.system.service.dto.MenuDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
|
||||||
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
|
@ -25,7 +23,7 @@ public interface MenuService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Cacheable(keyGenerator = "keyGenerator")
|
@Cacheable(keyGenerator = "keyGenerator")
|
||||||
List<MenuDTO> queryAll(CommonQueryCriteria criteria);
|
List<MenuDTO> queryAll(MenuQueryCriteria criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get
|
* get
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package me.zhengjie.modules.system.service;
|
package me.zhengjie.modules.system.service;
|
||||||
|
|
||||||
import me.zhengjie.modules.system.domain.Permission;
|
import me.zhengjie.modules.system.domain.Permission;
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
|
||||||
import me.zhengjie.modules.system.service.dto.PermissionDTO;
|
import me.zhengjie.modules.system.service.dto.PermissionDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.PermissionQueryCriteria;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,5 +75,5 @@ public interface PermissionService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Cacheable(keyGenerator = "keyGenerator")
|
@Cacheable(keyGenerator = "keyGenerator")
|
||||||
List<PermissionDTO> queryAll(CommonQueryCriteria criteria);
|
List<PermissionDTO> queryAll(PermissionQueryCriteria criteria);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package me.zhengjie.modules.system.service;
|
||||||
|
|
||||||
import me.zhengjie.modules.system.domain.Menu;
|
import me.zhengjie.modules.system.domain.Menu;
|
||||||
import me.zhengjie.modules.system.domain.Role;
|
import me.zhengjie.modules.system.domain.Role;
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
|
||||||
import me.zhengjie.modules.system.service.dto.RoleDTO;
|
import me.zhengjie.modules.system.service.dto.RoleDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
|
||||||
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
@ -94,5 +94,5 @@ public interface RoleService {
|
||||||
* @param criteria
|
* @param criteria
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Object queryAll(CommonQueryCriteria criteria, Pageable pageable);
|
Object queryAll(RoleQueryCriteria criteria, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package me.zhengjie.modules.system.service.dto;
|
package me.zhengjie.modules.system.service.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import me.zhengjie.annotation.Query;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,12 +15,10 @@ public class DictDTO implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 字典名称
|
* 字典名称
|
||||||
*/
|
*/
|
||||||
@Query(type = Query.Type.INNER_LIKE)
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述
|
* 描述
|
||||||
*/
|
*/
|
||||||
@Query(type = Query.Type.INNER_LIKE)
|
|
||||||
private String remark;
|
private String remark;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,9 @@ import me.zhengjie.annotation.Query;
|
||||||
* 公共查询类
|
* 公共查询类
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CommonQueryCriteria {
|
public class DictQueryCriteria {
|
||||||
|
|
||||||
@Query(type = Query.Type.INNER_LIKE)
|
// 多字段模糊
|
||||||
private String name;
|
@Query(blurry = "name,remark")
|
||||||
|
private String blurry;
|
||||||
}
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package me.zhengjie.modules.system.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import me.zhengjie.annotation.Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公共查询类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MenuQueryCriteria {
|
||||||
|
|
||||||
|
// 多字段模糊
|
||||||
|
@Query(blurry = "name,path,component")
|
||||||
|
private String blurry;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package me.zhengjie.modules.system.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import me.zhengjie.annotation.Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公共查询类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PermissionQueryCriteria {
|
||||||
|
|
||||||
|
// 多字段模糊
|
||||||
|
@Query(blurry = "name,alias")
|
||||||
|
private String blurry;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package me.zhengjie.modules.system.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import me.zhengjie.annotation.Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公共查询类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RoleQueryCriteria {
|
||||||
|
|
||||||
|
// 多字段模糊
|
||||||
|
@Query(blurry = "name,remark")
|
||||||
|
private String blurry;
|
||||||
|
}
|
|
@ -18,11 +18,9 @@ public class UserQueryCriteria implements Serializable {
|
||||||
@Query(propName = "id", type = Query.Type.IN, joinName = "dept")
|
@Query(propName = "id", type = Query.Type.IN, joinName = "dept")
|
||||||
private Set<Long> deptIds;
|
private Set<Long> deptIds;
|
||||||
|
|
||||||
@Query(type = Query.Type.INNER_LIKE)
|
// 多字段模糊
|
||||||
private String username;
|
@Query(blurry = "email,username")
|
||||||
|
private String blurry;
|
||||||
@Query(type = Query.Type.INNER_LIKE)
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
@Query
|
@Query
|
||||||
private Boolean enabled;
|
private Boolean enabled;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package me.zhengjie.modules.system.service.impl;
|
package me.zhengjie.modules.system.service.impl;
|
||||||
|
|
||||||
import me.zhengjie.modules.system.domain.Dict;
|
import me.zhengjie.modules.system.domain.Dict;
|
||||||
|
import me.zhengjie.modules.system.service.dto.DictQueryCriteria;
|
||||||
import me.zhengjie.utils.PageUtil;
|
import me.zhengjie.utils.PageUtil;
|
||||||
import me.zhengjie.utils.QueryHelp;
|
import me.zhengjie.utils.QueryHelp;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
|
@ -31,7 +32,7 @@ public class DictServiceImpl implements DictService {
|
||||||
private DictMapper dictMapper;
|
private DictMapper dictMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(DictDTO dict, Pageable pageable){
|
public Object queryAll(DictQueryCriteria dict, Pageable pageable){
|
||||||
Page<Dict> page = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb), pageable);
|
Page<Dict> page = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb), pageable);
|
||||||
return PageUtil.toPage(page.map(dictMapper::toDto));
|
return PageUtil.toPage(page.map(dictMapper::toDto));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.exception.EntityExistException;
|
import me.zhengjie.exception.EntityExistException;
|
||||||
import me.zhengjie.modules.system.repository.MenuRepository;
|
import me.zhengjie.modules.system.repository.MenuRepository;
|
||||||
import me.zhengjie.modules.system.service.MenuService;
|
import me.zhengjie.modules.system.service.MenuService;
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
|
||||||
import me.zhengjie.modules.system.service.dto.MenuDTO;
|
import me.zhengjie.modules.system.service.dto.MenuDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
|
||||||
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||||
import me.zhengjie.modules.system.service.mapper.MenuMapper;
|
import me.zhengjie.modules.system.service.mapper.MenuMapper;
|
||||||
import me.zhengjie.utils.QueryHelp;
|
import me.zhengjie.utils.QueryHelp;
|
||||||
|
@ -32,7 +32,7 @@ public class MenuServiceImpl implements MenuService {
|
||||||
private MenuMapper menuMapper;
|
private MenuMapper menuMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List queryAll(CommonQueryCriteria criteria){
|
public List queryAll(MenuQueryCriteria criteria){
|
||||||
return menuMapper.toDto(menuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
return menuMapper.toDto(menuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.exception.EntityExistException;
|
import me.zhengjie.exception.EntityExistException;
|
||||||
import me.zhengjie.modules.system.repository.PermissionRepository;
|
import me.zhengjie.modules.system.repository.PermissionRepository;
|
||||||
import me.zhengjie.modules.system.service.PermissionService;
|
import me.zhengjie.modules.system.service.PermissionService;
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
|
||||||
import me.zhengjie.modules.system.service.dto.PermissionDTO;
|
import me.zhengjie.modules.system.service.dto.PermissionDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.PermissionQueryCriteria;
|
||||||
import me.zhengjie.modules.system.service.mapper.PermissionMapper;
|
import me.zhengjie.modules.system.service.mapper.PermissionMapper;
|
||||||
import me.zhengjie.utils.QueryHelp;
|
import me.zhengjie.utils.QueryHelp;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
|
@ -31,7 +31,7 @@ public class PermissionServiceImpl implements PermissionService {
|
||||||
private PermissionMapper permissionMapper;
|
private PermissionMapper permissionMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PermissionDTO> queryAll(CommonQueryCriteria criteria) {
|
public List<PermissionDTO> queryAll(PermissionQueryCriteria criteria) {
|
||||||
return permissionMapper.toDto(permissionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
return permissionMapper.toDto(permissionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import me.zhengjie.modules.system.domain.Role;
|
||||||
import me.zhengjie.exception.EntityExistException;
|
import me.zhengjie.exception.EntityExistException;
|
||||||
import me.zhengjie.modules.system.repository.RoleRepository;
|
import me.zhengjie.modules.system.repository.RoleRepository;
|
||||||
import me.zhengjie.modules.system.service.RoleService;
|
import me.zhengjie.modules.system.service.RoleService;
|
||||||
import me.zhengjie.modules.system.service.dto.CommonQueryCriteria;
|
|
||||||
import me.zhengjie.modules.system.service.dto.RoleDTO;
|
import me.zhengjie.modules.system.service.dto.RoleDTO;
|
||||||
|
import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
|
||||||
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||||
import me.zhengjie.modules.system.service.mapper.RoleMapper;
|
import me.zhengjie.modules.system.service.mapper.RoleMapper;
|
||||||
import me.zhengjie.modules.system.service.mapper.RoleSmallMapper;
|
import me.zhengjie.modules.system.service.mapper.RoleSmallMapper;
|
||||||
|
@ -45,7 +45,7 @@ public class RoleServiceImpl implements RoleService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(CommonQueryCriteria criteria, Pageable pageable) {
|
public Object queryAll(RoleQueryCriteria criteria, Pageable pageable) {
|
||||||
Page<Role> page = roleRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
Page<Role> page = roleRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||||
return PageUtil.toPage(page.map(roleMapper::toDto));
|
return PageUtil.toPage(page.map(roleMapper::toDto));
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -84,7 +84,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||||
/**
|
/**
|
||||||
* 构造一个带指定Zone对象的配置类
|
* 构造一个带指定Zone对象的配置类
|
||||||
*/
|
*/
|
||||||
Configuration cfg = QiNiuUtil.getConfiguration(qiniuConfig.getZone());
|
Configuration cfg = new Configuration(QiNiuUtil.getRegion(qiniuConfig.getZone()));
|
||||||
UploadManager uploadManager = new UploadManager(cfg);
|
UploadManager uploadManager = new UploadManager(cfg);
|
||||||
Auth auth = Auth.create(qiniuConfig.getAccessKey(), qiniuConfig.getSecretKey());
|
Auth auth = Auth.create(qiniuConfig.getAccessKey(), qiniuConfig.getSecretKey());
|
||||||
String upToken = auth.uploadToken(qiniuConfig.getBucket());
|
String upToken = auth.uploadToken(qiniuConfig.getBucket());
|
||||||
|
@ -136,7 +136,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void delete(QiniuContent content, QiniuConfig config) {
|
public void delete(QiniuContent content, QiniuConfig config) {
|
||||||
//构造一个带指定Zone对象的配置类
|
//构造一个带指定Zone对象的配置类
|
||||||
Configuration cfg = QiNiuUtil.getConfiguration(config.getZone());
|
Configuration cfg = new Configuration(QiNiuUtil.getRegion(config.getZone()));
|
||||||
Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
|
Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
|
||||||
BucketManager bucketManager = new BucketManager(auth, cfg);
|
BucketManager bucketManager = new BucketManager(auth, cfg);
|
||||||
try {
|
try {
|
||||||
|
@ -154,7 +154,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||||
throw new BadRequestException("请先添加相应配置,再操作");
|
throw new BadRequestException("请先添加相应配置,再操作");
|
||||||
}
|
}
|
||||||
//构造一个带指定Zone对象的配置类
|
//构造一个带指定Zone对象的配置类
|
||||||
Configuration cfg = QiNiuUtil.getConfiguration(config.getZone());
|
Configuration cfg = new Configuration(QiNiuUtil.getRegion(config.getZone()));
|
||||||
Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
|
Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
|
||||||
BucketManager bucketManager = new BucketManager(auth, cfg);
|
BucketManager bucketManager = new BucketManager(auth, cfg);
|
||||||
//文件名前缀
|
//文件名前缀
|
||||||
|
@ -181,7 +181,6 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package me.zhengjie.utils;
|
package me.zhengjie.utils;
|
||||||
|
|
||||||
import com.qiniu.common.Zone;
|
import com.qiniu.storage.Region;
|
||||||
import com.qiniu.storage.Configuration;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -26,20 +24,19 @@ public class QiNiuUtil {
|
||||||
* @param zone
|
* @param zone
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Configuration getConfiguration(String zone){
|
public static Region getRegion(String zone){
|
||||||
|
|
||||||
if(HUAD.equals(zone)){
|
if(HUAD.equals(zone)){
|
||||||
return new Configuration(Zone.zone0());
|
return Region.huadong();
|
||||||
} else if(HUAB.equals(zone)){
|
} else if(HUAB.equals(zone)){
|
||||||
return new Configuration(Zone.zone1());
|
return Region.huabei();
|
||||||
} else if(HUAN.equals(zone)){
|
} else if(HUAN.equals(zone)){
|
||||||
return new Configuration(Zone.zone2());
|
return Region.huanan();
|
||||||
} else if (BEIM.equals(zone)){
|
} else if (BEIM.equals(zone)){
|
||||||
return new Configuration(Zone.zoneNa0());
|
return Region.beimei();
|
||||||
|
|
||||||
// 否则就是东南亚
|
// 否则就是东南亚
|
||||||
} else {
|
} else {
|
||||||
return new Configuration(Zone.zoneAs0());
|
return Region.qvmHuadong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
pom.xml
6
pom.xml
|
@ -149,6 +149,12 @@
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>${hutool.version}</version>
|
<version>${hutool.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--https://gitee.com/lionsoul/ip2region/tree/v1.4-release/-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lionsoul</groupId>
|
||||||
|
<artifactId>ip2region</artifactId>
|
||||||
|
<version>1.7.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- fastjson -->
|
<!-- fastjson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
Loading…
Reference in New Issue