Commit 1c3d04f9 authored by yanzg's avatar yanzg

修改实例化关系

parent aee91ed5
...@@ -13,7 +13,9 @@ public class YzgError { ...@@ -13,7 +13,9 @@ public class YzgError {
private static YzgErrorData error = new YzgErrorData("999."); private static YzgErrorData error = new YzgErrorData("999.");
private static void init() { private static void init() {
error.add("001", ""); error.add("001", "该页面未绑定表");
error.add("002", "类%s未发现表结构");
error.add("003", "类%未发现SQL语句%s");
} }
private static void initTemp() { private static void initTemp() {
...@@ -36,7 +38,7 @@ public class YzgError { ...@@ -36,7 +38,7 @@ public class YzgError {
* @param code * @param code
* @param args * @param args
*/ */
public CodeException throwException(Exception ex, String code, Object... args) { public static CodeException throwException(Exception ex, String code, Object... args) {
throw error.getCodeException(ex, code, args); throw error.getCodeException(ex, code, args);
} }
...@@ -46,7 +48,7 @@ public class YzgError { ...@@ -46,7 +48,7 @@ public class YzgError {
* @param code * @param code
* @param args * @param args
*/ */
public CodeException getException(String code, Object... args) { public static CodeException getException(String code, Object... args) {
return error.getCodeException(null, code, args); return error.getCodeException(null, code, args);
} }
...@@ -56,7 +58,7 @@ public class YzgError { ...@@ -56,7 +58,7 @@ public class YzgError {
* @param code * @param code
* @param args * @param args
*/ */
public CodeException getException(Exception ex, String code, Object... args) { public static CodeException getException(Exception ex, String code, Object... args) {
return error.getCodeException(ex, code, args); return error.getCodeException(ex, code, args);
} }
...@@ -66,7 +68,7 @@ public class YzgError { ...@@ -66,7 +68,7 @@ public class YzgError {
* @param code * @param code
* @param args * @param args
*/ */
public RuntimeCodeException throwRuntimeException(String code, Object... args) { public static RuntimeCodeException throwRuntimeException(String code, Object... args) {
throw error.getRuntimeException(null, code, args); throw error.getRuntimeException(null, code, args);
} }
...@@ -76,7 +78,7 @@ public class YzgError { ...@@ -76,7 +78,7 @@ public class YzgError {
* @param code * @param code
* @param args * @param args
*/ */
public RuntimeCodeException throwRuntimeException(Exception ex, String code, Object... args) { public static RuntimeCodeException throwRuntimeException(Exception ex, String code, Object... args) {
throw error.getRuntimeException(ex, code, args); throw error.getRuntimeException(ex, code, args);
} }
...@@ -86,7 +88,7 @@ public class YzgError { ...@@ -86,7 +88,7 @@ public class YzgError {
* @param code * @param code
* @param args * @param args
*/ */
public RuntimeCodeException getRuntimeException(String code, Object... args) { public static RuntimeCodeException getRuntimeException(String code, Object... args) {
return error.getRuntimeException(null, code, args); return error.getRuntimeException(null, code, args);
} }
...@@ -96,7 +98,7 @@ public class YzgError { ...@@ -96,7 +98,7 @@ public class YzgError {
* @param code * @param code
* @param args * @param args
*/ */
public RuntimeCodeException getRuntimeException(Exception ex, String code, Object... args) { public static RuntimeCodeException getRuntimeException(Exception ex, String code, Object... args) {
return error.getRuntimeException(ex, code, args); return error.getRuntimeException(ex, code, args);
} }
......
...@@ -5,6 +5,7 @@ import com.yanzuoguang.dao.QueryPara; ...@@ -5,6 +5,7 @@ import com.yanzuoguang.dao.QueryPara;
import com.yanzuoguang.dao.TableAnnotation; import com.yanzuoguang.dao.TableAnnotation;
import com.yanzuoguang.db.DbExecute; import com.yanzuoguang.db.DbExecute;
import com.yanzuoguang.db.impl.DbRow; import com.yanzuoguang.db.impl.DbRow;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.base.ObjectHelper; import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.cache.MemoryCache; import com.yanzuoguang.util.cache.MemoryCache;
import com.yanzuoguang.util.helper.ArrayHelper; import com.yanzuoguang.util.helper.ArrayHelper;
...@@ -114,7 +115,7 @@ public abstract class BaseDaoSql { ...@@ -114,7 +115,7 @@ public abstract class BaseDaoSql {
protected TableSqlCache register(Class<?> clsModel) { protected TableSqlCache register(Class<?> clsModel) {
TableAnnotation annotation = clsModel.getAnnotation(TableAnnotation.class); TableAnnotation annotation = clsModel.getAnnotation(TableAnnotation.class);
if (annotation == null) { if (annotation == null) {
throw new RuntimeException("该页面未绑定表"); throw YzgError.getRuntimeException("001");
} }
return this.register(annotation.value(), clsModel); return this.register(annotation.value(), clsModel);
} }
...@@ -152,11 +153,11 @@ public abstract class BaseDaoSql { ...@@ -152,11 +153,11 @@ public abstract class BaseDaoSql {
*/ */
public SqlData getSql(String name, boolean isThrow) { public SqlData getSql(String name, boolean isThrow) {
if (this.table == null) { if (this.table == null) {
throw new RuntimeException("类" + this.getClass().getName() + "未发现表结构"); throw YzgError.getRuntimeException("002", this.getClass().getName());
} }
SqlData sql = this.table.getNameCache().get(name); SqlData sql = this.table.getNameCache().get(name);
if (isThrow && sql == null) { if (isThrow && sql == null) {
throw new RuntimeException("类" + this.getClass().getName() + "未发现SQL语句" + name); throw YzgError.getRuntimeException("003", this.getClass().getName(), name);
} }
return sql; return sql;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment