@@ -1,6 +1,6 @@ | |||||
package cc.smtweb.framework.core.cache.redis; | package cc.smtweb.framework.core.cache.redis; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.systask.SysTaskManager; | import cc.smtweb.framework.core.systask.SysTaskManager; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; | ||||
import cc.smtweb.framework.core.util.SpringUtil; | import cc.smtweb.framework.core.util.SpringUtil; | ||||
@@ -1,5 +1,6 @@ | |||||
package cc.smtweb.framework.core.common; | package cc.smtweb.framework.core.common; | ||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.util.MapUtil; | import cc.smtweb.framework.core.util.MapUtil; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
@@ -1,7 +1,8 @@ | |||||
package cc.smtweb.framework.core.db; | package cc.smtweb.framework.core.db; | ||||
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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.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; | ||||
@@ -154,7 +155,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> { | |||||
public int[] batchInsertEntity(List<T> entities, String fields) { | public int[] batchInsertEntity(List<T> entities, String fields) { | ||||
StringBuilder sql = new StringBuilder(); | StringBuilder sql = new StringBuilder(); | ||||
sql.append("insert into ").append(tableName).append("("); | |||||
sql.append("insert into ").append(modelTable.getSchemaTableName()).append("("); | |||||
List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value); | List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value); | ||||
List<EntityColumn> insertColumns = new ArrayList<>(this.columns.size()); | List<EntityColumn> insertColumns = new ArrayList<>(this.columns.size()); | ||||
@@ -234,7 +235,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> { | |||||
*/ | */ | ||||
public int deleteEntity(String whereSql, Object... params) { | public int deleteEntity(String whereSql, Object... params) { | ||||
StringBuilder sb = new StringBuilder("DELETE FROM "); | StringBuilder sb = new StringBuilder("DELETE FROM "); | ||||
sb.append(getTableName()).append(" ").append(whereSql); | |||||
sb.append(modelTable.getSchemaTableName()).append(" ").append(whereSql); | |||||
return jdbcEngine.update(sb.toString(), params); | return jdbcEngine.update(sb.toString(), params); | ||||
} | } | ||||
@@ -344,6 +345,11 @@ public class EntityDao<T> extends AbstractEntityDao<T> { | |||||
return jdbcEngine.queryLongList(sb.toString(), type, params); | return jdbcEngine.queryLongList(sb.toString(), type, params); | ||||
} | } | ||||
/** | |||||
* 检查表字段是否违反唯一索引 | |||||
* @param bean | |||||
* @param fields | |||||
*/ | |||||
public void checkUnique(T bean, String... fields) { | public void checkUnique(T bean, String... fields) { | ||||
if (fields.length == 0) return; | if (fields.length == 0) return; | ||||
String ss = "", sTitle = ""; | String ss = "", sTitle = ""; | ||||
@@ -355,7 +361,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> { | |||||
args.add(readValue(bean, f)); | args.add(readValue(bean, f)); | ||||
sTitle += "+" + modelTable.findFieldTitle(f); | sTitle += "+" + modelTable.findFieldTitle(f); | ||||
} | } | ||||
if (jdbcEngine.isExists("select 1 from " + tableName + " where " + modelTable.getIdField() + "=? " + ss, args.toArray())) | |||||
throw new SwException(sTitle.substring(1) + " 不能重复!"); | |||||
if (jdbcEngine.isExists("select 1 from " + modelTable.getSchemaTableName() + " where " + modelTable.getIdField() + "=? " + ss, args.toArray())) | |||||
throw new BizException(sTitle.substring(1) + " 不能重复!"); | |||||
} | } | ||||
} | } |
@@ -2,7 +2,8 @@ package cc.smtweb.framework.core.db; | |||||
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.SwException; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
@@ -155,15 +156,20 @@ public class EntityHelper { | |||||
//检查表记录是否被引用 | //检查表记录是否被引用 | ||||
public static void checkExists(long tableId, long id) { | public static void checkExists(long tableId, long id) { | ||||
ModelTable fkTable = ModelTableCache.getInstance().get(tableId); | ModelTable fkTable = ModelTableCache.getInstance().get(tableId); | ||||
if (fkTable == null) throw new SwException("待检查表(" + tableId + ")为空!"); | |||||
if (fkTable == null) throw new BizException("待检查表(" + tableId + ")为空!"); | |||||
checkExists(fkTable, id); | checkExists(fkTable, id); | ||||
} | } | ||||
public static void checkExists(String tableName, long id) { | public static void checkExists(String tableName, long id) { | ||||
ModelTable fkTable = ModelTableCache.getInstance().getByName(tableName); | ModelTable fkTable = ModelTableCache.getInstance().getByName(tableName); | ||||
if (fkTable == null) throw new SwException("待检查表(" + tableName + ")为空!"); | |||||
if (fkTable == null) throw new BizException("待检查表(" + tableName + ")为空!"); | |||||
checkExists(fkTable, id); | checkExists(fkTable, id); | ||||
} | } | ||||
/** | |||||
* 检查记录是否被使用 | |||||
* @param fkTable | |||||
* @param id | |||||
*/ | |||||
public static void checkExists(ModelTable fkTable, long id) { | public static void checkExists(ModelTable fkTable, long id) { | ||||
Set<ModelTable> list = ModelTableCache.getInstance().getByLink(fkTable.getId()); | Set<ModelTable> list = ModelTableCache.getInstance().getByLink(fkTable.getId()); | ||||
if (list == null || list.isEmpty()) return; | if (list == null || list.isEmpty()) return; | ||||
@@ -178,8 +184,10 @@ public class EntityHelper { | |||||
} | } | ||||
if (sql.length() == 0) continue; | if (sql.length() == 0) continue; | ||||
if (DbEngine.getInstance().isExists("select 1 from " + table.getSchemaTableName() + " where " + sql.substring(4), args.toArray())) { | if (DbEngine.getInstance().isExists("select 1 from " + table.getSchemaTableName() + " where " + sql.substring(4), args.toArray())) { | ||||
throw new SwException("该记录被表【" + table.getTitle() + "(" + table.getName() + ")】引用,不能删除!"); | |||||
throw new BizException("该记录被表【" + table.getTitle() + "(" + table.getName() + ")】引用,不能删除!"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -3,7 +3,7 @@ package cc.smtweb.framework.core.db.dao; | |||||
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.exception.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; | ||||
@@ -179,7 +179,7 @@ public abstract class AbstractEntityDao<T> { | |||||
protected Object[] handleInsert(T obj, StringBuilder sql, String fields) { | protected Object[] handleInsert(T obj, StringBuilder sql, String fields) { | ||||
List<Object> result; | List<Object> result; | ||||
List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value); | List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value); | ||||
sql.append("insert into ").append(tableName).append("("); | |||||
sql.append("insert into ").append(modelTable.getSchemaTableName()).append("("); | |||||
updateTime(obj, SwEnum.FieldType.CREATE_TIME.value); | updateTime(obj, SwEnum.FieldType.CREATE_TIME.value); | ||||
updateTime(obj, SwEnum.FieldType.LAST_TIME.value); | updateTime(obj, SwEnum.FieldType.LAST_TIME.value); | ||||
@@ -228,7 +228,7 @@ public abstract class AbstractEntityDao<T> { | |||||
List<String> listFields = adjustFields(fields, SwEnum.FieldType.LAST_TIME.value); | List<String> listFields = adjustFields(fields, SwEnum.FieldType.LAST_TIME.value); | ||||
updateTime(obj, SwEnum.FieldType.LAST_TIME.value); | updateTime(obj, SwEnum.FieldType.LAST_TIME.value); | ||||
sql.append("update ").append(tableName).append(" set "); | |||||
sql.append("update ").append(modelTable.getSchemaTableName()).append(" set "); | |||||
List<Object> result = new ArrayList<>(); | List<Object> result = new ArrayList<>(); | ||||
if (listFields == null) { | if (listFields == null) { | ||||
@@ -300,7 +300,7 @@ public abstract class AbstractEntityDao<T> { | |||||
protected Object[] handleDelete(T obj, StringBuilder sql) { | protected Object[] handleDelete(T obj, StringBuilder sql) { | ||||
EntityColumn idColumn = findIdColumn(); | EntityColumn idColumn = findIdColumn(); | ||||
sql.append("DELETE FROM ").append(tableName).append(" WHERE ").append(idColumn.getField()).append("=?"); | |||||
sql.append("DELETE FROM ").append(modelTable.getSchemaTableName()).append(" WHERE ").append(idColumn.getField()).append("=?"); | |||||
return new Object[]{idColumn.readValue(obj)}; | return new Object[]{idColumn.readValue(obj)}; | ||||
} | } | ||||
@@ -312,7 +312,7 @@ public abstract class AbstractEntityDao<T> { | |||||
*/ | */ | ||||
protected void handleDelete(StringBuilder sql) { | protected void handleDelete(StringBuilder sql) { | ||||
EntityColumn idColumn = findIdColumn(); | EntityColumn idColumn = findIdColumn(); | ||||
sql.append("DELETE FROM ").append(tableName).append(" WHERE ").append(idColumn.getField().getName()).append("=?"); | |||||
sql.append("DELETE FROM ").append(modelTable.getSchemaTableName()).append(" WHERE ").append(idColumn.getField().getName()).append("=?"); | |||||
} | } | ||||
public Object readValue(T obj, String fieldName) { | public Object readValue(T obj, String fieldName) { | ||||
@@ -333,15 +333,6 @@ public abstract class AbstractEntityDao<T> { | |||||
} | } | ||||
/** | /** | ||||
* 获取表名 | |||||
* | |||||
* @return 表名 | |||||
*/ | |||||
protected String getTableName() { | |||||
return tableName; | |||||
} | |||||
/** | |||||
* 拼接查询SQL语句 | * 拼接查询SQL语句 | ||||
* | * | ||||
* @param sql SQL字符缓存 | * @param sql SQL字符缓存 | ||||
@@ -359,7 +350,7 @@ public abstract class AbstractEntityDao<T> { | |||||
sql.setCharAt(sql.length() - 1, ' '); | sql.setCharAt(sql.length() - 1, ' '); | ||||
} | } | ||||
sql.append("from ").append(tableName); | |||||
sql.append("from ").append(modelTable.getSchemaTableName()); | |||||
} | } | ||||
protected void handleSelectOne(StringBuilder sql, String fields) { | protected void handleSelectOne(StringBuilder sql, String fields) { | ||||
@@ -376,7 +367,7 @@ public abstract class AbstractEntityDao<T> { | |||||
sql.setCharAt(sql.length() - 1, ' '); | sql.setCharAt(sql.length() - 1, ' '); | ||||
} | } | ||||
sql.append("from ").append(tableName).append(" where ").append(idColumn.getField().getName()).append("=?"); | |||||
sql.append("from ").append(modelTable.getSchemaTableName()).append(" where ").append(idColumn.getField().getName()).append("=?"); | |||||
} | } | ||||
/** | /** | ||||
@@ -391,7 +382,7 @@ public abstract class AbstractEntityDao<T> { | |||||
return (Long) idColumn.readValue(entity); | return (Long) idColumn.readValue(entity); | ||||
} | } | ||||
public T createBean() throws SwException { | |||||
public T createBean() { | |||||
try { | try { | ||||
T bean = this.type.newInstance(); | T bean = this.type.newInstance(); | ||||
if (bean instanceof DefaultEntity) { | if (bean instanceof DefaultEntity) { | ||||
@@ -1,12 +1,11 @@ | |||||
package cc.smtweb.framework.core.db.jdbc; | package cc.smtweb.framework.core.db.jdbc; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.impl.BaseBean; | import cc.smtweb.framework.core.db.impl.BaseBean; | ||||
import cc.smtweb.framework.core.exception.DbException; | import cc.smtweb.framework.core.exception.DbException; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.dao.DataAccessException; | |||||
import org.springframework.dao.EmptyResultDataAccessException; | import org.springframework.dao.EmptyResultDataAccessException; | ||||
import org.springframework.jdbc.core.BeanPropertyRowMapper; | import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||||
import org.springframework.jdbc.core.JdbcTemplate; | import org.springframework.jdbc.core.JdbcTemplate; | ||||
@@ -1,7 +1,5 @@ | |||||
package cc.smtweb.framework.core.exception; | package cc.smtweb.framework.core.exception; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
/** | /** | ||||
* bean绑定错误 | * bean绑定错误 | ||||
* @author kevin | * @author kevin | ||||
@@ -1,7 +1,5 @@ | |||||
package cc.smtweb.framework.core.exception; | package cc.smtweb.framework.core.exception; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import java.text.ParseException; | import java.text.ParseException; | ||||
public class BindParamException extends SwException { | public class BindParamException extends SwException { | ||||
@@ -1,13 +0,0 @@ | |||||
package cc.smtweb.framework.core.exception; | |||||
import cc.smtweb.framework.core.common.SwException; | |||||
public class CacheException extends SwException { | |||||
public CacheException(String message) { | |||||
super(message); | |||||
} | |||||
public CacheException(Throwable e) { | |||||
super(e); | |||||
} | |||||
} |
@@ -1,7 +1,5 @@ | |||||
package cc.smtweb.framework.core.exception; | package cc.smtweb.framework.core.exception; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
public class JsonParseException extends SwException { | public class JsonParseException extends SwException { | ||||
public JsonParseException(String s, Exception e) { | public JsonParseException(String s, Exception e) { | ||||
super(s, e); | super(s, e); | ||||
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.framework.core.common; | |||||
package cc.smtweb.framework.core.exception; | |||||
import cc.smtweb.framework.core.exception.ExceptionMessage; | import cc.smtweb.framework.core.exception.ExceptionMessage; | ||||
@@ -1,6 +1,8 @@ | |||||
package cc.smtweb.framework.core.mvc.controller.access; | package cc.smtweb.framework.core.mvc.controller.access; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
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.binder.ParamEditor; | import cc.smtweb.framework.core.mvc.controller.binder.ParamEditor; | ||||
@@ -14,99 +16,102 @@ import java.util.Map; | |||||
/** | /** | ||||
* API方法执行 | * API方法执行 | ||||
* | |||||
* @author xkliu | * @author xkliu | ||||
*/ | */ | ||||
public class MethodAccess implements IMethodAccess { | public class MethodAccess implements IMethodAccess { | ||||
private final ControllerAccess controllerAccess; | |||||
private final Method method; | |||||
@Getter | |||||
private final String perm; | |||||
private final MethodParamAccess[] paramBinds; | |||||
public MethodAccess(ControllerAccess controllerAccess, Method method, String perm, MethodParamAccess[] paramBinds) { | |||||
this.controllerAccess = controllerAccess; | |||||
this.method = method; | |||||
this.perm = perm; | |||||
this.paramBinds = paramBinds; | |||||
} | |||||
@Override | |||||
public Class<?> getReturnType() { | |||||
return this.method.getReturnType(); | |||||
} | |||||
@Override | |||||
public Class<?> getBodyType() { | |||||
for (MethodParamAccess methodParamAccess: paramBinds) { | |||||
if (methodParamAccess.getBindType() == ParamEditor.TYPE_BODY) { | |||||
return methodParamAccess.getParamType(); | |||||
} | |||||
private final ControllerAccess controllerAccess; | |||||
private final Method method; | |||||
@Getter | |||||
private final String perm; | |||||
private final MethodParamAccess[] paramBinds; | |||||
public MethodAccess(ControllerAccess controllerAccess, Method method, String perm, MethodParamAccess[] paramBinds) { | |||||
this.controllerAccess = controllerAccess; | |||||
this.method = method; | |||||
this.perm = perm; | |||||
this.paramBinds = paramBinds; | |||||
} | } | ||||
return null; | |||||
} | |||||
@Override | |||||
public Class<?> getReturnType() { | |||||
return this.method.getReturnType(); | |||||
} | |||||
@Override | |||||
public Class<?> getBodyType() { | |||||
for (MethodParamAccess methodParamAccess : paramBinds) { | |||||
if (methodParamAccess.getBindType() == ParamEditor.TYPE_BODY) { | |||||
return methodParamAccess.getParamType(); | |||||
} | |||||
} | |||||
@Override | |||||
public Class<?> getAttrType(String paramName) { | |||||
for (MethodParamAccess methodParamAccess: paramBinds) { | |||||
if (methodParamAccess.getBindType() == ParamEditor.TYPE_ATTR && paramName.equals(methodParamAccess.getParamName())) { | |||||
return methodParamAccess.getParamType(); | |||||
} | |||||
return null; | |||||
} | } | ||||
return null; | |||||
} | |||||
@Override | |||||
public Class<?> getAttrType(String paramName) { | |||||
for (MethodParamAccess methodParamAccess : paramBinds) { | |||||
if (methodParamAccess.getBindType() == ParamEditor.TYPE_ATTR && paramName.equals(methodParamAccess.getParamName())) { | |||||
return methodParamAccess.getParamType(); | |||||
} | |||||
} | |||||
@Override | |||||
public Object invoke(IBeanContext context) { | |||||
return invoke(context, null, null, null); | |||||
} | |||||
return null; | |||||
} | |||||
@Override | |||||
public Object invoke(IBeanContext context, Map<String, Object> params, String body, HttpServletRequest request) { | |||||
// 通过请求数据转换函数参数值 | |||||
Object[] args = null; | |||||
@Override | |||||
public Object invoke(IBeanContext context) { | |||||
return invoke(context, null, null, null); | |||||
} | |||||
if (!ObjectUtils.isEmpty(paramBinds)) { | |||||
args = new Object[paramBinds.length]; | |||||
for (int i = 0; i < paramBinds.length; i++) { | |||||
MethodParamAccess param = paramBinds[i]; | |||||
@Override | |||||
public Object invoke(IBeanContext context, Map<String, Object> params, String body, HttpServletRequest request) { | |||||
// 通过请求数据转换函数参数值 | |||||
Object[] args = null; | |||||
if (!ObjectUtils.isEmpty(paramBinds)) { | |||||
args = new Object[paramBinds.length]; | |||||
for (int i = 0; i < paramBinds.length; i++) { | |||||
MethodParamAccess param = paramBinds[i]; | |||||
try { | |||||
args[i] = param.getParamValue(context, params, body, request); | |||||
} catch (Exception e) { | |||||
throw new BindBeanException(String.format("%s error value: %s", param.getParamName(), param.toString()), e); | |||||
} | |||||
} | |||||
} | |||||
// 获取服务实例,然后执行方法 | |||||
try { | try { | ||||
args[i] = param.getParamValue(context, params, body, request); | |||||
} catch (Exception e) { | |||||
throw new BindBeanException(String.format("%s error value: %s", param.getParamName(), param.toString()), e); | |||||
Object instance = controllerAccess.getOrNewInstance(context, params); | |||||
return method.invoke(instance, args); | |||||
} catch (IllegalAccessException | InstantiationException e) { | |||||
throw new SwException(e); | |||||
} catch (InvocationTargetException e) { | |||||
throw new SwException(e.getCause()); | |||||
} catch (BizException e) { | |||||
return R.error(e.getMessage()); | |||||
} | } | ||||
} | |||||
} | } | ||||
// 获取服务实例,然后执行方法 | |||||
try { | |||||
Object instance = controllerAccess.getOrNewInstance(context, params); | |||||
return method.invoke(instance, args); | |||||
} catch (IllegalAccessException | InstantiationException e) { | |||||
throw new SwException(e); | |||||
} catch (InvocationTargetException e) { | |||||
throw new SwException(e.getCause()); | |||||
} | |||||
} | |||||
@Override | |||||
public String fullName() { | |||||
return controllerAccess.getFullName() + "." + method.getName(); | |||||
} | |||||
public Class<?> findParam(Class<?> clazz) { | |||||
for (MethodParamAccess param: paramBinds) { | |||||
Class<?> paramType = param.getParamType(); | |||||
if (clazz.equals(paramType)) { | |||||
return paramType; | |||||
} | |||||
@Override | |||||
public String fullName() { | |||||
return controllerAccess.getFullName() + "." + method.getName(); | |||||
} | } | ||||
return null; | |||||
} | |||||
public Class<?> findParam(Class<?> clazz) { | |||||
for (MethodParamAccess param : paramBinds) { | |||||
Class<?> paramType = param.getParamType(); | |||||
if (clazz.equals(paramType)) { | |||||
return paramType; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public String controllerFullName() { | |||||
return this.controllerAccess.getFullName(); | |||||
} | |||||
public String controllerFullName() { | |||||
return this.controllerAccess.getFullName(); | |||||
} | |||||
} | } |
@@ -4,7 +4,7 @@ import cc.smtweb.framework.core.annotation.SwBean; | |||||
import cc.smtweb.framework.core.annotation.SwConstruct; | import cc.smtweb.framework.core.annotation.SwConstruct; | ||||
import cc.smtweb.framework.core.annotation.SwDestroy; | import cc.smtweb.framework.core.annotation.SwDestroy; | ||||
import cc.smtweb.framework.core.annotation.SwScheduling; | import cc.smtweb.framework.core.annotation.SwScheduling; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
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,6 @@ | |||||
package cc.smtweb.framework.core.mvc.realm.exception; | package cc.smtweb.framework.core.mvc.realm.exception; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
public class AuthorizationException extends SwException { | public class AuthorizationException extends SwException { | ||||
public AuthorizationException(String s) { | public AuthorizationException(String s) { | ||||
@@ -2,7 +2,8 @@ package cc.smtweb.framework.core.mvc.service; | |||||
import cc.smtweb.framework.core.annotation.SwBody; | 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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
@@ -22,7 +23,7 @@ public abstract class AbstractCompService { | |||||
protected AbstractHandler getHandler(SwMap params, UserSession us, String type) throws Exception { | protected AbstractHandler getHandler(SwMap params, UserSession us, String type) throws Exception { | ||||
AbstractHandler handler = createHandler(type); | AbstractHandler handler = createHandler(type); | ||||
if (handler == null) throw new SwException("暂不支持此类服务:" + type); | |||||
if (handler == null) throw new BizException("暂不支持此类服务:" + type); | |||||
if (params == null) params = new SwMap(); | if (params == null) params = new SwMap(); | ||||
if (us == null) us = UserSession.createSys(); | if (us == null) us = UserSession.createSys(); | ||||
handler.init(params, us); | handler.init(params, us); | ||||
@@ -2,7 +2,8 @@ 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.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
@@ -31,7 +32,7 @@ public class DefaultComboHandler<T extends DefaultEntity> extends DefaultListHan | |||||
protected SwListData filterData() { | protected SwListData filterData() { | ||||
String text = params.readString("text"); | String text = params.readString("text"); | ||||
if (StringUtils.isEmpty(text)) throw new SwException("没有搜素内容!"); | |||||
if (StringUtils.isEmpty(text)) throw new BizException("没有搜素内容!"); | |||||
SqlPara sqlPara = buildDataSql(); | SqlPara sqlPara = buildDataSql(); | ||||
String sort = params.readString("sort"); | String sort = params.readString("sort"); | ||||
@@ -42,7 +43,7 @@ public class DefaultComboHandler<T extends DefaultEntity> extends DefaultListHan | |||||
Collections.addAll(args, sqlPara.paras); | Collections.addAll(args, sqlPara.paras); | ||||
buildFilterCondition(text, sqlFilter, args); | buildFilterCondition(text, sqlFilter, args); | ||||
if (sqlFilter.length() == 0) throw new SwException("没有待搜索的字段!"); | |||||
if (sqlFilter.length() == 0) throw new BizException("没有待搜索的字段!"); | |||||
String sql = "select ar.* from (" + sqlPara.sql + ") ar where " + sqlFilter.substring(4); | String sql = "select ar.* from (" + sqlPara.sql + ") ar where " + sqlFilter.substring(4); | ||||
if (StringUtils.isNotEmpty(sort)) { | if (StringUtils.isNotEmpty(sort)) { | ||||
@@ -1,6 +1,7 @@ | |||||
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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.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.EntityHelper; | import cc.smtweb.framework.core.db.EntityHelper; | ||||
@@ -23,7 +24,7 @@ public class DefaultProvider<T extends DefaultEntity> extends AbstractCompProvid | |||||
private T loadBean(long id) { | private T loadBean(long id) { | ||||
EntityDao<T> bdao = (EntityDao<T>) DbEngine.getInstance().findDao(tableName); | EntityDao<T> bdao = (EntityDao<T>) DbEngine.getInstance().findDao(tableName); | ||||
T bean = bdao.queryEntity(id); | T bean = bdao.queryEntity(id); | ||||
if (bean == null) throw new SwException("没有找到指定数据(id=" + id + ")"); | |||||
if (bean == null) throw new BizException("没有找到指定数据(id=" + id + ")"); | |||||
EntityHelper.loadBeanLink(bean.getTableName(), bean.getData(), null); | EntityHelper.loadBeanLink(bean.getTableName(), bean.getData(), null); | ||||
return bean; | return bean; | ||||
} | } | ||||
@@ -4,7 +4,8 @@ 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.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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.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; | ||||
@@ -68,7 +69,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | 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()))) { | if (field.isNotNull() && StringUtils.isEmpty(bean.getStr(field.getName()))) { | ||||
throw new SwException(field.getTitle() + "不能为空!"); | |||||
throw new BizException(field.getTitle() + "不能为空!"); | |||||
} | } | ||||
if (field.getFieldType() == SwEnum.FieldType.PARENT_ID.value) { | if (field.getFieldType() == SwEnum.FieldType.PARENT_ID.value) { | ||||
TreeHelper.getTreeHelper(tableName).checkParent(bean); | TreeHelper.getTreeHelper(tableName).checkParent(bean); | ||||
@@ -136,7 +137,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||||
//树,改变父亲 | //树,改变父亲 | ||||
public R changeParent(){ | public R changeParent(){ | ||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ||||
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) throw new SwException("非树型表,不支持更改父节点"); | |||||
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) throw new BizException("非树型表,不支持更改父节点"); | |||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
long parentId = params.readLong("parent_id"); | long parentId = params.readLong("parent_id"); | ||||
@@ -4,7 +4,8 @@ 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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.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; | ||||
@@ -90,22 +91,22 @@ public class TreeHelper<T extends DefaultEntity> { | |||||
public void checkParent(T bean) { | public void checkParent(T bean) { | ||||
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return; | if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return; | ||||
if (!table.isNeedCache()) throw new SwException("请定义为需要缓存!"); | |||||
if (!table.isNeedCache()) throw new BizException("请将树型表定义为需要缓存!"); | |||||
long pId = getParentId(bean); | long pId = getParentId(bean); | ||||
if (bean.getEntityId() == pId) throw new SwException("上级节点不能为自己!"); | |||||
if (bean.getEntityId() == pId) throw new BizException("上级节点不能为自己!"); | |||||
if (pId <= 0) return; | if (pId <= 0) return; | ||||
T parent = cache.get(pId); | T parent = cache.get(pId); | ||||
if (parent == null) return; | if (parent == null) return; | ||||
String plevelcode = SwConsts.SPLIT_CHAR + parent.getStr(fieldLevelCode) + SwConsts.SPLIT_CHAR; | String plevelcode = SwConsts.SPLIT_CHAR + parent.getStr(fieldLevelCode) + SwConsts.SPLIT_CHAR; | ||||
if (plevelcode.contains(SwConsts.SPLIT_CHAR + bean.getEntityId() + SwConsts.SPLIT_CHAR)) { | if (plevelcode.contains(SwConsts.SPLIT_CHAR + bean.getEntityId() + SwConsts.SPLIT_CHAR)) { | ||||
throw new SwException("上级节点不能为自己的下级!"); | |||||
throw new BizException("上级节点不能为自己的下级!"); | |||||
} | } | ||||
} | } | ||||
public List<T> resetTreeLevel(T bean) { | public List<T> resetTreeLevel(T bean) { | ||||
List<T> list = new ArrayList<>(); | List<T> list = new ArrayList<>(); | ||||
if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return list; | if (table.getType() != SwEnum.TableType.TYPE_TREE.value) return list; | ||||
if (!table.isNeedCache()) throw new SwException("请定义为需要缓存!"); | |||||
if (!table.isNeedCache()) throw new BizException("请定义为需要缓存!"); | |||||
T oldBean = cache.get(bean.getEntityId()); | T oldBean = cache.get(bean.getEntityId()); | ||||
if (bean.getLong(fieldParent) != oldBean.getLong(fieldParent)) { | if (bean.getLong(fieldParent) != oldBean.getLong(fieldParent)) { | ||||
@@ -1,6 +1,7 @@ | |||||
package cc.smtweb.framework.core.mvc.variable; | package cc.smtweb.framework.core.mvc.variable; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.framework.core.util.DateUtil; | import cc.smtweb.framework.core.util.DateUtil; | ||||
@@ -31,14 +32,14 @@ public class SwVariableFactory { | |||||
//注册变量 | //注册变量 | ||||
public void regVariable(String name, String label, String remark, ICalcVar calcVar) { | public void regVariable(String name, String label, String remark, ICalcVar calcVar) { | ||||
if (map.containsKey(name)) throw new SwException("变量重复定义:name=" + name); | |||||
if (map.containsKey(name)) throw new BizException("变量重复定义:name=" + name); | |||||
map.put(name, new SwVariable(name, label, remark, calcVar)); | map.put(name, new SwVariable(name, label, remark, calcVar)); | ||||
} | } | ||||
//计算变量值 | //计算变量值 | ||||
public Object calcVar(String name, SwMap params, UserSession us) { | public Object calcVar(String name, SwMap params, UserSession us) { | ||||
SwVariable var = map.get(name); | SwVariable var = map.get(name); | ||||
if (var == null) throw new SwException("没有定义此变量:" + name); | |||||
if (var == null) throw new BizException("没有定义此变量:" + name); | |||||
return var.getCalcVar().calcVar(params, us); | return var.getCalcVar().calcVar(params, us); | ||||
} | } | ||||
} | } |
@@ -1,6 +1,6 @@ | |||||
package cc.smtweb.system.bpm.util; | package cc.smtweb.system.bpm.util; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import org.springframework.beans.BeanUtils; | import org.springframework.beans.BeanUtils; | ||||
import org.springframework.beans.BeansException; | import org.springframework.beans.BeansException; | ||||
@@ -1,25 +1,17 @@ | |||||
package cc.smtweb.system.bpm.util; | package cc.smtweb.system.bpm.util; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
import cc.smtweb.framework.core.util.DateUtil; | |||||
import freemarker.template.Configuration; | import freemarker.template.Configuration; | ||||
import freemarker.template.Template; | import freemarker.template.Template; | ||||
import freemarker.template.TemplateMethodModelEx; | import freemarker.template.TemplateMethodModelEx; | ||||
import freemarker.template.TemplateModelException; | import freemarker.template.TemplateModelException; | ||||
import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import sun.nio.ch.IOUtil; | |||||
import java.io.*; | import java.io.*; | ||||
import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collection; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -4,10 +4,10 @@ import cc.smtweb.framework.core.common.*; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelCache; | import cc.smtweb.framework.core.db.vo.ModelCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelProject; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.mvc.service.AbstractHandler; | import cc.smtweb.framework.core.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.util.CommUtil; | |||||
import cc.smtweb.framework.core.util.DateUtil; | import cc.smtweb.framework.core.util.DateUtil; | ||||
import cc.smtweb.framework.core.util.MapUtil; | import cc.smtweb.framework.core.util.MapUtil; | ||||
import cc.smtweb.framework.core.util.SpringUtil; | import cc.smtweb.framework.core.util.SpringUtil; | ||||
@@ -65,7 +65,7 @@ public class CodeBuildHandler extends AbstractHandler { | |||||
*/ | */ | ||||
private void buildCodeJavaPath(long pageId) { | private void buildCodeJavaPath(long pageId) { | ||||
ModelForm form = ModelFormCache.getInstance().get(pageId); | ModelForm form = ModelFormCache.getInstance().get(pageId); | ||||
if (form == null) throw new SwException("未找到指定的页面定义!"); | |||||
if (form == null) throw new BizException("未找到指定的页面定义(" + pageId + ")!"); | |||||
String moduleName = ModelProjectCache.getInstance().getModule(form.getPrjId()); | String moduleName = ModelProjectCache.getInstance().getModule(form.getPrjId()); | ||||
if (StringUtils.isEmpty(moduleName) || SwConsts.DEF_DB_NAME.equals(moduleName) || moduleName.equals("bpm")) { | if (StringUtils.isEmpty(moduleName) || SwConsts.DEF_DB_NAME.equals(moduleName) || moduleName.equals("bpm")) { | ||||
@@ -76,10 +76,10 @@ public class CodeBuildHandler extends AbstractHandler { | |||||
} | } | ||||
BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class); | BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class); | ||||
Map<String, String> mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath()); | Map<String, String> mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath()); | ||||
if (mapIdeaModules == null || mapIdeaModules.isEmpty()) throw new SwException("没有定义idea项目的路径!"); | |||||
if (mapIdeaModules == null || mapIdeaModules.isEmpty()) throw new BizException("没有定义idea项目的路径(smtweb.bpm.codeJavaPath)!"); | |||||
codeJavaPath = mapIdeaModules.get(moduleName); | codeJavaPath = mapIdeaModules.get(moduleName); | ||||
if (StringUtils.isEmpty(codeJavaPath)) { | if (StringUtils.isEmpty(codeJavaPath)) { | ||||
throw new SwException("没有找到对应项目在idea中Module的路径!"); | |||||
throw new BizException("没有找到对应项目在idea中Module的路径(" + moduleName + ")!"); | |||||
} | } | ||||
codeJavaPath += "/src/main/java/"; | codeJavaPath += "/src/main/java/"; | ||||
//加上目录 | //加上目录 | ||||
@@ -98,7 +98,7 @@ public class CodeBuildHandler extends AbstractHandler { | |||||
*/ | */ | ||||
private void buildJavaTable(long tableId, boolean needBean, boolean needCache) { | private void buildJavaTable(long tableId, boolean needBean, boolean needCache) { | ||||
ModelTable table = ModelTableCache.getInstance().get(tableId); | ModelTable table = ModelTableCache.getInstance().get(tableId); | ||||
if (table == null) throw new SwException("没有找到对应的表定义!"); | |||||
if (table == null) throw new BizException("没有找到对应的表定义(" + tableId + ")!"); | |||||
SwMap model = new SwMap(); | SwMap model = new SwMap(); | ||||
model.put("user", userName); | model.put("user", userName); | ||||
model.put("sysTime", DateUtil.nowDateTime()); | model.put("sysTime", DateUtil.nowDateTime()); | ||||
@@ -126,7 +126,7 @@ public class CodeBuildHandler extends AbstractHandler { | |||||
} | } | ||||
if (needCache) { | if (needCache) { | ||||
if (!table.isNeedCache()) throw new SwException("表设置为不需要缓存!" + table.getTitle()); | |||||
if (!table.isNeedCache()) throw new BizException("表设置为不需要缓存!" + table.getTitle()); | |||||
List<SwMap> caches = new ArrayList<>(); | List<SwMap> caches = new ArrayList<>(); | ||||
model.put("caches", caches); | model.put("caches", caches); | ||||
for (ModelCache cache : table.getCaches()) { | for (ModelCache cache : table.getCaches()) { | ||||
@@ -146,7 +146,7 @@ public class CodeBuildHandler extends AbstractHandler { | |||||
private void buildJavaService(long pageId) { | private void buildJavaService(long pageId) { | ||||
ModelForm form = ModelFormCache.getInstance().get(pageId); | ModelForm form = ModelFormCache.getInstance().get(pageId); | ||||
String sName = form.getService(); | String sName = form.getService(); | ||||
if (StringUtils.isEmpty(sName)) throw new SwException("页面设置未定义服务名!" + form.getTitle()); | |||||
if (StringUtils.isEmpty(sName)) throw new BizException("页面设置未定义服务名!" + form.getTitle()); | |||||
sName = CodeGenUtil.toUpperHump(sName); | sName = CodeGenUtil.toUpperHump(sName); | ||||
SwMap model = new SwMap(); | SwMap model = new SwMap(); | ||||
@@ -2,7 +2,8 @@ package cc.smtweb.system.bpm.web.design.form; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
@@ -98,16 +99,16 @@ public class ModelFormHelper { | |||||
private static void buildSaveModelFields(PageDatasets datasets, PageModel pageInfo, Map<String, Object> model, boolean isField) { | private static void buildSaveModelFields(PageDatasets datasets, PageModel pageInfo, Map<String, Object> model, boolean isField) { | ||||
String db = (String) model.get("dataset"); | String db = (String) model.get("dataset"); | ||||
//没有配置db,配置有误,不处理 | //没有配置db,配置有误,不处理 | ||||
if (StringUtils.isEmpty(db)) throw new SwException("model未配置数据集db,无法解析!"); | |||||
if (StringUtils.isEmpty(db)) throw new BizException("model未配置数据集db,无法解析!"); | |||||
PageDataset pds = datasets.findById(db); | PageDataset pds = datasets.findById(db); | ||||
String key = isField ? "fields" : "filters"; | String key = isField ? "fields" : "filters"; | ||||
List<Map<String, Object>> fields = (List<Map<String, Object>>) model.get(key); | List<Map<String, Object>> fields = (List<Map<String, Object>>) model.get(key); | ||||
if (fields == null || fields.isEmpty()) return; | if (fields == null || fields.isEmpty()) return; | ||||
for (Map<String, Object> field : fields) { | for (Map<String, Object> field : fields) { | ||||
String fn = (String) field.get("field"); | String fn = (String) field.get("field"); | ||||
if (StringUtils.isEmpty(fn)) throw new SwException("model[" + db + "]." + key + "未配置字段名field,无法解析!"); | |||||
if (StringUtils.isEmpty(fn)) throw new BizException("model[" + db + "]." + key + "未配置字段名field,无法解析!"); | |||||
PageDatasetField pdf = isField ? pds.findFieldByName(fn) : pds.findFilterByName(fn); | PageDatasetField pdf = isField ? pds.findFieldByName(fn) : pds.findFilterByName(fn); | ||||
if (pdf == null) throw new SwException("model[" + db + "]." + key + "未找到定义的数据集字段(" + fn + "),无法解析!"); | |||||
if (pdf == null) throw new BizException("model[" + db + "]." + key + "未找到定义的数据集字段(" + fn + "),无法解析!"); | |||||
if (CommUtil.isStrEquals(MapUtil.readString(field, "label"), pdf.label)) { | if (CommUtil.isStrEquals(MapUtil.readString(field, "label"), pdf.label)) { | ||||
field.remove("label"); | field.remove("label"); | ||||
@@ -263,7 +264,7 @@ public class ModelFormHelper { | |||||
for (Map<String, Object> model : pageInfo.model) { | for (Map<String, Object> model : pageInfo.model) { | ||||
String db = (String) model.get("dataset"); | String db = (String) model.get("dataset"); | ||||
PageDataset dataSet = datasets.findById(db); | PageDataset dataSet = datasets.findById(db); | ||||
if (dataSet == null) throw new SwException("未找到指定的数据集定义!" + db); | |||||
if (dataSet == null) throw new BizException("未找到指定的数据集定义!" + db); | |||||
listModel.add(buildEngineModelMap(dataSet, model)); | listModel.add(buildEngineModelMap(dataSet, model)); | ||||
} | } | ||||
@@ -311,9 +312,9 @@ public class ModelFormHelper { | |||||
id = (Integer) v; | id = (Integer) v; | ||||
} else if (v instanceof Long) { | } else if (v instanceof Long) { | ||||
id = (Long) v; | id = (Long) v; | ||||
} else throw new SwException("不能识别的控件Id:" + v); | |||||
} else throw new BizException("不能识别的控件Id:" + v); | |||||
ModelForm widgetForm = getFromCache(id); | ModelForm widgetForm = getFromCache(id); | ||||
if (widgetForm == null) throw new SwException("没有找到指定的控件定义!id=" + id); | |||||
if (widgetForm == null) throw new BizException("没有找到指定的控件定义!id=" + id); | |||||
SwMap w = new SwMap(); | SwMap w = new SwMap(); | ||||
widget.put("w" + id, w); | widget.put("w" + id, w); | ||||
SwMap widgetOpts = widgetForm.getOpts(); | SwMap widgetOpts = widgetForm.getOpts(); | ||||
@@ -414,7 +415,7 @@ public class ModelFormHelper { | |||||
final String dsId = MapUtil.readString(field, "dataset"); | final String dsId = MapUtil.readString(field, "dataset"); | ||||
if (dataset == null || !dataset.id.equals(dsId)) { | if (dataset == null || !dataset.id.equals(dsId)) { | ||||
dataset = datasets.findById(dsId); | dataset = datasets.findById(dsId); | ||||
if (dataset == null) throw new SwException("没有找到指定数据集:" + dsId); | |||||
if (dataset == null) throw new BizException("没有找到指定数据集:" + dsId); | |||||
} | } | ||||
String fn = MapUtil.readString(field, "field"); | String fn = MapUtil.readString(field, "field"); | ||||
PageDatasetField pdf; | PageDatasetField pdf; | ||||
@@ -424,7 +425,7 @@ public class ModelFormHelper { | |||||
pdf = dataset.findFieldById(fn); | pdf = dataset.findFieldById(fn); | ||||
if (pdf == null) pdf = dataset.findFilterByName(fn); | if (pdf == null) pdf = dataset.findFilterByName(fn); | ||||
} | } | ||||
if (pdf == null) throw new SwException("model[" + dsId + "]未找到定义的数据集字段(" + fn + "),无法解析!"); | |||||
if (pdf == null) throw new BizException("model[" + dsId + "]未找到定义的数据集字段(" + fn + "),无法解析!"); | |||||
field.put("id", pdf.id); | field.put("id", pdf.id); | ||||
field.put("field", pdf.field); | field.put("field", pdf.field); | ||||
field.put("name", pdf.name); | field.put("name", pdf.name); | ||||
@@ -1,7 +1,8 @@ | |||||
package cc.smtweb.system.bpm.web.design.form; | package cc.smtweb.system.bpm.web.design.form; | ||||
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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | import cc.smtweb.framework.core.util.JsonUtil; | ||||
@@ -32,7 +33,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
public R loadDataset() { | public R loadDataset() { | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
ModelForm bean = super.loadComp(id); | ModelForm bean = super.loadComp(id); | ||||
if (bean == null) throw new SwException("没有找到指定定义信息!id=" + id); | |||||
if (bean == null) throw new BizException("没有找到指定定义信息!id=" + id); | |||||
return R.success(ModelFormHelper.buildReqDataset(bean.getDatasets())); | return R.success(ModelFormHelper.buildReqDataset(bean.getDatasets())); | ||||
} | } | ||||
@@ -40,7 +41,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
public R loadModel() { | public R loadModel() { | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
ModelForm bean = super.loadComp(id); | ModelForm bean = super.loadComp(id); | ||||
if (bean == null) throw new SwException("没有找到指定定义信息!id=" + id); | |||||
if (bean == null) throw new BizException("没有找到指定定义信息!id=" + id); | |||||
return R.success(ModelFormHelper.buildReqModel(bean)); | return R.success(ModelFormHelper.buildReqModel(bean)); | ||||
} | } | ||||
@@ -48,7 +49,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
public R loadForm() { | public R loadForm() { | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
ModelForm bean = super.loadComp(id); | ModelForm bean = super.loadComp(id); | ||||
if (bean == null) throw new SwException("没有找到指定定义信息!id=" + id); | |||||
if (bean == null) throw new BizException("没有找到指定定义信息!id=" + id); | |||||
return R.success(ModelFormHelper.buildEngineModel(bean, params, us)); | return R.success(ModelFormHelper.buildEngineModel(bean, params, us)); | ||||
} | } | ||||
@@ -56,7 +57,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
public R loadWidgetFilter() { | public R loadWidgetFilter() { | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
ModelForm bean = super.loadComp(id); | ModelForm bean = super.loadComp(id); | ||||
if (bean == null) throw new SwException("没有找到指定控件定义!id=" + id); | |||||
if (bean == null) throw new BizException("没有找到指定控件定义!id=" + id); | |||||
return R.success(ModelFormHelper.buildWidgetFilter(bean)); | return R.success(ModelFormHelper.buildWidgetFilter(bean)); | ||||
} | } | ||||
} | } |
@@ -2,7 +2,8 @@ package cc.smtweb.system.bpm.web.design.form; | |||||
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.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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; | ||||
@@ -39,7 +40,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { | |||||
String data = params.readString("data"); | String data = params.readString("data"); | ||||
bean = loadComp(id); | bean = loadComp(id); | ||||
if (StringUtils.isEmpty(data)) { | if (StringUtils.isEmpty(data)) { | ||||
throw new SwException("没有待保存的数据!"); | |||||
throw new BizException("没有待保存的数据!"); | |||||
} | } | ||||
bean.setDataset(ModelFormHelper.buildSaveDataset(data)); | bean.setDataset(ModelFormHelper.buildSaveDataset(data)); | ||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | DbEngine.getInstance().doTrans(new AbsDbWorker() { | ||||
@@ -71,7 +72,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { | |||||
String data = params.readString("data"); | String data = params.readString("data"); | ||||
bean = loadComp(id); | bean = loadComp(id); | ||||
if (StringUtils.isEmpty(data)) { | if (StringUtils.isEmpty(data)) { | ||||
throw new SwException("没有待保存的数据!"); | |||||
throw new BizException("没有待保存的数据!"); | |||||
} | } | ||||
bean.setContent(ModelFormHelper.buildSaveModel(bean, data)); | bean.setContent(ModelFormHelper.buildSaveModel(bean, data)); | ||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | DbEngine.getInstance().doTrans(new AbsDbWorker() { | ||||
@@ -104,7 +105,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { | |||||
String data = params.readString("data"); | String data = params.readString("data"); | ||||
bean = loadComp(id); | bean = loadComp(id); | ||||
if (StringUtils.isEmpty(data)) { | if (StringUtils.isEmpty(data)) { | ||||
throw new SwException("没有待保存的数据!"); | |||||
throw new BizException("没有待保存的数据!"); | |||||
} | } | ||||
bean.setTmpl(data); | bean.setTmpl(data); | ||||
ModelFormHelper.buildSaveModelByTmpl(bean, templateId); | ModelFormHelper.buildSaveModelByTmpl(bean, templateId); | ||||
@@ -1,7 +1,8 @@ | |||||
package cc.smtweb.system.bpm.web.design.form.define; | package cc.smtweb.system.bpm.web.design.form.define; | ||||
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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
@@ -100,7 +101,7 @@ public class PageDataset { | |||||
} | } | ||||
if (table == null) continue; | if (table == null) continue; | ||||
ModelField mf = table.findField(field.field); | ModelField mf = table.findField(field.field); | ||||
if (mf == null) throw new SwException("未找到表字段的定义信息(" + table.getName() + "." + field.field + ")"); | |||||
if (mf == null) throw new BizException("未找到表字段的定义信息(" + table.getName() + "." + field.field + ")"); | |||||
field.table_text = table.getTitle(); | field.table_text = table.getTitle(); | ||||
field.fieldType = mf.getFieldType(); | field.fieldType = mf.getFieldType(); | ||||
field.notNull = mf.getNotNull(); | field.notNull = mf.getNotNull(); | ||||
@@ -3,7 +3,8 @@ package cc.smtweb.system.bpm.web.design.preview; | |||||
import cc.smtweb.framework.core.annotation.SwParam; | import cc.smtweb.framework.core.annotation.SwParam; | ||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
@@ -23,7 +24,7 @@ public class PreviewMenuTreeService { | |||||
// long prj_id = StringUtils.isNotEmpty(module) ? Long.parseLong(module) : 0L; | // long prj_id = StringUtils.isNotEmpty(module) ? Long.parseLong(module) : 0L; | ||||
List<ModelForm> listForm = new ArrayList<>(ModelFormCache.getInstance().getAll()); | List<ModelForm> listForm = new ArrayList<>(ModelFormCache.getInstance().getAll()); | ||||
listForm.sort((o1, o2) -> CommUtil.chineseCompare(o1.getTitle(), o2.getTitle())); | listForm.sort((o1, o2) -> CommUtil.chineseCompare(o1.getTitle(), o2.getTitle())); | ||||
if (listForm.isEmpty()) throw new SwException("此项目无页面设计!"); | |||||
if (listForm.isEmpty()) throw new BizException("此项目无页面设计!"); | |||||
List<MenuVO> list = new ArrayList<>(listForm.size()); | List<MenuVO> list = new ArrayList<>(listForm.size()); | ||||
for (ModelForm form: listForm) { | for (ModelForm form: listForm) { | ||||
@@ -1,6 +1,7 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | package cc.smtweb.system.bpm.web.engine.dynPage; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.mvc.service.AbstractHandler; | import cc.smtweb.framework.core.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
@@ -24,9 +25,9 @@ public abstract class AbstractDynPageHandler extends AbstractHandler { | |||||
super.init(params, us); | super.init(params, us); | ||||
pageId = params.readLong("pageId"); | pageId = params.readLong("pageId"); | ||||
ModelForm form = ModelFormHelper.getFromCache(pageId); | ModelForm form = ModelFormHelper.getFromCache(pageId); | ||||
if (form == null) throw new SwException("没有找到页面定义数据!"); | |||||
if (form == null) throw new BizException("没有找到页面定义数据(" + pageId + ")!"); | |||||
datasets = form.getDatasets(); | datasets = form.getDatasets(); | ||||
if (datasets == null || datasets.list == null) throw new SwException("没有找到页面定义数据!"); | |||||
if (datasets == null || datasets.list == null) throw new BizException("没有找到页面定义的数据集数据(" + pageId + ")!"); | |||||
provider.pageId = pageId; | provider.pageId = pageId; | ||||
provider.datasets = datasets; | provider.datasets = datasets; | ||||
@@ -47,7 +48,7 @@ public abstract class AbstractDynPageHandler extends AbstractHandler { | |||||
String dbName = params.readString("dataset"); | String dbName = params.readString("dataset"); | ||||
//对应的数据集定义 | //对应的数据集定义 | ||||
PageDataset pageDataSet = findDataset(dbName); | PageDataset pageDataSet = findDataset(dbName); | ||||
if (pageDataSet == null) throw new SwException("没有找到指定的的数据集定义:" + dbName + "!"); | |||||
if (pageDataSet == null) throw new BizException("没有找到指定的的数据集定义:" + dbName + "!"); | |||||
return pageDataSet; | return pageDataSet; | ||||
} | } | ||||
} | } |
@@ -4,7 +4,8 @@ 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.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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.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.EntityHelper; | import cc.smtweb.framework.core.db.EntityHelper; | ||||
@@ -33,7 +34,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler { | |||||
*/ | */ | ||||
public R delOne() { | public R delOne() { | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
if (id == 0) throw new SwException("没有收到待删除记录Id!"); | |||||
if (id == 0) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | |||||
//数据集 | //数据集 | ||||
PageDataset pageDataSet = readParamDs(); | PageDataset pageDataSet = readParamDs(); | ||||
@@ -43,7 +44,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler { | |||||
@Override | @Override | ||||
public void work() { | public void work() { | ||||
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ||||
if (table == null) throw new SwException("没有找到指定的的表定义:" + pageDataSet.name + "!"); | |||||
if (table == null) throw new BizException("没有找到指定的的表定义:" + pageDataSet.name + "!"); | |||||
EntityDao dao = DbEngine.getInstance().findDao(table.getName()); | EntityDao dao = DbEngine.getInstance().findDao(table.getName()); | ||||
dao.deleteEntity(id); | dao.deleteEntity(id); | ||||
} | } | ||||
@@ -62,11 +63,11 @@ public class DynPageDelHandler extends AbstractDynPageHandler { | |||||
public R delAll() { | public R delAll() { | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
if (id == 0) throw new SwException("没有收到待删除记录Id!"); | |||||
if (id == 0) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | |||||
//校验主表即可 | //校验主表即可 | ||||
PageDataset masterDs = findMasterDataset(); | PageDataset masterDs = findMasterDataset(); | ||||
if (masterDs == null || !masterDs.canEdit || !SwEnum.DatasetType.FORM.value.equals(masterDs.type)) | if (masterDs == null || !masterDs.canEdit || !SwEnum.DatasetType.FORM.value.equals(masterDs.type)) | ||||
throw new SwException("主表不允许删除!"); | |||||
throw new BizException("主表不允许删除!"); | |||||
checkBean(masterDs, id); | checkBean(masterDs, id); | ||||
Map<String, RemovableInfo> mapRemovableInfo = new HashMap<>(); | Map<String, RemovableInfo> mapRemovableInfo = new HashMap<>(); | ||||
@@ -79,7 +80,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler { | |||||
if (pageDataSet != masterDs) {//非主表,记录一下关联字段 | if (pageDataSet != masterDs) {//非主表,记录一下关联字段 | ||||
PageDatasetFilter f = pageDataSet.findFilterByDs(masterDs.name); | PageDatasetFilter f = pageDataSet.findFilterByDs(masterDs.name); | ||||
if (f == null) { | if (f == null) { | ||||
throw new SwException("无法删除表【" + pageDataSet.name + "】,此表未关联主表!"); | |||||
throw new BizException("无法删除表【" + pageDataSet.name + "】,此表未关联主表!"); | |||||
} | } | ||||
ret.field = f.field; | ret.field = f.field; | ||||
} | } | ||||
@@ -2,7 +2,8 @@ package cc.smtweb.system.bpm.web.engine.dynPage; | |||||
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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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; | ||||
@@ -36,12 +37,8 @@ public class DynPageHelper { | |||||
//主表 | //主表 | ||||
ModelTable masterTable = ModelTableCache.getInstance().get(dataSet.masterTable); | ModelTable masterTable = ModelTableCache.getInstance().get(dataSet.masterTable); | ||||
EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(masterTable.getName()); | EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(masterTable.getName()); | ||||
try { | |||||
DefaultEntity bean = dao.createBean(); | |||||
return bean.getData(); | |||||
} catch (Exception e) { | |||||
throw new SwException(e); | |||||
} | |||||
DefaultEntity bean = dao.createBean(); | |||||
return bean.getData(); | |||||
} | } | ||||
/** | /** | ||||
@@ -178,7 +175,7 @@ public class DynPageHelper { | |||||
} | } | ||||
PageDatasetFilter filter = dataSet.findFilterById(dynCond.param); | PageDatasetFilter filter = dataSet.findFilterById(dynCond.param); | ||||
if (filter == null) throw new SwException("没有找到filter(" + dynCond.param + ")!"); | |||||
if (filter == null) throw new BizException("没有找到filter(" + dynCond.param + ")!"); | |||||
boolean isNameSelf = setFixedFilter.contains(filter.name); | boolean isNameSelf = setFixedFilter.contains(filter.name); | ||||
setFixedFilter.remove(filter.name); | setFixedFilter.remove(filter.name); | ||||
@@ -192,7 +189,7 @@ public class DynPageHelper { | |||||
} | } | ||||
if (value == null || StringUtils.isEmpty(value.toString())) { | if (value == null || StringUtils.isEmpty(value.toString())) { | ||||
if (filter.required) { | if (filter.required) { | ||||
throw new SwException("过滤条件不能为空(" + filter.name + ")!"); | |||||
throw new BizException("过滤条件不能为空(" + filter.name + ")!"); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
@@ -222,7 +219,7 @@ public class DynPageHelper { | |||||
mapBuilder.put(SwEnum.OptType.BT.value, (opt, field, name, value, args) -> { | mapBuilder.put(SwEnum.OptType.BT.value, (opt, field, name, value, args) -> { | ||||
String[] ss = value.toString().split(","); | String[] ss = value.toString().split(","); | ||||
if (ss.length != 2) throw new SwException("介于条件,参数值个数错误!"); | |||||
if (ss.length != 2) throw new BizException("介于条件,参数值个数错误!"); | |||||
args.put(name + "_1", ss[0]); | args.put(name + "_1", ss[0]); | ||||
args.put(name + "_2", ss[1]); | args.put(name + "_2", ss[1]); | ||||
return "(" + field + ">=:" + name + "_1 and " + field + "<=:" + name + "_2)"; | return "(" + field + ">=:" + name + "_1 and " + field + "<=:" + name + "_2)"; | ||||
@@ -1,6 +1,7 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | package cc.smtweb.system.bpm.web.engine.dynPage; | ||||
import cc.smtweb.framework.core.common.SwException; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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.EntityHelper; | import cc.smtweb.framework.core.db.EntityHelper; | ||||
@@ -24,7 +25,7 @@ public class DynPageProvider extends AbstractCompProvider { | |||||
SqlNamedPara sqlPara = DynPageHelper.buildSelectSql(pageDataSet, filter); | SqlNamedPara sqlPara = DynPageHelper.buildSelectSql(pageDataSet, filter); | ||||
SwMap map = DbEngine.getInstance().queryEntityN(sqlPara.sql, sqlPara.mapParas, SwMap.class); | SwMap map = DbEngine.getInstance().queryEntityN(sqlPara.sql, sqlPara.mapParas, SwMap.class); | ||||
if (map == null) { | if (map == null) { | ||||
throw new SwException("没有找到指定数据(ds=" + pageDataSet.name + ")"); | |||||
throw new BizException("没有找到指定数据(ds=" + pageDataSet.name + ")"); | |||||
} | } | ||||
ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ||||
EntityHelper.loadBeanLink(masterTable.getName(), map, sqlPara.mapFieldAlias); | EntityHelper.loadBeanLink(masterTable.getName(), map, sqlPara.mapFieldAlias); | ||||
@@ -4,7 +4,8 @@ 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.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.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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; | ||||
@@ -42,10 +43,10 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
SwMap filter = params.readMap("filter"); | SwMap filter = params.readMap("filter"); | ||||
//待保存数据 | //待保存数据 | ||||
SwMap data = params.readMap("data"); | SwMap data = params.readMap("data"); | ||||
if (data == null) throw new SwException("没有收到待保存的的数据:" + dbName + "!"); | |||||
if (data == null) throw new BizException("没有收到待保存的的数据:" + dbName + "!"); | |||||
//对应的数据集定义 | //对应的数据集定义 | ||||
PageDataset pageDataSet = findDataset(dbName); | PageDataset pageDataSet = findDataset(dbName); | ||||
if (pageDataSet == null) throw new SwException("没有找到指定的的数据集定义:" + dbName + "!"); | |||||
if (pageDataSet == null) throw new BizException("没有找到指定的的数据集定义:" + dbName + "!"); | |||||
//读取待保存的bean | //读取待保存的bean | ||||
DefaultEntity bean = readBeanFromPage(pageDataSet, data); | DefaultEntity bean = readBeanFromPage(pageDataSet, data); | ||||
if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 | if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 | ||||
@@ -79,7 +80,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
*/ | */ | ||||
public R saveAll() { | public R saveAll() { | ||||
SwMap data = params.readMap("data"); | SwMap data = params.readMap("data"); | ||||
if (data == null) throw new SwException("没有收到待保存的的数据!"); | |||||
if (data == null) throw new BizException("没有收到待保存的的数据!"); | |||||
SwMap filter = params.readMap("filter"); | SwMap filter = params.readMap("filter"); | ||||
Map<String, DefaultEntity> map = new LinkedHashMap<>(); | Map<String, DefaultEntity> map = new LinkedHashMap<>(); | ||||
@@ -143,7 +144,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
*/ | */ | ||||
protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) { | protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) { | ||||
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ||||
if (table == null) throw new SwException("没有找到待保存的表定义:" + pageDataSet.name); | |||||
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); | |||||
long id = data.readLong(table.getIdField()); | long id = data.readLong(table.getIdField()); | ||||
EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(table.getName()); | EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(table.getName()); | ||||
@@ -155,7 +156,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
} else { | } else { | ||||
bean = dao.queryEntity(id); | bean = dao.queryEntity(id); | ||||
if (bean == null) { | if (bean == null) { | ||||
throw new SwException("没有找到待保存的记录:" + table.getName() + "." + id); | |||||
throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); | |||||
} | } | ||||
} | } | ||||
//暂时不考虑list保存的情况 | //暂时不考虑list保存的情况 | ||||
@@ -174,14 +175,14 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
String value = bean.getStr(field.getName()); | String value = bean.getStr(field.getName()); | ||||
//非空校验 | //非空校验 | ||||
if (field.isNotNull() && StringUtils.isEmpty(value)) { | if (field.isNotNull() && StringUtils.isEmpty(value)) { | ||||
throw new SwException("字段不允许为空:" + field.getTitle()); | |||||
throw new BizException("字段不允许为空:" + field.getTitle()); | |||||
} | } | ||||
//长度校验 | //长度校验 | ||||
if (StringUtils.isNotEmpty(value)) { | if (StringUtils.isNotEmpty(value)) { | ||||
int len = SwEnum.DataType.instance.getByValue(field.getDataType()).dataLength; | int len = SwEnum.DataType.instance.getByValue(field.getDataType()).dataLength; | ||||
if (len > 0 && CommUtil.getStrLenB(value) > len) { | if (len > 0 && CommUtil.getStrLenB(value) > len) { | ||||
throw new SwException("字段值超长:" + field.getTitle()); | |||||
throw new BizException("字段值超长:" + field.getTitle()); | |||||
} | } | ||||
} | } | ||||
} | } | ||||