refactor: 优化分页查询和代码生成模板
This commit is contained in:
parent
18ccee7c7f
commit
c31dcb671c
@ -52,8 +52,8 @@ public class GeneratorController {
|
|||||||
|
|
||||||
@ApiOperation("查询数据库数据")
|
@ApiOperation("查询数据库数据")
|
||||||
@GetMapping(value = "/tables")
|
@GetMapping(value = "/tables")
|
||||||
public ResponseEntity<PageResult<TableInfo>> queryTables(@RequestParam(defaultValue = "") String name, Page<Object> page){
|
public ResponseEntity<PageResult<TableInfo>> queryTables(@RequestParam(defaultValue = "") String name, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size){
|
||||||
return new ResponseEntity<>(generatorService.getTables(name, page), HttpStatus.OK);
|
return new ResponseEntity<>(generatorService.getTables(name, new Page<>(page, size)), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询字段数据")
|
@ApiOperation("查询字段数据")
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
# Database type to Java type
|
|
||||||
tinyint=Integer
|
|
||||||
smallint=Integer
|
|
||||||
mediumint=Integer
|
|
||||||
int=Integer
|
|
||||||
integer=Integer
|
|
||||||
|
|
||||||
bigint=Long
|
|
||||||
|
|
||||||
float=Float
|
|
||||||
|
|
||||||
double=Double
|
|
||||||
|
|
||||||
decimal=BigDecimal
|
|
||||||
|
|
||||||
bit=Boolean
|
|
||||||
|
|
||||||
char=String
|
|
||||||
varchar=String
|
|
||||||
tinytext=String
|
|
||||||
text=String
|
|
||||||
mediumtext=String
|
|
||||||
longtext=String
|
|
||||||
|
|
||||||
date=Timestamp
|
|
||||||
datetime=Timestamp
|
|
||||||
timestamp=Timestamp
|
|
@ -54,7 +54,8 @@ public class ${className}Controller {
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查询${apiAlias}")
|
@ApiOperation("查询${apiAlias}")
|
||||||
@PreAuthorize("@el.check('${changeClassName}:list')")
|
@PreAuthorize("@el.check('${changeClassName}:list')")
|
||||||
public ResponseEntity<PageResult<${className}>> query${className}(${className}QueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<${className}>> query${className}(${className}QueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,page),HttpStatus.OK);
|
return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,page),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import java.math.BigDecimal;
|
|||||||
<#if betweens?? && (betweens?size > 0)>
|
<#if betweens?? && (betweens?size > 0)>
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
</#if>
|
</#if>
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
@ -32,6 +33,12 @@ import java.util.List;
|
|||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
public class ${className}QueryCriteria{
|
public class ${className}QueryCriteria{
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
<#if queryColumns??>
|
<#if queryColumns??>
|
||||||
<#list queryColumns as column>
|
<#list queryColumns as column>
|
||||||
|
|
||||||
|
@ -39,4 +39,10 @@ public class SysLogQueryCriteria {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private List<Timestamp> createTime;
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
||||||
|
@ -61,27 +61,31 @@ public class SysLogController {
|
|||||||
criteria.setLogType("ERROR");
|
criteria.setLogType("ERROR");
|
||||||
sysLogService.download(sysLogService.queryAll(criteria), response);
|
sysLogService.download(sysLogService.queryAll(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("日志查询")
|
@ApiOperation("日志查询")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity<PageResult<SysLog>> queryLog(SysLogQueryCriteria criteria, Page<SysLog> page){
|
public ResponseEntity<PageResult<SysLog>> queryLog(SysLogQueryCriteria criteria){
|
||||||
criteria.setLogType("INFO");
|
criteria.setLogType("INFO");
|
||||||
|
Page<SysLog> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(sysLogService.queryAll(criteria,page), HttpStatus.OK);
|
return new ResponseEntity<>(sysLogService.queryAll(criteria,page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/user")
|
@GetMapping(value = "/user")
|
||||||
@ApiOperation("用户日志查询")
|
@ApiOperation("用户日志查询")
|
||||||
public ResponseEntity<PageResult<SysLog>> queryUserLog(SysLogQueryCriteria criteria, Page<SysLog> page){
|
public ResponseEntity<PageResult<SysLog>> queryUserLog(SysLogQueryCriteria criteria){
|
||||||
criteria.setLogType("INFO");
|
criteria.setLogType("INFO");
|
||||||
criteria.setUsername(SecurityUtils.getCurrentUsername());
|
criteria.setUsername(SecurityUtils.getCurrentUsername());
|
||||||
|
Page<SysLog> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(sysLogService.queryAllByUser(criteria,page), HttpStatus.OK);
|
return new ResponseEntity<>(sysLogService.queryAllByUser(criteria,page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/error")
|
@GetMapping(value = "/error")
|
||||||
@ApiOperation("错误日志查询")
|
@ApiOperation("错误日志查询")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity<PageResult<SysLog>> queryErrorLog(SysLogQueryCriteria criteria, Page<SysLog> page){
|
public ResponseEntity<PageResult<SysLog>> queryErrorLog(SysLogQueryCriteria criteria){
|
||||||
criteria.setLogType("ERROR");
|
criteria.setLogType("ERROR");
|
||||||
|
Page<SysLog> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(sysLogService.queryAll(criteria,page), HttpStatus.OK);
|
return new ResponseEntity<>(sysLogService.queryAll(criteria,page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,4 +35,10 @@ public class QuartzJobQueryCriteria {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private List<Timestamp> createTime;
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,8 @@ public class QuartzJobController {
|
|||||||
@ApiOperation("查询定时任务")
|
@ApiOperation("查询定时任务")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('timing:list')")
|
@PreAuthorize("@el.check('timing:list')")
|
||||||
public ResponseEntity<PageResult<QuartzJob>> queryQuartzJob(QuartzJobQueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<QuartzJob>> queryQuartzJob(QuartzJobQueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(quartzJobService.queryAll(criteria,page), HttpStatus.OK);
|
return new ResponseEntity<>(quartzJobService.queryAll(criteria,page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +76,8 @@ public class QuartzJobController {
|
|||||||
@ApiOperation("查询任务执行日志")
|
@ApiOperation("查询任务执行日志")
|
||||||
@GetMapping(value = "/logs")
|
@GetMapping(value = "/logs")
|
||||||
@PreAuthorize("@el.check('timing:list')")
|
@PreAuthorize("@el.check('timing:list')")
|
||||||
public ResponseEntity<PageResult<QuartzLog>> queryQuartzJobLog(QuartzJobQueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<QuartzLog>> queryQuartzJobLog(QuartzJobQueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(quartzJobService.queryAllLog(criteria,page), HttpStatus.OK);
|
return new ResponseEntity<>(quartzJobService.queryAllLog(criteria,page), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,4 +30,10 @@ public class DictDetailQueryCriteria {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "字典名称")
|
@ApiModelProperty(value = "字典名称")
|
||||||
private String dictName;
|
private String dictName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
@ -27,4 +27,10 @@ public class DictQueryCriteria {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "模糊查询")
|
@ApiModelProperty(value = "模糊查询")
|
||||||
private String blurry;
|
private String blurry;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,10 @@ public class JobQueryCriteria {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private List<Timestamp> createTime;
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
@ -32,4 +32,10 @@ public class RoleQueryCriteria {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private List<Timestamp> createTime;
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
||||||
|
@ -47,4 +47,10 @@ public class UserQueryCriteria implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private List<Timestamp> createTime;
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,7 @@ public class DeptController {
|
|||||||
@ApiOperation("查询部门:根据ID获取同级与上级数据")
|
@ApiOperation("查询部门:根据ID获取同级与上级数据")
|
||||||
@PostMapping("/superior")
|
@PostMapping("/superior")
|
||||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||||
public ResponseEntity<Object> getDeptSuperior(@RequestBody List<Long> ids,
|
public ResponseEntity<Object> getDeptSuperior(@RequestBody List<Long> ids, @RequestParam(defaultValue = "false") Boolean exclude) {
|
||||||
@RequestParam(defaultValue = "false") Boolean exclude) {
|
|
||||||
Set<Dept> deptSet = new LinkedHashSet<>();
|
Set<Dept> deptSet = new LinkedHashSet<>();
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
Dept dept = deptService.findById(id);
|
Dept dept = deptService.findById(id);
|
||||||
|
@ -65,8 +65,9 @@ public class DictController {
|
|||||||
@ApiOperation("查询字典")
|
@ApiOperation("查询字典")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('dict:list')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public ResponseEntity<PageResult<Dict>> queryDict(DictQueryCriteria resources, Page<Object> page){
|
public ResponseEntity<PageResult<Dict>> queryDict(DictQueryCriteria criteria){
|
||||||
return new ResponseEntity<>(dictService.queryAll(resources, page),HttpStatus.OK);
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
return new ResponseEntity<>(dictService.queryAll(criteria, page),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("新增字典")
|
@Log("新增字典")
|
||||||
|
@ -49,7 +49,8 @@ public class DictDetailController {
|
|||||||
|
|
||||||
@ApiOperation("查询字典详情")
|
@ApiOperation("查询字典详情")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<PageResult<DictDetail>> queryDictDetail(DictDetailQueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<DictDetail>> queryDictDetail(DictDetailQueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(dictDetailService.queryAll(criteria, page),HttpStatus.OK);
|
return new ResponseEntity<>(dictDetailService.queryAll(criteria, page),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,8 @@ public class JobController {
|
|||||||
@ApiOperation("查询岗位")
|
@ApiOperation("查询岗位")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('job:list','user:list')")
|
@PreAuthorize("@el.check('job:list','user:list')")
|
||||||
public ResponseEntity<PageResult<Job>> queryJob(JobQueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<Job>> queryJob(JobQueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(jobService.queryAll(criteria, page),HttpStatus.OK);
|
return new ResponseEntity<>(jobService.queryAll(criteria, page),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,8 @@ public class RoleController {
|
|||||||
@ApiOperation("查询角色")
|
@ApiOperation("查询角色")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('roles:list')")
|
@PreAuthorize("@el.check('roles:list')")
|
||||||
public ResponseEntity<PageResult<Role>> queryRole(RoleQueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<Role>> queryRole(RoleQueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(roleService.queryAll(criteria, page),HttpStatus.OK);
|
return new ResponseEntity<>(roleService.queryAll(criteria, page),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,8 @@ public class UserController {
|
|||||||
@ApiOperation("查询用户")
|
@ApiOperation("查询用户")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('user:list')")
|
@PreAuthorize("@el.check('user:list')")
|
||||||
public ResponseEntity<PageResult<User>> queryUser(UserQueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<User>> queryUser(UserQueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
||||||
criteria.getDeptIds().add(criteria.getDeptId());
|
criteria.getDeptIds().add(criteria.getDeptId());
|
||||||
// 先查找是否存在子节点
|
// 先查找是否存在子节点
|
||||||
|
@ -32,4 +32,10 @@ public class LocalStorageQueryCriteria{
|
|||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private List<Timestamp> createTime;
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
@ -32,4 +32,10 @@ public class QiniuQueryCriteria{
|
|||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private List<Timestamp> createTime;
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,8 @@ public class LocalStorageController {
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查询文件")
|
@ApiOperation("查询文件")
|
||||||
@PreAuthorize("@el.check('storage:list')")
|
@PreAuthorize("@el.check('storage:list')")
|
||||||
public ResponseEntity<PageResult<LocalStorage>> queryFile(LocalStorageQueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<LocalStorage>> queryFile(LocalStorageQueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(localStorageService.queryAll(criteria,page),HttpStatus.OK);
|
return new ResponseEntity<>(localStorageService.queryAll(criteria,page),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ public class QiniuController {
|
|||||||
|
|
||||||
@ApiOperation("查询文件")
|
@ApiOperation("查询文件")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<PageResult<QiniuContent>> queryQiNiu(QiniuQueryCriteria criteria, Page<Object> page){
|
public ResponseEntity<PageResult<QiniuContent>> queryQiNiu(QiniuQueryCriteria criteria){
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return new ResponseEntity<>(qiniuContentService.queryAll(criteria, page),HttpStatus.OK);
|
return new ResponseEntity<>(qiniuContentService.queryAll(criteria, page),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user