mirror of https://github.com/elunez/eladmin
所有列表加入日期搜索与导出功能
parent
938ae1fcd8
commit
905c8c649c
|
@ -29,7 +29,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
|
|||
/**
|
||||
* Page 数据处理,预防redis反序列化报错
|
||||
*/
|
||||
public static Map toPage(Page page) {
|
||||
public static Map<String,Object> toPage(Page page) {
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",page.getContent());
|
||||
map.put("totalElements",page.getTotalElements());
|
||||
|
@ -39,7 +39,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
|
|||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
public static Map toPage(Object object, Object totalElements) {
|
||||
public static Map<String,Object> toPage(Object object, Object totalElements) {
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",object);
|
||||
map.put("totalElements",totalElements);
|
||||
|
|
|
@ -2,6 +2,7 @@ package me.zhengjie.rest;
|
|||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import me.zhengjie.aop.log.Log;
|
||||
import me.zhengjie.service.LogService;
|
||||
import me.zhengjie.service.dto.LogQueryCriteria;
|
||||
import me.zhengjie.utils.SecurityUtils;
|
||||
|
@ -14,6 +15,9 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-24
|
||||
|
@ -29,6 +33,14 @@ public class LogController {
|
|||
this.logService = logService;
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check()")
|
||||
public void download(HttpServletResponse response, LogQueryCriteria criteria) throws IOException {
|
||||
logService.download(logService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("日志查询")
|
||||
@PreAuthorize("@el.check()")
|
||||
|
|
|
@ -6,6 +6,10 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
|||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-24
|
||||
|
@ -14,6 +18,8 @@ public interface LogService {
|
|||
|
||||
Object queryAll(LogQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
List<Log> queryAll(LogQueryCriteria criteria);
|
||||
|
||||
Object queryAllByUser(LogQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
@Async
|
||||
|
@ -25,4 +31,6 @@ public interface LogService {
|
|||
* @return Object
|
||||
*/
|
||||
Object findByErrDetail(Long id);
|
||||
|
||||
void download(List<Log> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.service.dto;
|
|||
import lombok.Data;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* 日志查询类
|
||||
* @author Zheng Jie
|
||||
|
@ -17,4 +19,10 @@ public class LogQueryCriteria {
|
|||
|
||||
@Query
|
||||
private String logType;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package me.zhengjie.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import me.zhengjie.domain.Log;
|
||||
import me.zhengjie.repository.LogRepository;
|
||||
|
@ -8,6 +9,7 @@ import me.zhengjie.service.LogService;
|
|||
import me.zhengjie.service.dto.LogQueryCriteria;
|
||||
import me.zhengjie.service.mapper.LogErrorMapper;
|
||||
import me.zhengjie.service.mapper.LogSmallMapper;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.StringUtils;
|
||||
|
@ -18,7 +20,14 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
@ -49,6 +58,11 @@ public class LogServiceImpl implements LogService {
|
|||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Log> queryAll(LogQueryCriteria criteria) {
|
||||
return logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object queryAllByUser(LogQueryCriteria criteria, Pageable pageable) {
|
||||
Page<Log> page = logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)),pageable);
|
||||
|
@ -102,6 +116,25 @@ public class LogServiceImpl implements LogService {
|
|||
|
||||
@Override
|
||||
public Object findByErrDetail(Long id) {
|
||||
return Dict.create().set("exception",logRepository.findExceptionById(id).getExceptionDetail());
|
||||
byte[] details = logRepository.findExceptionById(id).getExceptionDetail();
|
||||
return Dict.create().set("exception",new String(ObjectUtil.isNotNull(details) ? details : "".getBytes()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<Log> logs, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Log log : logs) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("用户名", log.getUsername());
|
||||
map.put("IP", log.getRequestIp());
|
||||
map.put("IP来源", log.getAddress());
|
||||
map.put("描述", log.getDescription());
|
||||
map.put("浏览器", log.getBrowser());
|
||||
map.put("请求耗时/毫秒", log.getTime());
|
||||
map.put("异常详情", new String(ObjectUtil.isNotNull(log.getExceptionDetail()) ? log.getExceptionDetail() : "".getBytes()));
|
||||
map.put("创建日期", log.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import lombok.Data;
|
|||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -15,7 +16,7 @@ import java.sql.Timestamp;
|
|||
@Entity
|
||||
@Data
|
||||
@Table(name = "visits")
|
||||
public class Visits {
|
||||
public class Visits implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -11,6 +11,9 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-10
|
||||
|
@ -34,6 +37,14 @@ public class RedisController {
|
|||
return new ResponseEntity<>(redisService.findByKey(key,pageable), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('redis:list')")
|
||||
public void download(HttpServletResponse response, String key) throws IOException {
|
||||
redisService.download(redisService.findByKey(key), response);
|
||||
}
|
||||
|
||||
@Log("删除Redis缓存")
|
||||
@DeleteMapping
|
||||
@ApiOperation("删除Redis缓存")
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
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;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 可自行扩展
|
||||
* @author Zheng Jie
|
||||
|
@ -17,6 +22,13 @@ public interface RedisService {
|
|||
*/
|
||||
Page findByKey(String key, Pageable pageable);
|
||||
|
||||
/**
|
||||
* findById
|
||||
* @param key 键
|
||||
* @return /
|
||||
*/
|
||||
List<RedisVo> findByKey(String key);
|
||||
|
||||
/**
|
||||
* 查询验证码的值
|
||||
* @param key 键
|
||||
|
@ -41,4 +53,11 @@ public interface RedisService {
|
|||
* 清空缓存
|
||||
*/
|
||||
void deleteAll();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param redisVos /
|
||||
* @param response /
|
||||
*/
|
||||
void download(List<RedisVo> redisVos, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package me.zhengjie.modules.monitor.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import me.zhengjie.modules.monitor.domain.vo.RedisVo;
|
||||
import me.zhengjie.modules.monitor.service.RedisService;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
@ -10,6 +12,8 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -39,6 +43,15 @@ public class RedisServiceImpl implements RedisService {
|
|||
|
||||
@Override
|
||||
public Page<RedisVo> findByKey(String key, Pageable pageable){
|
||||
List<RedisVo> redisVos = findByKey(key);
|
||||
return new PageImpl<RedisVo>(
|
||||
PageUtil.toPage(pageable.getPageNumber(),pageable.getPageSize(),redisVos),
|
||||
pageable,
|
||||
redisVos.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RedisVo> findByKey(String key) {
|
||||
List<RedisVo> redisVos = new ArrayList<>();
|
||||
if(!"*".equals(key)){
|
||||
key = "*" + key + "*";
|
||||
|
@ -52,10 +65,7 @@ public class RedisServiceImpl implements RedisService {
|
|||
RedisVo redisVo = new RedisVo(s, Objects.requireNonNull(redisTemplate.opsForValue().get(s)).toString());
|
||||
redisVos.add(redisVo);
|
||||
}
|
||||
return new PageImpl<RedisVo>(
|
||||
PageUtil.toPage(pageable.getPageNumber(),pageable.getPageSize(),redisVos),
|
||||
pageable,
|
||||
redisVos.size());
|
||||
return redisVos;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,4 +93,16 @@ public class RedisServiceImpl implements RedisService {
|
|||
redisTemplate.opsForValue().set(key,val);
|
||||
redisTemplate.expire(key,expiration, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<RedisVo> redisVos, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (RedisVo redisVo : redisVos) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("key", redisVo.getKey());
|
||||
map.put("value", redisVo.getValue());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ 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;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +17,7 @@ import java.sql.Timestamp;
|
|||
@Setter
|
||||
@Entity
|
||||
@Table(name = "quartz_job")
|
||||
public class QuartzJob{
|
||||
public class QuartzJob implements Serializable {
|
||||
|
||||
public static final String JOB_KEY = "JOB_KEY";
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-01-07
|
||||
|
@ -41,6 +44,22 @@ public class QuartzJobController {
|
|||
return new ResponseEntity<>(quartzJobService.queryAll(criteria,pageable), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出任务数据")
|
||||
@ApiOperation("导出任务数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public void download(HttpServletResponse response, JobQueryCriteria criteria) throws IOException {
|
||||
quartzJobService.download(quartzJobService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@Log("导出日志数据")
|
||||
@ApiOperation("导出日志数据")
|
||||
@GetMapping(value = "/download/log")
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
public void downloadLog(HttpServletResponse response, JobQueryCriteria criteria) throws IOException {
|
||||
quartzJobService.downloadLog(quartzJobService.queryAllLog(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询任务执行日志")
|
||||
@GetMapping(value = "/logs")
|
||||
@PreAuthorize("@el.check('timing:list')")
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package me.zhengjie.modules.quartz.service;
|
||||
|
||||
import me.zhengjie.modules.quartz.domain.QuartzJob;
|
||||
import me.zhengjie.modules.quartz.domain.QuartzLog;
|
||||
import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-01-07
|
||||
|
@ -12,8 +17,12 @@ public interface QuartzJobService {
|
|||
|
||||
Object queryAll(JobQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
List<QuartzJob> queryAll(JobQueryCriteria criteria);
|
||||
|
||||
Object queryAllLog(JobQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
List<QuartzLog> queryAllLog(JobQueryCriteria criteria);
|
||||
|
||||
QuartzJob create(QuartzJob resources);
|
||||
|
||||
void update(QuartzJob resources);
|
||||
|
@ -33,4 +42,8 @@ public interface QuartzJobService {
|
|||
* @param quartzJob /
|
||||
*/
|
||||
void execution(QuartzJob quartzJob);
|
||||
|
||||
void download(List<QuartzJob> queryAll, HttpServletResponse response) throws IOException;
|
||||
|
||||
void downloadLog(List<QuartzLog> queryAllLog, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.quartz.service.dto;
|
|||
import lombok.Data;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-6-4 10:33:02
|
||||
|
@ -15,4 +17,10 @@ public class JobQueryCriteria {
|
|||
|
||||
@Query
|
||||
private Boolean isSuccess;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@ package me.zhengjie.modules.quartz.service.impl;
|
|||
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.quartz.domain.QuartzJob;
|
||||
import me.zhengjie.modules.quartz.domain.QuartzLog;
|
||||
import me.zhengjie.modules.quartz.repository.QuartzJobRepository;
|
||||
import me.zhengjie.modules.quartz.repository.QuartzLogRepository;
|
||||
import me.zhengjie.modules.quartz.service.QuartzJobService;
|
||||
import me.zhengjie.modules.quartz.service.dto.JobQueryCriteria;
|
||||
import me.zhengjie.modules.quartz.utils.QuartzManage;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
|
@ -19,6 +21,13 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-01-07
|
||||
|
@ -51,6 +60,16 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
|||
return PageUtil.toPage(quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuartzJob> queryAll(JobQueryCriteria criteria) {
|
||||
return quartzJobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuartzLog> queryAllLog(JobQueryCriteria criteria) {
|
||||
return quartzLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public QuartzJob findById(Long id) {
|
||||
|
@ -119,4 +138,41 @@ public class QuartzJobServiceImpl implements QuartzJobService {
|
|||
quartzManage.deleteJob(quartzJob);
|
||||
quartzJobRepository.delete(quartzJob);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<QuartzJob> quartzJobs, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (QuartzJob quartzJob : quartzJobs) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("任务名称", quartzJob.getJobName());
|
||||
map.put("Bean名称", quartzJob.getBeanName());
|
||||
map.put("执行方法", quartzJob.getMethodName());
|
||||
map.put("参数", quartzJob.getParams());
|
||||
map.put("表达式", quartzJob.getCronExpression());
|
||||
map.put("状态", quartzJob.getIsPause() ? "暂停中" : "运行中");
|
||||
map.put("描述", quartzJob.getRemark());
|
||||
map.put("创建日期", quartzJob.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadLog(List<QuartzLog> queryAllLog, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (QuartzLog quartzLog : queryAllLog) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("任务名称", quartzLog.getJobName());
|
||||
map.put("Bean名称", quartzLog.getBeanName());
|
||||
map.put("执行方法", quartzLog.getMethodName());
|
||||
map.put("参数", quartzLog.getParams());
|
||||
map.put("表达式", quartzLog.getCronExpression());
|
||||
map.put("异常详情", quartzLog.getExceptionDetail());
|
||||
map.put("耗时/毫秒", quartzLog.getTime());
|
||||
map.put("状态", quartzLog.getIsSuccess() ? "成功" : "失败");
|
||||
map.put("创建日期", quartzLog.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package me.zhengjie.modules.security.rest;
|
|||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import me.zhengjie.aop.log.Log;
|
||||
import me.zhengjie.modules.security.service.OnlineUserService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -9,6 +10,9 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth/online")
|
||||
@Api(tags = "系统:在线用户管理")
|
||||
|
@ -27,6 +31,14 @@ public class OnlineController {
|
|||
return new ResponseEntity<>(onlineUserService.getAll(filter, pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check()")
|
||||
public void download(HttpServletResponse response, String filter) throws IOException {
|
||||
onlineUserService.download(onlineUserService.getAll(filter), response);
|
||||
}
|
||||
|
||||
@ApiOperation("踢出用户")
|
||||
@DeleteMapping(value = "/{key}")
|
||||
@PreAuthorize("@el.check()")
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.security.service;
|
|||
import me.zhengjie.modules.security.security.JwtUser;
|
||||
import me.zhengjie.modules.security.security.OnlineUser;
|
||||
import me.zhengjie.utils.EncryptUtils;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -12,6 +13,8 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -51,6 +54,14 @@ public class OnlineUserService {
|
|||
}
|
||||
|
||||
public Page<OnlineUser> getAll(String filter, Pageable pageable){
|
||||
List<OnlineUser> onlineUsers = getAll(filter);
|
||||
return new PageImpl<OnlineUser>(
|
||||
PageUtil.toPage(pageable.getPageNumber(),pageable.getPageSize(),onlineUsers),
|
||||
pageable,
|
||||
onlineUsers.size());
|
||||
}
|
||||
|
||||
public List<OnlineUser> getAll(String filter){
|
||||
List<String> keys = new ArrayList<>(redisTemplate.keys(onlineKey + "*"));
|
||||
Collections.reverse(keys);
|
||||
List<OnlineUser> onlineUsers = new ArrayList<>();
|
||||
|
@ -67,10 +78,7 @@ public class OnlineUserService {
|
|||
Collections.sort(onlineUsers, (o1, o2) -> {
|
||||
return o2.getLoginTime().compareTo(o1.getLoginTime());
|
||||
});
|
||||
return new PageImpl<OnlineUser>(
|
||||
PageUtil.toPage(pageable.getPageNumber(),pageable.getPageSize(),onlineUsers),
|
||||
pageable,
|
||||
keys.size());
|
||||
return onlineUsers;
|
||||
}
|
||||
|
||||
public void kickOut(String val) throws Exception {
|
||||
|
@ -82,4 +90,19 @@ public class OnlineUserService {
|
|||
String key = onlineKey + token;
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
public void download(List<OnlineUser> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (OnlineUser user : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("用户名", user.getUserName());
|
||||
map.put("岗位", user.getJob());
|
||||
map.put("登录IP", user.getIp());
|
||||
map.put("登录地点", user.getAddress());
|
||||
map.put("浏览器", user.getBrowser());
|
||||
map.put("登录日期", user.getLoginTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ 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;
|
||||
|
||||
|
@ -18,7 +19,7 @@ import java.util.Set;
|
|||
@Getter
|
||||
@Setter
|
||||
@Table(name="dept")
|
||||
public class Dept {
|
||||
public class Dept implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.List;
|
||||
|
||||
|
@ -18,7 +19,7 @@ import java.util.List;
|
|||
@Getter
|
||||
@Setter
|
||||
@Table(name="dict")
|
||||
public class Dict{
|
||||
public class Dict implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -5,6 +5,7 @@ import lombok.Setter;
|
|||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -15,7 +16,7 @@ import java.sql.Timestamp;
|
|||
@Getter
|
||||
@Setter
|
||||
@Table(name="dict_detail")
|
||||
public class DictDetail {
|
||||
public class DictDetail implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -8,6 +8,7 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +19,7 @@ import java.sql.Timestamp;
|
|||
@Getter
|
||||
@Setter
|
||||
@Table(name="job")
|
||||
public class Job {
|
||||
public class Job implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -7,6 +7,7 @@ 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;
|
||||
|
@ -19,7 +20,7 @@ import java.util.Set;
|
|||
@Getter
|
||||
@Setter
|
||||
@Table(name = "menu")
|
||||
public class Menu{
|
||||
public class Menu implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -7,6 +7,7 @@ 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;
|
||||
|
@ -20,7 +21,7 @@ import java.util.Set;
|
|||
@Table(name = "role")
|
||||
@Getter
|
||||
@Setter
|
||||
public class Role{
|
||||
public class Role implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -7,6 +7,7 @@ import javax.persistence.*;
|
|||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
@ -19,7 +20,7 @@ import java.util.Set;
|
|||
@Getter
|
||||
@Setter
|
||||
@Table(name="user")
|
||||
public class User{
|
||||
public class User implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -8,6 +8,7 @@ import me.zhengjie.base.BaseEntity;
|
|||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +20,7 @@ import java.sql.Timestamp;
|
|||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "user_avatar")
|
||||
public class UserAvatar {
|
||||
public class UserAvatar implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -15,6 +15,9 @@ 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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -37,6 +40,14 @@ public class DeptController {
|
|||
this.dataScope = dataScope;
|
||||
}
|
||||
|
||||
@Log("导出部门数据")
|
||||
@ApiOperation("导出部门数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('dept:list')")
|
||||
public void download(HttpServletResponse response, DeptQueryCriteria criteria) throws IOException {
|
||||
deptService.download(deptService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@Log("查询部门")
|
||||
@ApiOperation("查询部门")
|
||||
@GetMapping
|
||||
|
|
|
@ -14,6 +14,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
|
@ -31,6 +34,14 @@ public class DictController {
|
|||
this.dictService = dictService;
|
||||
}
|
||||
|
||||
@Log("导出字典数据")
|
||||
@ApiOperation("导出字典数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('dict:list')")
|
||||
public void download(HttpServletResponse response, DictQueryCriteria criteria) throws IOException {
|
||||
dictService.download(dictService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@Log("查询字典")
|
||||
@ApiOperation("查询字典")
|
||||
@GetMapping
|
||||
|
|
|
@ -16,6 +16,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-29
|
||||
|
@ -36,6 +39,14 @@ public class JobController {
|
|||
this.dataScope = dataScope;
|
||||
}
|
||||
|
||||
@Log("导出岗位数据")
|
||||
@ApiOperation("导出岗位数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('job:list')")
|
||||
public void download(HttpServletResponse response, JobQueryCriteria criteria) throws IOException {
|
||||
jobService.download(jobService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@Log("查询岗位")
|
||||
@ApiOperation("查询岗位")
|
||||
@GetMapping
|
||||
|
|
|
@ -17,6 +17,9 @@ 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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -45,6 +48,14 @@ public class MenuController {
|
|||
this.roleService = roleService;
|
||||
}
|
||||
|
||||
@Log("导出菜单数据")
|
||||
@ApiOperation("导出菜单数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public void download(HttpServletResponse response, MenuQueryCriteria criteria) throws IOException {
|
||||
menuService.download(menuService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("获取前端所需菜单")
|
||||
@GetMapping(value = "/build")
|
||||
public ResponseEntity buildMenus(){
|
||||
|
|
|
@ -19,6 +19,9 @@ 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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -47,6 +50,14 @@ public class RoleController {
|
|||
return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出角色数据")
|
||||
@ApiOperation("导出角色数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('role:list')")
|
||||
public void download(HttpServletResponse response, RoleQueryCriteria criteria) throws IOException {
|
||||
roleService.download(roleService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的角色")
|
||||
@GetMapping(value = "/all")
|
||||
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
||||
|
|
|
@ -61,7 +61,7 @@ public class UserController {
|
|||
@ApiOperation("导出用户数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public void update(HttpServletResponse response, UserQueryCriteria criteria) throws IOException {
|
||||
public void download(HttpServletResponse response, UserQueryCriteria criteria) throws IOException {
|
||||
userService.download(userService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@ package me.zhengjie.modules.system.service;
|
|||
import me.zhengjie.modules.system.domain.Dept;
|
||||
import me.zhengjie.modules.system.service.dto.DeptDTO;
|
||||
import me.zhengjie.modules.system.service.dto.DeptQueryCriteria;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -27,4 +30,6 @@ public interface DeptService {
|
|||
List<Dept> findByPid(long pid);
|
||||
|
||||
Set<Dept> findByRoleIds(Long id);
|
||||
|
||||
void download(List<DeptDTO> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -5,13 +5,20 @@ import me.zhengjie.modules.system.service.dto.DictDTO;
|
|||
import me.zhengjie.modules.system.service.dto.DictQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
public interface DictService {
|
||||
|
||||
Object queryAll(DictQueryCriteria dict, Pageable pageable);
|
||||
Map<String,Object> queryAll(DictQueryCriteria dict, Pageable pageable);
|
||||
|
||||
List<DictDTO> queryAll(DictQueryCriteria dict);
|
||||
|
||||
DictDTO findById(Long id);
|
||||
|
||||
|
@ -20,4 +27,6 @@ public interface DictService {
|
|||
void update(Dict resources);
|
||||
|
||||
void delete(Long id);
|
||||
|
||||
void download(List<DictDTO> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -5,6 +5,11 @@ import me.zhengjie.modules.system.service.dto.JobDTO;
|
|||
import me.zhengjie.modules.system.service.dto.JobQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-29
|
||||
|
@ -19,5 +24,9 @@ public interface JobService {
|
|||
|
||||
void delete(Long id);
|
||||
|
||||
Object queryAll(JobQueryCriteria criteria, Pageable pageable);
|
||||
Map<String,Object> queryAll(JobQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
List<JobDTO> queryAll(JobQueryCriteria criteria);
|
||||
|
||||
void download(List<JobDTO> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -4,6 +4,9 @@ import me.zhengjie.modules.system.domain.Menu;
|
|||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -37,4 +40,6 @@ public interface MenuService {
|
|||
Menu findOne(Long id);
|
||||
|
||||
void delete(Set<Menu> menuSet);
|
||||
|
||||
void download(List<MenuDTO> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ 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 org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -35,4 +38,6 @@ public interface RoleService {
|
|||
Object queryAll(RoleQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
List<RoleDTO> queryAll(RoleQueryCriteria criteria);
|
||||
|
||||
void download(List<RoleDTO> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -13,7 +14,7 @@ import java.util.List;
|
|||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DeptDTO{
|
||||
public class DeptDTO implements Serializable {
|
||||
|
||||
// ID
|
||||
private Long id;
|
||||
|
|
|
@ -2,6 +2,8 @@ package me.zhengjie.modules.system.service.dto;
|
|||
|
||||
import lombok.Data;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -22,4 +24,10 @@ public class DeptQueryCriteria{
|
|||
|
||||
@Query
|
||||
private Long pid;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
|
@ -3,7 +3,9 @@ package me.zhengjie.modules.system.service.dto;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
@ -11,7 +13,7 @@ import java.sql.Timestamp;
|
|||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DictDTO{
|
||||
public class DictDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
|
@ -19,5 +21,7 @@ public class DictDTO{
|
|||
|
||||
private String remark;
|
||||
|
||||
private List<DictDetailDTO> dictDetails;
|
||||
|
||||
private Timestamp createTime;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -11,7 +12,7 @@ import java.sql.Timestamp;
|
|||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DictDetailDTO{
|
||||
public class DictDetailDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.system.service.dto;
|
|||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -12,7 +14,7 @@ import java.sql.Timestamp;
|
|||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class JobDTO{
|
||||
public class JobDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
|
|
|
@ -27,4 +27,10 @@ public class JobQueryCriteria {
|
|||
|
||||
@Query(propName = "id", joinName = "dept", type = Query.Type.IN)
|
||||
private Set<Long> deptIds;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -12,7 +13,7 @@ import java.util.List;
|
|||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class MenuDTO{
|
||||
public class MenuDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.system.service.dto;
|
|||
import lombok.Data;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* 公共查询类
|
||||
*/
|
||||
|
@ -12,4 +14,10 @@ public class MenuQueryCriteria {
|
|||
// 多字段模糊
|
||||
@Query(blurry = "name,path,component")
|
||||
private String blurry;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -12,7 +13,7 @@ import java.util.Set;
|
|||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class RoleDTO{
|
||||
public class RoleDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.system.service.dto;
|
|||
import lombok.Data;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* 公共查询类
|
||||
*/
|
||||
|
@ -12,4 +14,10 @@ public class RoleQueryCriteria {
|
|||
// 多字段模糊
|
||||
@Query(blurry = "name,remark")
|
||||
private String blurry;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
@ -14,7 +16,7 @@ import java.util.Set;
|
|||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class UserDTO {
|
||||
public class UserDTO implements Serializable {
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long id;
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto;
|
|||
import lombok.Data;
|
||||
import me.zhengjie.annotation.Query;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -26,4 +27,10 @@ public class UserQueryCriteria implements Serializable {
|
|||
private Boolean enabled;
|
||||
|
||||
private Long deptId;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.impl;
|
|||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.system.domain.Dept;
|
||||
import me.zhengjie.modules.system.service.dto.DeptQueryCriteria;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.modules.system.repository.DeptRepository;
|
||||
|
@ -16,6 +17,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -127,4 +131,17 @@ public class DeptServiceImpl implements DeptService {
|
|||
public void delete(Long id) {
|
||||
deptRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<DeptDTO> deptDTOs, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (DeptDTO deptDTO : deptDTOs) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("部门名称", deptDTO.getName());
|
||||
map.put("部门状态", deptDTO.getEnabled() ? "启用" : "停用");
|
||||
map.put("创建日期", deptDTO.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package me.zhengjie.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import me.zhengjie.modules.system.domain.Dict;
|
||||
import me.zhengjie.modules.system.service.dto.DictDetailDTO;
|
||||
import me.zhengjie.modules.system.service.dto.DictQueryCriteria;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
|
@ -18,6 +21,13 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
|
@ -38,11 +48,17 @@ public class DictServiceImpl implements DictService {
|
|||
|
||||
@Override
|
||||
@Cacheable
|
||||
public Object queryAll(DictQueryCriteria dict, Pageable pageable){
|
||||
public Map<String, Object> queryAll(DictQueryCriteria dict, Pageable pageable){
|
||||
Page<Dict> page = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb), pageable);
|
||||
return PageUtil.toPage(page.map(dictMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDTO> queryAll(DictQueryCriteria dict) {
|
||||
List<Dict> list = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb));
|
||||
return dictMapper.toDto(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public DictDTO findById(Long id) {
|
||||
|
@ -74,4 +90,31 @@ public class DictServiceImpl implements DictService {
|
|||
public void delete(Long id) {
|
||||
dictRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<DictDTO> dictDTOS, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (DictDTO dictDTO : dictDTOS) {
|
||||
if(CollectionUtil.isNotEmpty(dictDTO.getDictDetails())){
|
||||
for (DictDetailDTO dictDetail : dictDTO.getDictDetails()) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("字典名称", dictDTO.getName());
|
||||
map.put("字典描述", dictDTO.getRemark());
|
||||
map.put("字典标签", dictDetail.getLabel());
|
||||
map.put("字典值", dictDetail.getValue());
|
||||
map.put("创建日期", dictDetail.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
} else {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("字典名称", dictDTO.getName());
|
||||
map.put("字典描述", dictDTO.getRemark());
|
||||
map.put("字典标签", null);
|
||||
map.put("字典值", null);
|
||||
map.put("创建日期", dictDTO.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.impl;
|
|||
import me.zhengjie.modules.system.domain.Job;
|
||||
import me.zhengjie.modules.system.repository.DeptRepository;
|
||||
import me.zhengjie.modules.system.service.dto.JobQueryCriteria;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
|
@ -18,8 +19,13 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
@ -43,7 +49,8 @@ public class JobServiceImpl implements JobService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object queryAll(JobQueryCriteria criteria, Pageable pageable) {
|
||||
@Cacheable
|
||||
public Map<String,Object> queryAll(JobQueryCriteria criteria, Pageable pageable) {
|
||||
Page<Job> page = jobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
List<JobDTO> jobs = new ArrayList<>();
|
||||
for (Job job : page.getContent()) {
|
||||
|
@ -52,6 +59,13 @@ public class JobServiceImpl implements JobService {
|
|||
return PageUtil.toPage(jobs,page.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public List<JobDTO> queryAll(JobQueryCriteria criteria) {
|
||||
List<Job> list = jobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
return jobMapper.toDto(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public JobDTO findById(Long id) {
|
||||
|
@ -83,4 +97,18 @@ public class JobServiceImpl implements JobService {
|
|||
public void delete(Long id) {
|
||||
jobRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<JobDTO> jobDTOs, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (JobDTO jobDTO : jobDTOs) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("岗位名称", jobDTO.getName());
|
||||
map.put("所属部门", jobDTO.getDept().getName());
|
||||
map.put("岗位状态", jobDTO.getEnabled() ? "启用" : "停用");
|
||||
map.put("创建日期", jobDTO.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ 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.mapper.MenuMapper;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.StringUtils;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
|
@ -24,6 +25,9 @@ import org.springframework.data.domain.Sort;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -261,4 +265,21 @@ public class MenuServiceImpl implements MenuService {
|
|||
ValidationUtil.isNull(menu.getId(),"Menu","id",id);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<MenuDTO> menuDTOS, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (MenuDTO menuDTO : menuDTOS) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("菜单名称", menuDTO.getName());
|
||||
map.put("菜单类型", menuDTO.getType() == 0 ? "目录" : menuDTO.getType() == 1 ? "菜单" : "按钮");
|
||||
map.put("权限标识", menuDTO.getPermission());
|
||||
map.put("外链菜单", menuDTO.getIFrame() ? "是" : "否");
|
||||
map.put("菜单可见", menuDTO.getHidden() ? "否" : "是");
|
||||
map.put("是否缓存", menuDTO.getCache() ? "是" : "否");
|
||||
map.put("创建日期", menuDTO.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
|
|||
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||
import me.zhengjie.modules.system.service.mapper.RoleMapper;
|
||||
import me.zhengjie.modules.system.service.mapper.RoleSmallMapper;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
|
@ -20,6 +21,9 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -139,4 +143,19 @@ public class RoleServiceImpl implements RoleService {
|
|||
}
|
||||
return Collections.min(roleDTOS.stream().map(RoleDTO::getLevel).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<RoleDTO> roles, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (RoleDTO role : roles) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("角色名称", role.getName());
|
||||
map.put("默认权限", role.getPermission());
|
||||
map.put("角色级别", role.getLevel());
|
||||
map.put("描述", role.getRemark());
|
||||
map.put("创建日期", role.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import me.zhengjie.base.BaseEntity;
|
|||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +19,7 @@ import java.sql.Timestamp;
|
|||
@Entity
|
||||
@Table(name="local_storage")
|
||||
@NoArgsConstructor
|
||||
public class LocalStorage {
|
||||
public class LocalStorage implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.hibernate.annotations.CreationTimestamp;
|
|||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +19,7 @@ import java.sql.Timestamp;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Table(name = "verification_code")
|
||||
public class VerificationCode {
|
||||
public class VerificationCode implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
|
|
@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.*;
|
|||
import io.swagger.annotations.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
|
@ -35,6 +38,14 @@ public class LocalStorageController {
|
|||
return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public void download(HttpServletResponse response, LocalStorageQueryCriteria criteria) throws IOException {
|
||||
localStorageService.download(localStorageService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('storage:add')")
|
||||
|
|
|
@ -13,6 +13,9 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -39,6 +42,14 @@ public class PictureController {
|
|||
return new ResponseEntity<>(pictureService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('pictures:list')")
|
||||
public void download(HttpServletResponse response, PictureQueryCriteria criteria) throws IOException {
|
||||
pictureService.download(pictureService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@Log("上传图片")
|
||||
@PreAuthorize("@el.check('pictures:add')")
|
||||
@PostMapping
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -48,6 +50,13 @@ public class QiniuController {
|
|||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download/list")
|
||||
public void download(HttpServletResponse response, QiniuQueryCriteria criteria) throws IOException {
|
||||
qiNiuService.downloadList(qiNiuService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@Log("查询文件")
|
||||
@ApiOperation("查询文件")
|
||||
@GetMapping
|
||||
|
|
|
@ -6,6 +6,10 @@ import me.zhengjie.service.dto.LocalStorageQueryCriteria;
|
|||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
|
@ -14,7 +18,7 @@ public interface LocalStorageService {
|
|||
|
||||
Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
Object queryAll(LocalStorageQueryCriteria criteria);
|
||||
List<LocalStorageDTO> queryAll(LocalStorageQueryCriteria criteria);
|
||||
|
||||
LocalStorageDTO findById(Long id);
|
||||
|
||||
|
@ -25,4 +29,6 @@ public interface LocalStorageService {
|
|||
void delete(Long id);
|
||||
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
void download(List<LocalStorageDTO> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -5,6 +5,10 @@ import me.zhengjie.service.dto.PictureQueryCriteria;
|
|||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-27
|
||||
|
@ -12,6 +16,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
public interface PictureService {
|
||||
|
||||
Object queryAll(PictureQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
List<Picture> queryAll(PictureQueryCriteria criteria);
|
||||
|
||||
Picture upload(MultipartFile file, String username);
|
||||
|
||||
|
@ -20,4 +26,6 @@ public interface PictureService {
|
|||
void delete(Picture picture);
|
||||
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
void download(List<Picture> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ import me.zhengjie.service.dto.QiniuQueryCriteria;
|
|||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
|
@ -14,6 +18,8 @@ public interface QiNiuService {
|
|||
|
||||
Object queryAll(QiniuQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
List<QiniuContent> queryAll(QiniuQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 查配置
|
||||
* @return Cacheable
|
||||
|
@ -75,4 +81,11 @@ public interface QiNiuService {
|
|||
* @param type 类型
|
||||
*/
|
||||
void update(String type);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param queryAll /
|
||||
* @param response /
|
||||
*/
|
||||
void downloadList(List<QiniuContent> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.zhengjie.service.dto;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
|
@ -11,7 +12,7 @@ import java.sql.Timestamp;
|
|||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class LocalStorageDTO{
|
||||
public class LocalStorageDTO implements Serializable {
|
||||
|
||||
// ID
|
||||
private Long id;
|
||||
|
|
|
@ -14,4 +14,10 @@ public class LocalStorageQueryCriteria{
|
|||
// 模糊
|
||||
@Query(blurry = "name,suffix,type,operate,size")
|
||||
private String blurry;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
|
@ -3,6 +3,8 @@ package me.zhengjie.service.dto;
|
|||
import lombok.Data;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* sm.ms图床
|
||||
*
|
||||
|
@ -17,4 +19,10 @@ public class PictureQueryCriteria{
|
|||
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String username;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "createTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "createTime")
|
||||
private Timestamp endTime;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.service.dto;
|
|||
import lombok.Data;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-6-4 09:54:37
|
||||
|
@ -12,4 +14,10 @@ public class QiniuQueryCriteria{
|
|||
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String key;
|
||||
|
||||
@Query(type = Query.Type.GREATER_THAN,propName = "updateTime")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Query(type = Query.Type.LESS_THAN,propName = "updateTime")
|
||||
private Timestamp endTime;
|
||||
}
|
||||
|
|
|
@ -17,10 +17,18 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
|
@ -54,7 +62,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
|||
|
||||
@Override
|
||||
@Cacheable
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria){
|
||||
public List<LocalStorageDTO> queryAll(LocalStorageQueryCriteria criteria){
|
||||
return localStorageMapper.toDto(localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
|
@ -126,4 +134,20 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
|||
localStorageRepository.delete(storage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<LocalStorageDTO> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (LocalStorageDTO localStorageDTO : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", localStorageDTO.getRealName());
|
||||
map.put("备注名", localStorageDTO.getName());
|
||||
map.put("文件类型", localStorageDTO.getType());
|
||||
map.put("文件大小", localStorageDTO.getSize());
|
||||
map.put("操作人", localStorageDTO.getOperate());
|
||||
map.put("创建日期", localStorageDTO.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,11 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
@ -50,6 +53,11 @@ public class PictureServiceImpl implements PictureService {
|
|||
return PageUtil.toPage(pictureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Picture> queryAll(PictureQueryCriteria criteria) {
|
||||
return pictureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
|
@ -106,4 +114,22 @@ public class PictureServiceImpl implements PictureService {
|
|||
delete(findById(id));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<Picture> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Picture picture : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", picture.getFilename());
|
||||
map.put("图片地址", picture.getUrl());
|
||||
map.put("文件大小", picture.getSize());
|
||||
map.put("操作人", picture.getUsername());
|
||||
map.put("高度", picture.getHeight());
|
||||
map.put("宽度", picture.getWidth());
|
||||
map.put("删除地址", picture.getDelete());
|
||||
map.put("创建日期", picture.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,10 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
@ -60,6 +63,11 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
return PageUtil.toPage(qiniuContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QiniuContent> queryAll(QiniuQueryCriteria criteria) {
|
||||
return qiniuContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'1'")
|
||||
public QiniuConfig find() {
|
||||
|
@ -206,4 +214,20 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
public void update(String type) {
|
||||
qiNiuConfigRepository.update(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadList(List<QiniuContent> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (QiniuContent content : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", content.getKey());
|
||||
map.put("文件类型", content.getSuffix());
|
||||
map.put("空间名称", content.getBucket());
|
||||
map.put("文件大小", content.getSize());
|
||||
map.put("空间类型", content.getType());
|
||||
map.put("创建日期", content.getUpdateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue