@@ -1,9 +1,9 @@ | |||||
package cc.smtweb.framework.core.cache; | package cc.smtweb.framework.core.cache; | ||||
import cc.smtweb.framework.core.annotation.SwCache; | import cc.smtweb.framework.core.annotation.SwCache; | ||||
import cc.smtweb.framework.core.cache.redis.RedisBroadcastEvent; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.common.SwConsts; | import cc.smtweb.framework.core.common.SwConsts; | ||||
import cc.smtweb.framework.core.redis.RedisBroadcastEvent; | |||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
import com.github.benmanes.caffeine.cache.Caffeine; | import com.github.benmanes.caffeine.cache.Caffeine; | ||||
import com.github.benmanes.caffeine.cache.LoadingCache; | import com.github.benmanes.caffeine.cache.LoadingCache; | ||||
@@ -1,10 +1,9 @@ | |||||
package cc.smtweb.framework.core.cache; | package cc.smtweb.framework.core.cache; | ||||
import cc.smtweb.framework.core.annotation.SwTable; | |||||
import cc.smtweb.framework.core.cache.redis.RedisBroadcastEvent; | |||||
import cc.smtweb.framework.core.db.cache.EntityCache; | import cc.smtweb.framework.core.db.cache.EntityCache; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.redis.RedisBroadcastEvent; | |||||
import cc.smtweb.framework.core.util.SpringUtil; | import cc.smtweb.framework.core.util.SpringUtil; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.context.event.EventListener; | import org.springframework.context.event.EventListener; | ||||
@@ -2,9 +2,6 @@ package cc.smtweb.framework.core.cache; | |||||
import com.github.benmanes.caffeine.cache.Cache; | import com.github.benmanes.caffeine.cache.Cache; | ||||
import com.github.benmanes.caffeine.cache.Caffeine; | import com.github.benmanes.caffeine.cache.Caffeine; | ||||
import com.github.benmanes.caffeine.cache.LoadingCache; | |||||
import com.github.benmanes.caffeine.cache.Scheduler; | |||||
import org.checkerframework.checker.nullness.qual.NonNull; | |||||
import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.framework.core.cache; | package cc.smtweb.framework.core.cache; | ||||
import java.util.HashMap; | |||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.framework.core.redis; | |||||
package cc.smtweb.framework.core.cache.redis; | |||||
import lombok.Data; | import lombok.Data; | ||||
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.framework.core.redis; | |||||
package cc.smtweb.framework.core.cache.redis; | |||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
import io.lettuce.core.KeyValue; | import io.lettuce.core.KeyValue; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.framework.core.redis; | |||||
package cc.smtweb.framework.core.cache.redis; | |||||
import cc.smtweb.framework.core.common.SwException; | import cc.smtweb.framework.core.common.SwException; | ||||
import cc.smtweb.framework.core.systask.SysTaskManager; | import cc.smtweb.framework.core.systask.SysTaskManager; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.framework.core.redis; | |||||
package cc.smtweb.framework.core.cache.redis; | |||||
import io.lettuce.core.RedisClient; | import io.lettuce.core.RedisClient; | ||||
import io.lettuce.core.api.StatefulRedisConnection; | import io.lettuce.core.api.StatefulRedisConnection; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.framework.core.redis; | |||||
package cc.smtweb.framework.core.cache.redis; | |||||
import cc.smtweb.framework.core.systask.ISysTask; | import cc.smtweb.framework.core.systask.ISysTask; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; |
@@ -1,9 +1,8 @@ | |||||
package cc.smtweb.framework.core.redis.config; | |||||
package cc.smtweb.framework.core.cache.redis.config; | |||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.systask.SysTaskManager; | import cc.smtweb.framework.core.systask.SysTaskManager; | ||||
import io.lettuce.core.RedisClient; | |||||
import io.lettuce.core.RedisURI; | import io.lettuce.core.RedisURI; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; |
@@ -1,7 +1,5 @@ | |||||
package cc.smtweb.framework.core.common; | package cc.smtweb.framework.core.common; | ||||
import lombok.Data; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/23 9:46 | * Created by Akmm at 2022/3/23 9:46 | ||||
*/ | */ | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.framework.core.common; | package cc.smtweb.framework.core.common; | ||||
import lombok.Data; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.sql.Types; | import java.sql.Types; | ||||
@@ -1,7 +1,7 @@ | |||||
package cc.smtweb.framework.core.db; | package cc.smtweb.framework.core.db; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.db.dao.AbstractEntityDao; | import cc.smtweb.framework.core.db.dao.AbstractEntityDao; | ||||
import cc.smtweb.framework.core.db.dao.EntityColumn; | import cc.smtweb.framework.core.db.dao.EntityColumn; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
@@ -1,8 +1,8 @@ | |||||
package cc.smtweb.framework.core.db; | package cc.smtweb.framework.core.db; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelLinkName; | import cc.smtweb.framework.core.db.vo.ModelLinkName; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.framework.core.db.cache; | package cc.smtweb.framework.core.db.cache; | ||||
import cc.smtweb.framework.core.annotation.SwCache; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.common.SwConsts; | import cc.smtweb.framework.core.common.SwConsts; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
@@ -10,14 +9,9 @@ import cc.smtweb.framework.core.db.vo.ModelCache; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.mvc.controller.scan.BeanManager; | import cc.smtweb.framework.core.mvc.controller.scan.BeanManager; | ||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
import com.github.benmanes.caffeine.cache.Caffeine; | |||||
import com.github.benmanes.caffeine.cache.Scheduler; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.checkerframework.checker.nullness.qual.NonNull; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.concurrent.ScheduledExecutorService; | |||||
import java.util.concurrent.TimeUnit; | |||||
/** | /** | ||||
* Created by Akmm at 2022/2/19 17:19 | * Created by Akmm at 2022/2/19 17:19 | ||||
@@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.boot.context.properties.ConfigurationProperties; | import org.springframework.boot.context.properties.ConfigurationProperties; | ||||
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.jdbc.core.JdbcTemplate; | |||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | ||||
/** | /** | ||||
@@ -1,9 +1,9 @@ | |||||
package cc.smtweb.framework.core.db.dao; | package cc.smtweb.framework.core.db.dao; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
@@ -18,7 +18,10 @@ import org.springframework.util.ClassUtils; | |||||
import java.beans.IntrospectionException; | import java.beans.IntrospectionException; | ||||
import java.beans.PropertyDescriptor; | import java.beans.PropertyDescriptor; | ||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
import java.util.*; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | /** | ||||
* 抽象的值对象数据库访问 | * 抽象的值对象数据库访问 | ||||
@@ -4,8 +4,6 @@ import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.util.SpringUtil; | import cc.smtweb.framework.core.util.SpringUtil; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.dao.DataAccessException; | |||||
import org.springframework.jdbc.core.ConnectionCallback; | |||||
import org.springframework.jdbc.support.JdbcUtils; | import org.springframework.jdbc.support.JdbcUtils; | ||||
import java.sql.Connection; | import java.sql.Connection; | ||||
@@ -1,8 +1,5 @@ | |||||
package cc.smtweb.framework.core.db.sqlbuilder; | package cc.smtweb.framework.core.db.sqlbuilder; | ||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.jdbc.JdbcEngine; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.function.BiFunction; | import java.util.function.BiFunction; | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.framework.core.db.sqlbuilder; | package cc.smtweb.framework.core.db.sqlbuilder; | ||||
import lombok.Data; | |||||
import lombok.Getter; | import lombok.Getter; | ||||
@Getter | @Getter | ||||
@@ -2,8 +2,6 @@ package cc.smtweb.framework.core.db.vo; | |||||
import lombok.Data; | import lombok.Data; | ||||
import java.util.List; | |||||
/** | /** | ||||
* 表缓存信息定义:{"name":"tn","title":"按表名","fields":"table_name","type":"M"} | * 表缓存信息定义:{"name":"tn","title":"按表名","fields":"table_name","type":"M"} | ||||
* Created by Akmm at 2022/2/21 16:22 | * Created by Akmm at 2022/2/21 16:22 | ||||
@@ -4,9 +4,6 @@ import cc.smtweb.framework.core.annotation.SwTable; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import lombok.Data; | import lombok.Data; | ||||
import java.io.Serializable; | |||||
import java.util.Map; | |||||
@Data | @Data | ||||
@SwTable(value = "ASP_MODEL_DATABASE") | @SwTable(value = "ASP_MODEL_DATABASE") | ||||
public class ModelDatabase extends DefaultEntity { | public class ModelDatabase extends DefaultEntity { | ||||
@@ -2,9 +2,6 @@ package cc.smtweb.framework.core.db.vo; | |||||
import lombok.Data; | import lombok.Data; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | /** | ||||
* 索引定义 {name:"索引名称,如idx_t1", fields:"字段,如f1,f2", type="索引类别:P-主键 I-一般索引 U-唯一索引"} | * 索引定义 {name:"索引名称,如idx_t1", fields:"字段,如f1,f2", type="索引类别:P-主键 I-一般索引 U-唯一索引"} | ||||
*/ | */ | ||||
@@ -1,16 +1,12 @@ | |||||
package cc.smtweb.framework.core.db.vo; | package cc.smtweb.framework.core.db.vo; | ||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.common.AbstractEnum; | |||||
import cc.smtweb.framework.core.common.IntEnum; | |||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.cache.ModelDatabaseCache; | import cc.smtweb.framework.core.db.cache.ModelDatabaseCache; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; | ||||
import cc.smtweb.framework.core.util.jackson.BaseBeanSerializer; | |||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
@@ -3,9 +3,6 @@ package cc.smtweb.framework.core.exception; | |||||
import lombok.Getter; | import lombok.Getter; | ||||
import lombok.Setter; | import lombok.Setter; | ||||
import lombok.ToString; | import lombok.ToString; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.Set; | |||||
/** | /** | ||||
* 错误码 JDK version used: <JDK1.8> | * 错误码 JDK version used: <JDK1.8> | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.framework.core.mvc.config; | package cc.smtweb.framework.core.mvc.config; | ||||
import cc.smtweb.framework.core.mvc.controller.scan.IScanAction; | |||||
import cc.smtweb.framework.core.mvc.controller.scan.IScanActionBuilder; | import cc.smtweb.framework.core.mvc.controller.scan.IScanActionBuilder; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
@@ -1,5 +1,6 @@ | |||||
package cc.smtweb.framework.core.mvc.config; | package cc.smtweb.framework.core.mvc.config; | ||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.mvc.realm.exception.*; | import cc.smtweb.framework.core.mvc.realm.exception.*; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.http.HttpStatus; | import org.springframework.http.HttpStatus; | ||||
@@ -8,7 +9,6 @@ import org.springframework.web.bind.MethodArgumentNotValidException; | |||||
import org.springframework.web.bind.annotation.ExceptionHandler; | import org.springframework.web.bind.annotation.ExceptionHandler; | ||||
import org.springframework.web.bind.annotation.ResponseStatus; | import org.springframework.web.bind.annotation.ResponseStatus; | ||||
import org.springframework.web.bind.annotation.RestControllerAdvice; | import org.springframework.web.bind.annotation.RestControllerAdvice; | ||||
import cc.smtweb.framework.core.common.R; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
@@ -1,8 +1,5 @@ | |||||
package cc.smtweb.framework.core.mvc.config; | package cc.smtweb.framework.core.mvc.config; | ||||
import java.io.File; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; | import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; | ||||
import org.springframework.boot.SpringApplication; | import org.springframework.boot.SpringApplication; | ||||
import org.springframework.boot.env.EnvironmentPostProcessor; | import org.springframework.boot.env.EnvironmentPostProcessor; | ||||
@@ -10,6 +7,10 @@ import org.springframework.core.env.ConfigurableEnvironment; | |||||
import org.springframework.core.env.PropertiesPropertySource; | import org.springframework.core.env.PropertiesPropertySource; | ||||
import org.springframework.core.io.FileSystemResource; | import org.springframework.core.io.FileSystemResource; | ||||
import java.io.File; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | /** | ||||
* 〈读取外部配置文件〉 | * 〈读取外部配置文件〉 | ||||
* | * | ||||
@@ -1,10 +1,10 @@ | |||||
package cc.smtweb.framework.core.mvc.config; | package cc.smtweb.framework.core.mvc.config; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.db.jdbc.IdGenerator; | import cc.smtweb.framework.core.db.jdbc.IdGenerator; | ||||
import cc.smtweb.framework.core.mvc.controller.MethodAccessManager; | |||||
import cc.smtweb.framework.core.mvc.controller.ApiConfigBean; | import cc.smtweb.framework.core.mvc.controller.ApiConfigBean; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import cc.smtweb.framework.core.mvc.controller.MethodAccessManager; | |||||
import cc.smtweb.framework.core.session.SessionManager; | import cc.smtweb.framework.core.session.SessionManager; | ||||
import cc.smtweb.framework.core.session.UserSessionArgumentResolver; | import cc.smtweb.framework.core.session.UserSessionArgumentResolver; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; | ||||
@@ -1,8 +1,9 @@ | |||||
package cc.smtweb.framework.core.mvc.controller; | package cc.smtweb.framework.core.mvc.controller; | ||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.cache.ISwCache; | import cc.smtweb.framework.core.cache.ISwCache; | ||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.mvc.SchedulerManager; | import cc.smtweb.framework.core.mvc.SchedulerManager; | ||||
import cc.smtweb.framework.core.mvc.controller.access.IMethodAccess; | import cc.smtweb.framework.core.mvc.controller.access.IMethodAccess; | ||||
import cc.smtweb.framework.core.mvc.controller.access.MethodAccess; | import cc.smtweb.framework.core.mvc.controller.access.MethodAccess; | ||||
@@ -10,7 +11,6 @@ import cc.smtweb.framework.core.mvc.controller.scan.BeanManager; | |||||
import cc.smtweb.framework.core.mvc.realm.interceptor.PermInterceptor; | import cc.smtweb.framework.core.mvc.realm.interceptor.PermInterceptor; | ||||
import cc.smtweb.framework.core.mvc.realm.service.PermChecker; | import cc.smtweb.framework.core.mvc.realm.service.PermChecker; | ||||
import cc.smtweb.framework.core.mvc.scheduler.SchedulerTaskManager; | import cc.smtweb.framework.core.mvc.scheduler.SchedulerTaskManager; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import lombok.Getter; | import lombok.Getter; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.framework.core.mvc.controller.access; | package cc.smtweb.framework.core.mvc.controller.access; | ||||
import cc.smtweb.framework.core.exception.BindBeanException; | |||||
import cc.smtweb.framework.core.mvc.controller.IBeanContext; | import cc.smtweb.framework.core.mvc.controller.IBeanContext; | ||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
@@ -2,7 +2,6 @@ package cc.smtweb.framework.core.mvc.controller.access; | |||||
import cc.smtweb.framework.core.exception.BindBeanException; | import cc.smtweb.framework.core.exception.BindBeanException; | ||||
import cc.smtweb.framework.core.mvc.controller.IBeanContext; | import cc.smtweb.framework.core.mvc.controller.IBeanContext; | ||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | |||||
import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -5,7 +5,6 @@ import cc.smtweb.framework.core.mvc.controller.IEditor; | |||||
import lombok.Getter; | import lombok.Getter; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.Map; | import java.util.Map; | ||||
/** | /** | ||||
@@ -1,8 +1,8 @@ | |||||
package cc.smtweb.framework.core.mvc.controller.binder; | package cc.smtweb.framework.core.mvc.controller.binder; | ||||
import cc.smtweb.framework.core.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.common.SwIpAddr; | import cc.smtweb.framework.core.common.SwIpAddr; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
import cc.smtweb.framework.core.mvc.controller.binder.attr.BeanAttrEditor; | import cc.smtweb.framework.core.mvc.controller.binder.attr.BeanAttrEditor; | ||||
import cc.smtweb.framework.core.mvc.controller.binder.bean.*; | import cc.smtweb.framework.core.mvc.controller.binder.bean.*; | ||||
@@ -4,7 +4,6 @@ import cc.smtweb.framework.core.mvc.controller.IBeanContext; | |||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.Map; | import java.util.Map; | ||||
public abstract class AbstractContextEditor implements IEditor { | public abstract class AbstractContextEditor implements IEditor { | ||||
@@ -4,7 +4,6 @@ import cc.smtweb.framework.core.mvc.controller.IBeanContext; | |||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.Map; | import java.util.Map; | ||||
public class NullEditor implements IEditor { | public class NullEditor implements IEditor { | ||||
@@ -1,13 +1,9 @@ | |||||
package cc.smtweb.framework.core.mvc.controller.binder.bean; | package cc.smtweb.framework.core.mvc.controller.binder.bean; | ||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | |||||
import cc.smtweb.framework.core.mvc.controller.binder.param.AbstractRequestEditor; | import cc.smtweb.framework.core.mvc.controller.binder.param.AbstractRequestEditor; | ||||
import cc.smtweb.framework.core.session.SessionUtil; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.beans.factory.BeanFactory; | |||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import java.util.Map; | |||||
/*** | /*** | ||||
* 获取客户端IP地址;这里通过了Nginx获取;X-Real-IP | * 获取客户端IP地址;这里通过了Nginx获取;X-Real-IP | ||||
@@ -4,7 +4,6 @@ import cc.smtweb.framework.core.mvc.controller.IBeanContext; | |||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.Map; | import java.util.Map; | ||||
public abstract class AbstractRequestEditor implements IEditor { | public abstract class AbstractRequestEditor implements IEditor { | ||||
@@ -4,7 +4,6 @@ import cc.smtweb.framework.core.mvc.controller.IBeanContext; | |||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.Map; | import java.util.Map; | ||||
public class BeanTypeEditor implements IEditor { | public class BeanTypeEditor implements IEditor { | ||||
@@ -10,9 +10,7 @@ import cc.smtweb.framework.core.mvc.controller.binder.WebDataBinder; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.commons.lang3.ObjectUtils; | import org.apache.commons.lang3.ObjectUtils; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.core.DefaultParameterNameDiscoverer; | |||||
import org.springframework.core.ResolvableType; | import org.springframework.core.ResolvableType; | ||||
import org.springframework.core.annotation.SynthesizingMethodParameter; | |||||
import java.lang.annotation.Annotation; | import java.lang.annotation.Annotation; | ||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
@@ -3,11 +3,9 @@ package cc.smtweb.framework.core.mvc.controller.scan; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileFilter; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.lang.reflect.Modifier; | import java.lang.reflect.Modifier; | ||||
import java.net.JarURLConnection; | import java.net.JarURLConnection; | ||||
import java.net.URISyntaxException; | |||||
import java.net.URL; | import java.net.URL; | ||||
import java.net.URLDecoder; | import java.net.URLDecoder; | ||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
@@ -1,7 +1,10 @@ | |||||
package cc.smtweb.framework.core.mvc.controller.scan; | package cc.smtweb.framework.core.mvc.controller.scan; | ||||
import cc.smtweb.framework.core.annotation.SwBean; | |||||
import cc.smtweb.framework.core.annotation.SwConstruct; | |||||
import cc.smtweb.framework.core.annotation.SwDestroy; | |||||
import cc.smtweb.framework.core.annotation.SwScheduling; | |||||
import cc.smtweb.framework.core.common.SwException; | import cc.smtweb.framework.core.common.SwException; | ||||
import cc.smtweb.framework.core.annotation.*; | |||||
import cc.smtweb.framework.core.mvc.controller.access.MethodAccess; | import cc.smtweb.framework.core.mvc.controller.access.MethodAccess; | ||||
import cc.smtweb.framework.core.mvc.controller.access.SchedulerMethodAccess; | import cc.smtweb.framework.core.mvc.controller.access.SchedulerMethodAccess; | ||||
import cc.smtweb.framework.core.mvc.controller.binder.WebDataBinder; | import cc.smtweb.framework.core.mvc.controller.binder.WebDataBinder; | ||||
@@ -1,6 +1,8 @@ | |||||
package cc.smtweb.framework.core.mvc.realm.interceptor; | package cc.smtweb.framework.core.mvc.realm.interceptor; | ||||
import cc.smtweb.framework.core.annotation.SwPerm; | import cc.smtweb.framework.core.annotation.SwPerm; | ||||
import cc.smtweb.framework.core.cache.ISwCache; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
import cc.smtweb.framework.core.mvc.realm.exception.ForbiddenException; | import cc.smtweb.framework.core.mvc.realm.exception.ForbiddenException; | ||||
import cc.smtweb.framework.core.mvc.realm.exception.UnauthenticatedException; | import cc.smtweb.framework.core.mvc.realm.exception.UnauthenticatedException; | ||||
@@ -8,8 +10,6 @@ import cc.smtweb.framework.core.mvc.realm.service.PermCheckItem; | |||||
import cc.smtweb.framework.core.mvc.realm.service.PermChecker; | import cc.smtweb.framework.core.mvc.realm.service.PermChecker; | ||||
import cc.smtweb.framework.core.session.SessionUtil; | import cc.smtweb.framework.core.session.SessionUtil; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.framework.core.cache.ISwCache; | |||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
@@ -1,7 +1,7 @@ | |||||
package cc.smtweb.framework.core.mvc.realm.interceptor; | package cc.smtweb.framework.core.mvc.realm.interceptor; | ||||
import cc.smtweb.framework.core.annotation.SwPerm; | import cc.smtweb.framework.core.annotation.SwPerm; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import org.springframework.web.method.HandlerMethod; | import org.springframework.web.method.HandlerMethod; | ||||
import org.springframework.web.servlet.HandlerInterceptor; | import org.springframework.web.servlet.HandlerInterceptor; | ||||
@@ -1,6 +1,6 @@ | |||||
package cc.smtweb.framework.core.mvc.realm.interceptor; | package cc.smtweb.framework.core.mvc.realm.interceptor; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
@@ -3,7 +3,6 @@ package cc.smtweb.framework.core.mvc.scheduler; | |||||
import lombok.Getter; | import lombok.Getter; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import java.lang.reflect.InvocationTargetException; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.concurrent.atomic.AtomicLong; | import java.util.concurrent.atomic.AtomicLong; | ||||
@@ -1,6 +1,7 @@ | |||||
package cc.smtweb.framework.core.mvc.scheduler; | package cc.smtweb.framework.core.mvc.scheduler; | ||||
import cc.smtweb.framework.core.annotation.SwScheduling; | import cc.smtweb.framework.core.annotation.SwScheduling; | ||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.mvc.ISchedulerWakeup; | import cc.smtweb.framework.core.mvc.ISchedulerWakeup; | ||||
import cc.smtweb.framework.core.mvc.controller.IBeanContext; | import cc.smtweb.framework.core.mvc.controller.IBeanContext; | ||||
@@ -9,7 +10,6 @@ import cc.smtweb.framework.core.mvc.scheduler.job.GroupJob; | |||||
import cc.smtweb.framework.core.mvc.scheduler.job.LocalJobExecutor; | import cc.smtweb.framework.core.mvc.scheduler.job.LocalJobExecutor; | ||||
import cc.smtweb.framework.core.mvc.scheduler.job.RedisJobExecutor; | import cc.smtweb.framework.core.mvc.scheduler.job.RedisJobExecutor; | ||||
import cc.smtweb.framework.core.mvc.scheduler.job.SimpleJob; | import cc.smtweb.framework.core.mvc.scheduler.job.SimpleJob; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import com.serotonin.timer.RealTimeTimer; | import com.serotonin.timer.RealTimeTimer; | ||||
import com.serotonin.timer.TimerTask; | import com.serotonin.timer.TimerTask; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
@@ -1,10 +1,10 @@ | |||||
package cc.smtweb.framework.core.mvc.scheduler.job; | package cc.smtweb.framework.core.mvc.scheduler.job; | ||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.mvc.controller.access.MethodAccess; | import cc.smtweb.framework.core.mvc.controller.access.MethodAccess; | ||||
import cc.smtweb.framework.core.mvc.scheduler.AbstractJob; | import cc.smtweb.framework.core.mvc.scheduler.AbstractJob; | ||||
import cc.smtweb.framework.core.mvc.scheduler.AbstractJobExecutor; | import cc.smtweb.framework.core.mvc.scheduler.AbstractJobExecutor; | ||||
import cc.smtweb.framework.core.mvc.scheduler.AbstractJobQueue; | import cc.smtweb.framework.core.mvc.scheduler.AbstractJobQueue; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
public class GroupJob extends AbstractJob { | public class GroupJob extends AbstractJob { | ||||
@Override | @Override | ||||
@@ -1,10 +1,10 @@ | |||||
package cc.smtweb.framework.core.mvc.scheduler.job; | package cc.smtweb.framework.core.mvc.scheduler.job; | ||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.mvc.controller.IBeanContext; | import cc.smtweb.framework.core.mvc.controller.IBeanContext; | ||||
import cc.smtweb.framework.core.mvc.scheduler.AbstractJob; | import cc.smtweb.framework.core.mvc.scheduler.AbstractJob; | ||||
import cc.smtweb.framework.core.mvc.scheduler.AbstractJobExecutor; | import cc.smtweb.framework.core.mvc.scheduler.AbstractJobExecutor; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import java.util.concurrent.ExecutorService; | import java.util.concurrent.ExecutorService; | ||||
@@ -1,10 +1,10 @@ | |||||
package cc.smtweb.framework.core.mvc.scheduler.job; | package cc.smtweb.framework.core.mvc.scheduler.job; | ||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.mvc.controller.access.MethodAccess; | import cc.smtweb.framework.core.mvc.controller.access.MethodAccess; | ||||
import cc.smtweb.framework.core.mvc.scheduler.AbstractJob; | import cc.smtweb.framework.core.mvc.scheduler.AbstractJob; | ||||
import cc.smtweb.framework.core.mvc.scheduler.AbstractJobExecutor; | import cc.smtweb.framework.core.mvc.scheduler.AbstractJobExecutor; | ||||
import cc.smtweb.framework.core.mvc.scheduler.AbstractJobQueue; | import cc.smtweb.framework.core.mvc.scheduler.AbstractJobQueue; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
public class SimpleJob extends AbstractJob { | public class SimpleJob extends AbstractJob { | ||||
public SimpleJob(MethodAccess methodAccess) { | public SimpleJob(MethodAccess methodAccess) { | ||||
@@ -1,8 +1,5 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -1,9 +1,9 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.annotation.SwBody; | |||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwException; | import cc.smtweb.framework.core.common.SwException; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.annotation.SwBody; | |||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
/** | /** | ||||
@@ -1,9 +1,9 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.cache.SessionCache; | import cc.smtweb.framework.core.cache.SessionCache; | ||||
import cc.smtweb.framework.core.cache.SessionCacheFactory; | import cc.smtweb.framework.core.cache.SessionCacheFactory; | ||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.mvc.service.list.FooterField; | import cc.smtweb.framework.core.mvc.service.list.FooterField; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
@@ -1,9 +1,9 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.common.SwException; | import cc.smtweb.framework.core.common.SwException; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
@@ -11,7 +11,9 @@ import cc.smtweb.framework.core.db.vo.ModelField; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.*; | |||||
import java.util.ArrayList; | |||||
import java.util.Collections; | |||||
import java.util.List; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/2 19:52 | * Created by Akmm at 2022/3/2 19:52 | ||||
@@ -1,7 +1,7 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.db.EntityHelper; | import cc.smtweb.framework.core.db.EntityHelper; | ||||
@@ -11,7 +11,8 @@ import cc.smtweb.framework.core.db.vo.ModelField; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.*; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/2 19:52 | * Created by Akmm at 2022/3/2 19:52 | ||||
@@ -1,10 +1,10 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
@@ -1,8 +1,6 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.session.UserSession; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/2 19:01 | * Created by Akmm at 2022/3/2 19:01 | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import lombok.Getter; | import lombok.Getter; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
@@ -1,10 +1,10 @@ | |||||
package cc.smtweb.framework.core.mvc.service; | package cc.smtweb.framework.core.mvc.service; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.SwConsts; | import cc.smtweb.framework.core.common.SwConsts; | ||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
@@ -1,9 +1,9 @@ | |||||
package cc.smtweb.framework.core.session; | package cc.smtweb.framework.core.session; | ||||
import cc.smtweb.framework.core.cache.redis.RedisBroadcastEvent; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.db.jdbc.IdGenerator; | import cc.smtweb.framework.core.db.jdbc.IdGenerator; | ||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
import cc.smtweb.framework.core.redis.RedisBroadcastEvent; | |||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.web.context.request.RequestAttributes; | import org.springframework.web.context.request.RequestAttributes; | ||||
import org.springframework.web.context.request.RequestContextHolder; | import org.springframework.web.context.request.RequestContextHolder; | ||||
@@ -1,8 +1,8 @@ | |||||
package cc.smtweb.framework.core.session; | package cc.smtweb.framework.core.session; | ||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | import cc.smtweb.framework.core.mvc.controller.IEditor; | ||||
import cc.smtweb.framework.core.mvc.realm.exception.UnauthenticatedException; | import cc.smtweb.framework.core.mvc.realm.exception.UnauthenticatedException; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.web.context.request.RequestContextHolder; | import org.springframework.web.context.request.RequestContextHolder; | ||||
@@ -1,9 +1,10 @@ | |||||
package cc.smtweb.framework.core.util; | package cc.smtweb.framework.core.util; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.util.regex.Matcher; | import java.util.regex.Matcher; | ||||
import java.util.regex.Pattern; | import java.util.regex.Pattern; | ||||
import javax.servlet.http.HttpServletRequest; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
/** | /** | ||||
* 〈IP〉工具类 | * 〈IP〉工具类 | ||||
@@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.JsonSerializer; | |||||
import com.fasterxml.jackson.databind.SerializerProvider; | import com.fasterxml.jackson.databind.SerializerProvider; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.Date; | |||||
public class BaseBeanSerializer extends JsonSerializer<BaseBean> { | public class BaseBeanSerializer extends JsonSerializer<BaseBean> { | ||||
@@ -1,8 +1,6 @@ | |||||
package cc.smtweb.framework.core.util.jackson; | package cc.smtweb.framework.core.util.jackson; | ||||
import com.fasterxml.jackson.core.JsonGenerationException; | |||||
import com.fasterxml.jackson.core.JsonParser; | import com.fasterxml.jackson.core.JsonParser; | ||||
import com.fasterxml.jackson.core.JsonProcessingException; | |||||
import com.fasterxml.jackson.databind.DeserializationContext; | import com.fasterxml.jackson.databind.DeserializationContext; | ||||
import com.fasterxml.jackson.databind.JsonDeserializer; | import com.fasterxml.jackson.databind.JsonDeserializer; | ||||
import com.fasterxml.jackson.databind.exc.InvalidFormatException; | import com.fasterxml.jackson.databind.exc.InvalidFormatException; | ||||
@@ -5,6 +5,7 @@ import com.esotericsoftware.kryo.io.Input; | |||||
import com.esotericsoftware.kryo.io.Output; | import com.esotericsoftware.kryo.io.Output; | ||||
import com.esotericsoftware.kryo.pool.KryoFactory; | import com.esotericsoftware.kryo.pool.KryoFactory; | ||||
import com.esotericsoftware.kryo.pool.KryoPool; | import com.esotericsoftware.kryo.pool.KryoPool; | ||||
import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
@@ -1,6 +1,6 @@ | |||||
package cc.smtweb.framework.file.spring.controller; | package cc.smtweb.framework.file.spring.controller; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.session.SessionUtil; | import cc.smtweb.framework.core.session.SessionUtil; | ||||
import cc.smtweb.framework.file.FilePathGenerator; | import cc.smtweb.framework.file.FilePathGenerator; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
@@ -2,7 +2,7 @@ package cc.smtweb.framework.file.spring.controller; | |||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.session.SessionUtil; | import cc.smtweb.framework.core.session.SessionUtil; | ||||
import cc.smtweb.framework.file.FilePathGenerator; | import cc.smtweb.framework.file.FilePathGenerator; | ||||
import cc.smtweb.framework.file.FilePathInfo; | import cc.smtweb.framework.file.FilePathInfo; | ||||
@@ -4,7 +4,7 @@ import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.annotation.*; | import cc.smtweb.framework.core.annotation.*; | ||||
import cc.smtweb.framework.core.mvc.SchedulerManager; | import cc.smtweb.framework.core.mvc.SchedulerManager; | ||||
import cc.smtweb.framework.core.mvc.scheduler.SchedulerPoint; | import cc.smtweb.framework.core.mvc.scheduler.SchedulerPoint; | ||||
import cc.smtweb.framework.core.redis.RedisManager; | |||||
import cc.smtweb.framework.core.cache.redis.RedisManager; | |||||
import cc.smtweb.framework.core.util.DateUtil; | import cc.smtweb.framework.core.util.DateUtil; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
@@ -1,20 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.annotation; | |||||
import java.lang.annotation.ElementType; | |||||
import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | |||||
import java.lang.annotation.Target; | |||||
/** | |||||
* 数据模型注解,放到@SwService类中使用 | |||||
* @author xkliu | |||||
*/ | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
@Target({ElementType.METHOD}) | |||||
public @interface BpmEvent { | |||||
/** 数据集地址,如 uc.perm.perm.sysRoleMenuPrivilege */ | |||||
String dataset(); | |||||
/** 事件类型, BpmEventType */ | |||||
int event(); | |||||
} |
@@ -1,39 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.annotation; | |||||
/** | |||||
* 数据模型事件类型 | |||||
* @author xkliu | |||||
*/ | |||||
public interface BpmEventType { | |||||
/** | |||||
* 卡片模型 | |||||
*/ | |||||
int CARD_BEFORE_LOAD = 101; | |||||
int CARD_LOAD = 102; | |||||
int CARD_AFTER_LOAD = 103; | |||||
int CARD_BEFORE_SAVE = 104; | |||||
int CARD_SAVE = 105; | |||||
int CARD_AFTER_SAVE = 106; | |||||
int CARD_BEFORE_REMOVE = 107; | |||||
int CARD_REMOVE = 108; | |||||
int CARD_AFTER_REMOVE = 109; | |||||
// int CARD_LOAD_LOOKUP = 16; | |||||
/** | |||||
* 列表模型 | |||||
*/ | |||||
int LIST_BEFORE_LIST = 201; | |||||
int LIST_LIST = 202; | |||||
int LIST_AFTER_LIST = 203; | |||||
int LIST_BEFORE_COUNT = 204; | |||||
int LIST_COUNT = 205; | |||||
int LIST_AFTER_COUNT = 206; | |||||
/** | |||||
* 树模型 | |||||
*/ | |||||
int TREE_BEFORE_TREE = 301; | |||||
int TREE_TREE = 302; | |||||
int TREE_AFTER_TREE = 303; | |||||
int TREE_BEFORE_MOVE = 304; | |||||
int TREE_MOVE = 305; | |||||
int TREE_AFTER_MOVE = 306; | |||||
} |
@@ -1,7 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.exception; | |||||
public class BpmDataException extends BpmException { | |||||
public BpmDataException(String msg) { | |||||
super(msg); | |||||
} | |||||
} |
@@ -1,19 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.exception; | |||||
import cc.smtweb.framework.core.common.SwException; | |||||
import java.io.IOException; | |||||
public class BpmException extends SwException { | |||||
public BpmException(String message) { | |||||
super(message); | |||||
} | |||||
public BpmException(Exception e) { | |||||
super(e); | |||||
} | |||||
public BpmException(String message, IOException e) { | |||||
super(message, e); | |||||
} | |||||
} |
@@ -1,14 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.exception; | |||||
import lombok.Data; | |||||
@Data | |||||
public class BpmFieldError { | |||||
private String field; | |||||
private String message; | |||||
public BpmFieldError(String field, String message) { | |||||
this.field = field; | |||||
this.message = message; | |||||
} | |||||
} |
@@ -1,12 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.exception; | |||||
import java.io.IOException; | |||||
public class BpmIlegalArgumentException extends RuntimeException { | |||||
public BpmIlegalArgumentException(String message) { | |||||
super(message); | |||||
} | |||||
public BpmIlegalArgumentException(String message, IOException e) { | |||||
super(message, e); | |||||
} | |||||
} |
@@ -1,7 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.exception; | |||||
public class BpmLockRevException extends BpmException { | |||||
public BpmLockRevException() { | |||||
super("update lock rev error"); | |||||
} | |||||
} |
@@ -1,7 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.exception; | |||||
public class BpmObjectNotFoundException extends BpmException { | |||||
public BpmObjectNotFoundException(String msg) { | |||||
super(msg); | |||||
} | |||||
} |
@@ -1,15 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.exception; | |||||
import lombok.Getter; | |||||
import java.util.List; | |||||
public class BpmValidException extends BpmException { | |||||
@Getter | |||||
private List<BpmFieldError> fieldErrors; | |||||
public BpmValidException(List<BpmFieldError> fieldErrors) { | |||||
super("数据验证失败"); | |||||
this.fieldErrors = fieldErrors; | |||||
} | |||||
} |
@@ -1,46 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.exception; | |||||
import lombok.Getter; | |||||
@Getter | |||||
public class ModelLoaderError { | |||||
public static final int ERROR_FLOW = 11; | |||||
public static final int ERROR_NODE = 12; | |||||
public static final int ERROR_ACTION = 13; | |||||
public static final int ERROR_CONNECTION = 14; | |||||
public static final int ERROR_DB = 21; | |||||
public static final int ERROR_TABLE = 22; | |||||
public static final int ERROR_FIELD = 23; | |||||
public static final int ERROR_INDEX = 24; | |||||
public static final int ERROR_UI = 31; | |||||
public static final int ERROR_UI_DATASET = 32; | |||||
private int type; | |||||
private final String id; | |||||
private final String subId; | |||||
private String msg; | |||||
public ModelLoaderError(int type, String msg) { | |||||
this(type, null, null, msg); | |||||
} | |||||
public ModelLoaderError(int type, String id, String msg) { | |||||
this(type, id, null, msg); | |||||
} | |||||
public ModelLoaderError(int type, String id, String subId, String msg) { | |||||
this.type = type; | |||||
this.id = id; | |||||
this.subId = subId; | |||||
this.msg = msg; | |||||
} | |||||
@Override | |||||
public String toString() { | |||||
if (id != null) { | |||||
return msg; | |||||
} else { | |||||
return "[id=" + id + "]"+ msg; | |||||
} | |||||
} | |||||
} |
@@ -1,9 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui; | |||||
import lombok.Data; | |||||
@Data | |||||
public class BpmKeyValue { | |||||
private String optKey; | |||||
private String optValue; | |||||
} |
@@ -1,37 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import lombok.Getter; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
@Getter | |||||
public class BpmListData { | |||||
public static final BpmListData EMPTY = new BpmListData(new ArrayList<>(), 0); | |||||
private final List<SwMap> rows; | |||||
// 总数, -1 表示需要异步获取数量, >=0 表示总数 | |||||
private int total; | |||||
private BpmListData(List<SwMap> rows, int total) { | |||||
this.rows = rows; | |||||
this.total = total; | |||||
} | |||||
public static BpmListData create(List<SwMap> list, boolean loadCount) { | |||||
if (list == null) { | |||||
return BpmListData.EMPTY; | |||||
} | |||||
if (loadCount) { | |||||
return new BpmListData(list, -1); | |||||
} else { | |||||
return new BpmListData(list, list.size()); | |||||
} | |||||
} | |||||
public boolean isEmpty() { | |||||
return rows == null || rows.isEmpty(); | |||||
} | |||||
} |
@@ -1,13 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui; | |||||
import java.util.HashMap; | |||||
public class BpmMapData extends HashMap<String, String> { | |||||
public BpmMapData() { | |||||
} | |||||
public BpmMapData(int initialCapacity) { | |||||
super(initialCapacity); | |||||
} | |||||
} |
@@ -1,60 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.mvc.controller.IBeanContext; | |||||
import cc.smtweb.framework.core.session.SessionUtil; | |||||
import cc.smtweb.framework.core.session.UserSession; | |||||
import cc.smtweb.framework.core.util.JsonUtil; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmFieldLookup; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.util.Map; | |||||
@Getter | |||||
public class BpmPageContext { | |||||
static final String ATTR_MAP_BODY = "_bpm_map_body"; | |||||
private final IBeanContext context; | |||||
private final Map<String, Object> params; | |||||
private final HttpServletRequest request; | |||||
private final String postBody; | |||||
private SwMap body; | |||||
private UserSession session; | |||||
@Setter | |||||
private boolean deploy = true; | |||||
@Setter | |||||
private String pageName; | |||||
@Setter | |||||
private BpmDataset dataset; | |||||
@Setter | |||||
private BpmFieldLookup fieldLookup; | |||||
// BpmPageContext(SwMap body, UserSession session) { | |||||
// this.body = body; | |||||
// this.session = session; | |||||
// } | |||||
public BpmPageContext(IBeanContext context, Map<String, Object> params, String body, HttpServletRequest request) { | |||||
this.context = context; | |||||
this.params = params; | |||||
this.request = request; | |||||
this.postBody = body; | |||||
SwMap mapBody = null; | |||||
if (StringUtils.isNotBlank(body)) { | |||||
mapBody = JsonUtil.parse(body, SwMap.class); | |||||
request.setAttribute(ATTR_MAP_BODY, mapBody); | |||||
} | |||||
this.body = mapBody; | |||||
this.session = (UserSession) SessionUtil.getSession(); | |||||
} | |||||
public long getParamId() { | |||||
return body.readLong(IParamConst.PARAM_ID, 0L); | |||||
} | |||||
} |
@@ -1,29 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui; | |||||
/** | |||||
* 前端页面参数名 | |||||
* @author xkliu | |||||
*/ | |||||
public interface IParamConst { | |||||
// 请求参数 | |||||
String PARAM_PAGE_ID = "pageId"; | |||||
String PARAM_PAGE_NAME = "pageName"; | |||||
String PARAM_DATASET = "dataset"; | |||||
String PARAM_ID = "id"; | |||||
String PARAMS_IDS = "ids"; | |||||
String PARAM_PARENT_ID = "dataParentId"; | |||||
String PARAM_ORDERS = "dataOrders"; | |||||
// 分页参数 | |||||
String PARAM_PAGE_INDEX = "pageIndex"; | |||||
String PARAM_PAGE_SIZE = "pageSize"; | |||||
int PAGE_DEFAULT_SIZE = 20; | |||||
// 字段参数后缀 | |||||
String LOOKUP_TEXT = "_text"; | |||||
String LOOKUP_KEY = "_key"; | |||||
// lookup : select/tree | |||||
String OPTION_KEY = "optKey"; | |||||
String OPTION_LABEL = "optLabel"; | |||||
String OPTION_ORDER = "optOrder"; | |||||
// tree 返回值 | |||||
String TREE_CHILDREN = "children"; | |||||
} |
@@ -1,80 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.bind; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.exception.BindBeanException; | |||||
import cc.smtweb.framework.core.mvc.controller.binder.attr.AbstractAttrEditor; | |||||
import cc.smtweb.system.bpm.util.BeanUtil; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.util.List; | |||||
/** | |||||
* API函数@SwBody参数的转换处理,POST请求直接转换Json内容为Bean对象,GET请求转换Map请求参数为Bean对 | |||||
* @author xkliu | |||||
*/ | |||||
public class BpmBeanAttrEditor extends AbstractAttrEditor implements IBpmBeanConst { | |||||
@Override | |||||
public Object getValue(String paramName, Class<?> paramType, HttpServletRequest request) { | |||||
if (ATTRIBUTE_ROW.equals(paramName)) { | |||||
return getBeanRow(paramType, request); | |||||
} else if (ATTRIBUTE_ROWS.equals(paramName)) { | |||||
return getBeanRows(paramType, request); | |||||
} | |||||
return request.getAttribute(paramName); | |||||
} | |||||
private Object getBeanRow(Class<?> paramType, HttpServletRequest request) { | |||||
SwMap map = (SwMap)request.getAttribute(BEAN_ROW_MAP); | |||||
Object bean = request.getAttribute(BEAN_ROW_BEAN); | |||||
if (bean != null) { | |||||
if (map != null) { | |||||
// 逻辑有错误 map 和 bean 不会同时有值 | |||||
request.removeAttribute(BEAN_ROW_BEAN); | |||||
} | |||||
// if (paramType != null) { | |||||
// if (!paramType.equals(bean.getClass())) { | |||||
// throw new BindBeanException("type noe equals " + paramType.getName() + "," + bean.getClass().getName()); | |||||
// } | |||||
// } | |||||
} else if (map != null) { | |||||
try { | |||||
bean = paramType.newInstance(); | |||||
} catch (IllegalAccessException | InstantiationException e) { | |||||
throw new BindBeanException(e); | |||||
} | |||||
BeanUtil.mapToBean(map, bean); | |||||
request.setAttribute(BEAN_ROW_MAP, bean); | |||||
request.removeAttribute(BEAN_ROW_BEAN); | |||||
} | |||||
return bean; | |||||
} | |||||
private List<?> getBeanRows(Class<?> paramType, HttpServletRequest request) { | |||||
List<SwMap> map = (List<SwMap>)request.getAttribute(BEAN_ROWS_MAP); | |||||
List<?> bean = (List<?>)request.getAttribute(BEAN_ROWS_BEAN); | |||||
if (bean != null) { | |||||
if (map != null) { | |||||
// 逻辑有错误 map 和 bean 不会同时有值 | |||||
request.removeAttribute(BEAN_ROWS_MAP); | |||||
} | |||||
// if (paramType != null) { | |||||
// if (!paramType.equals(bean.getClass())) { | |||||
// throw new BindBeanException("type noe equals " + paramType.getName() + "," + bean.getClass().getName()); | |||||
// } | |||||
// } | |||||
} else if (map != null) { | |||||
bean = BeanUtil.toBeanList(map, paramType); | |||||
request.setAttribute(BEAN_ROWS_BEAN, bean); | |||||
request.removeAttribute(BEAN_ROWS_MAP); | |||||
} | |||||
return bean; | |||||
} | |||||
} |
@@ -1,62 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.bind; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.mvc.controller.binder.attr.AbstractAttrEditor; | |||||
import cc.smtweb.system.bpm.util.BeanUtil; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.util.List; | |||||
/** | |||||
* API函数@SwBody参数的转换处理,POST请求直接转换Json内容为Bean对象,GET请求转换Map请求参数为Bean对 | |||||
* @author xkliu | |||||
*/ | |||||
public class BpmMapAttrEditor extends AbstractAttrEditor implements IBpmBeanConst { | |||||
@Override | |||||
public Object getValue(String paramName, Class<?> paramType, HttpServletRequest request) { | |||||
if (ATTRIBUTE_ROW.equals(paramName)) { | |||||
return getMapRow(request); | |||||
} else if (ATTRIBUTE_ROWS.equals(paramName)) { | |||||
return getMapRows(request); | |||||
} | |||||
return request.getAttribute(paramName); | |||||
} | |||||
private Object getMapRow(HttpServletRequest request) { | |||||
SwMap map = (SwMap)request.getAttribute(BEAN_ROW_MAP); | |||||
Object bean = request.getAttribute(BEAN_ROW_BEAN); | |||||
if (map != null) { | |||||
if (bean != null) { | |||||
// 逻辑有错误 map 和 bean 不会同时有值 | |||||
request.removeAttribute(BEAN_ROW_BEAN); | |||||
} | |||||
} else if (bean != null) { | |||||
map = new SwMap(); | |||||
BeanUtil.beanToMap(bean, map); | |||||
request.setAttribute(BEAN_ROW_MAP, map); | |||||
request.removeAttribute(BEAN_ROW_BEAN); | |||||
} | |||||
return map; | |||||
} | |||||
private Object getMapRows(HttpServletRequest request) { | |||||
List<SwMap> map = (List<SwMap>)request.getAttribute(BEAN_ROWS_MAP); | |||||
List<?> bean = (List<?>)request.getAttribute(BEAN_ROWS_BEAN); | |||||
if (map != null) { | |||||
if (bean != null) { | |||||
// 逻辑有错误 map 和 bean 不会同时有值 | |||||
request.removeAttribute(BEAN_ROWS_BEAN); | |||||
} | |||||
} else if (bean != null) { | |||||
map = BeanUtil.toMapList(bean); | |||||
request.setAttribute(BEAN_ROWS_MAP, map); | |||||
request.removeAttribute(BEAN_ROWS_BEAN); | |||||
} | |||||
return map; | |||||
} | |||||
} |
@@ -1,68 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.bind; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.mvc.controller.IBeanContext; | |||||
import cc.smtweb.framework.core.mvc.controller.IEditor; | |||||
import cc.smtweb.system.bpm.core.exception.BpmException; | |||||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||||
import cc.smtweb.system.bpm.core.ui.IParamConst; | |||||
import cc.smtweb.system.bpm.core.ui.entity.BpmPage; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||||
import cc.smtweb.system.bpm.spring.cache.BpmPageCache; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.util.Map; | |||||
public class BpmPageContextEditor implements IEditor { | |||||
public BpmPageContextEditor(){ | |||||
} | |||||
@Override | |||||
public Object getParamValue(String paramName, Class<?> paramType, IBeanContext context, Map<String, Object> params, String body, HttpServletRequest request) { | |||||
BpmPageContext pageContext = new BpmPageContext(context, params, body, request); | |||||
SwMap mapBody = pageContext.getBody(); | |||||
String pageName = mapBody.readString(IParamConst.PARAM_PAGE_NAME); | |||||
if (pageName == null) { | |||||
pageName = mapBody.readString(IParamConst.PARAM_PAGE_ID); | |||||
} | |||||
BpmPage page = loadPage(pageName); | |||||
pageContext.setPageName(page.getFullName()); | |||||
pageContext.setDeploy(page.isDeploy()); | |||||
pageContext.setDataset(findUiDataset(page, mapBody.readString(IParamConst.PARAM_DATASET))); | |||||
return pageContext; | |||||
} | |||||
private BpmPage loadPage(String pageName) { | |||||
if (pageName == null) { | |||||
throw new BpmException("参数 pageName 必填"); | |||||
} | |||||
BpmPage uiPage = BpmPageCache.getInstance().get(pageName); | |||||
if (uiPage == null) { | |||||
uiPage = BpmPageCache.getInstance().getByOtherKey(pageName); | |||||
} | |||||
if (uiPage == null) { | |||||
throw new BpmException("未找到页面, name=" + pageName); | |||||
} | |||||
return uiPage; | |||||
} | |||||
private BpmDataset findUiDataset(BpmPage uiPage, String datasetName) { | |||||
if (datasetName == null) { | |||||
throw new BpmException("参数 dataset 必填"); | |||||
} | |||||
BpmDataset dataset = uiPage.findDatasetByName(datasetName); | |||||
if (dataset == null) { | |||||
throw new BpmException("未找到dataset, pageId=" + uiPage.getId() + ", id=" + datasetName); | |||||
} | |||||
return dataset; | |||||
} | |||||
} |
@@ -1,13 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.bind; | |||||
public interface IBpmBeanConst { | |||||
String ATTRIBUTE_ROW = "row"; | |||||
String ATTRIBUTE_ROWS = "rows"; | |||||
String BEAN_ROW = "_sw_bpm_" + ATTRIBUTE_ROW; | |||||
String BEAN_ROW_MAP = BEAN_ROW + "_map"; | |||||
String BEAN_ROW_BEAN = BEAN_ROW + "_bean"; | |||||
String BEAN_ROWS = "_sw_bpm_" + ATTRIBUTE_ROWS; | |||||
String BEAN_ROWS_MAP = BEAN_ROWS + "_map"; | |||||
String BEAN_ROWS_BEAN = BEAN_ROWS + "_bean"; | |||||
} |
@@ -1,310 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.builder; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.AbstractUpdateSqlBuilder; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.DeleteSqlBuilder; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.InsertSqlBuilder; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder; | |||||
import cc.smtweb.framework.core.session.UserSession; | |||||
import cc.smtweb.framework.core.util.DateUtil; | |||||
import cc.smtweb.system.bpm.core.exception.BpmFieldError; | |||||
import cc.smtweb.system.bpm.core.exception.BpmValidException; | |||||
import cc.smtweb.system.bpm.core.ui.IParamConst; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmField; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmFieldLookup; | |||||
import cc.smtweb.system.bpm.engine.ui.entity.consts.UiEnum; | |||||
import lombok.Getter; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.*; | |||||
import java.util.regex.Pattern; | |||||
/** | |||||
* 卡片界面保存操作的SQL构建 | |||||
* @author xkliu | |||||
*/ | |||||
public class CardDataBuilder { | |||||
private DbEngine dbEngine; | |||||
@Getter | |||||
private long masterId; | |||||
private Long masterParentId; | |||||
@Getter | |||||
private boolean instert; | |||||
private UserSession userSession; | |||||
private Long now; | |||||
private CardTreeDataBuilder cardTreeDataBuilder; | |||||
private List<AbstractUpdateSqlBuilder> sqlBuilders = new ArrayList<>(); | |||||
private BpmDataset masterDataset; | |||||
/* 字段验证错误列表 */ | |||||
@Getter | |||||
private List<BpmFieldError> fieldErrors; | |||||
public CardDataBuilder(DbEngine dbEngine, long dataId, Long parentDataId, UserSession userSession) { | |||||
this.dbEngine = dbEngine; | |||||
this.masterId = dataId; | |||||
this.masterParentId = parentDataId; | |||||
this.instert = dataId == 0; | |||||
this.userSession = userSession; | |||||
} | |||||
public void build(BpmDataset dataset, SwMap body, UserSession us) { | |||||
masterDataset = dataset; | |||||
build(dataset, body, masterId, masterParentId); | |||||
List<BpmDataset> slaves = dataset.getOneToOneDataset(); | |||||
if (slaves != null) { | |||||
for (BpmDataset slave : slaves) { | |||||
long slaveId = body.readLong(slave.getIdField().getName(), 0L); | |||||
build(slave, body, slaveId, null); | |||||
} | |||||
} | |||||
} | |||||
private void build(BpmDataset dataset, SwMap body, long dataId, Long parentDataId) { | |||||
AbstractUpdateSqlBuilder sqlBuilder; | |||||
if (dataId == 0) { | |||||
// insert | |||||
sqlBuilder = SqlBuilder.createInsert(dataset.getDatabase(), dataset.getTable()); | |||||
if (masterId == 0) { | |||||
masterId = dbEngine.nextId(); | |||||
if (dataset.getIdField() != null) { | |||||
body.put(dataset.getIdField().getName(), masterId); | |||||
} | |||||
} | |||||
// remove: 放到后面统一处理 | |||||
// sqlBuilder.add(dataset.getIdFieldName(), masterId); | |||||
// if (parentDataId != null && parentDataId > 0) { | |||||
// BpmField parentIdField = dataset.findFieldByRefType(UiEnum.FieldRefType.PARENT_ID); | |||||
// if (parentIdField != null) { | |||||
// sqlBuilder.add(parentIdField.getFieldName(), parentDataId); | |||||
// } | |||||
// } | |||||
} else { | |||||
// update | |||||
sqlBuilder = SqlBuilder.createUpdate(dataset.getDatabase(), dataset.getTable()); | |||||
sqlBuilder.addWhere(dataset.readIdFieldName(), masterId); | |||||
} | |||||
cardTreeDataBuilder = null; | |||||
for (Map.Entry<String, BpmField> entry: dataset.getFields().entrySet()) { | |||||
BpmField bpmField = entry.getValue(); | |||||
String fieldName = bpmField.getFieldName(); | |||||
// 只读和虚拟控件不进行保存 | |||||
if (!bpmField.isReadonly() && StringUtils.isNotBlank(fieldName)) { | |||||
if (dataset.getIdField() == bpmField) { | |||||
// id字段新增才需要设置值 | |||||
if (dataId == 0) { | |||||
sqlBuilder.add(fieldName, masterId); | |||||
} | |||||
} else { | |||||
Object fieldValue = body.get(bpmField.getName()); | |||||
validField(bpmField, fieldValue); | |||||
if (bpmField.isLookupManyToMay()) { | |||||
// 中间表数据修改 | |||||
buildManyToMany(dataset, bpmField, (String) fieldValue); | |||||
} else { | |||||
// 处理String空串为NULL值 | |||||
if (fieldValue != null) { | |||||
if (fieldValue instanceof String && StringUtils.isBlank((String) fieldValue)) { | |||||
fieldValue = null; | |||||
} | |||||
} | |||||
// 处理默认值字段和计算字段 | |||||
switch (bpmField.getRefType()) { | |||||
case UiEnum.FieldRefType.SITE_ID: | |||||
if (dataId == 0) { | |||||
// 新增才保存数据 | |||||
sqlBuilder.add(fieldName, userSession.getSiteId()); | |||||
} | |||||
break; | |||||
case UiEnum.FieldRefType.CREATE_TIME: | |||||
if (dataId == 0) { | |||||
// 新增才保存数据 | |||||
sqlBuilder.add(fieldName, loadLastTime()); | |||||
} | |||||
break; | |||||
case UiEnum.FieldRefType.LAST_TIME: | |||||
sqlBuilder.add(fieldName, loadLastTime()); | |||||
break; | |||||
case UiEnum.FieldRefType.PARENT_ID: | |||||
sqlBuilder.add(fieldName, fieldValue); | |||||
updateCardTreeData(UiEnum.FieldRefType.PARENT_ID, fieldName, fieldValue); | |||||
break; | |||||
case UiEnum.FieldRefType.PARENT_ID_LIST: | |||||
updateCardTreeData(UiEnum.FieldRefType.PARENT_ID_LIST, fieldName, fieldValue); | |||||
break; | |||||
case UiEnum.FieldRefType.TREE_LEVEL: | |||||
updateCardTreeData(UiEnum.FieldRefType.TREE_LEVEL, fieldName, fieldValue); | |||||
break; | |||||
default: | |||||
sqlBuilder.add(fieldName, fieldValue); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
saveCardTreeData(dataset, dataId, sqlBuilder); | |||||
sqlBuilders.add(sqlBuilder); | |||||
} | |||||
private void updateCardTreeData(int type, String fieldName, Object fieldValue) { | |||||
if (cardTreeDataBuilder == null) { | |||||
cardTreeDataBuilder = new CardTreeDataBuilder(dbEngine); | |||||
} | |||||
cardTreeDataBuilder.add(type, fieldName, fieldValue); | |||||
} | |||||
private void saveCardTreeData(BpmDataset dataset, long dataId, AbstractUpdateSqlBuilder sqlBuilder) { | |||||
if (cardTreeDataBuilder != null) { | |||||
AbstractUpdateSqlBuilder newSqlBuilder = cardTreeDataBuilder.save(dataset, dataId, sqlBuilder); | |||||
cardTreeDataBuilder = null; | |||||
if (newSqlBuilder != null) { | |||||
sqlBuilders.add(newSqlBuilder); | |||||
} | |||||
} | |||||
} | |||||
private Long loadLastTime() { | |||||
if (now == null) { | |||||
now = DateUtil.nowDateTimeLong(); | |||||
} | |||||
return now; | |||||
} | |||||
private void validField(BpmField bpmField, Object fieldValue) { | |||||
if (bpmField.isRequired()) { | |||||
if (fieldValue == null || StringUtils.isBlank(fieldValue.toString())) { | |||||
// 对应前端的验证错误对象 ValidateError(message, field) | |||||
addFieldError(bpmField.getName(), bpmField.getLabel() + "必须填写"); | |||||
return; | |||||
} | |||||
} | |||||
if (fieldValue != null && StringUtils.isNotBlank(bpmField.getValidPatten())) { | |||||
if (!Pattern.matches(bpmField.getValidPatten(), fieldValue.toString())) { | |||||
if (StringUtils.isNotBlank(bpmField.getValidMessage())) { | |||||
addFieldError(bpmField.getName(), bpmField.getValidMessage()); | |||||
} else { | |||||
addFieldError(bpmField.getName(), bpmField.getLabel() + "格式不正确"); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
private void addFieldError(String field, String message) { | |||||
if (this.fieldErrors == null) { | |||||
this.fieldErrors = new ArrayList<>(); | |||||
} | |||||
this.fieldErrors.add(new BpmFieldError(field, message)); | |||||
} | |||||
private void buildManyToMany(BpmDataset dataset, BpmField bpmField, String newValue) { | |||||
BpmFieldLookup lookup = (BpmFieldLookup) bpmField.getLookup(); | |||||
// 读取旧记录 | |||||
Set<String> oldIds = dbEngine.queryStringSet("SELECT " + lookup.getMiddleValueField() + " FROM " + dataset.getDatabase() + "." + lookup.getMiddleTable() | |||||
+ " WHERE " + lookup.getMiddleKeyField() + "=?", masterId); | |||||
Set<String> newIds = toIdSet(newValue); | |||||
for (String newId: newIds) { | |||||
if (!oldIds.remove(newId)) { | |||||
// insert | |||||
InsertSqlBuilder sqlBuilder = SqlBuilder.createInsert(dataset.getDatabase(), lookup.getMiddleTable()); | |||||
sqlBuilder.add(lookup.getMiddleIdField(), dbEngine.nextId()); | |||||
sqlBuilder.add(lookup.getMiddleKeyField(), masterId); | |||||
sqlBuilder.add(lookup.getMiddleValueField(), newId); | |||||
sqlBuilders.add(sqlBuilder); | |||||
} | |||||
} | |||||
for (String oldId: oldIds) { | |||||
// delete | |||||
DeleteSqlBuilder sqlBuilder = SqlBuilder.createDelete(dataset.getDatabase(), lookup.getMiddleTable()); | |||||
sqlBuilder.addWhere(lookup.getMiddleKeyField(), masterId); | |||||
sqlBuilder.addWhere(lookup.getMiddleValueField(), oldId); | |||||
sqlBuilders.add(sqlBuilder); | |||||
} | |||||
} | |||||
private Set<String> toIdSet(String str) { | |||||
Set<String> result = new HashSet<>(); | |||||
if (StringUtils.isNotBlank(str)) { | |||||
Collections.addAll(result, str.split(",")); | |||||
} | |||||
return result; | |||||
} | |||||
public long update() { | |||||
if (sqlBuilders.size() > 1) { | |||||
dbEngine.doTrans(() -> { | |||||
for (AbstractUpdateSqlBuilder sqlBuilder : sqlBuilders) { | |||||
sqlBuilder.update(dbEngine); | |||||
} | |||||
return true; | |||||
}); | |||||
} else { | |||||
for (AbstractUpdateSqlBuilder sqlBuilder : sqlBuilders) { | |||||
sqlBuilder.update(dbEngine); | |||||
} | |||||
} | |||||
return masterId; | |||||
} | |||||
public SwMap update(SwMap data) { | |||||
if (data == null) { | |||||
data = new SwMap(); | |||||
} | |||||
for (AbstractUpdateSqlBuilder sqlBuilder : sqlBuilders) { | |||||
sqlBuilder.updateMap(data); | |||||
} | |||||
return data; | |||||
} | |||||
public String getTableName() { | |||||
return masterDataset.fullName(); | |||||
} | |||||
public boolean hasFieldErrors() { | |||||
return this.fieldErrors != null; | |||||
} | |||||
public static CardDataBuilder create(DbEngine dbEngine, BpmDataset dataset, SwMap body, UserSession us) { | |||||
long dataId = body.readLong(IParamConst.PARAM_ID, 0L); | |||||
Long parentDataId = body.readLong(IParamConst.PARAM_PARENT_ID); | |||||
CardDataBuilder cardDataBuilder = new CardDataBuilder(dbEngine, dataId, parentDataId, us); | |||||
cardDataBuilder.build(dataset, body, us); | |||||
if (cardDataBuilder.hasFieldErrors()) { | |||||
throw new BpmValidException(cardDataBuilder.getFieldErrors()); | |||||
} | |||||
return cardDataBuilder; | |||||
} | |||||
} |
@@ -1,134 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.builder; | |||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.AbstractSelectSqlBuilder; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.AbstractUpdateSqlBuilder; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.UpdateSqlBuilder; | |||||
import cc.smtweb.system.bpm.core.exception.BpmDataException; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||||
import cc.smtweb.system.bpm.engine.ui.entity.consts.UiEnum; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
public class CardTreeDataBuilder { | |||||
private Long parentId; | |||||
private String fieldParentId; | |||||
private String fieldParentIdList; | |||||
private String fieldLevel; | |||||
private DbEngine dbEngine; | |||||
public CardTreeDataBuilder(DbEngine dbEngine) { | |||||
this.dbEngine = dbEngine; | |||||
} | |||||
public void add(int type, String fieldName, Object fieldValue) { | |||||
switch (type) { | |||||
case UiEnum.FieldRefType.PARENT_ID: | |||||
parentId = readLong(fieldValue); | |||||
fieldParentId = fieldName; | |||||
break; | |||||
case UiEnum.FieldRefType.PARENT_ID_LIST: | |||||
fieldParentIdList = fieldName; | |||||
break; | |||||
case UiEnum.FieldRefType.TREE_LEVEL: | |||||
fieldLevel = fieldName; | |||||
break; | |||||
default: | |||||
throw new IllegalStateException("Unexpected value: " + type); | |||||
} | |||||
} | |||||
public static Long readLong(Object s) { | |||||
if (s != null) { | |||||
if (s instanceof Number) { | |||||
return ((Number) s).longValue(); | |||||
} else { | |||||
String value = s.toString(); | |||||
if (StringUtils.isNotBlank(value)) { | |||||
return Long.parseLong(value); | |||||
} | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public AbstractUpdateSqlBuilder save(BpmDataset dataset, long dataId, AbstractUpdateSqlBuilder sqlBuilder) { | |||||
if (fieldParentId != null) { | |||||
if (fieldParentIdList == null && fieldLevel == null) { | |||||
return null; | |||||
} | |||||
if (fieldParentIdList == null || fieldLevel == null) { | |||||
throw new BpmDataException("必须同时设置parentIdList和level作用字段"); | |||||
} | |||||
// TODO 检测需要同时设置idList和level | |||||
String idFileName = dataset.readIdFieldName(); | |||||
String parentIdList = null; | |||||
int treeLevel = 0; | |||||
if (parentId == null) { | |||||
sqlBuilder.add(fieldParentIdList, ""); | |||||
sqlBuilder.add(fieldLevel, 0); | |||||
parentIdList = parentId + "-"; | |||||
} else { | |||||
// 读取SQL | |||||
AbstractSelectSqlBuilder select = SqlBuilder.createSelect(dataset.getDatabase(), dataset.getTable()); | |||||
select.add(fieldParentIdList + " parentIdList"); | |||||
select.add(fieldLevel + " level"); | |||||
select.addWhere(idFileName, parentId); | |||||
TreeItemVO parentVO = select.queryEntity(dbEngine, TreeItemVO.class); | |||||
if (parentVO != null) { | |||||
parentIdList = parentVO.getParentIdList() + parentId + "-"; | |||||
treeLevel = parentVO.getLevel() + 1; | |||||
sqlBuilder.add(fieldParentIdList, parentIdList); | |||||
sqlBuilder.add(fieldLevel, treeLevel); | |||||
} else { | |||||
throw new BpmDataException("not find parent by " + dataset.getTable() + "." + idFileName + "=" + parentId); | |||||
} | |||||
} | |||||
// 如果parentId有修改,需要处理所有下级的 parentIdList 和 level | |||||
if (dataId != 0) { | |||||
AbstractSelectSqlBuilder select = SqlBuilder.createSelect(dataset.getDatabase(), dataset.getTable()); | |||||
select.add(fieldParentIdList, parentIdList); | |||||
select.add(fieldParentId + " parentId"); | |||||
select.add(fieldLevel + " level"); | |||||
select.addWhere(idFileName, dataId); | |||||
TreeItemVO curVO = select.queryEntity(dbEngine, TreeItemVO.class); | |||||
if (curVO != null) { | |||||
if (!LongEquals(curVO.getParentId(), parentId)) { | |||||
parentIdList = parentIdList + dataId + "-"; | |||||
// update table set parentIdList=CONCAT('1-2-4-', SUBSTR(parentIdList, 6)) where parentIdList like "1-2-3-%", level = level + 1; | |||||
UpdateSqlBuilder sb = SqlBuilder.createUpdate(dataset.getDatabase(), dataset.getTable()); | |||||
sb.add(String.format("%s=CONCAT('%s', SUBSTR(%s, %d))", fieldParentIdList, parentIdList, fieldParentIdList, curVO.getParentIdList().length() + 1), | |||||
UpdateSqlBuilder.VALUE_INVALID); | |||||
if (curVO.getLevel() > treeLevel) { | |||||
sb.add(String.format("%s=%s + %d", fieldLevel, fieldLevel, curVO.getLevel() - treeLevel), UpdateSqlBuilder.VALUE_INVALID); | |||||
} else if (curVO.getLevel() < treeLevel) { | |||||
sb.add(String.format("%s=%s - %d", fieldLevel, fieldLevel, treeLevel - curVO.getLevel()), UpdateSqlBuilder.VALUE_INVALID); | |||||
} | |||||
sb.addWhere(fieldParentIdList, curVO.getParentIdList() + "%", " like "); | |||||
return sb; | |||||
} | |||||
} else { | |||||
throw new BpmDataException("not find data by " + dataset.getTable() + "." + idFileName + "=" + dataId); | |||||
} | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
private static boolean LongEquals(Long oldValue, Long newValue) { | |||||
if (oldValue != null) { | |||||
return oldValue.equals(newValue); | |||||
} | |||||
return newValue == null; | |||||
} | |||||
} |
@@ -1,106 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.builder; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder; | |||||
import java.util.List; | |||||
import java.util.function.Function; | |||||
public class SqlUtil { | |||||
// 包含 | |||||
static final int OP_SUB = 1; | |||||
// 全匹配 | |||||
static final int OP_ALL = 2; | |||||
// 前匹配 | |||||
static final int OP_BEGIN = 3; | |||||
// 后匹配 | |||||
static final int OP_END = 4; | |||||
// 等于 | |||||
static final int OP_EQUAL = 5; | |||||
// 不等于 | |||||
static final int OP_NOT_EQUAL = 6; | |||||
// 大于 | |||||
static final int OP_GRATER = 7; | |||||
// 大于等于 | |||||
static final int OP_NOT_LESS = 8; | |||||
// 小于 | |||||
static final int OP_LESS = 9; | |||||
// 小于等于 | |||||
static final int OP_NOT_GRATER = 10; | |||||
// 查询参数 | |||||
public static final String PN_FILTER = "filter"; | |||||
public static final String PN_SEARCH = "search"; | |||||
public static final String PN_SEARCH_TYPE = "searchType"; | |||||
private SqlUtil(){} | |||||
public static void addSqlWhere(SqlBuilder sqlBuilder, String field, int op, Object keyword) { | |||||
if (keyword instanceof String) { | |||||
keyword = ((String) keyword).trim(); | |||||
} | |||||
switch (op) { | |||||
default: | |||||
case OP_EQUAL: | |||||
case OP_ALL: | |||||
sqlBuilder.addWhere(field, keyword, "="); | |||||
break; | |||||
case OP_NOT_EQUAL: | |||||
sqlBuilder.addWhere(field, keyword, "<>"); | |||||
break; | |||||
case OP_GRATER: | |||||
sqlBuilder.addWhere(field, keyword, ">"); | |||||
break; | |||||
case OP_NOT_LESS: | |||||
sqlBuilder.addWhere(field, keyword, ">="); | |||||
break; | |||||
case OP_LESS: | |||||
sqlBuilder.addWhere(field, keyword, "<"); | |||||
break; | |||||
case OP_NOT_GRATER: | |||||
sqlBuilder.addWhere(field, keyword, "<="); | |||||
break; | |||||
case OP_SUB: | |||||
sqlBuilder.addWhere(field, "%" + keyword + "%", " like "); | |||||
break; | |||||
case OP_BEGIN: | |||||
sqlBuilder.addWhere(field, "%" + keyword, " like "); | |||||
break; | |||||
case OP_END: | |||||
sqlBuilder.addWhere(field, keyword + "%", " like "); | |||||
break; | |||||
} | |||||
} | |||||
public static String makeSummaryField(String rule, String fieldName) { | |||||
switch (rule) { | |||||
case "${count}": | |||||
return "count(" + fieldName + ")"; | |||||
case "${sum}": | |||||
return "sum(" + fieldName + ")"; | |||||
case "${avg}": | |||||
return "avg(" + fieldName + ")"; | |||||
case "${min}": | |||||
return "min(" + fieldName + ")"; | |||||
case "${max}": | |||||
return "max(" + fieldName + ")"; | |||||
default: | |||||
return rule; | |||||
} | |||||
} | |||||
public static <T> String join(List<T> list, Function<T, String> action) { | |||||
if (list.isEmpty()) { | |||||
return null; | |||||
} | |||||
StringBuilder sb = new StringBuilder(); | |||||
for (T t: list) { | |||||
sb.append(action.apply(t)).append(','); | |||||
} | |||||
sb.setLength(sb.length() - 1); | |||||
return sb.toString(); | |||||
} | |||||
} |
@@ -1,207 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.builder; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.AbstractSelectSqlBuilder; | |||||
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder; | |||||
import cc.smtweb.framework.core.util.JsonUtil; | |||||
import cc.smtweb.system.bpm.core.exception.BpmException; | |||||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||||
import cc.smtweb.system.bpm.core.ui.IParamConst; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmField; | |||||
import cc.smtweb.system.bpm.engine.ui.entity.consts.UiEnum; | |||||
import cc.smtweb.system.bpm.engine.ui.entity.po.DynFormLogPO; | |||||
import lombok.Getter; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | |||||
* 数据模型处理,读取和排序处理 | |||||
*/ | |||||
@Getter | |||||
public class TreeDataBuilder { | |||||
private BpmField idField = null; | |||||
private BpmField parentField = null; | |||||
private BpmField orderField = null; | |||||
private BpmField titleField = null; | |||||
private BpmDataset dataset; | |||||
private Long parentId; | |||||
private Long[] orders; | |||||
private String idName; | |||||
public static TreeDataBuilder create(BpmPageContext ctx) { | |||||
SwMap body = ctx.getBody(); | |||||
Long parentId = body.readLong(IParamConst.PARAM_PARENT_ID); | |||||
Long[] orders = body.readLongArray(IParamConst.PARAM_ORDERS); | |||||
if (orders == null) { | |||||
throw new BpmException(IParamConst.PARAM_ORDERS + " 参数必填"); | |||||
} | |||||
TreeDataBuilder treeDataBuilder = new TreeDataBuilder(ctx.getDataset(), parentId, orders); | |||||
if (treeDataBuilder.getParentField() == null) { | |||||
throw new BpmException("dataset未设置‘上级ID’字段"); | |||||
} | |||||
if (treeDataBuilder.getOrderField() == null) { | |||||
throw new BpmException("dataset未设置‘排序’字段"); | |||||
} | |||||
return treeDataBuilder; | |||||
} | |||||
public TreeDataBuilder(BpmDataset dataset, Long parentId, Long[] orders) { | |||||
this.dataset = dataset; | |||||
this.parentId = parentId; | |||||
this.orders = orders; | |||||
for (Map.Entry<String, BpmField> entry: dataset.getFields().entrySet()) { | |||||
BpmField bpmField = entry.getValue(); | |||||
switch (bpmField.getRefType()) { | |||||
case UiEnum.FieldRefType.ID: | |||||
idField = bpmField; | |||||
break; | |||||
case UiEnum.FieldRefType.PARENT_ID: | |||||
parentField = bpmField; | |||||
break; | |||||
case UiEnum.FieldRefType.ORDER: | |||||
orderField = bpmField; | |||||
break; | |||||
case UiEnum.FieldRefType.TITLE: | |||||
titleField = bpmField; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
idName = idField != null ? idField.getName() : IParamConst.PARAM_ID; | |||||
} | |||||
public AbstractSelectSqlBuilder tableSqlBuilder() { | |||||
AbstractSelectSqlBuilder sqlBuilder = SqlBuilder.createSelect(dataset.getDatabase(), dataset.getTable()); | |||||
if (idField != null) { | |||||
sqlBuilder.add(idField.getFieldName() + " " + idField.getName()); | |||||
} else { | |||||
sqlBuilder.add(dataset.readIdFieldName() + " id"); | |||||
} | |||||
sqlBuilder.add(parentField.getFieldName() + " " + parentField.getName()); | |||||
sqlBuilder.add(titleField.getFieldName() + " " + titleField.getName()); | |||||
if (orderField != null) { | |||||
sqlBuilder.addOrderBy(orderField.getFieldName() + "," + dataset.readIdFieldName()); | |||||
} else { | |||||
sqlBuilder.addOrderBy(dataset.readIdFieldName()); | |||||
} | |||||
return sqlBuilder; | |||||
} | |||||
public SwMap mapTreeFields(BpmDataset dataset, DynFormLogPO po) { | |||||
if (StringUtils.isNotBlank(po.getDflContent())) { | |||||
SwMap item = new SwMap(); | |||||
SwMap entity = JsonUtil.parse(po.getDflContent(), SwMap.class); | |||||
item.put(parentField.getName(), entity.get(parentField.getFieldName())); | |||||
item.put(titleField.getName(), entity.get(titleField.getFieldName())); | |||||
item.put("id", po.getDflId()); | |||||
return item; | |||||
} | |||||
return null; | |||||
} | |||||
public SwMap updateOrder(DynFormLogPO po, Long parentId, int order) { | |||||
SwMap entity; | |||||
if (StringUtils.isNotBlank(po.getDflContent())) { | |||||
entity = JsonUtil.parse(po.getDflContent(), SwMap.class); | |||||
} else { | |||||
entity = new SwMap(); | |||||
} | |||||
entity.put(this.parentField.getFieldName(), parentId); | |||||
entity.put(this.orderField.getFieldName(), order); | |||||
return entity; | |||||
} | |||||
public static boolean longEquals(Long l1, Long l2) { | |||||
if (l1 != null) { | |||||
return l1.equals(l2); | |||||
} | |||||
return l2 == null; | |||||
} | |||||
private void addChild(SwMap parent, SwMap item) { | |||||
List<SwMap> children = readChildren(parent); | |||||
if (children == null) { | |||||
children = new ArrayList<>(); | |||||
parent.put(IParamConst.TREE_CHILDREN, children); | |||||
} | |||||
children.add(item); | |||||
} | |||||
private boolean findAndAdd(SwMap parent, SwMap item) { | |||||
if (longEquals(parent.readLong(idName), item.readLong(parentField.getName()))) { | |||||
addChild(parent, item); | |||||
return true; | |||||
} else { | |||||
List<SwMap> children = readChildren(parent); | |||||
if (children != null) { | |||||
for (SwMap child : children) { | |||||
if (findAndAdd(child, item)) { | |||||
return true; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
private List<SwMap> readChildren(SwMap parent) { | |||||
return (List<SwMap>) parent.get(IParamConst.TREE_CHILDREN); | |||||
} | |||||
// 读取树结构 | |||||
public List<SwMap> buildTree(List<SwMap> list, boolean forceAdd) { | |||||
SwMap root = new SwMap(); | |||||
if (list != null) { | |||||
for (SwMap item: list) { | |||||
if (!findAndAdd(root, item)) { | |||||
for (SwMap it: list) { | |||||
// TODO IParamConst.PARAM_ID => idField.getId() | |||||
if (longEquals(it.readLong(idName), item.readLong(parentField.getName()))) { | |||||
addChild(it, item); | |||||
item = null; | |||||
break; | |||||
} | |||||
} | |||||
// not find item parent | |||||
if (item != null && forceAdd) { | |||||
addChild(root, item); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
List<SwMap> result = readChildren(root); | |||||
if (result == null) { | |||||
result = new ArrayList<>(); | |||||
} | |||||
return result; | |||||
} | |||||
} |
@@ -1,10 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.builder; | |||||
import lombok.Data; | |||||
@Data | |||||
public class TreeItemVO { | |||||
private Long parentId; | |||||
private String parentIdList; | |||||
private int level; | |||||
} |
@@ -1,20 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.dataset; | |||||
import cc.smtweb.framework.core.util.DateUtil; | |||||
public class DateFieldFormater extends FieldFormatter { | |||||
public DateFieldFormater(String name) { | |||||
super(name); | |||||
} | |||||
@Override | |||||
public String format(Object value) { | |||||
if (value instanceof Number) { | |||||
return DateUtil.formatDate(((Number) value).longValue()); | |||||
} | |||||
return ""; | |||||
} | |||||
} |
@@ -1,20 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.dataset; | |||||
import cc.smtweb.framework.core.util.DateUtil; | |||||
public class DateTimeFieldFormater extends FieldFormatter { | |||||
public DateTimeFieldFormater(String name) { | |||||
super(name); | |||||
} | |||||
@Override | |||||
public String format(Object value) { | |||||
if (value instanceof Number) { | |||||
return DateUtil.formatDateTime(((Number) value).longValue()); | |||||
} | |||||
return ""; | |||||
} | |||||
} |
@@ -1,42 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.dataset; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmField; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
/** | |||||
* 字段格式化工具 | |||||
* | |||||
* @author xkliu | |||||
*/ | |||||
public class FieldFormatTool { | |||||
public static boolean needFormat(BpmField bpmField) { | |||||
return StringUtils.isNotBlank(bpmField.getDisplayFormat()); | |||||
} | |||||
public static FieldFormatter buildFormatter(BpmField bpmField) { | |||||
switch (bpmField.getType()) { | |||||
case BpmField.TYPE_DATE: | |||||
return new DateFieldFormater(bpmField.getName()); | |||||
case BpmField.TYPE_DATE_TIME: | |||||
return new DateTimeFieldFormater(bpmField.getName()); | |||||
default: | |||||
return new FieldFormatter(bpmField.getName()); | |||||
} | |||||
} | |||||
public static void fixDisplayFormat(BpmField bpmField) { | |||||
if (StringUtils.isBlank(bpmField.getDisplayFormat())) { | |||||
switch (bpmField.getType()) { | |||||
case BpmField.TYPE_DATE: | |||||
bpmField.setDisplayFormat("yyyy-MM-dd"); | |||||
break; | |||||
case BpmField.TYPE_DATE_TIME: | |||||
bpmField.setDisplayFormat("yyyy-MM-dd HH:mm:ss"); | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -1,16 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.dataset; | |||||
import lombok.Getter; | |||||
public class FieldFormatter { | |||||
@Getter | |||||
private String name; | |||||
FieldFormatter(String name) { | |||||
this.name = name; | |||||
} | |||||
public String format(Object value) { | |||||
return value.toString(); | |||||
} | |||||
} |
@@ -1,43 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.entity; | |||||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||||
import cc.smtweb.system.bpm.core.ui.entity.form.BpmForm; | |||||
import lombok.Data; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.io.Serializable; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
@Data | |||||
public class BpmPage implements Serializable { | |||||
private long id; | |||||
private String fullName; | |||||
private int modelType; | |||||
private boolean isDeploy = true; | |||||
private Boolean destroyOnClose; | |||||
// 数据集 | |||||
private List<BpmDataset> datasets = new ArrayList<>(); | |||||
// 界面 | |||||
private List<BpmForm> forms = new ArrayList<>(); | |||||
public BpmDataset findDatasetByName(String name) { | |||||
if (StringUtils.isNotBlank(name)) { | |||||
for (BpmDataset dataset : datasets) { | |||||
if (name.equals(dataset.getName())) { | |||||
return dataset; | |||||
} | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public BpmDataset findMasterDataset() { | |||||
return datasets.get(0); | |||||
} | |||||
public void addDataset(BpmDataset dataset) { | |||||
datasets.add(dataset); | |||||
} | |||||
} |
@@ -1,33 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.entity.dataset; | |||||
import cc.smtweb.system.bpm.engine.ui.entity.consts.MappingTypeEnum; | |||||
import lombok.Getter; | |||||
public abstract class AbstractBpmFieldLookup { | |||||
@Getter | |||||
private final String db; | |||||
@Getter | |||||
private final String table; | |||||
@Getter | |||||
private final boolean number; | |||||
/** | |||||
* lookup对象类型 | |||||
* @return Lookup对象类型 | |||||
*/ | |||||
public abstract int type(); | |||||
public AbstractBpmFieldLookup(String dbName, String table, boolean isNumber) { | |||||
this.db = dbName; | |||||
this.table = table; | |||||
this.number = isNumber; | |||||
} | |||||
public abstract MappingTypeEnum getMappingType(); | |||||
public boolean isManyToMany() { | |||||
return MappingTypeEnum.manyToMany.equals(getMappingType()); | |||||
} | |||||
} |
@@ -1,186 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.entity.dataset; | |||||
import cc.smtweb.system.bpm.engine.ui.entity.consts.UiEnum; | |||||
import lombok.Data; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | |||||
* BPM界面引擎后台执行用到的对象 | |||||
* @author xkliu | |||||
*/ | |||||
@Data | |||||
public class BpmDataset { | |||||
public static final int DATA_MODEL_CARD = 1; | |||||
public static final int DATA_MODEL_LIST = 2; | |||||
public static final int DATA_MODEL_TREE = 3; | |||||
private String id; | |||||
private String name; | |||||
private String database; | |||||
private String table; | |||||
/** 主键字段名 */ | |||||
private BpmField idField; | |||||
private String fieldPrefix; | |||||
// 字段列表,name => UiField | |||||
private Map<String, BpmField> fields = new HashMap<>(); | |||||
// 是否只读 | |||||
private boolean readonly; | |||||
// 是否有统计字段 | |||||
private boolean useSummary; | |||||
// 是否有查找字段 | |||||
private boolean useLookup; | |||||
// 外键关联属性 | |||||
private AbstractBpmFieldLookup lookup; | |||||
// 与主表的映射关系 | |||||
private BpmMasterMapping masterMapping = new BpmMasterMapping(); | |||||
// 1:1 映射的从表 | |||||
private List<BpmDataset> oneToOneDataset; | |||||
// 数据模型 | |||||
private int dataModel; | |||||
// 是否有级联数据集,TODO: 分离前台界面需要的参数 | |||||
// private boolean cascade; | |||||
private String customApi; | |||||
private boolean initData; | |||||
private BpmDatasetSql sql; | |||||
public void addField(BpmField bpmField) { | |||||
fields.put(bpmField.getName(), bpmField); | |||||
String summary = bpmField.getSummary(); | |||||
if (StringUtils.isNotBlank(summary)) { | |||||
this.useSummary = true; | |||||
} | |||||
if (bpmField.getLookup() != null) { | |||||
this.useLookup = true; | |||||
} | |||||
if (bpmField.getRefType() == UiEnum.FieldRefType.ID) { | |||||
setIdField(bpmField); | |||||
// props.setIdField(bpmField.getName()); | |||||
} | |||||
} | |||||
public BpmField addField(String fieldName, String name) { | |||||
return addField(fieldName, name, 0); | |||||
} | |||||
public BpmField addField(String fieldName, String name, int refType) { | |||||
BpmField bpmField = null; | |||||
if (StringUtils.isNotBlank(fieldName)) { | |||||
bpmField = new BpmField(); | |||||
bpmField.setId(name); | |||||
bpmField.setFieldName(fieldName); | |||||
bpmField.setName(name); | |||||
bpmField.setRefType(refType); | |||||
this.addField(bpmField); | |||||
} | |||||
return bpmField; | |||||
} | |||||
public BpmField findFieldByName(String name) { | |||||
return fields.get(name); | |||||
} | |||||
public BpmField findFieldById(String fieldId) { | |||||
return findFieldById(fieldId, false); | |||||
} | |||||
public BpmField findFieldById(String fieldId, boolean findSlave) { | |||||
if (StringUtils.isNotBlank(fieldId)) { | |||||
for (BpmField field : fields.values()) { | |||||
if (fieldId.equals(field.getId())) { | |||||
return field; | |||||
} | |||||
} | |||||
} | |||||
if(findSlave && this.oneToOneDataset != null) { | |||||
for (BpmDataset slave: this.oneToOneDataset) { | |||||
BpmField field = slave.findFieldById(fieldId); | |||||
if (field != null) { | |||||
return field; | |||||
} | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public String fullName() { | |||||
return database + "." + table; | |||||
} | |||||
// public String getFieldPrefix() { | |||||
// return props.getFieldPrefix(); | |||||
// } | |||||
// | |||||
// public String getId() { | |||||
// return props.getId(); | |||||
// } | |||||
// public BpmField findFieldByRefType(int refType) { | |||||
// for (Map.Entry<String, BpmField> entry: fields.entrySet()) { | |||||
// BpmField bpmField = entry.getValue(); | |||||
// | |||||
// if (bpmField.getRefType() == refType) { | |||||
// return bpmField; | |||||
// } | |||||
// } | |||||
// | |||||
// return null; | |||||
// } | |||||
public BpmField findFieldByFieldName(String fieldName) { | |||||
if (fieldName != null) { | |||||
for (Map.Entry<String, BpmField> entry : fields.entrySet()) { | |||||
BpmField bpmField = entry.getValue(); | |||||
if (fieldName.equals(bpmField.getFieldName())) { | |||||
return bpmField; | |||||
} | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public void addOneToOneDataset(BpmDataset slave) { | |||||
if (oneToOneDataset == null) { | |||||
oneToOneDataset = new ArrayList<>(); | |||||
} | |||||
oneToOneDataset.add(slave); | |||||
} | |||||
// public BpmDataset findById(String datasetId) { | |||||
// if (datasetId.equals(getProps().getId())) { | |||||
// return this; | |||||
// } | |||||
// | |||||
// if (this.oneToOneDataset != null) { | |||||
// for (BpmDataset slave: this.oneToOneDataset) { | |||||
// if (datasetId.equals(slave.getProps().getId())) { | |||||
// return slave; | |||||
// } | |||||
// } | |||||
// } | |||||
// | |||||
// return null; | |||||
// } | |||||
public String readIdFieldName() { | |||||
return idField != null ? idField.getFieldName() : null; | |||||
} | |||||
} |
@@ -1,10 +0,0 @@ | |||||
package cc.smtweb.system.bpm.core.ui.entity.dataset; | |||||
import lombok.Data; | |||||
@Data | |||||
public class BpmDatasetSql { | |||||
private String select; | |||||
private String insert; | |||||
private String update; | |||||
} |