Pārlūkot izejas kodu

异常修改:所有业务逻辑错误,使用BizException

master
郑根木 pirms 2 gadiem
vecāks
revīzija
b4e1eed845
33 mainītis faili ar 212 papildinājumiem un 217 dzēšanām
  1. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/cache/redis/RedisManager.java
  2. +1
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwMap.java
  3. +11
    -5
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java
  4. +12
    -4
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/EntityHelper.java
  5. +8
    -17
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/dao/AbstractEntityDao.java
  6. +1
    -2
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/jdbc/JdbcEngine.java
  7. +0
    -2
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/BindBeanException.java
  8. +0
    -2
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/BindParamException.java
  9. +0
    -13
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/CacheException.java
  10. +0
    -2
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/JsonParseException.java
  11. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/SwException.java
  12. +83
    -78
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/controller/access/MethodAccess.java
  13. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/controller/scan/ScanContext.java
  14. +1
    -1
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/realm/exception/AuthorizationException.java
  15. +3
    -2
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractCompService.java
  16. +4
    -3
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultComboHandler.java
  17. +3
    -2
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultProvider.java
  18. +4
    -3
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java
  19. +6
    -5
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java
  20. +4
    -3
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/variable/SwVariableFactory.java
  21. +1
    -1
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/BeanUtil.java
  22. +1
    -9
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java
  23. +8
    -8
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java
  24. +10
    -9
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  25. +6
    -5
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java
  26. +5
    -4
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java
  27. +3
    -2
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java
  28. +3
    -2
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/PreviewMenuTreeService.java
  29. +5
    -4
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java
  30. +7
    -6
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageDelHandler.java
  31. +7
    -10
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java
  32. +3
    -2
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java
  33. +9
    -8
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java

+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/cache/redis/RedisManager.java Parādīt failu

@@ -1,6 +1,6 @@
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.util.JsonUtil;
import cc.smtweb.framework.core.util.SpringUtil;


+ 1
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwMap.java Parādīt failu

@@ -1,5 +1,6 @@
package cc.smtweb.framework.core.common;

import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.util.MapUtil;

import java.util.HashMap;


+ 11
- 5
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java Parādīt failu

@@ -1,7 +1,8 @@
package cc.smtweb.framework.core.db;

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.EntityColumn;
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) {
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<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) {
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);
}
@@ -344,6 +345,11 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
return jdbcEngine.queryLongList(sb.toString(), type, params);
}

/**
* 检查表字段是否违反唯一索引
* @param bean
* @param fields
*/
public void checkUnique(T bean, String... fields) {
if (fields.length == 0) return;
String ss = "", sTitle = "";
@@ -355,7 +361,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
args.add(readValue(bean, 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) + " 不能重复!");
}
}

+ 12
- 4
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/EntityHelper.java Parādīt failu

@@ -2,7 +2,8 @@ package cc.smtweb.framework.core.db;

import cc.smtweb.framework.core.cache.AbstractCache;
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.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.vo.ModelField;
@@ -155,15 +156,20 @@ public class EntityHelper {
//检查表记录是否被引用
public static void checkExists(long tableId, long id) {
ModelTable fkTable = ModelTableCache.getInstance().get(tableId);
if (fkTable == null) throw new SwException("待检查表(" + tableId + ")为空!");
if (fkTable == null) throw new BizException("待检查表(" + tableId + ")为空!");
checkExists(fkTable, id);
}
public static void checkExists(String tableName, long id) {
ModelTable fkTable = ModelTableCache.getInstance().getByName(tableName);
if (fkTable == null) throw new SwException("待检查表(" + tableName + ")为空!");
if (fkTable == null) throw new BizException("待检查表(" + tableName + ")为空!");
checkExists(fkTable, id);
}

/**
* 检查记录是否被使用
* @param fkTable
* @param id
*/
public static void checkExists(ModelTable fkTable, long id) {
Set<ModelTable> list = ModelTableCache.getInstance().getByLink(fkTable.getId());
if (list == null || list.isEmpty()) return;
@@ -178,8 +184,10 @@ public class EntityHelper {
}
if (sql.length() == 0) continue;
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() + ")】引用,不能删除!");
}
}
}


}

+ 8
- 17
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/dao/AbstractEntityDao.java Parādīt failu

