代码优化

pull/214/head
dqjdda 2019-11-24 12:09:19 +08:00
parent aaeb67b280
commit 776cee4b14
24 changed files with 93 additions and 72 deletions

View File

@ -52,6 +52,8 @@ public @interface Query {
, IN
// 不等于
,NOT_EQUAL
// between
,BETWEEN
}
/**

View File

@ -109,6 +109,11 @@ public class QueryHelp {
case NOT_EQUAL:
list.add(cb.notEqual(getExpression(attributeName,join,root), val));
break;
case BETWEEN:
List<Object> between = new ArrayList<>((List<Object>)val);
list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()),
(Comparable) between.get(0), (Comparable) between.get(1)));
break;
default: break;
}
}

View File

@ -56,9 +56,6 @@ public class ColumnInfo {
// 字典名称
private String dictName;
// 关联表名
private String joinName;
// 日期注解
private String dateAnnotation;

View File

@ -118,9 +118,11 @@ public class GeneratorServiceImpl implements GeneratorService {
throw new BadRequestException("请先配置生成器");
}
try {
GenUtil.generatorCode(columns,genConfig);
// 查询是否存在关联实体字段信息
GenUtil.generatorCode(columns, genConfig);
} catch (IOException e) {
throw new RuntimeException(e);
e.printStackTrace();
throw new BadRequestException("生成失败,请手动处理已生成的文件");
}
return null;
}

View File

@ -170,8 +170,6 @@ public class GenUtil {
listMap.put("capitalColumnName",capitalColumnName);
// 字典名称
listMap.put("dictName",column.getDictName());
// 关联字段
listMap.put("joinName",column.getJoinName());
// 日期注解
listMap.put("dateAnnotation",column.getDateAnnotation());
if(StringUtils.isNotBlank(column.getDateAnnotation())){

View File

@ -2,8 +2,8 @@ package me.zhengjie.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
/**
*
@ -20,9 +20,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -54,7 +54,7 @@ public class QuartzJobController {
@Log("导出日志数据")
@ApiOperation("导出日志数据")
@GetMapping(value = "/download/log")
@GetMapping(value = "/logs/download")
@PreAuthorize("@el.check('timing:list')")
public void downloadLog(HttpServletResponse response, JobQueryCriteria criteria) throws IOException {
quartzJobService.downloadLog(quartzJobService.queryAllLog(criteria), response);

View File

@ -4,6 +4,7 @@ import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
/**
* @author Zheng Jie
@ -18,9 +19,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author Zheng Jie
@ -51,8 +52,7 @@ public class JobController {
@ApiOperation("查询岗位")
@GetMapping
@PreAuthorize("@el.check('job:list','user:list')")
public ResponseEntity getJobs(JobQueryCriteria criteria,
Pageable pageable){
public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){
// 数据权限
criteria.setDeptIds(dataScope.getDeptIds());
return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK);

View File

@ -4,6 +4,7 @@ import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
import java.util.Set;
/**
@ -25,9 +26,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -22,5 +22,7 @@ public class DictDetailDTO implements Serializable {
private String sort;
private DictSmallDTO dict;
private Timestamp createTime;
}

View File

@ -0,0 +1,16 @@
package me.zhengjie.modules.system.service.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Getter
@Setter
public class DictSmallDTO implements Serializable {
private Long id;
}

View File

@ -3,9 +3,8 @@ package me.zhengjie.modules.system.service.dto;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.zhengjie.annotation.Query;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import java.util.Set;
/**
@ -28,9 +27,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -4,6 +4,7 @@ import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
/**
*
@ -15,9 +16,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -4,6 +4,7 @@ import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
/**
*
@ -15,9 +16,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -4,6 +4,7 @@ import lombok.Data;
import me.zhengjie.annotation.Query;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import java.util.Set;
/**
@ -28,9 +29,6 @@ public class UserQueryCriteria implements Serializable {
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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-04-10
*/
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
@Mapper(componentModel = "spring", uses = {DictSmallMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface DictDetailMapper extends BaseMapper<DictDetailDTO, DictDetail> {
}

View File

@ -0,0 +1,17 @@
package me.zhengjie.modules.system.service.mapper;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.system.domain.Dict;
import me.zhengjie.modules.system.service.dto.DictDTO;
import me.zhengjie.modules.system.service.dto.DictSmallDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface DictSmallMapper extends BaseMapper<DictSmallDTO, Dict> {
}

View File

@ -7,6 +7,9 @@ import java.sql.Timestamp;
<#if queryHasBigDecimal>
import java.math.BigDecimal;
</#if>
<#if dateRanges??>
import java.util.List;
</#if>
<#if queryColumns??>
import me.zhengjie.annotation.Query;
</#if>
@ -49,13 +52,8 @@ public class ${className}QueryCriteria{
</#if>
<#if dateRanges??>
<#list dateRanges as column>
// 时间段查询
@Query(type = Query.Type.GREATER_THAN, propName = "${column.changeColumnName}")
private ${column.columnType} ${column.changeColumnName}Start;
@Query(type = Query.Type.LESS_THAN, propName = "${column.changeColumnName}")
private ${column.columnType} ${column.changeColumnName}End;
@Query(type = Query.Type.BETWEEN)
private List<${column.columnType}> createTime;
</#list>
</#if>
}

View File

@ -5,6 +5,9 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class EladminSystemApplicationTests {
@ -13,5 +16,8 @@ public class EladminSystemApplicationTests {
public void contextLoads() {
}
public static void main(String[] args) {
}
}

View File

@ -52,7 +52,7 @@ public class QiniuController {
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download/list")
@GetMapping(value = "/download")
public void download(HttpServletResponse response, QiniuQueryCriteria criteria) throws IOException {
qiNiuService.downloadList(qiNiuService.queryAll(criteria), response);
}

View File

@ -2,6 +2,8 @@ package me.zhengjie.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
@ -15,9 +17,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -4,6 +4,7 @@ import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
/**
* sm.ms
@ -20,9 +21,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

View File

@ -4,6 +4,7 @@ import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
/**
* @author Zheng Jie
@ -15,9 +16,6 @@ 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;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}