mirror of https://github.com/elunez/eladmin
代码优化,获取Ip优化
parent
f26342ee0e
commit
0c738b1ef3
|
@ -23,10 +23,10 @@ import java.lang.reflect.Method;
|
|||
@Component
|
||||
public class LimitAspect {
|
||||
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final RedisTemplate<Object,Object> redisTemplate;
|
||||
private static final Logger logger = LoggerFactory.getLogger(LimitAspect.class);
|
||||
|
||||
public LimitAspect(RedisTemplate redisTemplate) {
|
||||
public LimitAspect(RedisTemplate<Object,Object> redisTemplate) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,11 @@ public class LimitAspect {
|
|||
}
|
||||
}
|
||||
|
||||
ImmutableList keys = ImmutableList.of(StringUtils.join(limit.prefix(), "_", key, "_", request.getRequestURI().replaceAll("/","_")));
|
||||
ImmutableList<Object> keys = ImmutableList.of(StringUtils.join(limit.prefix(), "_", key, "_", request.getRequestURI().replaceAll("/","_")));
|
||||
|
||||
String luaScript = buildLuaScript();
|
||||
RedisScript<Number> redisScript = new DefaultRedisScript<>(luaScript, Number.class);
|
||||
Number count = (Number) redisTemplate.execute(redisScript, keys, limit.count(), limit.period());
|
||||
Number count = redisTemplate.execute(redisScript, keys, limit.count(), limit.period());
|
||||
if (null != count && count.intValue() <= limit.count()) {
|
||||
logger.info("第{}次访问key为 {},描述为 [{}] 的接口", count, keys, limit.name());
|
||||
return joinPoint.proceed();
|
||||
|
|
|
@ -31,8 +31,6 @@ public class BaseEntity implements Serializable {
|
|||
@UpdateTimestamp
|
||||
private Timestamp updateTime;
|
||||
|
||||
public @interface New {}
|
||||
|
||||
public @interface Update {}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.springframework.data.redis.core.RedisOperations;
|
|||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.SerializationException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
|
@ -56,7 +55,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
|||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
//序列化
|
||||
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
|
||||
FastJsonRedisSerializer<Object> fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class);
|
||||
// value值的序列化采用fastJsonRedisSerializer
|
||||
template.setValueSerializer(fastJsonRedisSerializer);
|
||||
template.setHashValueSerializer(fastJsonRedisSerializer);
|
||||
|
@ -140,7 +139,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(T t) throws SerializationException {
|
||||
public byte[] serialize(T t) {
|
||||
if (t == null) {
|
||||
return new byte[0];
|
||||
}
|
||||
|
@ -148,7 +147,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
|||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(byte[] bytes) throws SerializationException {
|
||||
public T deserialize(byte[] bytes) {
|
||||
if (bytes == null || bytes.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.fasterxml.classmate.TypeResolver;
|
|||
import com.google.common.base.Predicates;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -22,7 +23,6 @@ import springfox.documentation.spring.web.plugins.Docket;
|
|||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static springfox.documentation.schema.AlternateTypeRules.newRule;
|
||||
|
||||
|
@ -43,6 +43,7 @@ public class SwaggerConfig {
|
|||
private Boolean enabled;
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("all")
|
||||
public Docket createRestApi() {
|
||||
ParameterBuilder ticketPar = new ParameterBuilder();
|
||||
List<Parameter> pars = new ArrayList<>();
|
||||
|
@ -93,7 +94,8 @@ class SwaggerDataConfig {
|
|||
}
|
||||
|
||||
@ApiModel
|
||||
static class Page {
|
||||
@Data
|
||||
private static class Page {
|
||||
@ApiModelProperty("页码 (0..N)")
|
||||
private Integer page;
|
||||
|
||||
|
@ -102,29 +104,5 @@ class SwaggerDataConfig {
|
|||
|
||||
@ApiModelProperty("以下列格式排序标准:property[,asc | desc]。 默认排序顺序为升序。 支持多种排序条件:如:id,asc")
|
||||
private List<String> sort;
|
||||
|
||||
public Integer getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(Integer page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public List<String> getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(List<String> sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ 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 java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -109,17 +109,27 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*/
|
||||
public static String getIp(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
String[] ips = ip.split(",");
|
||||
return "0:0:0:0:0:0:0:1".equals(ips[0])?"127.0.0.1":ips[0];
|
||||
if (ip.contains(",")) {
|
||||
ip = ip.split(",")[0];
|
||||
}
|
||||
if ("127.0.0.1".equals(ip)) {
|
||||
// 获取本机真正的ip地址
|
||||
try {
|
||||
ip = InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package me.zhengjie.service;
|
||||
|
||||
import me.zhengjie.domain.GenConfig;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
|
|
@ -28,6 +28,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||
private EntityManager em;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public Object getTables(String name, int[] startEnd) {
|
||||
// 使用预编译防止sql注入
|
||||
String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " +
|
||||
|
@ -49,6 +50,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public Object getColumns(String name) {
|
||||
// 使用预编译防止sql注入
|
||||
String sql = "select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns " +
|
||||
|
|
|
@ -2,7 +2,6 @@ package me.zhengjie.aspect;
|
|||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhengjie.domain.Log;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.service.LogService;
|
||||
import me.zhengjie.utils.RequestHolder;
|
||||
import me.zhengjie.utils.SecurityUtils;
|
||||
|
@ -14,11 +13,8 @@ import org.aspectj.lang.annotation.AfterThrowing;
|
|||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-24
|
||||
|
@ -28,11 +24,14 @@ import javax.servlet.http.HttpServletRequest;
|
|||
@Slf4j
|
||||
public class LogAspect {
|
||||
|
||||
@Autowired
|
||||
private LogService logService;
|
||||
private final LogService logService;
|
||||
|
||||
private long currentTime = 0L;
|
||||
|
||||
public LogAspect(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置切入点
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,7 @@ public class VisitsInitialization implements ApplicationRunner {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
public void run(ApplicationArguments args){
|
||||
System.out.println("--------------- 初始化站点统计,如果存在今日统计则跳过 ---------------");
|
||||
visitsService.save();
|
||||
System.out.println("--------------- 初始化站点统计完成 ---------------");
|
||||
|
|
|
@ -4,7 +4,6 @@ import io.swagger.annotations.Api;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import me.zhengjie.modules.monitor.service.VisitsService;
|
||||
import me.zhengjie.utils.RequestHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package me.zhengjie.modules.monitor.service;
|
||||
|
||||
import me.zhengjie.modules.monitor.domain.vo.RedisVo;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package me.zhengjie.modules.quartz.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
@ -10,7 +11,8 @@ import javax.validation.constraints.NotNull;
|
|||
* @author Zheng Jie
|
||||
* @date 2019-01-07
|
||||
*/
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "quartz_job")
|
||||
public class QuartzJob extends BaseEntity {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package me.zhengjie.modules.quartz.task;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
|
@ -12,7 +11,7 @@ import org.springframework.stereotype.Component;
|
|||
@Slf4j
|
||||
@Component
|
||||
public class TestTask {
|
||||
|
||||
|
||||
public void run(){
|
||||
log.info("执行成功");
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class ExecutionJob extends QuartzJobBean {
|
|||
private ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void executeInternal(JobExecutionContext context) {
|
||||
QuartzJob quartzJob = (QuartzJob) context.getMergedJobDataMap().get(QuartzJob.JOB_KEY);
|
||||
// 获取spring bean
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
import org.hibernate.annotations.*;
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
|
|
@ -4,12 +4,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
|
@ -4,12 +4,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,12 +4,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class User extends BaseEntity {
|
|||
private UserAvatar userAvatar;
|
||||
|
||||
@NotBlank
|
||||
@Pattern(regexp = "([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}",message = "格式错误")
|
||||
@Pattern(regexp = "([a-z0-9A-Z]+[-|.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}",message = "格式错误")
|
||||
private String email;
|
||||
|
||||
@NotBlank
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
|
|
@ -7,7 +7,6 @@ import me.zhengjie.exception.BadRequestException;
|
|||
import me.zhengjie.modules.system.domain.Dict;
|
||||
import me.zhengjie.modules.system.service.DictService;
|
||||
import me.zhengjie.modules.system.service.dto.DictQueryCriteria;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
|
|
@ -7,7 +7,6 @@ import me.zhengjie.exception.BadRequestException;
|
|||
import me.zhengjie.modules.system.domain.DictDetail;
|
||||
import me.zhengjie.modules.system.service.DictDetailService;
|
||||
import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
|
@ -16,11 +15,8 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
@ -43,8 +39,7 @@ public class DictDetailController {
|
|||
@ApiOperation("查询字典详情")
|
||||
@GetMapping
|
||||
public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria,
|
||||
@PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||
String[] names = criteria.getDictName().split(",");
|
||||
@PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||
return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
@ -52,7 +47,7 @@ public class DictDetailController {
|
|||
@ApiOperation("查询多个字典详情")
|
||||
@GetMapping(value = "/map")
|
||||
public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria,
|
||||
@PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||
@PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||
String[] names = criteria.getDictName().split(",");
|
||||
Map<String,Object> map = new HashMap<>(names.length);
|
||||
for (String name : names) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import me.zhengjie.modules.system.domain.Job;
|
|||
import me.zhengjie.modules.system.service.JobService;
|
||||
import me.zhengjie.modules.system.service.dto.JobQueryCriteria;
|
||||
import me.zhengjie.utils.ThrowableUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -17,8 +16,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-29
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Set;
|
|||
@Api(tags = "系统:菜单管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/menus")
|
||||
@SuppressWarnings("unchecked")
|
||||
public class MenuController {
|
||||
|
||||
private final MenuService menuService;
|
||||
|
@ -49,7 +50,8 @@ public class MenuController {
|
|||
public ResponseEntity buildMenus(){
|
||||
UserDTO user = userService.findByName(SecurityUtils.getUsername());
|
||||
List<MenuDTO> menuDTOList = menuService.findByRoles(roleService.findByUsers_Id(user.getId()));
|
||||
return new ResponseEntity<>(menuService.buildMenus((List<MenuDTO>) menuService.buildTree(menuDTOList).get("content")),HttpStatus.OK);
|
||||
List<MenuDTO> menuDTOS = (List<MenuDTO>) menuService.buildTree(menuDTOList).get("content");
|
||||
return new ResponseEntity<>(menuService.buildMenus(menuDTOS),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的菜单")
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package me.zhengjie.modules.system.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
|
|
@ -17,9 +17,7 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
|
|
@ -22,7 +22,7 @@ public class QiniuContent implements Serializable {
|
|||
private Long id;
|
||||
|
||||
// 文件名
|
||||
@Column(name = "name",unique = false)
|
||||
@Column(name = "name")
|
||||
private String key;
|
||||
|
||||
// 空间名
|
||||
|
|
|
@ -10,7 +10,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||
*/
|
||||
public interface PictureRepository extends JpaRepository<Picture,Long>, JpaSpecificationExecutor<Picture> {
|
||||
|
||||
Picture findByUrl(String url);
|
||||
|
||||
Picture findByMd5Code(String code);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ public interface VerificationCodeRepository extends JpaRepository<VerificationCo
|
|||
/**
|
||||
* 获取有效的验证码
|
||||
* @param scenes 业务场景,如重置密码,重置邮箱等等
|
||||
* @param type
|
||||
* @param value
|
||||
* @return
|
||||
* @param type 类型
|
||||
* @param value 值
|
||||
* @return VerificationCode
|
||||
*/
|
||||
VerificationCode findByScenesAndTypeAndValueAndStatusIsTrue(String scenes, String type, String value);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package me.zhengjie.service;
|
|||
|
||||
import me.zhengjie.domain.AlipayConfig;
|
||||
import me.zhengjie.domain.vo.TradeVo;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
|
|
@ -28,7 +28,7 @@ public interface EmailService {
|
|||
* 发送邮件
|
||||
* @param emailVo 邮件发送的内容
|
||||
* @param emailConfig 邮件配置
|
||||
* @throws Exception
|
||||
* @throws Exception /
|
||||
*/
|
||||
@Async
|
||||
void send(EmailVo emailVo, EmailConfig emailConfig) throws Exception;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
|
|||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface LocalStorageMapper extends BaseMapper<LocalStorageDTO, LocalStorage> {
|
||||
|
||||
}
|
Loading…
Reference in New Issue