@@ -3,7 +3,7 @@ package cc.smtweb.framework.core.db.dao;
import cc.smtweb.framework.core.annotation.SwTable;
import cc.smtweb.framework.core.cache.CacheManager;
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.impl.DefaultEntity;
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) {
List<Object> result;
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.LAST_TIME.value);
@@ -228,7 +228,7 @@ public abstract class AbstractEntityDao<T> {
List<String> listFields = adjustFields(fields, 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<>();

if (listFields == null) {
@@ -300,7 +300,7 @@ public abstract class AbstractEntityDao<T> {
protected Object[] handleDelete(T obj, StringBuilder sql) {
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)};
}
@@ -312,7 +312,7 @@ public abstract class AbstractEntityDao<T> {
*/
protected void handleDelete(StringBuilder sql) {
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) {
@@ -333,15 +333,6 @@ public abstract class AbstractEntityDao<T> {
}

/**
* 获取表名
*
* @return 表名
*/
protected String getTableName() {
return tableName;
}

/**
* 拼接查询SQL语句
*
* @param sql SQL字符缓存
@@ -359,7 +350,7 @@ public abstract class AbstractEntityDao<T> {
sql.setCharAt(sql.length() - 1, ' ');
}

sql.append("from ").append(tableName);
sql.append("from ").append(modelTable.getSchemaTableName());
}

protected void handleSelectOne(StringBuilder sql, String fields) {
@@ -376,7 +367,7 @@ public abstract class AbstractEntityDao<T> {
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);
}

public T createBean() throws SwException {
public T createBean() {
try {
T bean = this.type.newInstance();
if (bean instanceof DefaultEntity) {


+ 1
- 2
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/db/jdbc/JdbcEngine.java Parādīt failu

@@ -1,12 +1,11 @@
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.db.impl.BaseBean;
import cc.smtweb.framework.core.exception.DbException;
import cc.smtweb.framework.core.util.JsonUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;


+ 0
- 2
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/BindBeanException.java Parādīt failu

@@ -1,7 +1,5 @@
package cc.smtweb.framework.core.exception;

import cc.smtweb.framework.core.common.SwException;

/**
* bean绑定错误
* @author kevin


+ 0
- 2
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/BindParamException.java Parādīt failu

@@ -1,7 +1,5 @@
package cc.smtweb.framework.core.exception;

import cc.smtweb.framework.core.common.SwException;

import java.text.ParseException;

public class BindParamException extends SwException {


+ 0
- 13
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/CacheException.java Parādīt failu

@@ -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);
}
}

+ 0
- 2
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/JsonParseException.java Parādīt failu

@@ -1,7 +1,5 @@
package cc.smtweb.framework.core.exception;

import cc.smtweb.framework.core.common.SwException;

public class JsonParseException extends SwException {
public JsonParseException(String s, Exception e) {
super(s, e);


smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwException.java → smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/exception/SwException.java Parādīt failu

@@ -1,4 +1,4 @@
package cc.smtweb.framework.core.common;
package cc.smtweb.framework.core.exception;

import cc.smtweb.framework.core.exception.ExceptionMessage;


+ 83
- 78
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/controller/access/MethodAccess.java Parādīt failu

@@ -1,6 +1,8 @@
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.mvc.controller.IBeanContext;
import cc.smtweb.framework.core.mvc.controller.binder.ParamEditor;
@@ -14,99 +16,102 @@ import java.util.Map;

/**
* API方法执行
*
* @author xkliu
*/
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 {
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();
}
}

+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/controller/scan/ScanContext.java Parādīt failu

@@ -4,7 +4,7 @@ import cc.smtweb.framework.core.annotation.SwBean;
import cc.smtweb.framework.core.annotation.SwConstruct;
import cc.smtweb.framework.core.annotation.SwDestroy;
import cc.smtweb.framework.core.annotation.SwScheduling;
import cc.smtweb.framework.core.common.SwException;
import cc.smtweb.framework.core.exception.SwException;
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.binder.WebDataBinder;


+ 1
- 1
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/realm/exception/AuthorizationException.java Parādīt failu

@@ -1,6 +1,6 @@
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 AuthorizationException(String s) {


+ 3
- 2
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractCompService.java Parādīt failu

@@ -2,7 +2,8 @@ package cc.smtweb.framework.core.mvc.service;

import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.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.session.UserSession;

@@ -22,7 +23,7 @@ public abstract class AbstractCompService {

protected AbstractHandler getHandler(SwMap params, UserSession us, String type) throws Exception {
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 (us == null) us = UserSession.createSys();
handler.init(params, us);


+ 4
- 3
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultComboHandler.java Parādīt failu

@@ -2,7 +2,8 @@ package cc.smtweb.framework.core.mvc.service;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwException;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
@@ -31,7 +32,7 @@ public class DefaultComboHandler<T extends DefaultEntity> extends DefaultListHan

protected SwListData filterData() {
String text = params.readString("text");
if (StringUtils.isEmpty(text)) throw new SwException("没有搜素内容!");
if (StringUtils.isEmpty(text)) throw new BizException("没有搜素内容!");

SqlPara sqlPara = buildDataSql();
String sort = params.readString("sort");
@@ -42,7 +43,7 @@ public class DefaultComboHandler<T extends DefaultEntity> extends DefaultListHan
Collections.addAll(args, sqlPara.paras);

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);
if (StringUtils.isNotEmpty(sort)) {


+ 3
- 2
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultProvider.java Parādīt failu

@@ -1,6 +1,7 @@
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.EntityDao;
import cc.smtweb.framework.core.db.EntityHelper;
@@ -23,7 +24,7 @@ public class DefaultProvider<T extends DefaultEntity> extends AbstractCompProvid
private T loadBean(long id) {
EntityDao<T> bdao = (EntityDao<T>) DbEngine.getInstance().findDao(tableName);
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);
return bean;
}


+ 4
- 3
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java Parādīt failu

@@ -4,7 +4,8 @@ import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.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.EntityDao;
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);
for (ModelField field : table.getFields()) {
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) {
TreeHelper.getTreeHelper(tableName).checkParent(bean);
@@ -136,7 +137,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
//树,改变父亲
public R changeParent(){
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 parentId = params.readLong("parent_id");


+ 6
- 5
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/service/TreeHelper.java Parādīt failu

@@ -4,7 +4,8 @@ import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.SwConsts;
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.EntityDao;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
@@ -90,22 +91,22 @@ public class TreeHelper<T extends DefaultEntity> {

public void checkParent(T bean) {
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);
if (bean.getEntityId() == pId) throw new SwException("上级节点不能为自己!");
if (bean.getEntityId() == pId) throw new BizException("上级节点不能为自己!");
if (pId <= 0) return;
T parent = cache.get(pId);
if (parent == null) return;
String plevelcode = SwConsts.SPLIT_CHAR + parent.getStr(fieldLevelCode) + 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) {
List<T> list = new ArrayList<>();
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());
if (bean.getLong(fieldParent) != oldBean.getLong(fieldParent)) {


+ 4
- 3
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/mvc/variable/SwVariableFactory.java Parādīt failu

@@ -1,6 +1,7 @@
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.session.UserSession;
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) {
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));
}

//计算变量值
public Object calcVar(String name, SwMap params, UserSession us) {
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);
}
}

+ 1
- 1
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/BeanUtil.java Parādīt failu

@@ -1,6 +1,6 @@
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 org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;


+ 1
- 9
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java Parādīt failu

@@ -1,25 +1,17 @@
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.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.Template;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import sun.nio.ch.IOUtil;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;



+ 8
- 8
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java Parādīt failu

@@ -4,10 +4,10 @@ import cc.smtweb.framework.core.common.*;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.vo.ModelCache;
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.exception.BizException;
import cc.smtweb.framework.core.exception.SwException;
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.MapUtil;
import cc.smtweb.framework.core.util.SpringUtil;
@@ -65,7 +65,7 @@ public class CodeBuildHandler extends AbstractHandler {
*/
private void buildCodeJavaPath(long 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());

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);
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);
if (StringUtils.isEmpty(codeJavaPath)) {
throw new SwException("没有找到对应项目在idea中Module的路径!");
throw new BizException("没有找到对应项目在idea中Module的路径(" + moduleName + ")!");
}
codeJavaPath += "/src/main/java/";
//加上目录
@@ -98,7 +98,7 @@ public class CodeBuildHandler extends AbstractHandler {
*/
private void buildJavaTable(long tableId, boolean needBean, boolean needCache) {
ModelTable table = ModelTableCache.getInstance().get(tableId);
if (table == null) throw new SwException("没有找到对应的表定义!");
if (table == null) throw new BizException("没有找到对应的表定义(" + tableId + ")!");
SwMap model = new SwMap();
model.put("user", userName);
model.put("sysTime", DateUtil.nowDateTime());
@@ -126,7 +126,7 @@ public class CodeBuildHandler extends AbstractHandler {
}

if (needCache) {
if (!table.isNeedCache()) throw new SwException("表设置为不需要缓存!" + table.getTitle());
if (!table.isNeedCache()) throw new BizException("表设置为不需要缓存!" + table.getTitle());
List<SwMap> caches = new ArrayList<>();
model.put("caches", caches);
for (ModelCache cache : table.getCaches()) {
@@ -146,7 +146,7 @@ public class CodeBuildHandler extends AbstractHandler {
private void buildJavaService(long pageId) {
ModelForm form = ModelFormCache.getInstance().get(pageId);
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);

SwMap model = new SwMap();


+ 10
- 9
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java Parādīt failu

@@ -2,7 +2,8 @@ package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.cache.AbstractCache;
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.db.cache.ModelTableCache;
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) {
String db = (String) model.get("dataset");
//没有配置db,配置有误,不处理
if (StringUtils.isEmpty(db)) throw new SwException("model未配置数据集db,无法解析!");
if (StringUtils.isEmpty(db)) throw new BizException("model未配置数据集db,无法解析!");
PageDataset pds = datasets.findById(db);
String key = isField ? "fields" : "filters";
List<Map<String, Object>> fields = (List<Map<String, Object>>) model.get(key);
if (fields == null || fields.isEmpty()) return;
for (Map<String, Object> field : fields) {
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);
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)) {
field.remove("label");
@@ -263,7 +264,7 @@ public class ModelFormHelper {
for (Map<String, Object> model : pageInfo.model) {
String db = (String) model.get("dataset");
PageDataset dataSet = datasets.findById(db);
if (dataSet == null) throw new SwException("未找到指定的数据集定义!" + db);
if (dataSet == null) throw new BizException("未找到指定的数据集定义!" + db);

listModel.add(buildEngineModelMap(dataSet, model));
}
@@ -311,9 +312,9 @@ public class ModelFormHelper {
id = (Integer) v;
} else if (v instanceof Long) {
id = (Long) v;
} else throw new SwException("不能识别的控件Id:" + v);
} else throw new BizException("不能识别的控件Id:" + v);
ModelForm widgetForm = getFromCache(id);
if (widgetForm == null) throw new SwException("没有找到指定的控件定义!id=" + id);
if (widgetForm == null) throw new BizException("没有找到指定的控件定义!id=" + id);
SwMap w = new SwMap();
widget.put("w" + id, w);
SwMap widgetOpts = widgetForm.getOpts();
@@ -414,7 +415,7 @@ public class ModelFormHelper {
final String dsId = MapUtil.readString(field, "dataset");
if (dataset == null || !dataset.id.equals(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");
PageDatasetField pdf;
@@ -424,7 +425,7 @@ public class ModelFormHelper {
pdf = dataset.findFieldById(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("field", pdf.field);
field.put("name", pdf.name);


+ 6
- 5
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java Parādīt failu

@@ -1,7 +1,8 @@
package cc.smtweb.system.bpm.web.design.form;

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.mvc.service.DefaultLoadHandler;
import cc.smtweb.framework.core.util.JsonUtil;
@@ -32,7 +33,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
public R loadDataset() {
long id = params.readLong("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()));
}

@@ -40,7 +41,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
public R loadModel() {
long id = params.readLong("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));
}

@@ -48,7 +49,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
public R loadForm() {
long id = params.readLong("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));
}

@@ -56,7 +57,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
public R loadWidgetFilter() {
long id = params.readLong("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));
}
}

+ 5
- 4
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java Parādīt failu

@@ -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.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.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
@@ -39,7 +40,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
String data = params.readString("data");
bean = loadComp(id);
if (StringUtils.isEmpty(data)) {
throw new SwException("没有待保存的数据!");
throw new BizException("没有待保存的数据!");
}
bean.setDataset(ModelFormHelper.buildSaveDataset(data));
DbEngine.getInstance().doTrans(new AbsDbWorker() {
@@ -71,7 +72,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
String data = params.readString("data");
bean = loadComp(id);
if (StringUtils.isEmpty(data)) {
throw new SwException("没有待保存的数据!");
throw new BizException("没有待保存的数据!");
}
bean.setContent(ModelFormHelper.buildSaveModel(bean, data));
DbEngine.getInstance().doTrans(new AbsDbWorker() {
@@ -104,7 +105,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
String data = params.readString("data");
bean = loadComp(id);
if (StringUtils.isEmpty(data)) {
throw new SwException("没有待保存的数据!");
throw new BizException("没有待保存的数据!");
}
bean.setTmpl(data);
ModelFormHelper.buildSaveModelByTmpl(bean, templateId);


+ 3
- 2
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java Parādīt failu

@@ -1,7 +1,8 @@
package cc.smtweb.system.bpm.web.design.form.define;

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.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelTable;
@@ -100,7 +101,7 @@ public class PageDataset {
}
if (table == null) continue;
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.fieldType = mf.getFieldType();
field.notNull = mf.getNotNull();


+ 3
- 2
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/PreviewMenuTreeService.java Parādīt failu

@@ -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.SwService;
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.session.UserSession;
import cc.smtweb.framework.core.util.CommUtil;
@@ -23,7 +24,7 @@ public class PreviewMenuTreeService {
// long prj_id = StringUtils.isNotEmpty(module) ? Long.parseLong(module) : 0L;
List<ModelForm> listForm = new ArrayList<>(ModelFormCache.getInstance().getAll());
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());
for (ModelForm form: listForm) {


+ 5
- 4
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java Parādīt failu

@@ -1,6 +1,7 @@
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.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
@@ -24,9 +25,9 @@ public abstract class AbstractDynPageHandler extends AbstractHandler {
super.init(params, us);
pageId = params.readLong("pageId");
ModelForm form = ModelFormHelper.getFromCache(pageId);
if (form == null) throw new SwException("没有找到页面定义数据!");
if (form == null) throw new BizException("没有找到页面定义数据(" + pageId + ")!");
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.datasets = datasets;
@@ -47,7 +48,7 @@ public abstract class AbstractDynPageHandler extends AbstractHandler {
String dbName = params.readString("dataset");
//对应的数据集定义
PageDataset pageDataSet = findDataset(dbName);
if (pageDataSet == null) throw new SwException("没有找到指定的的数据集定义:" + dbName + "!");
if (pageDataSet == null) throw new BizException("没有找到指定的的数据集定义:" + dbName + "!");
return pageDataSet;
}
}

+ 7
- 6
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageDelHandler.java Parādīt failu

@@ -4,7 +4,8 @@ import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.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.EntityDao;
import cc.smtweb.framework.core.db.EntityHelper;
@@ -33,7 +34,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler {
*/
public R delOne() {
long id = params.readLong("id");
if (id == 0) throw new SwException("没有收到待删除记录Id!");
if (id == 0) throw new BizException("没有收到待删除记录Id(" + id + ")!");
//数据集
PageDataset pageDataSet = readParamDs();

@@ -43,7 +44,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler {
@Override
public void work() {
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());
dao.deleteEntity(id);
}
@@ -62,11 +63,11 @@ public class DynPageDelHandler extends AbstractDynPageHandler {

public R delAll() {
long id = params.readLong("id");
if (id == 0) throw new SwException("没有收到待删除记录Id!");
if (id == 0) throw new BizException("没有收到待删除记录Id(" + id + ")!");
//校验主表即可
PageDataset masterDs = findMasterDataset();
if (masterDs == null || !masterDs.canEdit || !SwEnum.DatasetType.FORM.value.equals(masterDs.type))
throw new SwException("主表不允许删除!");
throw new BizException("主表不允许删除!");
checkBean(masterDs, id);

Map<String, RemovableInfo> mapRemovableInfo = new HashMap<>();
@@ -79,7 +80,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler {
if (pageDataSet != masterDs) {//非主表,记录一下关联字段
PageDatasetFilter f = pageDataSet.findFilterByDs(masterDs.name);
if (f == null) {
throw new SwException("无法删除表【" + pageDataSet.name + "】,此表未关联主表!");
throw new BizException("无法删除表【" + pageDataSet.name + "】,此表未关联主表!");
}
ret.field = f.field;
}


+ 7
- 10
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java Parādīt failu

@@ -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.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.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
@@ -36,12 +37,8 @@ public class DynPageHelper {
//主表
ModelTable masterTable = ModelTableCache.getInstance().get(dataSet.masterTable);
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);
if (filter == null) throw new SwException("没有找到filter(" + dynCond.param + ")!");
if (filter == null) throw new BizException("没有找到filter(" + dynCond.param + ")!");

boolean isNameSelf = setFixedFilter.contains(filter.name);
setFixedFilter.remove(filter.name);
@@ -192,7 +189,7 @@ public class DynPageHelper {
}
if (value == null || StringUtils.isEmpty(value.toString())) {
if (filter.required) {
throw new SwException("过滤条件不能为空(" + filter.name + ")!");
throw new BizException("过滤条件不能为空(" + filter.name + ")!");
}
return null;
}
@@ -222,7 +219,7 @@ public class DynPageHelper {

mapBuilder.put(SwEnum.OptType.BT.value, (opt, field, name, value, args) -> {
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 + "_2", ss[1]);
return "(" + field + ">=:" + name + "_1 and " + field + "<=:" + name + "_2)";


+ 3
- 2
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java Parādīt failu

@@ -1,6 +1,7 @@
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.db.DbEngine;
import cc.smtweb.framework.core.db.EntityHelper;
@@ -24,7 +25,7 @@ public class DynPageProvider extends AbstractCompProvider {
SqlNamedPara sqlPara = DynPageHelper.buildSelectSql(pageDataSet, filter);
SwMap map = DbEngine.getInstance().queryEntityN(sqlPara.sql, sqlPara.mapParas, SwMap.class);
if (map == null) {
throw new SwException("没有找到指定数据(ds=" + pageDataSet.name + ")");
throw new BizException("没有找到指定数据(ds=" + pageDataSet.name + ")");
}
ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable);
EntityHelper.loadBeanLink(masterTable.getName(), map, sqlPara.mapFieldAlias);


+ 9
- 8
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java Parādīt failu

@@ -4,7 +4,8 @@ import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.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.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
@@ -42,10 +43,10 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
SwMap filter = params.readMap("filter");
//待保存数据
SwMap data = params.readMap("data");
if (data == null) throw new SwException("没有收到待保存的的数据:" + dbName + "!");
if (data == null) throw new BizException("没有收到待保存的的数据:" + dbName + "!");
//对应的数据集定义
PageDataset pageDataSet = findDataset(dbName);
if (pageDataSet == null) throw new SwException("没有找到指定的的数据集定义:" + dbName + "!");
if (pageDataSet == null) throw new BizException("没有找到指定的的数据集定义:" + dbName + "!");
//读取待保存的bean
DefaultEntity bean = readBeanFromPage(pageDataSet, data);
if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上
@@ -79,7 +80,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
*/
public R saveAll() {
SwMap data = params.readMap("data");
if (data == null) throw new SwException("没有收到待保存的的数据!");
if (data == null) throw new BizException("没有收到待保存的的数据!");
SwMap filter = params.readMap("filter");

Map<String, DefaultEntity> map = new LinkedHashMap<>();
@@ -143,7 +144,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
*/
protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) {
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());

EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(table.getName());
@@ -155,7 +156,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
} else {
bean = dao.queryEntity(id);
if (bean == null) {
throw new SwException("没有找到待保存的记录:" + table.getName() + "." + id);
throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id);
}
}
//暂时不考虑list保存的情况
@@ -174,14 +175,14 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
String value = bean.getStr(field.getName());
//非空校验
if (field.isNotNull() && StringUtils.isEmpty(value)) {
throw new SwException("字段不允许为空:" + field.getTitle());
throw new BizException("字段不允许为空:" + field.getTitle());
}

//长度校验
if (StringUtils.isNotEmpty(value)) {
int len = SwEnum.DataType.instance.getByValue(field.getDataType()).dataLength;
if (len > 0 && CommUtil.getStrLenB(value) > len) {
throw new SwException("字段值超长:" + field.getTitle());
throw new BizException("字段值超长:" + field.getTitle());
}
}
}


Notiek ielāde…
Atcelt
Saglabāt