@@ -30,6 +30,9 @@ import java.util.concurrent.TimeUnit; | |||
*/ | |||
@Slf4j | |||
public abstract class AbstractCache<T extends Serializable> implements ISwCache<String, T> { | |||
//树节点按parent的key | |||
public static final String KEY_PARENT_ID = "pr"; | |||
protected final static int LS_NONE = 0; | |||
protected final static int LS_LOADING = 1; | |||
protected final static int LS_LOADED = 2; | |||
@@ -238,7 +241,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||
* @param key | |||
* @return | |||
*/ | |||
protected T getForRemove(String key) { | |||
public T getOrg(String key) { | |||
return cacheOrg.get(key); | |||
} | |||
@@ -248,7 +251,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||
* @param key | |||
*/ | |||
protected void doRemove(String key) { | |||
T bean = getForRemove(key); | |||
T bean = getOrg(key); | |||
if (bean != null) { | |||
for (Map.Entry<String, IGetBeanKey<T>> entry : mapListReg.entrySet()) { | |||
doRemoveList(entry.getKey(), getBeanKey(entry.getValue(), bean), bean); | |||
@@ -334,7 +337,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||
*/ | |||
public final void reset(T bean) { | |||
final String id = getId(bean); | |||
T b = getForRemove(id); | |||
T b = getOrg(id); | |||
if (b != null) { | |||
cache.put(id, b); | |||
} | |||
@@ -356,7 +359,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||
* @param key | |||
* @return | |||
*/ | |||
protected final T localGetByKey(String rk, String key) { | |||
protected final T getByKey(String rk, String key) { | |||
Map<String, T> map = mapMapLocal.get(rk); | |||
if (map != null) { | |||
return map.get(key); | |||
@@ -364,7 +367,7 @@ public abstract class AbstractCache<T extends Serializable> implements ISwCache< | |||
return null; | |||
} | |||
public final Set<T> localGetListByKey(String rk, String key) { | |||
public final Set<T> getListByKey(String rk, String key) { | |||
return mapListLocal.get(rk + split_char + key); | |||
} | |||
@@ -6,11 +6,7 @@ import cc.smtweb.framework.core.cache.CacheManager; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.EntityDao; | |||
import cc.smtweb.framework.core.db.vo.ModelDatabase; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.jdbc.core.RowMapper; | |||
import java.sql.ResultSet; | |||
import java.sql.SQLException; | |||
import java.util.List; | |||
/** | |||
@@ -40,6 +36,6 @@ public class ModelDatabaseCache extends AbstractCache<ModelDatabase> { | |||
} | |||
public final ModelDatabase getByName(String key) { | |||
return localGetByKey(mk, key); | |||
return getByKey(mk, key); | |||
} | |||
} |
@@ -85,9 +85,9 @@ public class ModelTableCache extends AbstractCache<ModelTable> { | |||
} | |||
public final ModelTable getByName(String key) { | |||
return localGetByKey(mk, key.toUpperCase()); | |||
return getByKey(mk, key.toUpperCase()); | |||
} | |||
public final Set<ModelTable> getDbTables(long dbId) { | |||
return localGetListByKey(md, String.valueOf(dbId)); | |||
return getListByKey(md, String.valueOf(dbId)); | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
package cc.smtweb.framework.core.db.jdbc; | |||
/** | |||
* Created by Akmm at 14-2-15 下午1:51 | |||
* 数据库事务操作方法类 | |||
*/ | |||
public abstract class AbsDbWorker implements IDbWorker { | |||
@Override | |||
public void doAfterDbCommit() throws Exception {} | |||
@Override | |||
public void doAfterDbRollback() throws Exception {} | |||
} |
@@ -0,0 +1,15 @@ | |||
package cc.smtweb.framework.core.db.jdbc; | |||
/** | |||
* Created by Akmm at 14-2-3 下午4:52 | |||
* 数据库事务操作方法类 | |||
*/ | |||
public interface IDbWorker { | |||
public void work() throws Exception; | |||
//数据库提交完后的业务或缓存处理 | |||
public void doAfterDbCommit() throws Exception; | |||
//数据库回滚后的业务或缓存处理 | |||
public void doAfterDbRollback() throws Exception; | |||
} |
@@ -13,14 +13,15 @@ import org.springframework.jdbc.core.JdbcTemplate; | |||
import org.springframework.jdbc.core.ResultSetExtractor; | |||
import org.springframework.jdbc.core.RowMapper; | |||
import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |||
import org.springframework.transaction.TransactionDefinition; | |||
import org.springframework.transaction.TransactionStatus; | |||
import org.springframework.transaction.support.DefaultTransactionDefinition; | |||
import javax.sql.DataSource; | |||
import java.sql.Connection; | |||
import java.sql.SQLException; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import java.util.Set; | |||
import java.util.*; | |||
import java.util.concurrent.ConcurrentHashMap; | |||
import java.util.function.Function; | |||
import java.util.function.Supplier; | |||
@@ -30,6 +31,7 @@ import java.util.function.Supplier; | |||
public class JdbcEngine { | |||
private final static String DB_TYPE_MYSQL = "mysql"; | |||
private Map<Thread, JdbcTrans> mapThreadTrans = new ConcurrentHashMap<>(); | |||
private JdbcTemplate jdbcTemplate; | |||
private DataSourceTransactionManager dataSourceTransactionManager; | |||
private IdGenerator idGenerator; | |||
@@ -321,6 +323,73 @@ public class JdbcEngine { | |||
return false; | |||
} | |||
public void beginTrans() throws Exception { | |||
Thread t = Thread.currentThread(); | |||
JdbcTrans jdbcTrans = mapThreadTrans.get(t); | |||
if (jdbcTrans != null) { | |||
jdbcTrans.inc(); | |||
return; | |||
} | |||
mapThreadTrans.put(t, openTrans()); | |||
} | |||
public void commit() throws Exception { | |||
Thread t = Thread.currentThread(); | |||
JdbcTrans tm = this.mapThreadTrans.get(t); | |||
if (tm == null) throw new Exception("当前没有开启事务。"); | |||
if (tm.canCommit()) { | |||
tm.doEnd("commit"); | |||
tm.commit(); | |||
this.mapThreadTrans.remove(t); | |||
} | |||
} | |||
public void recTransLog() { | |||
for (JdbcTrans tm: mapThreadTrans.values()) { | |||
tm.doEnd("process"); | |||
} | |||
} | |||
public void rollback(Exception e) throws Exception { | |||
Thread t = Thread.currentThread(); | |||
JdbcTrans tm = mapThreadTrans.get(t); | |||
if (tm == null) throw new Exception("当前没有开启事务。"); | |||
if (tm.canCommit()) { | |||
tm.doEnd("rollback"); | |||
mapThreadTrans.remove(t); | |||
tm.rollback(); | |||
} | |||
if (e != null) throw e; | |||
} | |||
public void doTrans(IDbWorker dbWorker) throws Exception { | |||
beginTrans(); | |||
try { | |||
dbWorker.work(); | |||
commit(); | |||
} catch (Exception e) { | |||
rollback(e); | |||
dbWorker.doAfterDbRollback(); | |||
throw e; | |||
} | |||
dbWorker.doAfterDbCommit(); | |||
} | |||
//独立事务 | |||
public void doTransSingle(IDbWorker worker) throws Exception { | |||
JdbcTrans jdbcTrans = openTrans(); | |||
try { | |||
worker.work(); | |||
jdbcTrans.commit(); | |||
} catch (Exception e) { | |||
jdbcTrans.rollback(); | |||
worker.doAfterDbRollback(); | |||
throw e; | |||
} | |||
worker.doAfterDbCommit(); | |||
} | |||
/** | |||
* 获取原始数据库连接执行命令 | |||
* | |||
@@ -1,56 +1,87 @@ | |||
package cc.smtweb.framework.core.db.jdbc; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |||
import org.springframework.transaction.TransactionDefinition; | |||
import org.springframework.transaction.TransactionStatus; | |||
import org.springframework.transaction.support.DefaultTransactionDefinition; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
/** | |||
* JDBC事务处理类,可以在try中使用自动结束事务 | |||
* | |||
* @author xkliu | |||
*/ | |||
public class JdbcTrans implements AutoCloseable { | |||
private DataSourceTransactionManager transactionManager; | |||
private TransactionStatus status; | |||
/** | |||
* 构造事务执行 | |||
* @param transactionManager spring事务管理对象 | |||
*/ | |||
public JdbcTrans(DataSourceTransactionManager transactionManager) { | |||
this.transactionManager = transactionManager; | |||
// 事务定义类 | |||
DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |||
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |||
// 返回事务对象 | |||
this.status = transactionManager.getTransaction(def); | |||
} | |||
/** | |||
* 回滚事务 | |||
*/ | |||
public void rollback() { | |||
if (status != null) { | |||
transactionManager.rollback(status); | |||
status = null; | |||
} | |||
} | |||
/** | |||
* 提交事务 | |||
*/ | |||
public void commit() { | |||
if (status != null) { | |||
transactionManager.commit(status); | |||
status = null; | |||
} | |||
} | |||
/** | |||
* 实现自动关闭,回滚方式结束事务 | |||
*/ | |||
@Override | |||
public void close() { | |||
this.rollback(); | |||
} | |||
private Logger logger = LoggerFactory.getLogger("trans"); | |||
protected long time = System.currentTimeMillis(); | |||
protected String info = Thread.currentThread().getStackTrace()[6].getFileName() + "::::" + Thread.currentThread().getStackTrace()[6].getLineNumber(); | |||
private AtomicInteger count = new AtomicInteger(1); | |||
public int getCount() { | |||
return count.get(); | |||
} | |||
public void inc() { | |||
count.incrementAndGet(); | |||
} | |||
public boolean canCommit() { | |||
return count.decrementAndGet() == 0; | |||
} | |||
public void doEnd(String ei) { | |||
long t = System.currentTimeMillis() - time; | |||
if (t > 10000L) { | |||
logger.info(info + "::::::" + t + "::::::" + ei); | |||
} | |||
} | |||
private DataSourceTransactionManager transactionManager; | |||
private TransactionStatus status; | |||
/** | |||
* 构造事务执行 | |||
* | |||
* @param transactionManager spring事务管理对象 | |||
*/ | |||
public JdbcTrans(DataSourceTransactionManager transactionManager) { | |||
this.transactionManager = transactionManager; | |||
// 事务定义类 | |||
DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |||
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |||
// 返回事务对象 | |||
this.status = transactionManager.getTransaction(def); | |||
} | |||
/** | |||
* 回滚事务 | |||
*/ | |||
public void rollback() { | |||
if (status != null) { | |||
transactionManager.rollback(status); | |||
status = null; | |||
} | |||
} | |||
/** | |||
* 提交事务 | |||
*/ | |||
public void commit() { | |||
if (status != null) { | |||
transactionManager.commit(status); | |||
status = null; | |||
} | |||
} | |||
/** | |||
* 实现自动关闭,回滚方式结束事务 | |||
*/ | |||
@Override | |||
public void close() { | |||
this.rollback(); | |||
} | |||
} |
@@ -9,6 +9,8 @@ public enum FieldType { | |||
ID, | |||
// 上级ID,树结构需要 | |||
PARENT_ID, | |||
//级次码 | |||
LEVEL_CODE, | |||
// 排序字段,树结构需要 | |||
ORDER, | |||
// 编码字段 | |||
@@ -0,0 +1,14 @@ | |||
package cc.smtweb.framework.core.db.vo.def; | |||
/** | |||
* Created by Akmm at 2022/3/17 17:02 | |||
*/ | |||
public class TableType { | |||
//0-普通表,1 树型表 2 编码表 9-虚拟抽象表 11 视图 | |||
public static final int TYPE_GENERAL = 0; | |||
public static final int TYPE_TREE = 1; | |||
public static final int TYPE_CODE = 2; | |||
public static final int TYPE_ABSTACT = 3; | |||
public static final int TYPE_VIEW = 3; | |||
} |
@@ -1,6 +1,7 @@ | |||
package cc.smtweb.framework.core.mvc.service; | |||
import cc.smtweb.framework.core.R; | |||
import cc.smtweb.framework.core.SwException; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.annotation.SwBody; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
@@ -17,45 +18,83 @@ import java.util.Map; | |||
*/ | |||
public abstract class AbstractCompService { | |||
public final static String TYPE_LIST = "list"; | |||
public final static String TYPE_COMBO = "combo"; | |||
public final static String TYPE_TREE = "tree"; | |||
public final static String TYPE_LOAD = "load"; | |||
public final static String TYPE_SAVE = "save"; | |||
public final static String TYPE_DEL = "del"; | |||
protected abstract IHandler createHanlder(String type); | |||
private R pageHandler(SwMap params, UserSession us, String type) { | |||
try { | |||
IHandler handler = createHanlder(type); | |||
private IHandler getHandler(SwMap params, UserSession us, String type) throws Exception { | |||
IHandler handler = createHanlder(type); | |||
if (handler == null) throw new SwException("暂不支持此类服务:" + type); | |||
if (params == null) params = new SwMap(); | |||
if (us == null) us = UserSession.createSys(); | |||
return handler.doWork(params, us); | |||
handler.init(params, us); | |||
return handler; | |||
} | |||
private R pageHandler(SwMap params, UserSession us, String type) { | |||
try { | |||
IHandler handler = getHandler(params, us, type); | |||
return handler.doWork(); | |||
} catch (Exception e) { | |||
return R.error("操作失败!", e); | |||
} | |||
} | |||
//保存 | |||
public R save(@SwBody SwMap params, UserSession us) { | |||
return pageHandler(params, us, TYPE_SAVE); | |||
} | |||
//树,换爹 | |||
public R trcp(@SwBody SwMap params, UserSession us) { | |||
try { | |||
DefaultSaveHandler handler = (DefaultSaveHandler)getHandler(params, us,TYPE_SAVE); | |||
return handler.changeParent(); | |||
} catch (Exception e) { | |||
return R.error("操作失败!", e); | |||
} | |||
} | |||
//读取 | |||
public R load(@SwBody SwMap params, UserSession us) { | |||
return pageHandler(params, us, TYPE_LOAD); | |||
} | |||
//删除 | |||
public R del(@SwBody SwMap params, UserSession us) { | |||
return pageHandler(params, us, TYPE_DEL); | |||
} | |||
//列表数据 | |||
public R list(@SwBody SwMap params, UserSession us) { | |||
return pageHandler(params, us, TYPE_LIST); | |||
} | |||
public R getTotal(@SwBody SwMap params, UserSession us) { | |||
//列表总记录数及合计栏 | |||
public R listTotal(@SwBody SwMap params, UserSession us) { | |||
try { | |||
AbstractListHandler handler = (AbstractListHandler)createHanlder(TYPE_LIST); | |||
return handler.getTotal(params, us); | |||
AbstractListHandler handler = (AbstractListHandler)getHandler(params, us, TYPE_LIST); | |||
return handler.getTotal(); | |||
} catch (Exception e) { | |||
return R.error("操作失败!", e); | |||
} | |||
} | |||
//combo数据 | |||
public R combo(@SwBody SwMap params, UserSession us) { | |||
return pageHandler(params, us, TYPE_COMBO); | |||
} | |||
//combo总记录数及合计栏 | |||
public R comboTotal(@SwBody SwMap params, UserSession us) { | |||
try { | |||
AbstractListHandler handler = (AbstractListHandler)getHandler(params, us, TYPE_COMBO); | |||
return handler.getTotal(); | |||
} catch (Exception e) { | |||
return R.error("操作失败!", e); | |||
} | |||
} | |||
//树数据 | |||
public R tree(@SwBody SwMap params, UserSession us) { | |||
return pageHandler(params, us, TYPE_TREE); | |||
} | |||
} |
@@ -17,10 +17,13 @@ public abstract class AbstractDelHandler<T> implements IHandler{ | |||
protected long id; | |||
@Override | |||
public R doWork(SwMap params, UserSession us) throws Exception { | |||
public void init(SwMap params, UserSession us) { | |||
this.params = params; | |||
this.us = us; | |||
} | |||
@Override | |||
public R doWork() throws Exception { | |||
id = readId(); | |||
checkValid(); | |||
@@ -7,10 +7,8 @@ import cc.smtweb.framework.core.cache.SessionCacheFactory; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.mvc.service.list.FooterField; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.framework.core.util.NumberUtil; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.dao.DataAccessException; | |||
import org.springframework.jdbc.core.ResultSetExtractor; | |||
import java.sql.ResultSet; | |||
@@ -32,24 +30,46 @@ public abstract class AbstractListHandler implements IHandler { | |||
protected SwMap params; | |||
protected UserSession us; | |||
private SessionCache cacheBean; | |||
private List<FooterField> footerFields = null; | |||
// private SqlPara sqlPara = null; | |||
private SessionCache sessionCache; | |||
@Override | |||
public R doWork(SwMap params, UserSession us) throws Exception { | |||
public void init(SwMap params, UserSession us) { | |||
this.params = params; | |||
this.us = us; | |||
} | |||
@Override | |||
public R doWork() throws Exception { | |||
return R.success(listData()); | |||
} | |||
protected String getCompId() { | |||
return this.getClass().getSimpleName(); | |||
} | |||
protected <T> T getCache(String key) { | |||
if (sessionCache == null) | |||
sessionCache = SessionCacheFactory.getInstance().getUserCache(us.getUserId()); | |||
return sessionCache.get(getCompId() + "." + key); | |||
} | |||
protected void setCache(String key, Object v) { | |||
if (sessionCache == null) | |||
sessionCache = SessionCacheFactory.getInstance().getUserCache(us.getUserId()); | |||
sessionCache.put(getCompId() + "." + key, v); | |||
} | |||
protected void removeCache(String key) { | |||
if (sessionCache == null) | |||
sessionCache = SessionCacheFactory.getInstance().getUserCache(us.getUserId()); | |||
sessionCache.remove(getCompId() + "." + key); | |||
} | |||
protected SwListData listData() throws Exception { | |||
List<SwMap> listData = new ArrayList<>(); | |||
SqlPara sqlPara = buildDataSql(); | |||
int rows = params.readInt("rows", 20); | |||
int rows = params.readInt("rows", 0); | |||
int page = params.readInt("page", 1); | |||
String sort = params.readString("sort"); | |||
String order = params.readString("order"); | |||
@@ -74,13 +94,12 @@ public abstract class AbstractListHandler implements IHandler { | |||
} | |||
protected SqlPara buildSumSqlPara() { | |||
final SessionCache userCache = getCacheBean(); | |||
SqlPara sqlPara = userCache.get(KEY_SQLPARA); | |||
SqlPara sqlPara = getCache(KEY_SQLPARA); | |||
if (sqlPara == null) return null; | |||
getFooterFields(); | |||
List<FooterField> footerFields = getFooterFields(); | |||
StringBuilder sql = new StringBuilder(128); | |||
sql.append("select count(1) F_1"); | |||
sql.append("select count(1) total_count"); | |||
int n = 2; | |||
for (FooterField cn : footerFields) { | |||
if (!FooterField.STATIC_TEXT.equals(cn.type)) { | |||
@@ -93,7 +112,7 @@ public abstract class AbstractListHandler implements IHandler { | |||
} | |||
if (FooterField.SUM_TYPE_COUNT.equals(cn.type)) | |||
sql.append("distinct "); | |||
sql.append(cn.field).append(") F_").append(n++); | |||
sql.append(cn.field).append(") ").append(cn.field); | |||
} | |||
} | |||
sql.append(" from (").append(sqlPara.getSqlNoOrderBy()).append(") xxxxxz"); | |||
@@ -101,70 +120,21 @@ public abstract class AbstractListHandler implements IHandler { | |||
return new SqlPara(sql.toString(), sqlPara.paras); | |||
} | |||
public R getTotal(SwMap params, UserSession us) { | |||
public R getTotal() { | |||
try { | |||
this.params = params; | |||
this.us = us; | |||
final SessionCache userCache = getCacheBean(); | |||
SqlPara sqlParaSum = userCache.get(KEY_SQLPARA_SUM); | |||
SqlPara sqlParaSum = getCache(KEY_SQLPARA_SUM); | |||
if (sqlParaSum == null) { | |||
Map<String, Object> map = userCache.get(KEY_PARAMS); | |||
Map<String, Object> map = getCache(KEY_PARAMS); | |||
if (map != null) params.putAll(map); | |||
sqlParaSum = buildSumSqlPara(); | |||
} | |||
if (sqlParaSum == null) return R.success(); | |||
userCache.put(KEY_SQLPARA_SUM, sqlParaSum); | |||
setCache(KEY_SQLPARA_SUM, sqlParaSum); | |||
Map<String, Object> mapFooter = new HashMap<>(); | |||
getFooterFields(); | |||
int total = DbEngine.getInstance().query(sqlParaSum.sql, new ResultSetExtractor<Integer>() { | |||
public Integer extractData(ResultSet rs) throws SQLException { | |||
try { | |||
for (FooterField c : footerFields) { | |||
if (FooterField.STATIC_TEXT.equals(c.type)) | |||
mapFooter.put(c.field, c.text); | |||
} | |||
int count = 0; | |||
if (rs.next()) { | |||
count = rs.getInt(1); | |||
int n = 2; | |||
for (FooterField c : footerFields) { | |||
switch (c.type) { | |||
case FooterField.STATIC_TEXT: | |||
mapFooter.put(c.field, c.text); | |||
break; | |||
case FooterField.SUM_TYPE_COUNT: | |||
case FooterField.SUM_TYPE_COUNT_ALL: | |||
mapFooter.put(c.field, String.valueOf(rs.getInt(n++))); | |||
break; | |||
case FooterField.SUM_TYPE_SUM_NUM: | |||
mapFooter.put(c.field, String.valueOf(rs.getInt(n++))); | |||
break; | |||
default: | |||
mapFooter.put(c.field, rs.getDouble(n++)); | |||
break; | |||
} | |||
} | |||
} else { | |||
for (FooterField c : footerFields) { | |||
if (FooterField.STATIC_TEXT.equals(c.type)) | |||
mapFooter.put(c.field, c.text); | |||
} | |||
} | |||
return count; | |||
} catch (Exception e) { | |||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. | |||
return 0; | |||
} | |||
} | |||
}, sqlParaSum.paras); | |||
Map<String, Object> mapFooter = DbEngine.getInstance().queryEntity(sqlParaSum.sql, Map.class, sqlParaSum.paras); | |||
R r = R.success(); | |||
r.put("total", total); | |||
r.put("total", mapFooter.get("total_count")); | |||
r.put("footer", mapFooter); | |||
return r; | |||
} catch (Exception e) { | |||
@@ -172,25 +142,12 @@ public abstract class AbstractListHandler implements IHandler { | |||
} | |||
} | |||
public SessionCache getCacheBean() { | |||
if (cacheBean == null) | |||
cacheBean = SessionCacheFactory.getInstance().getUserCache(us.getUserId()); | |||
return cacheBean; | |||
} | |||
public void clearCache() { | |||
getCacheBean().clear(); | |||
} | |||
protected SqlPara buildDataSql() throws Exception { | |||
SessionCache userCache = getCacheBean(); | |||
//从缓存里看看有没有保存的sql缓存; | |||
SqlPara sqlParaInCache = getCacheBean().get(KEY_SQLPARA); //缓存里面的对象; | |||
SqlPara sqlParaInCache = getCache(KEY_SQLPARA); //缓存里面的对象; | |||
boolean query = sqlParaInCache == null || params.readBool("query"); | |||
if (!query) { | |||
Map<String, Object> map = userCache.get(KEY_PARAMS); | |||
Map<String, Object> map = getCache(KEY_PARAMS); | |||
if (map == null) query = true; | |||
else { | |||
Map<String, Object> params = getCachedParams(); | |||
@@ -214,14 +171,14 @@ public abstract class AbstractListHandler implements IHandler { | |||
//缓存里面没有对象,重新构建查询条件,重新计算汇总数; | |||
buildParam();//构造过滤条件,设默认值 | |||
sqlPara = buildSqlPara(); //重新构建查询对象; | |||
userCache.remove(KEY_SQLPARA_SUM); | |||
removeCache(KEY_SQLPARA_SUM); | |||
userCache.put(KEY_SQLPARA, sqlPara); | |||
userCache.put(KEY_PARAMS, getCachedParams());//不缓存页码之类的东东,避免下次请求时,页码又回去了 | |||
setCache(KEY_SQLPARA, sqlPara); | |||
setCache(KEY_PARAMS, getCachedParams());//不缓存页码之类的东东,避免下次请求时,页码又回去了 | |||
} else { | |||
sqlPara = sqlParaInCache; | |||
Map<String, Object> map = userCache.get(KEY_PARAMS); | |||
Map<String, Object> map = getCache(KEY_PARAMS); | |||
if (map != null) params.putAll(map); | |||
} | |||
return sqlPara; | |||
@@ -252,10 +209,8 @@ public abstract class AbstractListHandler implements IHandler { | |||
//构建合计字段 | |||
private List<FooterField> getFooterFields() { | |||
if (footerFields == null) { | |||
footerFields = new ArrayList<>(); | |||
buildFooterFields(footerFields); | |||
} | |||
List<FooterField> footerFields = new ArrayList<>(); | |||
buildFooterFields(footerFields); | |||
return footerFields; | |||
} | |||
@@ -12,9 +12,13 @@ public abstract class AbstractLoadHandler<T> implements IHandler { | |||
protected UserSession us; | |||
@Override | |||
public R doWork(SwMap params, UserSession us) throws Exception { | |||
public void init(SwMap params, UserSession us) { | |||
this.params = params; | |||
this.us = us; | |||
} | |||
@Override | |||
public R doWork() throws Exception { | |||
long id = readId(); | |||
T bean; | |||
if (id <= 0L) { | |||
@@ -1,8 +1,10 @@ | |||
package cc.smtweb.framework.core.mvc.service; | |||
import cc.smtweb.framework.core.R; | |||
import cc.smtweb.framework.core.SwException; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -11,17 +13,20 @@ import lombok.extern.slf4j.Slf4j; | |||
* 保存 | |||
*/ | |||
@Slf4j | |||
public abstract class AbstractSaveHandler<T> implements IHandler{ | |||
public abstract class AbstractSaveHandler<T> implements IHandler { | |||
protected SwMap params; | |||
protected UserSession us; | |||
protected T bean; | |||
protected boolean isNew; | |||
@Override | |||
public R doWork(SwMap params, UserSession us) throws Exception { | |||
public void init(SwMap params, UserSession us) { | |||
this.params = params; | |||
this.us = us; | |||
} | |||
@Override | |||
public R doWork() throws Exception { | |||
long id = readId(); | |||
isNew = id <= 0L; | |||
@@ -32,15 +37,20 @@ public abstract class AbstractSaveHandler<T> implements IHandler{ | |||
} | |||
readFromPage(); | |||
checkValid(); | |||
DbEngine.getInstance().doTrans(() -> { | |||
try { | |||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||
@Override | |||
public void work() throws Exception { | |||
save(); | |||
} | |||
@Override | |||
public void doAfterDbCommit() throws Exception { | |||
saveSuccess(); | |||
return true; | |||
} catch (Exception e) { | |||
} | |||
@Override | |||
public void doAfterDbRollback() throws Exception { | |||
saveFailed(); | |||
log.error("保存失败!", e); | |||
return false; | |||
} | |||
}); | |||
return R.success(bean); | |||
@@ -48,18 +58,33 @@ public abstract class AbstractSaveHandler<T> implements IHandler{ | |||
/** | |||
* 读取页面传回来的id | |||
* | |||
* @return | |||
*/ | |||
protected long readId() { | |||
return params.readLong("id", 0L); | |||
} | |||
//从页面读取数据 | |||
protected abstract void readFromPage(); | |||
//保存前的校验 | |||
protected abstract void checkValid() throws Exception; | |||
//保存到数据库 | |||
protected abstract void save() throws Exception; | |||
protected void saveSuccess() {} | |||
protected void saveFailed() {} | |||
//保存成功之后 | |||
protected void saveSuccess() { | |||
} | |||
//保存失败之后 | |||
protected void saveFailed() { | |||
} | |||
//构建一个新对象 | |||
protected abstract T createComp() throws Exception; | |||
//从数据库读取 | |||
protected abstract T loadComp(long id) throws Exception; | |||
} |
@@ -1,5 +1,6 @@ | |||
package cc.smtweb.framework.core.mvc.service; | |||
import cc.smtweb.framework.core.R; | |||
import cc.smtweb.framework.core.SwException; | |||
import cc.smtweb.framework.core.cache.AbstractCache; | |||
import cc.smtweb.framework.core.cache.CacheManager; | |||
@@ -7,11 +8,17 @@ import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.EntityDao; | |||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||
import cc.smtweb.framework.core.db.vo.ModelField; | |||
import cc.smtweb.framework.core.db.vo.ModelIndex; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||
import cc.smtweb.framework.core.db.vo.def.TableType; | |||
import org.apache.commons.lang3.StringUtils; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* Created by Akmm at 2022/3/2 19:52 | |||
* 默认实体实现 | |||
@@ -19,6 +26,8 @@ import org.apache.commons.lang3.StringUtils; | |||
public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHandler<T> { | |||
protected String tableName; | |||
private List<T> listTreeBean = null; | |||
public DefaultSaveHandler(String tableName) { | |||
this.tableName = tableName; | |||
} | |||
@@ -44,14 +53,14 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||
@Override | |||
protected void checkValid() throws Exception { | |||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | |||
for (ModelField field: table.getFields()) { | |||
for (ModelField field : table.getFields()) { | |||
if (field.isNotNull() && StringUtils.isEmpty(bean.getStr(field.getName()))) { | |||
throw new SwException(field.getTitle() + "不能为空!"); | |||
} | |||
} | |||
EntityDao dao = DbEngine.getInstance().findDao(tableName); | |||
for (ModelIndex mi: table.getIndexes()) { | |||
for (ModelIndex mi : table.getIndexes()) { | |||
if (mi.isUnique()) { | |||
dao.checkUnique(bean, mi.getFields().split(",")); | |||
} | |||
@@ -59,22 +68,32 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||
} | |||
@Override | |||
protected void save() { | |||
EntityDao dao = DbEngine.getInstance().findDao(tableName); | |||
protected void save() throws Exception { | |||
EntityDao<T> dao = DbEngine.getInstance().findDao(tableName); | |||
if (isNew) { | |||
dao.insertEntity(bean); | |||
} else { | |||
dao.updateEntity(bean); | |||
listTreeBean = new TreeHelper<T>(tableName).resetTreeLevel(bean); | |||
} | |||
} | |||
@Override | |||
protected void saveSuccess() { | |||
super.saveSuccess(); | |||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | |||
if (table.isNeedCache()) { | |||
AbstractCache<T> cache = CacheManager.getIntance().getCache(tableName); | |||
cache.put(bean); | |||
//树型表,父亲改变了,要多处理下缓存;还有个东东:级次码 | |||
if (listTreeBean != null && !listTreeBean.isEmpty()) { | |||
for (T b : listTreeBean) { | |||
cache.put(b); | |||
} | |||
} else { | |||
cache.put(bean); | |||
} | |||
} | |||
} | |||
@@ -87,4 +106,42 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||
cache.reset(bean); | |||
} | |||
} | |||
//树,改变父亲 | |||
protected R changeParent() throws Exception { | |||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | |||
if (table.getType() != TableType.TYPE_TREE) throw new SwException("非树型表,不支持更改父节点"); | |||
long id = params.readLong("id"); | |||
long parentId = params.readLong("parent_id"); | |||
AbstractCache<T> cache = CacheManager.getIntance().getCache(tableName); | |||
if (table.isNeedCache()) { | |||
bean = cache.get(id); | |||
} else { | |||
bean = loadComp(id); | |||
} | |||
//不考虑没有级次码等情况,这个在表设计时校验 | |||
ModelField fieldParentCode = table.findFieldByType(FieldType.PARENT_ID); | |||
bean.put(fieldParentCode.getName(), parentId); | |||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||
@Override | |||
public void work() throws Exception { | |||
EntityDao dao = DbEngine.getInstance().findDao(tableName); | |||
dao.updateEntity(bean, fieldParentCode.getName()); | |||
} | |||
@Override | |||
public void doAfterDbCommit() throws Exception { | |||
saveSuccess(); | |||
} | |||
@Override | |||
public void doAfterDbRollback() throws Exception { | |||
saveFailed(); | |||
} | |||
}); | |||
return R.success(); | |||
} | |||
} |
@@ -9,5 +9,6 @@ import cc.smtweb.framework.core.session.UserSession; | |||
* 所有handler的接口 | |||
*/ | |||
public interface IHandler { | |||
R doWork(SwMap params, UserSession us) throws Exception; | |||
void init(SwMap params, UserSession us); | |||
R doWork() throws Exception; | |||
} |
@@ -0,0 +1,83 @@ | |||
package cc.smtweb.framework.core.mvc.service; | |||
import cc.smtweb.framework.core.SwException; | |||
import cc.smtweb.framework.core.cache.AbstractCache; | |||
import cc.smtweb.framework.core.cache.CacheManager; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.EntityDao; | |||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||
import cc.smtweb.framework.core.db.vo.ModelField; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.framework.core.db.vo.def.FieldType; | |||
import cc.smtweb.framework.core.db.vo.def.TableType; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* Created by Akmm at 2022/3/17 19:56 | |||
*/ | |||
public class TreeHelper<T extends DefaultEntity> { | |||
private String tableName; | |||
private ModelTable table; | |||
private AbstractCache<T> cache; | |||
private EntityDao<T> dao; | |||
private String fieldParent; | |||
private String fieldLevelCode; | |||
public TreeHelper(String tableName) { | |||
this.tableName = tableName; | |||
table = ModelTableCache.getInstance().getByName(tableName); | |||
cache = CacheManager.getIntance().getCache(tableName); | |||
dao = DbEngine.getInstance().findDao(tableName); | |||
ModelField field = table.findFieldByType(FieldType.PARENT_ID); | |||
fieldParent = field.getName(); | |||
field = table.findFieldByType(FieldType.LEVEL_CODE); | |||
fieldLevelCode = field.getName(); | |||
} | |||
public long getParentId(T bean) { | |||
return bean.getLong(fieldParent); | |||
} | |||
public String getLevelCode(T bean) { | |||
return bean.getStr(fieldLevelCode); | |||
} | |||
public Collection<T> getChildren(T bean) { | |||
return cache.getListByKey(AbstractCache.KEY_PARENT_ID, String.valueOf(bean.getEntityId())); | |||
} | |||
public List<T> resetTreeLevel(T bean) throws Exception { | |||
List<T> list = new ArrayList<>(); | |||
if (table.getType() != TableType.TYPE_TREE) return list; | |||
if (!table.isNeedCache()) throw new SwException("请定义为需要缓存!"); | |||
T oldBean = cache.get(bean.getEntityId()); | |||
if (bean.getLong(fieldParent) != oldBean.getLong(fieldParent)) { | |||
resetParentChildren(bean, list); | |||
} | |||
return list; | |||
} | |||
private void resetParentChildren(T bean, List<T> list) throws Exception { | |||
T parent = cache.get(getParentId(bean)); | |||
if (parent != null) { | |||
bean.put(fieldLevelCode, getLevelCode(parent) + "-" + parent.getEntityId()); | |||
dao.updateEntity(bean, fieldLevelCode); | |||
list.add(bean); | |||
} | |||
Collection<T> children = getChildren(bean); | |||
if (children != null && !children.isEmpty()) { | |||
for (T child : children) { | |||
resetParentChildren(child, list); | |||
} | |||
} | |||
} | |||
} |
@@ -1,7 +1,6 @@ | |||
package cc.smtweb.system.bpm.core.ui.bind; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.cache.CacheManager; | |||
import cc.smtweb.framework.core.mvc.controller.IBeanContext; | |||
import cc.smtweb.framework.core.mvc.controller.IEditor; | |||
import cc.smtweb.system.bpm.core.exception.BpmException; | |||
@@ -10,7 +9,6 @@ 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 cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import javax.servlet.http.HttpServletRequest; | |||
import java.util.Map; | |||
@@ -8,11 +8,11 @@ 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.exception.BpmFieldError; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmFieldLookup; | |||
import cc.smtweb.system.bpm.engine.ui.entity.consts.UiEnum; | |||
import lombok.Getter; | |||
@@ -1,7 +1,10 @@ | |||
package cc.smtweb.system.bpm.core.ui.builder; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.sqlbuilder.*; | |||
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; | |||
@@ -5,8 +5,8 @@ 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.IParamConst; | |||
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; | |||
@@ -2,7 +2,6 @@ package cc.smtweb.system.bpm.core.ui.entity.form; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.system.bpm.engine.ui.entity.vo.widiget.UiControlDataVO; | |||
import cc.smtweb.system.bpm.engine.ui.entity.vo.widiget.UiControlVO; | |||
import lombok.Data; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -9,7 +9,6 @@ import cc.smtweb.system.bpm.core.ui.dataset.FieldFormatTool; | |||
import cc.smtweb.system.bpm.core.ui.dataset.FieldFormatter; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.*; | |||
import cc.smtweb.system.bpm.core.ui.service.AbstractDatasetService; | |||
import cc.smtweb.system.bpm.engine.entity.DictPO; | |||
import cc.smtweb.system.bpm.engine.ui.entity.consts.MappingTypeEnum; | |||
import cc.smtweb.system.bpm.engine.ui.entity.consts.UiEnum; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -9,7 +9,6 @@ import cc.smtweb.system.bpm.core.ui.dataset.FieldFormatTool; | |||
import cc.smtweb.system.bpm.core.ui.dataset.FieldFormatter; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.*; | |||
import cc.smtweb.system.bpm.core.ui.service.AbstractDatasetService; | |||
import cc.smtweb.system.bpm.engine.entity.DictPO; | |||
import cc.smtweb.system.bpm.engine.ui.entity.consts.UiEnum; | |||
import java.util.*; | |||
@@ -1,8 +1,8 @@ | |||
package cc.smtweb.system.bpm.core.ui.service.list; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.BpmMapData; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmFieldLookup; | |||
import cc.smtweb.system.bpm.core.ui.service.DatasetWorker; | |||
@@ -5,9 +5,9 @@ import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.annotation.SwBody; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.framework.core.db.vo.ModelField; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.system.bpm.engine.process.impl.entity.CommitTaskVO; | |||
import cc.smtweb.system.bpm.engine.process.impl.entity.LoadTaskAckVO; | |||
import cc.smtweb.system.bpm.engine.process.impl.entity.LoadTaskVO; | |||
@@ -1,17 +1,15 @@ | |||
package cc.smtweb.system.bpm.engine.process.impl.dao; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.cache.CacheManager; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.cache.ModelDatabaseCache; | |||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||
import cc.smtweb.framework.core.db.sqlbuilder.InsertSqlBuilder; | |||
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder; | |||
import cc.smtweb.framework.core.db.sqlbuilder.UpdateSqlBuilder; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.framework.core.util.DateUtil; | |||
import cc.smtweb.system.bpm.core.exception.BpmObjectNotFoundException; | |||
import cc.smtweb.system.bpm.core.exception.BpmLockRevException; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.system.bpm.core.exception.BpmObjectNotFoundException; | |||
import cc.smtweb.system.bpm.engine.process.impl.entity.ProcessLogPO; | |||
import cc.smtweb.system.bpm.engine.process.impl.entity.ProcessPO; | |||
import cc.smtweb.system.bpm.engine.process.impl.entity.TaskPO; | |||
@@ -2,8 +2,6 @@ package cc.smtweb.system.bpm.engine.process.impl.entity; | |||
import lombok.Data; | |||
import java.sql.Timestamp; | |||
@Data | |||
public class ProcessLogPO { | |||
private Long plId; | |||
@@ -2,8 +2,6 @@ package cc.smtweb.system.bpm.engine.process.impl.entity; | |||
import lombok.Data; | |||
import java.sql.Timestamp; | |||
@Data | |||
public class ProcessPO { | |||
private Long processId; | |||
@@ -2,8 +2,6 @@ package cc.smtweb.system.bpm.engine.process.runtime; | |||
import lombok.Data; | |||
import java.sql.Timestamp; | |||
@Data | |||
public class ProcessInfo { | |||
protected Long id; | |||
@@ -1,8 +1,8 @@ | |||
package cc.smtweb.system.bpm.engine.process.runtime; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.framework.core.util.JsonUtil; | |||
import cc.smtweb.system.bpm.core.exception.BpmObjectNotFoundException; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.system.bpm.engine.process.vo.Flow; | |||
import cc.smtweb.system.bpm.engine.process.vo.FlowAction; | |||
import cc.smtweb.system.bpm.engine.process.vo.FlowConnection; | |||
@@ -2,8 +2,6 @@ package cc.smtweb.system.bpm.engine.process.task; | |||
import lombok.Data; | |||
import java.sql.Timestamp; | |||
@Data | |||
public class TaskInfo { | |||
protected long id; | |||
@@ -1,7 +1,6 @@ | |||
package cc.smtweb.system.bpm.engine.ui.codegen; | |||
import cc.smtweb.framework.core.util.jackson.*; | |||
import cc.smtweb.framework.core.db.vo.ModelField; | |||
import cc.smtweb.system.bpm.util.CodeGenUtil; | |||
import com.fasterxml.jackson.annotation.JsonInclude; | |||
import com.fasterxml.jackson.core.JsonProcessingException; | |||
@@ -2,6 +2,9 @@ package cc.smtweb.system.bpm.engine.ui.loader.json; | |||
import cc.smtweb.framework.core.db.cache.ModelDatabaseCache; | |||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||
import cc.smtweb.framework.core.db.vo.ModelDatabase; | |||
import cc.smtweb.framework.core.db.vo.ModelField; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.framework.core.util.MapUtil; | |||
import cc.smtweb.system.bpm.core.exception.ModelLoaderError; | |||
import cc.smtweb.system.bpm.core.ui.IParamConst; | |||
@@ -9,9 +12,6 @@ import cc.smtweb.system.bpm.core.ui.dataset.FieldFormatTool; | |||
import cc.smtweb.system.bpm.core.ui.entity.BpmPage; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.*; | |||
import cc.smtweb.system.bpm.engine.AbstractLoader; | |||
import cc.smtweb.framework.core.db.vo.ModelDatabase; | |||
import cc.smtweb.framework.core.db.vo.ModelField; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.system.bpm.engine.ui.entity.consts.MappingTypeEnum; | |||
import cc.smtweb.system.bpm.engine.ui.entity.consts.UiEnum; | |||
import cc.smtweb.system.bpm.engine.ui.entity.vo.dataset.FzDatasetPropsVO; | |||
@@ -9,7 +9,6 @@ import cc.smtweb.system.bpm.core.ui.bind.BpmMapAttrEditor; | |||
import cc.smtweb.system.bpm.core.ui.bind.BpmPageContextEditor; | |||
import cc.smtweb.system.bpm.spring.action.BpmEventDao; | |||
import cc.smtweb.system.bpm.spring.action.BpmEventLoader; | |||
import cc.smtweb.system.bpm.spring.cache.BpmPageCache; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.ComponentScan; | |||
import org.springframework.context.annotation.Configuration; | |||
@@ -1,8 +1,8 @@ | |||
package cc.smtweb.system.bpm.spring; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.system.bpm.core.exception.BpmObjectNotFoundException; | |||
import cc.smtweb.system.bpm.core.exception.BpmIlegalArgumentException; | |||
import cc.smtweb.system.bpm.core.exception.BpmObjectNotFoundException; | |||
import cc.smtweb.system.bpm.engine.process.impl.dao.TaskDao; | |||
import cc.smtweb.system.bpm.engine.process.impl.entity.CommitTaskUserVO; | |||
import cc.smtweb.system.bpm.engine.process.runtime.*; | |||
@@ -13,7 +13,6 @@ import cc.smtweb.system.bpm.engine.process.vo.FlowConnection; | |||
import cc.smtweb.system.bpm.engine.process.vo.FlowNode; | |||
import cc.smtweb.system.bpm.engine.ui.IFormDataStore; | |||
import cc.smtweb.system.bpm.engine.ui.impl.FormDataStoreImpl; | |||
import cc.smtweb.system.bpm.spring.cache.BpmFlowCache; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.stereotype.Service; | |||
@@ -4,8 +4,8 @@ import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.service.DatasetApiInvoker; | |||
import cc.smtweb.system.bpm.core.ui.service.card.AbstractDatasetCardService; | |||
import cc.smtweb.system.bpm.core.ui.service.card.DatasetCardWorker; | |||
import cc.smtweb.system.bpm.core.ui.service.card.DatasetCardAgentWorker; | |||
import cc.smtweb.system.bpm.core.ui.service.card.DatasetCardWorker; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetCardDao; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import lombok.Setter; | |||
@@ -4,8 +4,8 @@ import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.service.DatasetApiInvoker; | |||
import cc.smtweb.system.bpm.core.ui.service.list.AbstractDatasetListService; | |||
import cc.smtweb.system.bpm.core.ui.service.list.DatasetListWorker; | |||
import cc.smtweb.system.bpm.core.ui.service.list.DatasetListAgentWorker; | |||
import cc.smtweb.system.bpm.core.ui.service.list.DatasetListWorker; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetListDao; | |||
import lombok.Setter; | |||
@@ -4,8 +4,8 @@ import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.service.DatasetApiInvoker; | |||
import cc.smtweb.system.bpm.core.ui.service.tree.AbstractDatasetTreeService; | |||
import cc.smtweb.system.bpm.core.ui.service.tree.DatasetTreeWorker; | |||
import cc.smtweb.system.bpm.core.ui.service.tree.DatasetTreeAgentWorker; | |||
import cc.smtweb.system.bpm.core.ui.service.tree.DatasetTreeWorker; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetTreeDao; | |||
import lombok.Setter; | |||
@@ -145,7 +145,7 @@ public class BpmPageCache extends AbstractCache<BpmPage> { | |||
} | |||
public BpmPage getByOtherKey(String otherKey) { | |||
BpmPage bean = localGetByKey(fn, otherKey); | |||
BpmPage bean = getByKey(fn, otherKey); | |||
if (bean == null) { | |||
bean = loadFromOtherKey(otherKey); | |||
if (bean != null) { | |||
@@ -1,7 +1,6 @@ | |||
package cc.smtweb.system.bpm.spring.dao; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.sqlbuilder.AbstractSelectSqlBuilder; | |||
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder; | |||
@@ -2,10 +2,10 @@ package cc.smtweb.system.bpm.spring.dao; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.db.sqlbuilder.AbstractSelectSqlBuilder; | |||
import cc.smtweb.system.bpm.core.ui.IParamConst; | |||
import cc.smtweb.system.bpm.core.ui.BpmKeyValue; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.BpmMapData; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.IParamConst; | |||
import cc.smtweb.system.bpm.core.ui.builder.SqlUtil; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmFieldFilter; | |||
@@ -2,8 +2,8 @@ package cc.smtweb.system.bpm.spring.dao; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.db.sqlbuilder.AbstractSelectSqlBuilder; | |||
import cc.smtweb.system.bpm.core.ui.IParamConst; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.IParamConst; | |||
import cc.smtweb.system.bpm.core.ui.builder.TreeDataBuilder; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||
import cc.smtweb.system.bpm.engine.entity.AspModelTreeVO; | |||
@@ -0,0 +1,88 @@ | |||
package cc.smtweb.system.bpm.web.design.catalog; | |||
import cc.smtweb.framework.core.annotation.SwTable; | |||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||
/** | |||
* Created by Akmm at 2022/3/1 15:35 | |||
*/ | |||
@SwTable("ASP_MODEL_CATALOG") | |||
public class ModelCatalog extends DefaultEntity { | |||
public static final String ENTITY_NAME = "ASP_MODEL_CATALOG"; | |||
public ModelCatalog() { | |||
super(ENTITY_NAME); | |||
} | |||
private long getMcId() { | |||
return getLong("mc_id"); | |||
} | |||
private void setMcId(long mcId) { | |||
put("mc_id", mcId); | |||
} | |||
private long getMcParentId() { | |||
return getLong("mc_parent_id"); | |||
} | |||
private void setMcParentId(long mcParentId) { | |||
put("mc_parent_id", mcParentId); | |||
} | |||
private String getMcCode() { | |||
return getStr("mc_code"); | |||
} | |||
private void setMcCode(String mcCode) { | |||
put("mc_code", mcCode); | |||
} | |||
private String getMcName() { | |||
return getStr("mc_name"); | |||
} | |||
private void setMcName(String mcName) { | |||
put("mc_name", mcName); | |||
} | |||
private long getMcPrjId() { | |||
return getLong("mc_prj_id"); | |||
} | |||
private void setMcPrjId(long mcPrjId) { | |||
put("mc_prj_id", mcPrjId); | |||
} | |||
private long getMcCreateUid() { | |||
return getLong("mc_create_uid"); | |||
} | |||
private void setMcCreateUid(long mcCreateUid) { | |||
put("mc_create_uid", mcCreateUid); | |||
} | |||
private long getMcUpdateUid() { | |||
return getLong("mc_update_uid"); | |||
} | |||
private void setMcUpdateUid(long mcUpdateUid) { | |||
put("mc_update_uid", mcUpdateUid); | |||
} | |||
private long getMcCreateAt() { | |||
return getLong("mc_create_at"); | |||
} | |||
private void setMcCreateAt(long mcCreateAt) { | |||
put("mc_create_at", mcCreateAt); | |||
} | |||
private long getMcUpdateAt() { | |||
return getLong("mc_update_at"); | |||
} | |||
private void setMcUpdateAt(long mcUpdateAt) { | |||
put("mc_update_at", mcUpdateAt); | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
package cc.smtweb.system.bpm.web.design.catalog; | |||
import cc.smtweb.framework.core.R; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.annotation.SwBody; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.mvc.service.*; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
/** | |||
* Created by Akmm at 2022/3/1 17:00 | |||
* 项目服务类 | |||
*/ | |||
@SwService | |||
public class ModelCatalogService extends AbstractCompService { | |||
@Override | |||
protected IHandler createHanlder(String type) { | |||
switch (type) { | |||
case TYPE_LOAD: | |||
return new DefaultLoadHandler<ModelCatalog>(ModelCatalog.ENTITY_NAME); | |||
case TYPE_SAVE: | |||
return new DefaultSaveHandler<>(ModelCatalog.ENTITY_NAME); | |||
case TYPE_DEL: | |||
return new DefaultDelHandler<>(ModelCatalog.ENTITY_NAME); | |||
case TYPE_LIST: | |||
return new DefaultListHandler<>(ModelCatalog.ENTITY_NAME); | |||
case TYPE_COMBO: | |||
return new DefaultListHandler<>(ModelCatalog.ENTITY_NAME); | |||
} | |||
return null; | |||
} | |||
} |
@@ -3,9 +3,9 @@ package cc.smtweb.system.bpm.web.design.codegen; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.system.bpm.engine.entity.AspModelTreeVO; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import cc.smtweb.system.bpm.util.ITreeDataLevelHandler; | |||
import cc.smtweb.system.bpm.util.TreeDataUtil; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import java.util.List; | |||
@@ -6,6 +6,8 @@ import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.cache.ModelDatabaseCache; | |||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||
import cc.smtweb.framework.core.db.vo.ModelDatabase; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.framework.file.FilePathGenerator; | |||
import cc.smtweb.system.bpm.core.exception.ModelLoaderError; | |||
@@ -13,8 +15,6 @@ import cc.smtweb.system.bpm.core.ui.entity.BpmPage; | |||
import cc.smtweb.system.bpm.core.ui.entity.dataset.BpmDataset; | |||
import cc.smtweb.system.bpm.core.ui.entity.form.BpmForm; | |||
import cc.smtweb.system.bpm.core.ui.entity.form.BpmWidget; | |||
import cc.smtweb.framework.core.db.vo.ModelDatabase; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.system.bpm.engine.entity.AspModelTreeVO; | |||
import cc.smtweb.system.bpm.engine.ui.codegen.DefaultVelocityEngine; | |||
import cc.smtweb.system.bpm.engine.ui.entity.yaml.YamlDataset; | |||
@@ -7,13 +7,13 @@ import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.cache.ModelDatabaseCache; | |||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||
import cc.smtweb.framework.core.db.config.DesignConfig; | |||
import cc.smtweb.framework.core.db.sqlbuilder.InsertSqlBuilder; | |||
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder; | |||
import cc.smtweb.framework.core.db.sqlbuilder.UpdateSqlBuilder; | |||
import cc.smtweb.framework.core.db.vo.ModelDatabase; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.framework.core.util.DateUtil; | |||
import cc.smtweb.framework.core.db.config.DesignConfig; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -5,6 +5,7 @@ import cc.smtweb.framework.core.annotation.SwBody; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.config.DesignConfig; | |||
import cc.smtweb.framework.core.db.sqlbuilder.InsertSqlBuilder; | |||
import cc.smtweb.framework.core.db.sqlbuilder.SqlBuilder; | |||
import cc.smtweb.framework.core.db.sqlbuilder.UpdateSqlBuilder; | |||
@@ -19,12 +20,11 @@ import cc.smtweb.system.bpm.engine.ui.loader.IPageRouter; | |||
import cc.smtweb.system.bpm.engine.ui.loader.TreePageRouter; | |||
import cc.smtweb.system.bpm.engine.ui.loader.UiMobileLoader; | |||
import cc.smtweb.system.bpm.engine.ui.loader.UiPcLoader; | |||
import cc.smtweb.framework.core.db.config.DesignConfig; | |||
import cc.smtweb.system.bpm.spring.cache.BpmFlowCache; | |||
import cc.smtweb.system.bpm.spring.cache.BpmPageCache; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import cc.smtweb.system.bpm.util.ITreeDataLevelHandler; | |||
import cc.smtweb.system.bpm.util.TreeDataUtil; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetConfigDao; | |||
import org.apache.commons.codec.digest.DigestUtils; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -4,8 +4,8 @@ import cc.smtweb.framework.core.R; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.system.bpm.spring.BpmConfigBean; | |||
import cc.smtweb.framework.core.db.config.DesignConfig; | |||
import cc.smtweb.system.bpm.spring.BpmConfigBean; | |||
import cc.smtweb.system.bpm.util.YamlUtil; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -3,8 +3,8 @@ package cc.smtweb.system.bpm.web.design.model; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.jdbc.IdGenerator; | |||
import cc.smtweb.framework.core.db.config.DesignConfig; | |||
import cc.smtweb.framework.core.db.jdbc.IdGenerator; | |||
import cc.smtweb.system.bpm.spring.cache.BpmFlowCache; | |||
import cc.smtweb.system.bpm.spring.cache.BpmPageCache; | |||
@@ -6,7 +6,6 @@ import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.system.bpm.engine.entity.AspModelCatalogPO; | |||
import cc.smtweb.system.bpm.web.design.preview.entity.AppVO; | |||
import java.util.List; | |||
@@ -5,10 +5,7 @@ import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.system.bpm.engine.entity.AspModelCatalogPO; | |||
import cc.smtweb.system.bpm.util.TreeDataUtil; | |||
import cc.smtweb.system.bpm.web.design.preview.entity.AppVO; | |||
import cc.smtweb.system.bpm.web.design.preview.entity.MenuVO; | |||
import java.util.List; | |||
@@ -1,15 +1,7 @@ | |||
package cc.smtweb.system.bpm.web.design.project; | |||
import cc.smtweb.framework.core.R; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.annotation.SwBody; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.db.DbEngine; | |||
import cc.smtweb.framework.core.db.EntityDao; | |||
import cc.smtweb.framework.core.mvc.service.*; | |||
import cc.smtweb.framework.core.session.UserSession; | |||
import cc.smtweb.system.bpm.engine.entity.AspModelPO; | |||
/** | |||
* Created by Akmm at 2022/3/1 17:00 | |||
@@ -28,6 +20,8 @@ public class ModelProjectService extends AbstractCompService { | |||
return new DefaultDelHandler<>(ModelProject.ENTITY_NAME); | |||
case TYPE_LIST: | |||
return new DefaultListHandler<>(ModelProject.ENTITY_NAME); | |||
case TYPE_COMBO: | |||
return new DefaultListHandler<>(ModelProject.ENTITY_NAME); | |||
} | |||
return null; | |||
} | |||
@@ -2,7 +2,6 @@ package cc.smtweb.system.bpm.web.task.service; | |||
import cc.smtweb.framework.core.SwMap; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.framework.core.db.config.DesignConfig; | |||
import cc.smtweb.framework.core.db.vo.ModelField; | |||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||
import cc.smtweb.framework.core.db.vo.def.DataType; | |||
@@ -3,7 +3,7 @@ package cc.smtweb.system.bpm.web.ui.dynform; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.service.card.*; | |||
import cc.smtweb.system.bpm.core.ui.service.card.AbstractDatasetCardService; | |||
import cc.smtweb.system.bpm.core.ui.service.card.DatasetCardWorker; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetCardDao; | |||
import cc.smtweb.system.bpm.web.ui.dao.JsonDatasetCardDao; | |||
@@ -2,8 +2,9 @@ package cc.smtweb.system.bpm.web.ui.dynform; | |||
import cc.smtweb.framework.core.annotation.SwParam; | |||
import cc.smtweb.framework.core.annotation.SwService; | |||
import cc.smtweb.system.bpm.core.ui.service.list.*; | |||
import cc.smtweb.system.bpm.core.ui.BpmPageContext; | |||
import cc.smtweb.system.bpm.core.ui.service.list.AbstractDatasetListService; | |||
import cc.smtweb.system.bpm.core.ui.service.list.DatasetListWorker; | |||
import cc.smtweb.system.bpm.spring.dao.DatasetListDao; | |||
import cc.smtweb.system.bpm.web.ui.dao.JsonDatasetListDao; | |||
@@ -1,5 +1,3 @@ | |||
import { usePageDatasets } from "/@/sw-form"; | |||
export default { | |||
create({ pageDataset }) { | |||
this.pageDataset = pageDataset; | |||
@@ -36,11 +36,11 @@ | |||
</template> | |||
<script lang="ts"> | |||
import { usePageEngineEx, tabRouter } from "sw-widget"; | |||
import datasets from "./dataset"; | |||
import eventObject from "./event"; | |||
import {tabRouter, usePageEngineEx} from "sw-widget"; | |||
import datasets from "./dataset"; | |||
import eventObject from "./event"; | |||
export default { | |||
export default { | |||
name: "$pageRef.routerName", | |||
props: { | |||
id: { | |||
@@ -1,6 +1,5 @@ | |||
package cc.smtweb.system.bpm.test; | |||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||
import cc.smtweb.system.bpm.util.CodeGenUtil; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.junit.Test; | |||
@@ -12,15 +11,15 @@ import org.junit.Test; | |||
public class BuildJavaBean { | |||
@Test | |||
public void buildBean() { | |||
String str = "`prj_id` bigint(20) NOT NULL DEFAULT '-1',\n" + | |||
" `prj_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目名称',\n" + | |||
" `prj_depends` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '依赖其他的项目',\n" + | |||
" `prj_desc` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目描述',\n" + | |||
" `prj_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态:0 启用,1 禁用',\n" + | |||
" `prj_create_uid` bigint(20) DEFAULT NULL,\n" + | |||
" `prj_update_uid` bigint(20) DEFAULT NULL,\n" + | |||
" `prj_create_at` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',\n" + | |||
" `prj_update_at` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',"; | |||
String str = "`mc_id` bigint(20) NOT NULL,\n" + | |||
" `mc_parent_id` bigint(20) DEFAULT NULL COMMENT '-1',\n" + | |||
" `mc_code` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,\n" + | |||
" `mc_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目名称',\n" + | |||
" `mc_prj_id` bigint(20) NOT NULL DEFAULT '-1',\n" + | |||
" `mc_create_uid` bigint(20) DEFAULT NULL,\n" + | |||
" `mc_update_uid` bigint(20) DEFAULT NULL,\n" + | |||
" `mc_create_at` bigint(20) NOT NULL DEFAULT '0',\n" + | |||
" `mc_update_at` bigint(20) NOT NULL DEFAULT '0',"; | |||
String[] ss = str.split("\n"); | |||
for (String s: ss) { | |||
String[] s0 = s.trim().split(" "); | |||
@@ -1,7 +1,6 @@ | |||
package cc.smtweb.system.bpm.test.codegen.test; | |||
import cc.smtweb.system.bpm.core.ui.entity.BpmPage; | |||
import cc.smtweb.system.bpm.engine.ui.loader.UiPcLoader; | |||
import org.apache.velocity.Template; | |||
import org.apache.velocity.VelocityContext; | |||
import org.apache.velocity.app.VelocityEngine; | |||
@@ -4,10 +4,11 @@ import cc.smtweb.framework.core.util.JsonUtil; | |||
import cc.smtweb.system.bpm.util.YamlUtil; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.junit.jupiter.api.Test; | |||
import java.io.*; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.FileOutputStream; | |||
import java.io.OutputStream; | |||
import java.util.HashMap; | |||
public class YamlToJsonTest { | |||