提交 823d1523 编写于 作者: sq3536's avatar sq3536

提交

上级 30459151
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
<description>Ibzdata Boot</description> <description>Ibzdata Boot</description>
<dependencies> <dependencies>
<dependency>
<groupId>cn.ibizlab</groupId>
<artifactId>ibzdata-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>cn.ibizlab</groupId> <groupId>cn.ibizlab</groupId>
<artifactId>ibzdata-core</artifactId> <artifactId>ibzdata-core</artifactId>
......
...@@ -15,9 +15,113 @@ ...@@ -15,9 +15,113 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>cn.ibizlab</groupId> <groupId>org.springframework.data</groupId>
<artifactId>ibzdata-util</artifactId> <artifactId>spring-data-commons</artifactId>
<version>${project.version}</version> </dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem-spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo-shaded</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!-- Swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<!-- drools -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-json-converter</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-conf</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
......
package cn.ibizlab.core.data.domain; package cn.ibizlab.core.data.domain;
import java.sql.Timestamp;
import java.util.*; import java.util.*;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import cn.ibizlab.core.data.dto.BaseData; import cn.ibizlab.core.data.dto.BaseData;
import cn.ibizlab.core.data.model.POSchema; import cn.ibizlab.core.data.model.POSchema;
...@@ -14,19 +10,10 @@ import com.alibaba.fastjson.annotation.JSONField; ...@@ -14,19 +10,10 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.DigestUtils; import cn.ibizlab.core.data.dto.DataObject;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.enums.DupCheck;
import java.io.Serializable; import java.io.Serializable;
import lombok.*; import lombok.*;
import org.springframework.data.annotation.Transient;
import cn.ibizlab.util.annotation.Audit;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -41,12 +28,11 @@ import org.springframework.util.StringUtils; ...@@ -41,12 +28,11 @@ import org.springframework.util.StringUtils;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel("业务实体") @ApiModel("业务实体")
public class DOModel extends EntityBase implements Serializable { public class DOModel implements Serializable {
/** /**
* 标识 * 标识
*/ */
@DEField(isKeyField = true)
@JSONField(name = "id") @JSONField(name = "id")
@JsonProperty("id") @JsonProperty("id")
@ApiModelProperty("标识") @ApiModelProperty("标识")
......
...@@ -16,16 +16,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; ...@@ -16,16 +16,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.enums.DupCheck;
import java.io.Serializable; import java.io.Serializable;
import lombok.*; import lombok.*;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import cn.ibizlab.util.annotation.Audit;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -40,12 +33,11 @@ import org.springframework.util.StringUtils; ...@@ -40,12 +33,11 @@ import org.springframework.util.StringUtils;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel("数据传输对象") @ApiModel("数据传输对象")
public class DTOModel extends EntityBase implements Serializable { public class DTOModel implements Serializable {
/** /**
* 标识 * 标识
*/ */
@DEField(isKeyField = true)
@JSONField(name = "id") @JSONField(name = "id")
@JsonProperty("id") @JsonProperty("id")
@ApiModelProperty("标识") @ApiModelProperty("标识")
......
package cn.ibizlab.core.data.domain; package cn.ibizlab.core.data.domain;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.util.ObjectUtils;
import org.springframework.util.DigestUtils;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.enums.DupCheck;
import java.io.Serializable; import java.io.Serializable;
import lombok.*; import lombok.*;
import org.springframework.data.annotation.Transient;
import cn.ibizlab.util.annotation.Audit;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -37,12 +18,12 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -37,12 +18,12 @@ import io.swagger.annotations.ApiModelProperty;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel("持久化对象") @ApiModel("持久化对象")
public class POModel extends EntityBase implements Serializable { public class POModel implements Serializable {
/** /**
* 标识 * 标识
*/ */
@DEField(isKeyField = true)
@JSONField(name = "id") @JSONField(name = "id")
@JsonProperty("id") @JsonProperty("id")
@ApiModelProperty("标识") @ApiModelProperty("标识")
......
package cn.ibizlab.core.data.dto; package cn.ibizlab.core.data.dto;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -163,23 +160,7 @@ public class DataObj<K,V> extends HashMap<K,V> { ...@@ -163,23 +160,7 @@ public class DataObj<K,V> extends HashMap<K,V> {
public <T> T copyTo(T targetEntity, boolean bIncEmpty){ public <T> T copyTo(T targetEntity, boolean bIncEmpty){
if(targetEntity instanceof EntityBase){ if(targetEntity instanceof DataObj){
for(K field : this.keySet()){
Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
((EntityBase)targetEntity).set((String)field,value);
}
}
}
else if(targetEntity instanceof DTOBase){
for(K field : this.keySet()){
Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
((DTOBase)targetEntity).set(((String)field).toLowerCase(),value);
}
}
}
else if(targetEntity instanceof DataObj){
for(K field : this.keySet()){ for(K field : this.keySet()){
Object value=this.get(field); Object value=this.get(field);
if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){ if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && bIncEmpty ){
......
package cn.ibizlab.core.data.dto; package cn.ibizlab.core.data.dto;
import cn.ibizlab.util.filter.QueryWrapperContext; import cn.ibizlab.core.data.filter.QueryWrapperContext;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
...@@ -2,27 +2,20 @@ package cn.ibizlab.core.data.dto; ...@@ -2,27 +2,20 @@ package cn.ibizlab.core.data.dto;
import cn.ibizlab.core.data.model.POSchema; import cn.ibizlab.core.data.model.POSchema;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.filter.QueryFilter; import cn.ibizlab.core.data.filter.QueryFilter;
import cn.ibizlab.util.filter.QueryWrapperContext; import cn.ibizlab.core.data.filter.QueryWrapperContext;
import cn.ibizlab.util.helper.DEFieldCacheMap;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.security.AuthenticationUser; import cn.ibizlab.util.security.AuthenticationUser;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.lang.reflect.ParameterizedType;
import java.util.*; import java.util.*;
public class FilterData<T> extends BaseData public class FilterData<T> extends BaseData
......
package cn.ibizlab.core.data.filter; package cn.ibizlab.core.data.filter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import lombok.*; import lombok.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import cn.ibizlab.util.filter.SearchContextBase;
/** /**
* ServiceApi数据实体[DOModel] 查询条件对象 * ServiceApi数据实体[DOModel] 查询条件对象
......
package cn.ibizlab.core.data.filter; package cn.ibizlab.core.data.filter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import lombok.*; import lombok.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import cn.ibizlab.util.filter.SearchContextBase;
/** /**
* ServiceApi数据实体[DTOModel] 查询条件对象 * ServiceApi数据实体[DTOModel] 查询条件对象
......
package cn.ibizlab.core.data.filter; package cn.ibizlab.core.data.filter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import lombok.*; import lombok.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import cn.ibizlab.util.filter.SearchContextBase;
/** /**
* ServiceApi数据实体[POModel] 查询条件对象 * ServiceApi数据实体[POModel] 查询条件对象
......
package cn.ibizlab.core.data.filter;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mongodb.QueryBuilder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@Slf4j
@Data
public class QueryBuildContext extends SearchContextBase{
@JsonIgnore
@JSONField(serialize = false)
private QueryBuilder selectCond=new QueryBuilder();
public QueryBuilder getSearchCond(){
return this.selectCond;
}
/**
* 填充自定义查询条件
* @return
*/
public QueryBuilder getSelectCond() {
if(!ObjectUtils.isEmpty(filter)){
QueryBuilder queryBuilder=parseQueryFilter(filter);
if(!ObjectUtils.isEmpty(queryBuilder)){
selectCond.and(queryBuilder.get());
}
}
return selectCond;
}
/**
* 解析自定义查询条件
* @param queryFilter
* @return
*/
private QueryBuilder parseQueryFilter(QueryFilter queryFilter){
if(ObjectUtils.isEmpty(queryFilter.get$and()) && ObjectUtils.isEmpty(queryFilter.get$or()) && ObjectUtils.isEmpty(queryFilter.any())) {
return null;
}
QueryBuilder rsBuilder=QueryBuilder.start();
QueryBuilder fieldBuilder=parseFieldMap(queryFilter.any());
QueryBuilder orBuilder=parseOrQueryFilter(queryFilter.get$or());
QueryBuilder andBuilder=parseAndQueryFilter(queryFilter.get$and());
if(!ObjectUtils.isEmpty(fieldBuilder)){
rsBuilder.and(fieldBuilder.get());
}
if(!ObjectUtils.isEmpty(orBuilder)){
rsBuilder.and(orBuilder.get());
}
if(!ObjectUtils.isEmpty(andBuilder)){
rsBuilder.and(andBuilder.get());
}
return rsBuilder;
}
/**
* 解析自定义条件[or]
* @param queryFilters
* @return
*/
private QueryBuilder parseOrQueryFilter(List<QueryFilter> queryFilters) {
QueryBuilder orBuilder =new QueryBuilder();
if(queryFilters==null || queryFilters.size()==0){
return null;
}
for(QueryFilter queryFilter: queryFilters){
QueryBuilder queryBuilder=parseQueryFilter(queryFilter);
if(!ObjectUtils.isEmpty(queryBuilder)){
orBuilder.or(queryBuilder.get());
}
}
return orBuilder;
}
/**
* 解析自定义条件[and]
* @param queryFilters
* @return
*/
private QueryBuilder parseAndQueryFilter(List<QueryFilter> queryFilters) {
QueryBuilder orBuilder =new QueryBuilder();
if(queryFilters==null || queryFilters.size()==0){
return null;
}
for(QueryFilter queryFilter: queryFilters){
QueryBuilder queryBuilder=parseQueryFilter(queryFilter);
if(!ObjectUtils.isEmpty(queryBuilder)){
orBuilder.and(queryBuilder.get());
}
}
return orBuilder;
}
/**
* 解析自定义条件[字段条件]
* @param fieldMap
* @return
*/
private QueryBuilder parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) {
if(fieldMap.size()==0) {
return null;
}
QueryBuilder fieldBuilders=QueryBuilder.start();
for(Map.Entry<String, QueryFilter.SegmentCond> entry: fieldMap.entrySet()){
getSegmentCondSql(entry.getKey(),entry.getValue(),fieldBuilders);
}
return fieldBuilders;
}
/**
* 解析自定义条件[字段条件]
* @param fieldName
* @param segmentCond
* @param fieldBuilder
*/
private void getSegmentCondSql(String fieldName, QueryFilter.SegmentCond segmentCond,QueryBuilder fieldBuilder) {
Map<String , Object> segmentCondMap = segmentCond.any();
for(Map.Entry<String , Object> entry: segmentCondMap.entrySet()){
Object value=entry.getValue();
switch (entry.getKey()){
case "$eq":
fieldBuilder.and(QueryBuilder.start().and(fieldName).is(value).get());
break;
case "$ne":
fieldBuilder.and(QueryBuilder.start().not().and(fieldName).is(value).get());
break;
case "$gt":
fieldBuilder.and(QueryBuilder.start().and(fieldName).greaterThan(value).get());
break;
case "$gte":
fieldBuilder.and(QueryBuilder.start().and(fieldName).greaterThanEquals(value).get());
break;
case "$lt":
fieldBuilder.and(QueryBuilder.start().and(fieldName).lessThan(value).get());
break;
case "$lte":
fieldBuilder.and(QueryBuilder.start().and(fieldName).lessThanEquals(value).get());
break;
case "$null":
fieldBuilder.and(QueryBuilder.start().and(fieldName).exists(null).get());
break;
case "$notNull":
fieldBuilder.and(QueryBuilder.start().and(fieldName).exists(true).and(fieldName).notEquals("").and(fieldName).notEquals(null).get());
break;
case "$in":
fieldBuilder.and(QueryBuilder.start().and(fieldName).in(value).get());
break;
case "$notIn":
fieldBuilder.and(QueryBuilder.start().and(fieldName).not().in(value).get());
break;
case "$like":
Pattern likePattern = Pattern.compile("^.*" + value + ".*$", Pattern.CASE_INSENSITIVE);
fieldBuilder.and(QueryBuilder.start().and(fieldName).regex(likePattern).get());
break;
case "$startsWith":
Pattern startsWithPattern = Pattern.compile(value + ".*$", Pattern.CASE_INSENSITIVE);
fieldBuilder.and(QueryBuilder.start().and(fieldName).regex(startsWithPattern).get());
break;
case "$endsWith":
Pattern endsWithPattern = Pattern.compile("^.*" + value + "$", Pattern.CASE_INSENSITIVE);
fieldBuilder.and(QueryBuilder.start().and(fieldName).regex(endsWithPattern).get());
break;
case "$exists":
break;
case "$notExists":
break;
}
}
}
}
package cn.ibizlab.core.data.filter;
import com.fasterxml.jackson.annotation.*;
import org.springframework.data.annotation.Transient;
import java.util.*;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class QueryFilter {
public static QueryFilter createQuery()
{
QueryFilter queryFilter=new QueryFilter();
return queryFilter;
}
public QueryFilter eq(String column,Object value) {
return op(column, SegmentCond.eq(value));
}
public QueryFilter ne(String column,Object value) {
return op(column, SegmentCond.ne(value));
}
public QueryFilter gt(String column,Object value) {
return op(column, SegmentCond.gt(value));
}
public QueryFilter ge(String column,Object value) {
return op(column, SegmentCond.ge(value));
}
public QueryFilter lt(String column,Object value) {
return op(column, SegmentCond.lt(value));
}
public QueryFilter le(String column,Object value) {
return op(column, SegmentCond.le(value));
}
public QueryFilter isnull(String column) {
return op(column, SegmentCond.isnull());
}
public QueryFilter isnotnull(String column) {
return op(column, SegmentCond.isnotnull());
}
public QueryFilter in(String column,Collection value) {
return op(column, SegmentCond.in(value));
}
public QueryFilter notin(String column,Collection value) {
return op(column, SegmentCond.notin(value));
}
public QueryFilter like(String column,String value) {
return op(column, SegmentCond.like(value));
}
public QueryFilter startsWith(String column,String value) {
return op(column, SegmentCond.startsWith(value));
}
public QueryFilter endsWith(String column,String value) {
return op(column, SegmentCond.endsWith(value));
}
public QueryFilter between(String column,Object from,Object to) {
return op(column, SegmentCond.between(from,to));
}
@JsonIgnore
@Transient
private Map<String,SegmentCond> map;
private Map<String,SegmentCond> getMap()
{
if(map==null) {
map=new LinkedHashMap<>();
}
return map;
}
@JsonAnyGetter
public Map<String , SegmentCond> any() {
return getMap();
}
@JsonAnySetter
public void set(String column, SegmentCond value) {
getMap().put(column,value);
}
@JsonProperty(index = 999)
private List<QueryFilter> $or;
public List<QueryFilter> get$or() {
return $or;
}
public void set$or(List<QueryFilter> $or) {
this.$or = $or;
}
public QueryFilter or(QueryFilter... ors)
{
if ($or == null) {
$or = new ArrayList();
}
Collections.addAll($or, ors);
return this;
}
@JsonProperty(index = 999)
private List<QueryFilter> $and;
public List<QueryFilter> get$and() {
return $and;
}
public void set$and(List<QueryFilter> $and) {
this.$and = $and;
}
public QueryFilter and(QueryFilter... ands)
{
if ($and == null) {
$and = new ArrayList();
}
Collections.addAll($and, ands);
return this;
}
@Override
public String toString() {
return "QueryFilter{" +
"map=" + map +
", $or=" + $or +
'}';
}
private QueryFilter op(String column, SegmentCond segmentCond) {
if(this.getMap().containsKey(column)) {
((SegmentCond)this.getMap().get(column)).getMap().putAll(segmentCond.getMap());
}
else {
this.getMap().put(column,segmentCond);
}
return this;
}
public static class SegmentCond {
@JsonIgnore
@Transient
private Map<String,Object> map;
@Override
public String toString() {
return "SegmentCond{" +
"map=" + map +
'}';
}
private Map<String,Object> getMap()
{
if(map==null) {
map=new LinkedHashMap<>();
}
return map;
}
@JsonAnyGetter
public Map<String , Object> any() {
return getMap();
}
@JsonAnySetter
public void set(String column, Object value) {
getMap().put(column,value);
}
public static SegmentCond eq(Object value) {
return op(Segment.EQ,value);
}
public static SegmentCond ne(Object value) {
return op(Segment.NE,value);
}
public static SegmentCond gt(Object value) {
return op(Segment.GT,value);
}
public static SegmentCond ge(Object value) {
return op(Segment.GE,value);
}
public static SegmentCond lt(Object value) {
return op(Segment.LT,value);
}
public static SegmentCond le(Object value) {
return op(Segment.LE,value);
}
public static SegmentCond isnull() {
return op(Segment.IS_NULL,true);
}
public static SegmentCond isnotnull() {
return op(Segment.IS_NOT_NULL,true);
}
public static SegmentCond in(Collection value) {
return op(Segment.IN,value);
}
public static SegmentCond notin(Collection value) {
return op(Segment.NOTIN,value);
}
public static SegmentCond like(String value) {
return op(Segment.LIKE,value);
}
public static SegmentCond startsWith(String value) {
return op(Segment.LEFTLIKE,value);
}
public static SegmentCond endsWith(String value) {
return op(Segment.RIGHTLIKE,value);
}
public static SegmentCond between(Object from,Object to) {
return op(Segment.GE,from).op(Segment.LT,to);
}
private static SegmentCond op(Segment segment,Object value) {
SegmentCond segmentCond=new SegmentCond();
segmentCond.getMap().put(segment.keyword,value);
return segmentCond;
}
}
public enum Segment {
AND("$and"),
OR("$or"),
EQ("$eq"),
NE("$ne"),
GT("$gt"),
GE("$gte"),
LT("$lt"),
LE("$lte"),
IS_NULL("$null"),
IS_NOT_NULL("$notNull"),
IN("$in"),
NOTIN("$notIn"),
LIKE("$like"),
LEFTLIKE("$startsWith"),
RIGHTLIKE("$endsWith"),
EXISTS("$exists"),
NOTEXISTS("$notExists");
private final String keyword;
Segment(final String keyword) {
this.keyword = keyword;
}
}
}
package cn.ibizlab.core.data.filter;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Sort;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.lang.reflect.ParameterizedType;
import java.util.*;
import java.util.function.Consumer;
@Slf4j
@Data
public class QueryWrapperContext<T> extends SearchContextBase{
@JsonIgnore
@JSONField(serialize = false)
private QueryWrapper<T> selectCond=new QueryWrapper<T>();
/**
* 解析查询上下文中的参数,构建mybatis-plus分页对象
* @return
*/
@JsonIgnore
@JSONField(serialize = false)
public Page getPages(){
Page page;
List<String> asc_fieldList = new ArrayList<>();
List<String> desc_fieldList = new ArrayList<>();
int currentPage=getPageable().getPageNumber();
int pageSize=getPageable().getPageSize();
//构造mybatis-plus分页
if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize)) {
page=new Page(1,Short.MAX_VALUE);
}
else {
page=new Page(currentPage+1,pageSize);
}
//构造mybatis-plus排序
Sort sort = getPageable().getSort();
Iterator<Sort.Order> it_sort = sort.iterator();
if(ObjectUtils.isEmpty(it_sort)) {
return page;
}
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
Class<T> type = (Class<T>)parameterizedType.getActualTypeArguments()[0];
while (it_sort.hasNext()) {
Sort.Order sort_order = it_sort.next();
if(sort_order.getDirection()== Sort.Direction.ASC){
asc_fieldList.add(sort_order.getProperty());
}
else if(sort_order.getDirection()== Sort.Direction.DESC){
desc_fieldList.add(sort_order.getProperty());
}
}
if(asc_fieldList.size()>0){
page.setAscs(asc_fieldList);
}
if(desc_fieldList.size()>0){
page.setDescs(desc_fieldList);
}
return page;
}
public QueryWrapper<T> getSearchCond(){
return this.selectCond;
}
/**
* 填充自定义查询条件
* @return
*/
public QueryWrapper<T> getSelectCond() {
if(!ObjectUtils.isEmpty(filter)){
Consumer queryWrapper = parseQueryFilter(filter);
if(!ObjectUtils.isEmpty(queryWrapper)){
selectCond.and(queryWrapper);
}
}
return selectCond;
}
/**
* 解析自定义查询条件
* @param queryFilter
* @return
*/
private Consumer<QueryWrapper<T>> parseQueryFilter(QueryFilter queryFilter){
if(queryFilter.any().size()==0 && queryFilter.get$or()==null && queryFilter.get$and()==null) {
return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
Consumer fieldConsumer=parseFieldMap(queryFilter.any());
Consumer orConsumer=parseOrQueryFilter(queryFilter.get$or());
Consumer andConsumer=parseAndQueryFilter(queryFilter.get$and());
if(!ObjectUtils.isEmpty(fieldConsumer)){
queryWrapper.and(fieldConsumer);
}
if(!ObjectUtils.isEmpty(orConsumer)){
queryWrapper.and(orConsumer);
}
if(!ObjectUtils.isEmpty(andConsumer)){
queryWrapper.and(andConsumer);
}
};
return consumer;
}
/**
* 解析自定义条件[or]
* @param queryFilters
* @return
*/
private Consumer<QueryWrapper<T>> parseOrQueryFilter(List<QueryFilter> queryFilters) {
if(queryFilters==null || queryFilters.size()==0)
return null;
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(QueryFilter queryFilter: queryFilters){
Consumer tempQueryWrapper=parseQueryFilter(queryFilter);
queryWrapper.or(tempQueryWrapper);
}
};
return consumer;
}
/**
* 解析自定义条件[and]
* @param queryFilters
* @return
*/
private Consumer<QueryWrapper<T>> parseAndQueryFilter(List<QueryFilter> queryFilters) {
if(queryFilters==null || queryFilters.size()==0) {
return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(QueryFilter queryFilter: queryFilters){
Consumer tempQueryWrapper=parseQueryFilter(queryFilter);
queryWrapper.and(tempQueryWrapper);
}
};
return consumer;
}
/**
* 解析自定义条件[字段条件]
* @param fieldMap
* @return
*/
private Consumer<QueryWrapper<T>> parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) {
if(fieldMap.size()==0) {
return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(Map.Entry<String, QueryFilter.SegmentCond> field: fieldMap.entrySet()){
String fieldName=field.getKey();
QueryFilter.SegmentCond segmentCond=field.getValue();
Map<String , Object> segmentCondMap = segmentCond.any();
for(Map.Entry<String , Object> fieldCond: segmentCondMap.entrySet()){
Object value=fieldCond.getValue();
switch (fieldCond.getKey()){
case "$eq":
queryWrapper.eq(fieldName,value);
break;
case "$ne":
queryWrapper.ne(fieldName,value);
break;
case "$gt":
queryWrapper.gt(fieldName,value);
break;
case "$gte":
queryWrapper.ge(fieldName,value);
break;
case "$lt":
queryWrapper.lt(fieldName,value);
break;
case "$lte":
queryWrapper.le(fieldName,value);
break;
case "$null":
queryWrapper.isNull(fieldName);
break;
case "$notNull":
queryWrapper.isNotNull(fieldName);
break;
case "$in":
queryWrapper.in(fieldName,(Collection)value);
break;
case "$notIn":
queryWrapper.notIn(fieldName,(Collection)value);
break;
case "$like":
queryWrapper.like(fieldName,value);
break;
case "$startsWith":
queryWrapper.likeRight(fieldName,value);
break;
case "$endsWith":
queryWrapper.likeLeft(fieldName,value);
break;
case "$exists":
break;
case "$notExists":
break;
}
}
}
};
return consumer;
}
}
package cn.ibizlab.core.data.filter;
import cn.ibizlab.util.security.AuthenticationUser;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Data
public class SearchContextBase{
/**
* 自定义查询条件
*/
@JsonProperty("customcond")
public String customCond;
/**
* 自定义查询参数
*/
@JsonProperty("customparams")
public String customParams;
/**
* 快速搜索
*/
@JsonProperty("query")
public String query;
/**
* 条件表达式
*/
@JsonProperty("filter")
public QueryFilter filter;
/**
* 数据查询
*/
public List dataQueryList;
/**
* 当前页数
*/
public int page=0;
/**
* 每页显示条数
*/
public int size=20;
/**
* 排序
*/
public String sort;
/**
* 排序对象
*/
@JsonIgnore
public Sort pageSort;
/**
* 工作流步骤标识
*/
public String userTaskId;
/**
* 工作流流程标识
*/
public String processDefinitionKey;
/**
* 获取工作流步骤标识
*/
public String getUserTaskId() {
if(StringUtils.isEmpty(userTaskId)){
Object taskId=params.get("usertaskid");
return StringUtils.isEmpty(taskId)?null:String.valueOf(taskId);
}else{
return userTaskId;
}
}
/**
* 获取工作流流程标识
* @return
*/
public String getProcessDefinitionKey() {
if(StringUtils.isEmpty(processDefinitionKey)){
Object processKey=params.get("processdefinitionkey");
return StringUtils.isEmpty(processKey)?null:String.valueOf(processKey);
}
else{
return processDefinitionKey;
}
}
/**
* 获取分页参数
* @return
*/
public Pageable getPageable() {
if(ObjectUtils.isEmpty(pageSort)) {
return PageRequest.of(page,size);
}
else {
return PageRequest.of(page,size,pageSort);
}
}
/**
* 设置排序值
* @param strSort
*/
public void setSort(String strSort) {
this.sort=strSort;
if(!StringUtils.isEmpty(strSort)){
String sortArr[]=strSort.split(",");
String sortField=sortArr[0];
String sortDirection=sortArr[1];
if(sortDirection.equalsIgnoreCase("asc")){
this.pageSort=Sort.by(Sort.Direction.ASC,sortField);
}
else if(sortDirection.equalsIgnoreCase("desc")){
this.pageSort=Sort.by(Sort.Direction.DESC,sortField);
}
}
}
/**
* 上下文参数
*/
Map<String,Object> params = new HashMap<String,Object>() ;
/**
* 获取数据上下文
* @return
*/
public Map<String,Object> getDatacontext() {
return params;
}
/**
* 获取网页请求上下文
* @return
*/
public Map<String,Object> getWebcontext() {
return params;
}
/**
* 获取用户上下文
* @return
*/
@JsonIgnore
public Map<String,Object> getSessioncontext() {
return AuthenticationUser.getAuthenticationUser().getSessionParams();
}
@JsonAnyGetter
public Map<String , Object> any() {
return params;
}
@JsonAnySetter
public void set(String name, Object value) {
params.put(name, value);
}
}
package cn.ibizlab.core.data.lite; package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.core.data.dto.DataObject;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
......
package cn.ibizlab.core.data.lite; package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.core.data.dto.DataObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......
package cn.ibizlab.core.data.lite; package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.core.data.dto.DataObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
/** /**
* 实体[MetaModel] 服务对象接口 * 实体[MetaModel] 服务对象接口
*/ */
@FeignClient(value = "${ibiz.ref.service.ibzlite-api:ibzlite-api}", contextId = "LiteModel", fallback = LiteModelFallback.class) @FeignClient(value = "${ibiz.ref.service.ibzlite-api:ibzlite-api}", contextId = "DataLiteModel", fallback = LiteModelFallback.class)
public interface LiteModelFeignClient { public interface LiteModelFeignClient {
......
...@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component; ...@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.io.File; import java.io.File;
@Component @Component("DataLiteStorage")
public class LiteStorage { public class LiteStorage {
public static String MODEL_PATH; public static String MODEL_PATH;
......
package cn.ibizlab.core.data.lite; package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.core.data.dto.DataObject;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
......
package cn.ibizlab.core.data.lite; package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.core.data.dto.DataObject;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
......
package cn.ibizlab.core.data.lite; package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.domain.EntityBase; import cn.ibizlab.core.data.dto.DataObject;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -29,21 +28,12 @@ public class Setting { ...@@ -29,21 +28,12 @@ public class Setting {
return DataObject.getStringValue(getMap(configString).get(propertyName),""); return DataObject.getStringValue(getMap(configString).get(propertyName),"");
} }
public static <T extends EntityBase> T getEntity(String configString, T entityBase)
{
if(entityBase!=null) {
Map map=getMap(configString);
map.keySet().forEach(key->{
entityBase.set(key.toString(),map.get(key));
});
}
return entityBase;
}
public static Map getMap(String configString) public static Map getMap(String configString)
{ {
Map map=new HashMap(); Map map=new HashMap();
map.put("param",configString); map.put("tparam",configString);
if(!(StringUtils.isEmpty(configString))) if(!(StringUtils.isEmpty(configString)))
{ {
try try
......
package cn.ibizlab.core.data.model; package cn.ibizlab.core.data.model;
import cn.ibizlab.core.data.dto.DataObj; import cn.ibizlab.core.data.dto.DataObj;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......
package cn.ibizlab.core.data.model; package cn.ibizlab.core.data.model;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.core.data.dto.DataObject;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
...@@ -10,7 +10,6 @@ import lombok.Getter; ...@@ -10,7 +10,6 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
......
package cn.ibizlab.api.rest; package cn.ibizlab.core.data.rest;
import cn.ibizlab.core.data.dto.BaseData; import cn.ibizlab.core.data.dto.BaseData;
import cn.ibizlab.core.data.dto.FilterData; import cn.ibizlab.core.data.dto.FilterData;
import cn.ibizlab.core.data.dto.RequestData; import cn.ibizlab.core.data.dto.RequestData;
import cn.ibizlab.core.data.dto.ResponseData; import cn.ibizlab.core.data.dto.ResponseData;
import cn.ibizlab.core.data.service.IDataService; import cn.ibizlab.core.data.service.IDataService;
import cn.ibizlab.util.filter.SearchContextBase;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -18,7 +17,6 @@ import org.springframework.validation.annotation.Validated; ...@@ -18,7 +17,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.logging.Filter;
@Slf4j @Slf4j
@Api(tags = {"数据" }) @Api(tags = {"数据" })
......
...@@ -5,13 +5,10 @@ import cn.ibizlab.core.data.dto.BaseData; ...@@ -5,13 +5,10 @@ import cn.ibizlab.core.data.dto.BaseData;
import cn.ibizlab.core.data.dto.FilterData; import cn.ibizlab.core.data.dto.FilterData;
import cn.ibizlab.core.data.dto.RequestData; import cn.ibizlab.core.data.dto.RequestData;
import cn.ibizlab.core.data.dto.ResponseData; import cn.ibizlab.core.data.dto.ResponseData;
import cn.ibizlab.util.filter.SearchContextBase;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List; import java.util.List;
public interface IDataService public interface IDataService
......
package cn.ibizlab.core.data.service; package cn.ibizlab.core.data.service;
import cn.ibizlab.core.data.domain.DOModel; import cn.ibizlab.core.data.domain.DOModel;
import cn.ibizlab.core.data.lite.EntityModel; import cn.ibizlab.core.data.lite.*;
import cn.ibizlab.core.data.lite.LiteStorage;
import cn.ibizlab.core.data.model.PojoSchema; import cn.ibizlab.core.data.model.PojoSchema;
import cn.ibizlab.core.data.model.TransUtils; import cn.ibizlab.core.data.model.TransUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.File; import java.io.File;
...@@ -29,13 +31,78 @@ public class ModelService { ...@@ -29,13 +31,78 @@ public class ModelService {
@Value("${ibiz.model.path:/app/file/model/}") @Value("${ibiz.model.path:/app/file/model/}")
private String modelPath; private String modelPath;
public String getModelPath()
{
if(modelPath.equals(File.separator))
return modelPath.substring(0,modelPath.length()-1);
return modelPath;
}
@Autowired @Autowired
private IDOModelService doModelService; private IDOModelService doModelService;
@Autowired
private LiteModelFeignClient liteService;
@Autowired
@Lazy
private DynamicModelService dynamicService;
public DOModel getDOModel(String system,String entity) public DOModel getDOModel(String system,String entity)
{ {
return doModelService.get(system+".domain."+entity); return doModelService.get(system+".domain."+entity);
} }
@Cacheable( value="syspssystem",key = "'row:sys-dst-sys-models'")
public Map<String, DstSystemModel> getAllSystemModels()
{
Map<String,DstSystemModel> models=dynamicService.findAllDynamicModel();
List<DstSystemModel> liteSystems=liteService.getSysApps();
if(!ObjectUtils.isEmpty(liteSystems))
{
liteSystems.forEach(dstSystemModel->{
String system=dstSystemModel.getPssystemid();
if(!models.containsKey(system))
models.put(system, dstSystemModel);
if ((!system.toLowerCase().equals(system))&&(!models.containsKey(system.toLowerCase())))
models.put(system.toLowerCase(), dstSystemModel);
});
}
File modelDir=new File(getModelPath());
if(modelDir.exists())
{
for(File sysDir:modelDir.listFiles())
{
if(Files.exists(Paths.get(sysDir.getAbsolutePath(),"repo","domain")))
{
String system=sysDir.getName();
DstSystemModel dstSystemModel=new DstSystemModel().setPssystemid(system).setPssystemname(system);
if(!models.containsKey(system))
models.put(system, dstSystemModel);
if ((!system.toLowerCase().equals(system))&&(!models.containsKey(system.toLowerCase())))
models.put(system.toLowerCase(), dstSystemModel);
}
}
}
return models;
}
@Cacheable( value="meta-entities", key = "'system:'+#p0")
public Map<String,String> getEntitiesBySystem(String system) throws Exception {
Map<String, String> entities = new HashMap<>();
Map<String, MetaEntityModel> entityModels = dynamicService.getEntities(system);
entityModels.entrySet().forEach(entity->{
entities.put(entity.getKey(),entity.getValue().getEntityName());
});
return null;
}
} }
...@@ -4,7 +4,6 @@ import cn.ibizlab.core.data.domain.DOModel; ...@@ -4,7 +4,6 @@ import cn.ibizlab.core.data.domain.DOModel;
import cn.ibizlab.core.data.dto.*; import cn.ibizlab.core.data.dto.*;
import cn.ibizlab.core.data.service.IDataService; import cn.ibizlab.core.data.service.IDataService;
import cn.ibizlab.core.data.service.ModelService; import cn.ibizlab.core.data.service.ModelService;
import cn.ibizlab.util.filter.SearchContextBase;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
...@@ -15,7 +14,6 @@ import org.springframework.util.ObjectUtils; ...@@ -15,7 +14,6 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
......
package cn.ibizlab.core.data.service.impl; package cn.ibizlab.core.data.service.impl;
import cn.ibizlab.core.data.domain.DOModel;
import cn.ibizlab.core.data.domain.DOModel; import cn.ibizlab.core.data.domain.DOModel;
import cn.ibizlab.core.data.dto.*; import cn.ibizlab.core.data.dto.*;
import cn.ibizlab.core.data.filter.DOModelSearchContext;
import cn.ibizlab.core.data.mapper.DbDataMapper; import cn.ibizlab.core.data.mapper.DbDataMapper;
import cn.ibizlab.core.data.model.POSchema; import cn.ibizlab.core.data.model.POSchema;
import cn.ibizlab.core.data.model.PojoSchema;
import cn.ibizlab.core.data.service.IDOModelService;
import cn.ibizlab.core.data.service.IDataService; import cn.ibizlab.core.data.service.IDataService;
import cn.ibizlab.core.data.service.ModelService; import cn.ibizlab.core.data.service.ModelService;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.filter.SearchContextBase;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -21,7 +14,6 @@ import org.springframework.data.domain.Page; ...@@ -21,7 +14,6 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.io.Serializable; import java.io.Serializable;
......
...@@ -6,7 +6,6 @@ import cn.ibizlab.core.data.dto.FilterData; ...@@ -6,7 +6,6 @@ import cn.ibizlab.core.data.dto.FilterData;
import cn.ibizlab.core.data.dto.RequestData; import cn.ibizlab.core.data.dto.RequestData;
import cn.ibizlab.core.data.dto.ResponseData; import cn.ibizlab.core.data.dto.ResponseData;
import cn.ibizlab.core.data.service.IDataService; import cn.ibizlab.core.data.service.IDataService;
import cn.ibizlab.util.filter.SearchContextBase;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
......
...@@ -29,8 +29,6 @@ import cn.ibizlab.core.data.domain.POModel; ...@@ -29,8 +29,6 @@ import cn.ibizlab.core.data.domain.POModel;
import cn.ibizlab.core.data.filter.POModelSearchContext; import cn.ibizlab.core.data.filter.POModelSearchContext;
import cn.ibizlab.core.data.service.IPOModelService; import cn.ibizlab.core.data.service.IPOModelService;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.helper.DEFieldCacheMap;
/** /**
......
package cn.ibizlab.core.util.config; package cn.ibizlab.core.util.config;
import cn.ibizlab.core.data.dto.FilterData; import cn.ibizlab.core.data.dto.FilterData;
import cn.ibizlab.util.filter.SearchContextBase; import cn.ibizlab.core.data.filter.SearchContextBase;
import cn.ibizlab.util.domain.DTOBase;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
...@@ -11,7 +10,6 @@ import org.springframework.web.context.request.NativeWebRequest; ...@@ -11,7 +10,6 @@ import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer; import org.springframework.web.method.support.ModelAndViewContainer;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -28,7 +26,7 @@ public class FilterDataResolver implements HandlerMethodArgumentResolver { ...@@ -28,7 +26,7 @@ public class FilterDataResolver implements HandlerMethodArgumentResolver {
@Override @Override
public boolean supportsParameter(MethodParameter parameter) { public boolean supportsParameter(MethodParameter parameter) {
return SearchContextBase.class.isAssignableFrom(parameter.getParameterType()) || DTOBase.class.isAssignableFrom(parameter.getParameterType()) return SearchContextBase.class.isAssignableFrom(parameter.getParameterType())
|| FilterData.class.isAssignableFrom(parameter.getParameterType()); || FilterData.class.isAssignableFrom(parameter.getParameterType());
} }
......
package cn.ibizlab.core.util.config; package cn.ibizlab.core.util.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import java.util.Properties;
import org.springframework.context.annotation.Primary;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.jdbc.DataSourceBuilder;
import cn.ibizlab.util.domain.LiquibaseProp;
import org.springframework.beans.factory.annotation.Autowired;
import liquibase.integration.spring.SpringLiquibase;
import org.springframework.util.StringUtils;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
@Configuration
public class LiquibaseConfiguration { public class LiquibaseConfiguration {
/**
* 主数据源版本管理
* @param
* @return
*/
@Bean
public SpringLiquibase masterliquibase(LiquibaseProp masterProperties) {
return LiquibaseInit(masterProperties);
}
/**
* liquibase初始化数据库
* @param properties
* @return
*/
private SpringLiquibase LiquibaseInit(LiquibaseProp properties){
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setUsername(properties.getUsername());
druidDataSource.setPassword(properties.getPassword());
druidDataSource.setUrl(properties.getUrl());
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setDataSource(druidDataSource);
liquibase.setChangeLog(getChangelog(properties.getIsSyncDBSchema(),properties.getConf()));
liquibase.setContexts("development,test,production");
liquibase.setShouldRun(true);
liquibase.setDefaultSchema(properties.getDefaultSchema());
return liquibase;
}
/**
* 获取数据库差异文件
* @param isSyncDBSchema 是否同步表结构
* @param conf //liquibase配置文件
* @return
*/
private String getChangelog(String isSyncDBSchema,String conf){
String defaultChangelog="classpath:liquibase/empty.xml";
if((!StringUtils.isEmpty(isSyncDBSchema))&&(!StringUtils.isEmpty(conf))){
if(isSyncDBSchema.toLowerCase().equals("true"))
defaultChangelog=conf;
}
return defaultChangelog;
}
} }
\ No newline at end of file
package cn.ibizlab.core.util.config; package cn.ibizlab.core.util.config;
import cn.ibizlab.util.helper.JSR310DateConverters;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.data.mongodb.core.convert.*; import org.springframework.data.mongodb.core.convert.*;
import java.sql.Timestamp;
import java.time.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
@Configuration @Configuration
...@@ -22,4 +25,141 @@ public class MongoDBConfig { ...@@ -22,4 +25,141 @@ public class MongoDBConfig {
return new MongoCustomConversions(converterList); return new MongoCustomConversions(converterList);
} }
public static class JSR310DateConverters {
private JSR310DateConverters() {
}
public static class TimestampToDateConverter implements Converter<Timestamp, Date> {
public static final TimestampToDateConverter INSTANCE = new TimestampToDateConverter();
private TimestampToDateConverter() {
}
@Override
public Date convert(Timestamp source) {
return source == null ? null : new Date(source.getTime());
}
}
public static class DateToTimestampConverter implements Converter<Date, Timestamp> {
public static final DateToTimestampConverter INSTANCE = new DateToTimestampConverter();
private DateToTimestampConverter() {
}
@Override
public Timestamp convert(Date source) {
return source == null ? null : new Timestamp(source.getTime());
}
}
public static class LocalDateToDateConverter implements Converter<LocalDate, Date> {
public static final LocalDateToDateConverter INSTANCE = new LocalDateToDateConverter();
private LocalDateToDateConverter() {
}
@Override
public Date convert(LocalDate source) {
return source == null ? null : Date.from(source.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
}
public static class DateToLocalDateConverter implements Converter<Date, LocalDate> {
public static final DateToLocalDateConverter INSTANCE = new DateToLocalDateConverter();
private DateToLocalDateConverter() {
}
@Override
public LocalDate convert(Date source) {
return source == null ? null : ZonedDateTime.ofInstant(source.toInstant(), ZoneId.systemDefault())
.toLocalDate();
}
}
public static class ZonedDateTimeToDateConverter implements Converter<ZonedDateTime, Date> {
public static final ZonedDateTimeToDateConverter INSTANCE = new ZonedDateTimeToDateConverter();
private ZonedDateTimeToDateConverter() {
}
@Override
public Date convert(ZonedDateTime source) {
return source == null ? null : Date.from(source.toInstant());
}
}
public static class DateToZonedDateTimeConverter implements Converter<Date, ZonedDateTime> {
public static final DateToZonedDateTimeConverter INSTANCE = new DateToZonedDateTimeConverter();
private DateToZonedDateTimeConverter() {
}
@Override
public ZonedDateTime convert(Date source) {
return source == null ? null : ZonedDateTime.ofInstant(source.toInstant(), ZoneId.systemDefault());
}
}
public static class LocalDateTimeToDateConverter implements Converter<LocalDateTime, Date> {
public static final LocalDateTimeToDateConverter INSTANCE = new LocalDateTimeToDateConverter();
private LocalDateTimeToDateConverter() {
}
@Override
public Date convert(LocalDateTime source) {
return source == null ? null : Date.from(source.atZone(ZoneId.systemDefault()).toInstant());
}
}
public static class DateToLocalDateTimeConverter implements Converter<Date, LocalDateTime> {
public static final DateToLocalDateTimeConverter INSTANCE = new DateToLocalDateTimeConverter();
private DateToLocalDateTimeConverter() {
}
@Override
public LocalDateTime convert(Date source) {
return source == null ? null : LocalDateTime.ofInstant(source.toInstant(), ZoneId.systemDefault());
}
}
public static class DurationToLongConverter implements Converter<Duration, Long> {
public static final DurationToLongConverter INSTANCE = new DurationToLongConverter();
private DurationToLongConverter() {
}
@Override
public Long convert(Duration source) {
return source == null ? null : source.toNanos();
}
}
public static class LongToDurationConverter implements Converter<Long, Duration> {
public static final LongToDurationConverter INSTANCE = new LongToDurationConverter();
private LongToDurationConverter() {
}
@Override
public Duration convert(Long source) {
return source == null ? null : Duration.ofNanos(source);
}
}
}
} }
\ No newline at end of file
package cn.ibizlab.core.util.config; package cn.ibizlab.core.util.config;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import cn.ibizlab.util.helper.UniqueNameGenerator;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize; import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.apache.ibatis.mapping.DatabaseIdProvider; import org.apache.ibatis.mapping.DatabaseIdProvider;
...@@ -11,7 +7,7 @@ import org.apache.ibatis.mapping.VendorDatabaseIdProvider; ...@@ -11,7 +7,7 @@ import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Properties; import java.util.Properties;
/** /**
......
package cn.ibizlab.core.util.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
@Slf4j
public class UniqueNameGenerator extends AnnotationBeanNameGenerator {
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
//全限定类名
String beanName = definition.getBeanClassName();
return beanName;
}
}
package cn.ibizlab.core.util.config; package cn.ibizlab.core.util.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Configuration;
@ConditionalOnExpression("!'${jobs.admin-address:NA}'.equals('NA')")
@Configuration
public class XxlJobConfig { public class XxlJobConfig {
} }
package cn.ibizlab.util.errors;
import org.zalando.problem.AbstractThrowableProblem;
import org.zalando.problem.Status;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
public class BadRequestAlertException extends AbstractThrowableProblem {
private final String entityName;
private final String errorKey;
public static final String PROBLEM_BASE_URL = "";
public static final URI DEFAULT_TYPE = URI.create(PROBLEM_BASE_URL + "/problem-with-message");
public BadRequestAlertException(String defaultMessage, String entityName, String errorKey) {
this(DEFAULT_TYPE, defaultMessage, entityName, errorKey);
}
public BadRequestAlertException(URI type, String defaultMessage, String entityName, String errorKey) {
super(type, defaultMessage, Status.BAD_REQUEST, null, null, null, getAlertParameters(entityName, errorKey));
this.entityName = entityName;
this.errorKey = errorKey;
}
public String getEntityName() {
return entityName;
}
public String getErrorKey() {
return errorKey;
}
private static Map<String, Object> getAlertParameters(String entityName, String errorKey) {
Map<String, Object> parameters = new HashMap<>();
parameters.put("message", "error." + errorKey);
parameters.put("params", entityName);
return parameters;
}
}
package cn.ibizlab.util.security;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.ObjectUtils;
import java.sql.Timestamp;
import java.util.*;
import com.alibaba.fastjson.JSONObject;
@Data
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuthenticationUser implements UserDetails
{
public AuthenticationUser(){}
/**
* 用戶标识
*/
private String userid;
/**
* 用户全局名
*/
private String username;
/**
* 用户姓名
*/
private String personname;
/**
* 登录名
*/
private String loginname;
/**
* 用户工号
*/
private String usercode;
/**
* 登录密码
*/
private String password;
/**
* 区属
*/
private String domain;
/**
* 租户
*/
private String srfdcid;
/**
* 系统标识
*/
private String srfsystemid;
/**
/**
* 动态实例标识
*/
private String srfdynainstid;
/**
* 部门标识
*/
private String mdeptid;
/**
* 部门编码
*/
private String mdeptcode;
/**
* 部门名称
*/
private String mdeptname;
/**
* 业务编码
*/
private String bcode;
/**
* 岗位标识
*/
private String postid;
/**
* 岗位代码
*/
private String postcode;
/**
* 岗位名称
*/
private String postname;
/**
* 单位标识
*/
private String orgid;
/**
* 单位编码
*/
private String orgcode;
/**
* 单位名称
*/
private String orgname;
/**
* 昵称别名
*/
private String nickname;
/**
* 邮箱
*/
private String email;
/**
* 社交账号
*/
private String avatar;
/**
* 电话
*/
private String phone;
/**
* 照片
*/
private String usericon;
/**
* 性别
*/
private String sex;
/**
* 出生日期
*/
private Timestamp birthday;
/**
* 证件号码
*/
private String certcode;
/**
* 地址
*/
private String addr;
/**
* 主题
*/
private String theme;
/**
* 字号
*/
private String fontsize;
/**
* 语言
*/
private String lang;
/**
* 备注
*/
private String memo;
/**
* 保留字段
*/
private String reserver;
/**
* 用户上下文参数
*/
private Map <String,Object> sessionParams;
/**
* 用户权限资源
*/
@JsonIgnore
private Collection<GrantedAuthority> authorities;
/**
* 是否为超级管理员
*/
private int superuser;
/**
* 用户权限资源
*/
private JSONObject permissionList;
/**
* 用户上下文参数
*/
@JsonIgnore
private Map<String,Object> userSessionParam;
/**
* 当前用户上下级组织信息
*/
private Map<String, Set<String>> orgInfo;
/**
* 上级组织
*/
private String porg;
/**
* 下级组织
*/
private String sorg;
/**
* 上级部门
*/
private String pdept;
/**
* 下级部门
*/
private String sdept;
@JsonIgnore
@Override
public boolean isAccountNonExpired() {
return true;
}
@JsonIgnore
@Override
public boolean isAccountNonLocked() {
return true;
}
@JsonIgnore
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@JsonIgnore
@Override
public String getPassword() {
return password;
}
@Override
public boolean isEnabled() {
return true;
}
public static AuthenticationUser getAuthenticationUser()
{
if(SecurityContextHolder.getContext()==null||SecurityContextHolder.getContext().getAuthentication()==null||SecurityContextHolder.getContext().getAuthentication().getPrincipal()==null){
return new AuthenticationUser();
}
Object userDetails = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
AuthenticationUser authuserdetail;
if(userDetails instanceof AuthenticationUser ) {
authuserdetail= (AuthenticationUser)userDetails;
}
else {
authuserdetail=new AuthenticationUser();
}
return authuserdetail;
}
public static AuthenticationUser setAuthenticationUser(String userId , String userName) {
AuthenticationUser user = new AuthenticationUser();
user.setUserid(userId);
user.setPersonname(userName);
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
return user;
}
public Map <String,Object> getSessionParams()
{
if(this.sessionParams==null)
{
sessionParams = getUserSessionParam();
sessionParams.put("srfsystemid",this.getSrfsystemid());
sessionParams.put("srfpersonid", this.getUserid());
sessionParams.put("srfpersonname", this.getPersonname());
sessionParams.put("srforgsectorid", this.getMdeptid());
sessionParams.put("srforgsectorcode", this.getMdeptcode());
sessionParams.put("srforgsectorname", this.getMdeptname());
sessionParams.put("srforgid", this.getOrgid());
sessionParams.put("srforgcode", this.getOrgcode());
sessionParams.put("srforgname", this.getOrgname());
sessionParams.put("srfuserid", this.getUserid());
sessionParams.put("srfusername", this.getPersonname());
sessionParams.put("srfusermode", "");
sessionParams.put("srforgsectorbc", this.getBcode());
sessionParams.put("srfloginname", this.getLoginname());
sessionParams.put("srflocale", this.getLang());
sessionParams.put("srftimezone", "");
sessionParams.put("srfusercode", this.getUsercode());
sessionParams.put("srfporg", this.getPorg());
sessionParams.put("srfsorg", this.getSorg());
sessionParams.put("srfpdept", this.getPdept());
sessionParams.put("srfsdept", this.getSdept());
}
return this.sessionParams;
}
private Map<String, Object> getUserSessionParam() {
if(userSessionParam!=null){
return userSessionParam;
}
else{
return new HashMap<>();
}
}
public void setOrgInfo(Map<String, Set<String>> orgInfo) {
this.orgInfo = orgInfo;
if(!ObjectUtils.isEmpty(orgInfo) && !ObjectUtils.isEmpty(orgInfo.get("parentorg"))){
porg=(String.format("'%s'",String.join("','",orgInfo.get("parentorg"))));
this.getSessionParams().put("srfporg",porg);
}
if(!ObjectUtils.isEmpty(orgInfo) && !ObjectUtils.isEmpty(orgInfo.get("suborg")) ){
sorg=(String.format("'%s'",String.join("','",orgInfo.get("suborg"))));
this.getSessionParams().put("srfsorg",sorg);
}
if(!ObjectUtils.isEmpty(orgInfo) && !ObjectUtils.isEmpty(orgInfo.get("parentdept"))){
pdept=(String.format("'%s'",String.join("','",orgInfo.get("parentdept"))));
this.getSessionParams().put("srfpdept",pdept);
}
if(!ObjectUtils.isEmpty(orgInfo) && !ObjectUtils.isEmpty(orgInfo.get("subdept"))){
sdept=(String.format("'%s'",String.join("','",orgInfo.get("subdept"))));
this.getSessionParams().put("srfsdept",sdept);
}
}
public void setPermissionList(JSONObject permissionList) {
this.permissionList = permissionList;
if(authorities==null && permissionList !=null){
if(permissionList.getJSONArray("authorities")!=null){
authorities=new ArrayList<>();
permissionList.getJSONArray("authorities").
forEach(item->authorities.add(new SimpleGrantedAuthority(String.valueOf(item))));
}
}
}
}
#Mybatis-plus配置
mybatis-plus:
global-config:
refresh-mapper: true
db-config:
# 全局逻辑已删除默认值
logic-delete-value: 0
# 全局逻辑未删除默认值
logic-not-delete-value: 1
mapper-locations: classpath*:/mapper/*/*/*.xml
configuration:
jdbc-type-for-null: 'null'
map-underscore-to-camel-case: false
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
<description> micorservice</description> <description> micorservice</description>
<dependencies> <dependencies>
<dependency>
<groupId>cn.ibizlab</groupId>
<artifactId>ibzdata-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>cn.ibizlab</groupId> <groupId>cn.ibizlab</groupId>
<artifactId>ibzdata-core</artifactId> <artifactId>ibzdata-core</artifactId>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册