mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善
This commit is contained in:
@@ -20,6 +20,7 @@ import jakarta.persistence.metamodel.EntityType;
|
||||
import lombok.*;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder;
|
||||
@@ -47,6 +48,17 @@ public class CommonQuery {
|
||||
|
||||
public static Map<String, Class> classMap = new HashMap<>();
|
||||
|
||||
private static final List<Class> supportTypes =
|
||||
List.of(
|
||||
String.class,
|
||||
Integer.class,
|
||||
Long.class,
|
||||
Double.class,
|
||||
BigDecimal.class,
|
||||
LocalDate.class,
|
||||
LocalDateTime.class,
|
||||
List.class);
|
||||
|
||||
static {
|
||||
map.put(
|
||||
Tuple.of("like", String.class),
|
||||
@@ -56,628 +68,176 @@ public class CommonQuery {
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("nlike", String.class),
|
||||
Tuple.of("rlike", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notLike(
|
||||
parseKey(root, x.key), "%" + c.convert(x.value, String.class) + "%");
|
||||
return criteriaBuilder.like(
|
||||
parseKey(root, x.key), c.convert(x.value, String.class) + "%");
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("null", String.class),
|
||||
Tuple.of("llike", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNull(parseKey(root, x.key));
|
||||
return criteriaBuilder.like(
|
||||
parseKey(root, x.key), "%" + c.convert(x.value, String.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("null", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNull(parseKey(root, x.key));
|
||||
});
|
||||
for (Class supportType : supportTypes) {
|
||||
map.put(
|
||||
Tuple.of("null", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return criteriaBuilder.isNull(parseKey(root, x.key));
|
||||
});
|
||||
}
|
||||
|
||||
map.put(
|
||||
Tuple.of("null", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNull(parseKey(root, x.key));
|
||||
});
|
||||
for (Class supportType : supportTypes) {
|
||||
|
||||
map.put(
|
||||
Tuple.of("null", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNull(parseKey(root, x.key));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("null", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNull(parseKey(root, x.key));
|
||||
});
|
||||
if (Comparable.class.isAssignableFrom(supportType)) {
|
||||
|
||||
map.put(
|
||||
Tuple.of("null", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNull(parseKey(root, x.key));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("null", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNull(parseKey(root, x.key));
|
||||
});
|
||||
if (supportType == LocalDateTime.class) {
|
||||
map.put(
|
||||
Tuple.of("eq", LocalDateTime.class),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
try {
|
||||
|
||||
map.put(
|
||||
Tuple.of("nnull", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNotNull(parseKey(root, x.key));
|
||||
});
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.value, LocalDateTime.class));
|
||||
} catch (ConversionFailedException e) {
|
||||
|
||||
map.put(
|
||||
Tuple.of("nnull", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNotNull(parseKey(root, x.key));
|
||||
});
|
||||
return criteriaBuilder.and(
|
||||
criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key),
|
||||
c.convert(
|
||||
x.value + " 00:00:00",
|
||||
LocalDateTime.class)),
|
||||
criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key),
|
||||
c.convert(
|
||||
x.value + " 23:59:59",
|
||||
LocalDateTime.class)));
|
||||
}
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("nnull", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNotNull(parseKey(root, x.key));
|
||||
});
|
||||
} else {
|
||||
|
||||
map.put(
|
||||
Tuple.of("nnull", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNotNull(parseKey(root, x.key));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("nnull", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNotNull(parseKey(root, x.key));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("eq", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, supportType));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map.put(
|
||||
Tuple.of("nnull", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNotNull(parseKey(root, x.key));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("nnull", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNotNull(parseKey(root, x.key));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("eq", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, String.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("eq", Boolean.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, Boolean.class));
|
||||
});
|
||||
for (Class supportType : supportTypes) {
|
||||
|
||||
map.put(
|
||||
Tuple.of("eq", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, Integer.class));
|
||||
});
|
||||
if (Comparable.class.isAssignableFrom(supportType)) {
|
||||
|
||||
map.put(
|
||||
Tuple.of("eq", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, Long.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("between", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return criteriaBuilder.between(
|
||||
parseKey(root, x.key),
|
||||
(Comparable) c.convert(x.min, supportType),
|
||||
(Comparable) c.convert(x.max, supportType));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("eq", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, Double.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("eq", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, BigDecimal.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("lt", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return criteriaBuilder.lessThan(
|
||||
parseKey(root, x.key),
|
||||
(Comparable) c.convert(x.value, supportType));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("eq", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDate.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("eq", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
try {
|
||||
map.put(
|
||||
Tuple.of("le", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key),
|
||||
(Comparable) c.convert(x.value, supportType));
|
||||
});
|
||||
|
||||
return criteriaBuilder.equal(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDateTime.class));
|
||||
} catch (ConversionFailedException e) {
|
||||
map.put(
|
||||
Tuple.of("gt", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThan(
|
||||
parseKey(root, x.key),
|
||||
(Comparable) c.convert(x.value, supportType));
|
||||
});
|
||||
|
||||
return criteriaBuilder.and(
|
||||
criteriaBuilder.greaterThanOrEqualTo(
|
||||
map.put(
|
||||
Tuple.of("ge", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key),
|
||||
(Comparable) c.convert(x.value, supportType));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (Class supportType : supportTypes) {
|
||||
|
||||
if (Collection.class.isAssignableFrom(supportType)) {
|
||||
|
||||
map.put(
|
||||
Tuple.of("empty", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return criteriaBuilder.isEmpty(parseKey(root, x.key));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (Class supportType : supportTypes) {
|
||||
|
||||
if (Collection.class.isAssignableFrom(supportType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
map.put(
|
||||
Tuple.of("in", supportType),
|
||||
(Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.value + " 00:00:00", LocalDateTime.class)),
|
||||
criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.value + " 23:59:59", LocalDateTime.class)));
|
||||
}
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("neq", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notEqual(
|
||||
parseKey(root, x.key), c.convert(x.value, String.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("neq", Boolean.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notEqual(
|
||||
parseKey(root, x.key), c.convert(x.value, Boolean.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("neq", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notEqual(
|
||||
parseKey(root, x.key), c.convert(x.value, Integer.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("neq", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notEqual(
|
||||
parseKey(root, x.key), c.convert(x.value, Long.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("neq", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notEqual(
|
||||
parseKey(root, x.key), c.convert(x.value, Double.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("neq", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notEqual(
|
||||
parseKey(root, x.key), c.convert(x.value, BigDecimal.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("neq", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notEqual(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDate.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("neq", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.notEqual(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDateTime.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("between", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.between(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.min, String.class),
|
||||
c.convert(x.max, String.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("between", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.between(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.min, Integer.class),
|
||||
c.convert(x.max, Integer.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("between", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.between(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.min, Long.class),
|
||||
c.convert(x.max, Long.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("between", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.between(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.min, Double.class),
|
||||
c.convert(x.max, Double.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("between", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.between(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.min, BigDecimal.class),
|
||||
c.convert(x.max, BigDecimal.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("between", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.between(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.min, LocalDate.class),
|
||||
c.convert(x.max, LocalDate.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("between", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.between(
|
||||
parseKey(root, x.key),
|
||||
c.convert(x.min, LocalDateTime.class),
|
||||
c.convert(x.max, LocalDateTime.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("lt", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThan(
|
||||
parseKey(root, x.key), c.convert(x.value, String.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("lt", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThan(
|
||||
parseKey(root, x.key), c.convert(x.value, Integer.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("lt", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThan(
|
||||
parseKey(root, x.key), c.convert(x.value, Long.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("lt", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThan(
|
||||
parseKey(root, x.key), c.convert(x.value, Double.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("lt", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThan(
|
||||
parseKey(root, x.key), c.convert(x.value, BigDecimal.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("lt", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThan(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDate.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("lt", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThan(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDateTime.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("le", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, String.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("le", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, Integer.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("le", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, Long.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("le", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, Double.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("le", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, BigDecimal.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("le", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDate.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("le", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.lessThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDateTime.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("gt", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThan(
|
||||
parseKey(root, x.key), c.convert(x.value, String.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("gt", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThan(
|
||||
parseKey(root, x.key), c.convert(x.value, Integer.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("gt", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThan(
|
||||
parseKey(root, x.key), c.convert(x.value, Long.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("gt", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThan(
|
||||
parseKey(root, x.key), c.convert(x.value, Double.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("gt", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThan(
|
||||
parseKey(root, x.key), c.convert(x.value, BigDecimal.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("gt", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThan(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDate.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("gt", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThan(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDateTime.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("ge", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, String.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("ge", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, Integer.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("ge", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, Long.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("ge", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, Double.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("ge", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, BigDecimal.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("ge", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDate.class));
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("ge", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.greaterThanOrEqualTo(
|
||||
parseKey(root, x.key), c.convert(x.value, LocalDateTime.class));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("empty", List.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isEmpty(parseKey(root, x.key));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("nempty", List.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return criteriaBuilder.isNotEmpty(parseKey(root, x.key));
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("in", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, String.class))
|
||||
.toList());
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("in", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, Integer.class))
|
||||
.toList());
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("in", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, Long.class))
|
||||
.toList());
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("in", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, Double.class))
|
||||
.toList());
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("in", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, BigDecimal.class))
|
||||
.toList());
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("in", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, LocalDate.class))
|
||||
.toList());
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("in", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, LocalDateTime.class))
|
||||
.toList());
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("nin", String.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, String.class))
|
||||
.toList())
|
||||
.not();
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("nin", Integer.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, Integer.class))
|
||||
.toList())
|
||||
.not();
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("nin", Long.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, Long.class))
|
||||
.toList())
|
||||
.not();
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("nin", Double.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, Double.class))
|
||||
.toList())
|
||||
.not();
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("nin", BigDecimal.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, BigDecimal.class))
|
||||
.toList())
|
||||
.not();
|
||||
});
|
||||
|
||||
map.put(
|
||||
Tuple.of("nin", LocalDate.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, LocalDate.class))
|
||||
.toList())
|
||||
.not();
|
||||
});
|
||||
map.put(
|
||||
Tuple.of("nin", LocalDateTime.class),
|
||||
(Root root, CriteriaBuilder criteriaBuilder, QueryItem x, ConversionService c) -> {
|
||||
return ((SqmCriteriaNodeBuilder) criteriaBuilder)
|
||||
.in(
|
||||
parseKey(root, x.key),
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, LocalDateTime.class))
|
||||
.toList())
|
||||
.not();
|
||||
});
|
||||
Arrays.stream(getArray(x))
|
||||
.map(i -> c.convert(i, supportType))
|
||||
.toList());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private List<QueryItem> items;
|
||||
@@ -687,37 +247,13 @@ public class CommonQuery {
|
||||
|
||||
private Map<String, String> extras;
|
||||
|
||||
|
||||
public String get(String key, String def){
|
||||
|
||||
if (extras == null){
|
||||
return def;
|
||||
}
|
||||
|
||||
return extras.getOrDefault(key, def);
|
||||
|
||||
}
|
||||
|
||||
public static Path parseKey(Root root, String key) {
|
||||
Iterable<String> parts = Splitter.on(".").trimResults().omitEmptyStrings().split(key);
|
||||
|
||||
Path p = null;
|
||||
for (String part : parts) {
|
||||
if (p == null) {
|
||||
p = root.get(part);
|
||||
} else {
|
||||
p = p.get(part);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private static Predicate getPredicate(
|
||||
Root root,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
QueryItem x,
|
||||
ConversionService conversionService) {
|
||||
|
||||
// 处理嵌套对象
|
||||
if (x.key.contains(".")) {
|
||||
|
||||
Function4<Root, CriteriaBuilder, QueryItem, ConversionService, Predicate> function4 =
|
||||
@@ -733,6 +269,7 @@ public class CommonQuery {
|
||||
EntityType entityType = root.getModel();
|
||||
|
||||
Attribute attribute = entityType.getAttribute(x.key);
|
||||
|
||||
switch (attribute.getPersistentAttributeType()) {
|
||||
case BASIC -> {
|
||||
Class javaType = attribute.getJavaType();
|
||||
@@ -746,21 +283,7 @@ public class CommonQuery {
|
||||
|
||||
return function4.apply(root, criteriaBuilder, x, conversionService);
|
||||
}
|
||||
case ONE_TO_ONE -> {
|
||||
Function4<Root, CriteriaBuilder, QueryItem, ConversionService, Predicate>
|
||||
function4 = map.get(Tuple.of(x.opt, String.class));
|
||||
|
||||
if (function4 == null) {
|
||||
throw new RuntimeException("无法识别的查询 " + x);
|
||||
}
|
||||
|
||||
return function4.apply(
|
||||
root,
|
||||
criteriaBuilder,
|
||||
x.withKey(x.getKey() + "." + "id"),
|
||||
conversionService);
|
||||
}
|
||||
case MANY_TO_ONE -> {
|
||||
case ONE_TO_ONE, MANY_TO_ONE -> {
|
||||
Function4<Root, CriteriaBuilder, QueryItem, ConversionService, Predicate>
|
||||
function4 = map.get(Tuple.of(x.opt, String.class));
|
||||
|
||||
@@ -781,6 +304,29 @@ public class CommonQuery {
|
||||
}
|
||||
}
|
||||
|
||||
public static Path parseKey(Root root, String key) {
|
||||
Iterable<String> parts = Splitter.on(".").trimResults().omitEmptyStrings().split(key);
|
||||
|
||||
Path p = null;
|
||||
for (String part : parts) {
|
||||
if (p == null) {
|
||||
p = root.get(part);
|
||||
} else {
|
||||
p = p.get(part);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
public String get(String key, String def) {
|
||||
|
||||
if (extras == null) {
|
||||
return def;
|
||||
}
|
||||
|
||||
return extras.getOrDefault(key, def);
|
||||
}
|
||||
|
||||
public List<Sort.Order> getOrders() {
|
||||
|
||||
if (orders == null) {
|
||||
@@ -818,15 +364,24 @@ public class CommonQuery {
|
||||
List<Predicate> orPredicates = new ArrayList<>();
|
||||
for (List<QueryItem> queryItems : group.values()) {
|
||||
|
||||
//
|
||||
|
||||
Predicate[] predicates =
|
||||
queryItems.stream()
|
||||
.map(
|
||||
y ->
|
||||
getPredicate(
|
||||
root,
|
||||
criteriaBuilder,
|
||||
y,
|
||||
conversionService))
|
||||
ObjectUtils.defaultIfNull(y.not, false)
|
||||
? getPredicate(
|
||||
root,
|
||||
criteriaBuilder,
|
||||
y,
|
||||
conversionService).not()
|
||||
: getPredicate(
|
||||
root,
|
||||
criteriaBuilder,
|
||||
y,
|
||||
conversionService)
|
||||
)
|
||||
.toArray(Predicate[]::new);
|
||||
|
||||
orPredicates.add(criteriaBuilder.and(predicates));
|
||||
@@ -1154,6 +709,7 @@ public class CommonQuery {
|
||||
@With
|
||||
@AllArgsConstructor
|
||||
public static class QueryItem {
|
||||
private Boolean not;
|
||||
private String key;
|
||||
private String opt;
|
||||
private String value;
|
||||
|
||||
@@ -953,7 +953,7 @@ select id from tmp1 where rk = 1
|
||||
if (header.equals("身份证号") || header.equals("身份证")) {
|
||||
object.put("idCard", value);
|
||||
|
||||
} else if (StringUtils.equalsAny("姓名", "员工", "部门", "岗位")) {
|
||||
} else if (StringUtils.equalsAny(header,"姓名", "员工", "部门", "岗位")) {
|
||||
|
||||
// 忽略这些字段
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
@@ -67,6 +68,22 @@ public class EmployeeService extends BaseService<EmployeeEntity, EmployeeReposit
|
||||
public EmployeeDto create(CreateEmployeeDto request) {
|
||||
EmployeeEntity entity = mapper.toEntity(request);
|
||||
|
||||
request.setIdCard(request.getIdCard().toUpperCase());
|
||||
|
||||
// 校验身份证
|
||||
|
||||
Long idCard =
|
||||
em.createQuery(
|
||||
"select count(e) from EmployeeEntity e where e.idCard = :idCard and e.organizationId = :organizationId",
|
||||
Long.class)
|
||||
.setParameter("idCard", entity.getIdCard())
|
||||
.setParameter("organizationId", entity.getOrganizationId())
|
||||
.getSingleResult();
|
||||
|
||||
if (idCard > 0) {
|
||||
throw new BizException("身份证号已存在");
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
@@ -76,8 +93,27 @@ public class EmployeeService extends BaseService<EmployeeEntity, EmployeeReposit
|
||||
@Autowired ObjectMapper objectMapper;
|
||||
|
||||
public EmployeeDto update(UpdateEmployeeDto request) {
|
||||
|
||||
request.setIdCard(request.getIdCard().toUpperCase());
|
||||
|
||||
EmployeeEntity entity = this.repository.get(request.getId());
|
||||
|
||||
if (!StringUtils.equals(request.getIdCard(), entity.getIdCard())) {
|
||||
|
||||
Long idCard =
|
||||
em.createQuery(
|
||||
"select count(e) from EmployeeEntity e where e.idCard = :idCard and e.organizationId = :organizationId and e.id !=:id",
|
||||
Long.class)
|
||||
.setParameter("idCard", entity.getIdCard())
|
||||
.setParameter("id", entity.getId())
|
||||
.setParameter("organizationId", entity.getOrganizationId())
|
||||
.getSingleResult();
|
||||
|
||||
if (idCard > 0) {
|
||||
throw new BizException("身份证号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
this.saveHis(entity);
|
||||
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
@@ -2,7 +2,23 @@ package cn.lihongjie.coal.jobPost.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CreateJobPostDto extends OrgCommonDto {}
|
||||
public class CreateJobPostDto extends OrgCommonDto {
|
||||
|
||||
|
||||
@Comment("绑定部门")
|
||||
@Column(columnDefinition = "text[]")
|
||||
@Type(ListArrayType.class)
|
||||
private List<String> departmentIds;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,25 @@ package cn.lihongjie.coal.jobPost.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class JobPostDto extends OrgCommonDto {
|
||||
|
||||
private List<String> selfEmpIds;
|
||||
|
||||
|
||||
@Comment("绑定部门")
|
||||
@Column(columnDefinition = "text[]")
|
||||
@Type(ListArrayType.class)
|
||||
private List<String> departmentIds;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,23 @@ package cn.lihongjie.coal.jobPost.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdateJobPostDto extends OrgCommonDto {}
|
||||
public class UpdateJobPostDto extends OrgCommonDto {
|
||||
|
||||
|
||||
@Comment("绑定部门")
|
||||
@Column(columnDefinition = "text[]")
|
||||
@Type(ListArrayType.class)
|
||||
private List<String> departmentIds;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,28 @@ package cn.lihongjie.coal.jobPost.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class JobPostEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@Comment("绑定部门")
|
||||
@Column(columnDefinition = "text[]")
|
||||
@Type(ListArrayType.class)
|
||||
private List<String> departmentIds;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -78,6 +78,9 @@ public class MyPostgreSQLDialect extends PostgreSQLDialect {
|
||||
|
||||
functionContributions.getFunctionRegistry().registerPattern(
|
||||
"anyString", "any(?1)", stringType);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ INSERT INTO t_emp_salary_sys_item (id, create_time, create_user_id, file_ids, up
|
||||
case "0"-> d.setScale(scale, java.math.RoundingMode.HALF_UP).doubleValue()
|
||||
case "1"-> d.multiply(BigDecimal.valueOf(10).pow(scale)).setScale(0, java.math.RoundingMode.FLOOR).divide(BigDecimal.valueOf(10).pow(scale)).doubleValue()
|
||||
case "2"-> d.multiply(BigDecimal.valueOf(10).pow(scale)).setScale(0, java.math.RoundingMode.CEILING).divide(BigDecimal.valueOf(10).pow(scale)).doubleValue()
|
||||
default -> throw new IllegalArgumentException("Illegal mode: ${mode}")
|
||||
default -> throw new IllegalArgumentException("Illegal mode: " + mode)
|
||||
|
||||
}
|
||||
}', '2') on conflict (id) do nothing;
|
||||
|
||||
2
src/main/resources/db/migration/V54__idcard.sql
Normal file
2
src/main/resources/db/migration/V54__idcard.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
update t_employee set id_card = upper(id_card) where id_card is not null and id_card like '%x';
|
||||
update t_emp_salary set id_card = upper(id_card) where id_card is not null and id_card like '%x';
|
||||
Reference in New Issue
Block a user