Commit 905c8c64 authored by dqjdda's avatar dqjdda
Browse files

所有列表加入日期搜索与导出功能

parent 938ae1fc
...@@ -27,4 +27,10 @@ public class JobQueryCriteria { ...@@ -27,4 +27,10 @@ public class JobQueryCriteria {
@Query(propName = "id", joinName = "dept", type = Query.Type.IN) @Query(propName = "id", joinName = "dept", type = Query.Type.IN)
private Set<Long> deptIds; 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;
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto; ...@@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
...@@ -12,7 +13,7 @@ import java.util.List; ...@@ -12,7 +13,7 @@ import java.util.List;
*/ */
@Getter @Getter
@Setter @Setter
public class MenuDTO{ public class MenuDTO implements Serializable {
private Long id; private Long id;
......
...@@ -3,6 +3,8 @@ package me.zhengjie.modules.system.service.dto; ...@@ -3,6 +3,8 @@ package me.zhengjie.modules.system.service.dto;
import lombok.Data; import lombok.Data;
import me.zhengjie.annotation.Query; import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
/** /**
* 公共查询类 * 公共查询类
*/ */
...@@ -12,4 +14,10 @@ public class MenuQueryCriteria { ...@@ -12,4 +14,10 @@ public class MenuQueryCriteria {
// 多字段模糊 // 多字段模糊
@Query(blurry = "name,path,component") @Query(blurry = "name,path,component")
private String blurry; 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; ...@@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Set; import java.util.Set;
...@@ -12,7 +13,7 @@ import java.util.Set; ...@@ -12,7 +13,7 @@ import java.util.Set;
*/ */
@Getter @Getter
@Setter @Setter
public class RoleDTO{ public class RoleDTO implements Serializable {
private Long id; private Long id;
......
...@@ -3,6 +3,8 @@ package me.zhengjie.modules.system.service.dto; ...@@ -3,6 +3,8 @@ package me.zhengjie.modules.system.service.dto;
import lombok.Data; import lombok.Data;
import me.zhengjie.annotation.Query; import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
/** /**
* 公共查询类 * 公共查询类
*/ */
...@@ -12,4 +14,10 @@ public class RoleQueryCriteria { ...@@ -12,4 +14,10 @@ public class RoleQueryCriteria {
// 多字段模糊 // 多字段模糊
@Query(blurry = "name,remark") @Query(blurry = "name,remark")
private String blurry; 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; ...@@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
...@@ -14,7 +16,7 @@ import java.util.Set; ...@@ -14,7 +16,7 @@ import java.util.Set;
*/ */
@Getter @Getter
@Setter @Setter
public class UserDTO { public class UserDTO implements Serializable {
@ApiModelProperty(hidden = true) @ApiModelProperty(hidden = true)
private Long id; private Long id;
......
...@@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto; ...@@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.dto;
import lombok.Data; import lombok.Data;
import me.zhengjie.annotation.Query; import me.zhengjie.annotation.Query;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set; import java.util.Set;
/** /**
...@@ -26,4 +27,10 @@ public class UserQueryCriteria implements Serializable { ...@@ -26,4 +27,10 @@ public class UserQueryCriteria implements Serializable {
private Boolean enabled; private Boolean enabled;
private Long deptId; 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; ...@@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.impl;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.Dept; import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.service.dto.DeptQueryCriteria; import me.zhengjie.modules.system.service.dto.DeptQueryCriteria;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.QueryHelp; import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.modules.system.repository.DeptRepository; import me.zhengjie.modules.system.repository.DeptRepository;
...@@ -16,6 +17,9 @@ import org.springframework.stereotype.Service; ...@@ -16,6 +17,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -127,4 +131,17 @@ public class DeptServiceImpl implements DeptService { ...@@ -127,4 +131,17 @@ public class DeptServiceImpl implements DeptService {
public void delete(Long id) { public void delete(Long id) {
deptRepository.deleteById(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);
}
} }
\ No newline at end of file
package me.zhengjie.modules.system.service.impl; 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.domain.Dict;
import me.zhengjie.modules.system.service.dto.DictDetailDTO;
import me.zhengjie.modules.system.service.dto.DictQueryCriteria; import me.zhengjie.modules.system.service.dto.DictQueryCriteria;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp; import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
...@@ -18,6 +21,13 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +21,13 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; 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 * @author Zheng Jie
* @date 2019-04-10 * @date 2019-04-10
...@@ -38,11 +48,17 @@ public class DictServiceImpl implements DictService { ...@@ -38,11 +48,17 @@ public class DictServiceImpl implements DictService {
@Override @Override
@Cacheable @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); Page<Dict> page = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb), pageable);
return PageUtil.toPage(page.map(dictMapper::toDto)); return PageUtil.toPage(page.map(dictMapper::toDto));
} }
@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 @Override
@Cacheable(key = "#p0") @Cacheable(key = "#p0")
public DictDTO findById(Long id) { public DictDTO findById(Long id) {
...@@ -74,4 +90,31 @@ public class DictServiceImpl implements DictService { ...@@ -74,4 +90,31 @@ public class DictServiceImpl implements DictService {
public void delete(Long id) { public void delete(Long id) {
dictRepository.deleteById(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);
}
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.impl; ...@@ -3,6 +3,7 @@ package me.zhengjie.modules.system.service.impl;
import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.domain.Job;
import me.zhengjie.modules.system.repository.DeptRepository; import me.zhengjie.modules.system.repository.DeptRepository;
import me.zhengjie.modules.system.service.dto.JobQueryCriteria; import me.zhengjie.modules.system.service.dto.JobQueryCriteria;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp; import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
...@@ -18,8 +19,13 @@ import org.springframework.data.domain.Pageable; ...@@ -18,8 +19,13 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author Zheng Jie * @author Zheng Jie
...@@ -43,7 +49,8 @@ public class JobServiceImpl implements JobService { ...@@ -43,7 +49,8 @@ public class JobServiceImpl implements JobService {
} }
@Override @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); Page<Job> page = jobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
List<JobDTO> jobs = new ArrayList<>(); List<JobDTO> jobs = new ArrayList<>();
for (Job job : page.getContent()) { for (Job job : page.getContent()) {
...@@ -52,6 +59,13 @@ public class JobServiceImpl implements JobService { ...@@ -52,6 +59,13 @@ public class JobServiceImpl implements JobService {
return PageUtil.toPage(jobs,page.getTotalElements()); 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 @Override
@Cacheable(key = "#p0") @Cacheable(key = "#p0")
public JobDTO findById(Long id) { public JobDTO findById(Long id) {
...@@ -83,4 +97,18 @@ public class JobServiceImpl implements JobService { ...@@ -83,4 +97,18 @@ public class JobServiceImpl implements JobService {
public void delete(Long id) { public void delete(Long id) {
jobRepository.deleteById(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);
}
} }
\ No newline at end of file
...@@ -14,6 +14,7 @@ import me.zhengjie.modules.system.service.dto.MenuDTO; ...@@ -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.MenuQueryCriteria;
import me.zhengjie.modules.system.service.dto.RoleSmallDTO; import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
import me.zhengjie.modules.system.service.mapper.MenuMapper; import me.zhengjie.modules.system.service.mapper.MenuMapper;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.QueryHelp; import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.StringUtils; import me.zhengjie.utils.StringUtils;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
...@@ -24,6 +25,9 @@ import org.springframework.data.domain.Sort; ...@@ -24,6 +25,9 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -261,4 +265,21 @@ public class MenuServiceImpl implements MenuService { ...@@ -261,4 +265,21 @@ public class MenuServiceImpl implements MenuService {
ValidationUtil.isNull(menu.getId(),"Menu","id",id); ValidationUtil.isNull(menu.getId(),"Menu","id",id);
return menu; 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; ...@@ -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.dto.RoleSmallDTO;
import me.zhengjie.modules.system.service.mapper.RoleMapper; import me.zhengjie.modules.system.service.mapper.RoleMapper;
import me.zhengjie.modules.system.service.mapper.RoleSmallMapper; import me.zhengjie.modules.system.service.mapper.RoleSmallMapper;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp; import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
...@@ -20,6 +21,9 @@ import org.springframework.data.domain.Pageable; ...@@ -20,6 +21,9 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -139,4 +143,19 @@ public class RoleServiceImpl implements RoleService { ...@@ -139,4 +143,19 @@ public class RoleServiceImpl implements RoleService {
} }
return Collections.min(roleDTOS.stream().map(RoleDTO::getLevel).collect(Collectors.toList())); 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; ...@@ -7,6 +7,7 @@ import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
/** /**
...@@ -18,7 +19,7 @@ import java.sql.Timestamp; ...@@ -18,7 +19,7 @@ import java.sql.Timestamp;
@Entity @Entity
@Table(name="local_storage") @Table(name="local_storage")
@NoArgsConstructor @NoArgsConstructor
public class LocalStorage { public class LocalStorage implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -7,6 +7,7 @@ import org.hibernate.annotations.CreationTimestamp; ...@@ -7,6 +7,7 @@ import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
/** /**
...@@ -18,7 +19,7 @@ import java.sql.Timestamp; ...@@ -18,7 +19,7 @@ import java.sql.Timestamp;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Table(name = "verification_code") @Table(name = "verification_code")
public class VerificationCode { public class VerificationCode implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.*; ...@@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2019-09-05 * @date 2019-09-05
...@@ -35,6 +38,14 @@ public class LocalStorageController { ...@@ -35,6 +38,14 @@ public class LocalStorageController {
return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK); 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("上传文件") @ApiOperation("上传文件")
@PostMapping @PostMapping
@PreAuthorize("@el.check('storage:add')") @PreAuthorize("@el.check('storage:add')")
......
...@@ -13,6 +13,9 @@ import org.springframework.http.ResponseEntity; ...@@ -13,6 +13,9 @@ import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -39,6 +42,14 @@ public class PictureController { ...@@ -39,6 +42,14 @@ public class PictureController {
return new ResponseEntity<>(pictureService.queryAll(criteria,pageable),HttpStatus.OK); 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("上传图片") @Log("上传图片")
@PreAuthorize("@el.check('pictures:add')") @PreAuthorize("@el.check('pictures:add')")
@PostMapping @PostMapping
......
...@@ -14,6 +14,8 @@ import org.springframework.http.ResponseEntity; ...@@ -14,6 +14,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -48,6 +50,13 @@ public class QiniuController { ...@@ -48,6 +50,13 @@ public class QiniuController {
return new ResponseEntity(HttpStatus.OK); 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("查询文件") @Log("查询文件")
@ApiOperation("查询文件") @ApiOperation("查询文件")
@GetMapping @GetMapping
......
...@@ -6,6 +6,10 @@ import me.zhengjie.service.dto.LocalStorageQueryCriteria; ...@@ -6,6 +6,10 @@ import me.zhengjie.service.dto.LocalStorageQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2019-09-05 * @date 2019-09-05
...@@ -14,7 +18,7 @@ public interface LocalStorageService { ...@@ -14,7 +18,7 @@ public interface LocalStorageService {
Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable); Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable);
Object queryAll(LocalStorageQueryCriteria criteria); List<LocalStorageDTO> queryAll(LocalStorageQueryCriteria criteria);
LocalStorageDTO findById(Long id); LocalStorageDTO findById(Long id);
...@@ -25,4 +29,6 @@ public interface LocalStorageService { ...@@ -25,4 +29,6 @@ public interface LocalStorageService {
void delete(Long id); void delete(Long id);
void deleteAll(Long[] ids); void deleteAll(Long[] ids);
void download(List<LocalStorageDTO> queryAll, HttpServletResponse response) throws IOException;
} }
\ No newline at end of file
...@@ -5,6 +5,10 @@ import me.zhengjie.service.dto.PictureQueryCriteria; ...@@ -5,6 +5,10 @@ import me.zhengjie.service.dto.PictureQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-27 * @date 2018-12-27
...@@ -12,6 +16,8 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -12,6 +16,8 @@ import org.springframework.web.multipart.MultipartFile;
public interface PictureService { public interface PictureService {
Object queryAll(PictureQueryCriteria criteria, Pageable pageable); Object queryAll(PictureQueryCriteria criteria, Pageable pageable);
List<Picture> queryAll(PictureQueryCriteria criteria);
Picture upload(MultipartFile file, String username); Picture upload(MultipartFile file, String username);
...@@ -20,4 +26,6 @@ public interface PictureService { ...@@ -20,4 +26,6 @@ public interface PictureService {
void delete(Picture picture); void delete(Picture picture);
void deleteAll(Long[] ids); void deleteAll(Long[] ids);
void download(List<Picture> queryAll, HttpServletResponse response) throws IOException;
} }
...@@ -6,6 +6,10 @@ import me.zhengjie.service.dto.QiniuQueryCriteria; ...@@ -6,6 +6,10 @@ import me.zhengjie.service.dto.QiniuQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-31 * @date 2018-12-31
...@@ -14,6 +18,8 @@ public interface QiNiuService { ...@@ -14,6 +18,8 @@ public interface QiNiuService {
Object queryAll(QiniuQueryCriteria criteria, Pageable pageable); Object queryAll(QiniuQueryCriteria criteria, Pageable pageable);
List<QiniuContent> queryAll(QiniuQueryCriteria criteria);
/** /**
* 查配置 * 查配置
* @return Cacheable * @return Cacheable
...@@ -75,4 +81,11 @@ public interface QiNiuService { ...@@ -75,4 +81,11 @@ public interface QiNiuService {
* @param type 类型 * @param type 类型
*/ */
void update(String type); void update(String type);
/**
* 导出数据
* @param queryAll /
* @param response /
*/
void downloadList(List<QiniuContent> queryAll, HttpServletResponse response) throws IOException;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment