Commit ee88dbc8 authored by yanzg's avatar yanzg

SQL层级处理的支持

parent 168d95a5
package com.yanzuoguang.util.base; package com.yanzuoguang.util.base;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
...@@ -184,7 +183,7 @@ public class ObjectHelper { ...@@ -184,7 +183,7 @@ public class ObjectHelper {
try { try {
setByType(vType, target, field, value); setByType(vType, target, field, value);
} catch (Exception ex) { } catch (Exception ex) {
throw new CodeException(ex); throw new RuntimeException(ex);
} }
} }
} }
...@@ -240,7 +239,7 @@ public class ObjectHelper { ...@@ -240,7 +239,7 @@ public class ObjectHelper {
writeWithFromClass(to, from); writeWithFromClass(to, from);
return (T) to; return (T) to;
} catch (Exception e) { } catch (Exception e) {
throw new CodeException("对象" + cls.getName() + "不能复制", e); throw new RuntimeException("对象" + cls.getName() + "不能复制", e);
} }
} }
......
package com.yanzuoguang.util.helper; package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.exception.CodeException;
/** /**
* 通信格式转换 * 通信格式转换
...@@ -543,7 +542,7 @@ public class ByteHelper { ...@@ -543,7 +542,7 @@ public class ByteHelper {
*/ */
public static byte toBCD(int from) { public static byte toBCD(int from) {
if (from >= BCD_MAX_FLAG) { if (from >= BCD_MAX_FLAG) {
throw new CodeException("整形转换成字节的PCD码必须小于100"); throw new RuntimeException("整形转换成字节的PCD码必须小于100");
} }
byte bt = (byte) ((from / BYTE_TEN_UNIT * BYTE_HEX_UNIT) + from % BYTE_TEN_UNIT); byte bt = (byte) ((from / BYTE_TEN_UNIT * BYTE_HEX_UNIT) + from % BYTE_TEN_UNIT);
return bt; return bt;
......
package com.yanzuoguang.util.helper; package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -549,7 +548,7 @@ public class DateHelper { ...@@ -549,7 +548,7 @@ public class DateHelper {
long mill = toMill - fromMill; long mill = toMill - fromMill;
return mill; return mill;
} catch (ParseException ex) { } catch (ParseException ex) {
throw new CodeException(ex); throw new RuntimeException(ex);
} }
} }
...@@ -754,7 +753,7 @@ public class DateHelper { ...@@ -754,7 +753,7 @@ public class DateHelper {
Date dt = format.parse(from); Date dt = format.parse(from);
return format.format(dt); return format.format(dt);
} catch (ParseException e) { } catch (ParseException e) {
throw new CodeException(e); throw new RuntimeException(e);
} }
} }
......
package com.yanzuoguang.util.helper; package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.exception.CodeException;
import java.io.BufferedReader; import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
/** /**
* 登录相关函数 * 登录相关函数
...@@ -39,7 +33,7 @@ public class FileHelper { ...@@ -39,7 +33,7 @@ public class FileHelper {
if (file.isDirectory()) { if (file.isDirectory()) {
return StringHelper.EMPTY; return StringHelper.EMPTY;
} else { } else {
throw new CodeException("文件" + file.getName() + "已存在文件,不能创建目录"); throw new RuntimeException("文件" + file.getName() + "已存在文件,不能创建目录");
} }
} }
file.mkdirs(); file.mkdirs();
...@@ -65,10 +59,10 @@ public class FileHelper { ...@@ -65,10 +59,10 @@ public class FileHelper {
try { try {
InputStream inputStream = new FileInputStream(file); InputStream inputStream = new FileInputStream(file);
return readFile(inputStream, encoding); return readFile(inputStream, encoding);
} catch (CodeException e) { } catch (RuntimeException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new CodeException(e); throw new RuntimeException(e);
} }
} }
...@@ -99,10 +93,10 @@ public class FileHelper { ...@@ -99,10 +93,10 @@ public class FileHelper {
} finally { } finally {
inputStream.close();//关闭输入流 inputStream.close();//关闭输入流
} }
} catch (CodeException e) { } catch (RuntimeException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new CodeException(e); throw new RuntimeException(e);
} }
return sb.toString(); return sb.toString();
} }
...@@ -122,11 +116,11 @@ public class FileHelper { ...@@ -122,11 +116,11 @@ public class FileHelper {
if (parentFile != null) { if (parentFile != null) {
if (!parentFile.exists()) { if (!parentFile.exists()) {
if (!parentFile.mkdirs()) { if (!parentFile.mkdirs()) {
throw new CodeException("创建文件夹失败"); throw new RuntimeException("创建文件夹失败");
} }
} }
if (!parentFile.exists()) { if (!parentFile.exists()) {
throw new CodeException("创建文件夹失败"); throw new RuntimeException("创建文件夹失败");
} }
} }
// 文件不存在则创建 // 文件不存在则创建
...@@ -138,10 +132,10 @@ public class FileHelper { ...@@ -138,10 +132,10 @@ public class FileHelper {
raf.seek(file.length()); raf.seek(file.length());
raf.write(content.getBytes(encoding)); raf.write(content.getBytes(encoding));
raf.close(); raf.close();
} catch (CodeException e) { } catch (RuntimeException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new CodeException(e); throw new RuntimeException(e);
} }
} }
...@@ -157,17 +151,17 @@ public class FileHelper { ...@@ -157,17 +151,17 @@ public class FileHelper {
// 删除文件 // 删除文件
if (file.exists()) { if (file.exists()) {
if (!file.delete()) { if (!file.delete()) {
throw new CodeException("文件删除失败"); throw new RuntimeException("文件删除失败");
} }
} }
if (file.exists()) { if (file.exists()) {
throw new CodeException("文件删除失败"); throw new RuntimeException("文件删除失败");
} }
writeFileAppend(file, content, encoding); writeFileAppend(file, content, encoding);
} catch (CodeException e) { } catch (RuntimeException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new CodeException(e); throw new RuntimeException(e);
} }
} }
......
package com.yanzuoguang.util.helper; package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.thread.ProcessData; import com.yanzuoguang.util.thread.ProcessData;
import com.yanzuoguang.util.thread.RunProcess; import com.yanzuoguang.util.thread.RunProcess;
...@@ -10,7 +8,6 @@ import java.io.*; ...@@ -10,7 +8,6 @@ import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.charset.Charset;
/** /**
* HTTP请求工具类 * HTTP请求工具类
...@@ -31,7 +28,7 @@ public class HttpHelper { ...@@ -31,7 +28,7 @@ public class HttpHelper {
java.net.HttpURLConnection httpConn = getConn(url); java.net.HttpURLConnection httpConn = getConn(url);
return post(httpConn, jsonString); return post(httpConn, jsonString);
} catch (Exception ex) { } catch (Exception ex) {
throw new CodeException(ex); throw new RuntimeException(ex);
} }
} }
...@@ -49,7 +46,7 @@ public class HttpHelper { ...@@ -49,7 +46,7 @@ public class HttpHelper {
httpConn.setRequestProperty("Content-Type", "application/json"); httpConn.setRequestProperty("Content-Type", "application/json");
return post(httpConn, jsonString); return post(httpConn, jsonString);
} catch (Exception ex) { } catch (Exception ex) {
throw new CodeException(ex); throw new RuntimeException(ex);
} }
} }
......
package com.yanzuoguang.util.helper; package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.thread.ThreadHelper; import com.yanzuoguang.util.thread.ThreadHelper;
/** /**
* 重复执行工具类 * 重复执行工具类
*
* @author 颜佐光 * @author 颜佐光
*/ */
public class RunHelper { public class RunHelper {
...@@ -50,7 +50,7 @@ public class RunHelper { ...@@ -50,7 +50,7 @@ public class RunHelper {
} }
} }
if (ex != null) { if (ex != null) {
throw new CodeException(tag + ex.getMessage(), ex); throw new RuntimeException(tag + ex.getMessage(), ex);
} }
} }
} }
package com.yanzuoguang.util.helper; package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.base.ObjectHelper; import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.*; import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -910,7 +912,7 @@ public class StringHelper { ...@@ -910,7 +912,7 @@ public class StringHelper {
*/ */
public static String getNewMD5Id(Date date, Object... froms) { public static String getNewMD5Id(Date date, Object... froms) {
if (date == null) { if (date == null) {
throw new CodeException("生成时间搓 MD5 ID 时,时间不能为空"); throw new RuntimeException("生成时间搓 MD5 ID 时,时间不能为空");
} }
String tag = getNewIdTag(date.getTime()); String tag = getNewIdTag(date.getTime());
String id = md51(getId(froms)); String id = md51(getId(froms));
......
package com.yanzuoguang.util.helper; package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.contants.SystemContants; import com.yanzuoguang.util.contants.SystemContants;
import com.yanzuoguang.util.exception.CodeException;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
...@@ -33,7 +32,7 @@ public class UrlHelper { ...@@ -33,7 +32,7 @@ public class UrlHelper {
} }
return sb.toString(); return sb.toString();
} catch (Exception ex) { } catch (Exception ex) {
throw new CodeException(ex); throw new RuntimeException(ex);
} }
} }
...@@ -48,7 +47,7 @@ public class UrlHelper { ...@@ -48,7 +47,7 @@ public class UrlHelper {
try { try {
return URLDecoder.decode(from, encoding); return URLDecoder.decode(from, encoding);
} catch (Exception ex) { } catch (Exception ex) {
throw new CodeException(ex); throw new RuntimeException(ex);
} }
} }
......
package com.yanzuoguang.util.helper; package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.exception.CodeException;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
...@@ -39,10 +38,10 @@ public class ZipHelper { ...@@ -39,10 +38,10 @@ public class ZipHelper {
*/ */
public static void zipDirectory(File dirFile, File zipFile, boolean isDir) throws IOException { public static void zipDirectory(File dirFile, File zipFile, boolean isDir) throws IOException {
if (dirFile == null) { if (dirFile == null) {
throw new CodeException("压缩时文件夹对象不能为空。"); throw new RuntimeException("压缩时文件夹对象不能为空。");
} }
if (!dirFile.isDirectory()) { if (!dirFile.isDirectory()) {
throw new CodeException("[" + dirFile.getName() + "]不是一个文件夹,或者不存在。"); throw new RuntimeException("[" + dirFile.getName() + "]不是一个文件夹,或者不存在。");
} }
if (zipFile == null) { if (zipFile == null) {
zipFile = new File(dirFile.getAbsolutePath() + ".zip"); zipFile = new File(dirFile.getAbsolutePath() + ".zip");
...@@ -158,7 +157,7 @@ public class ZipHelper { ...@@ -158,7 +157,7 @@ public class ZipHelper {
if (flag) { if (flag) {
tempFile.renameTo(zipTo); tempFile.renameTo(zipTo);
} else { } else {
throw new CodeException("删除文件失败"); throw new RuntimeException("删除文件失败");
} }
} }
} }
...@@ -216,7 +215,7 @@ public class ZipHelper { ...@@ -216,7 +215,7 @@ public class ZipHelper {
*/ */
private static void zipFile(String sourcePath, File file, ZipOutputStream zipOutStream, BufferedOutputStream bufferOutStream) throws IOException { private static void zipFile(String sourcePath, File file, ZipOutputStream zipOutStream, BufferedOutputStream bufferOutStream) throws IOException {
if (!file.exists()) { if (!file.exists()) {
throw new CodeException("文件" + file.getAbsolutePath() + "不存在"); throw new RuntimeException("文件" + file.getAbsolutePath() + "不存在");
} }
// 创建压缩文件实体 // 创建压缩文件实体
ZipEntry entry = new ZipEntry(sourcePath + file.getName()); ZipEntry entry = new ZipEntry(sourcePath + file.getName());
......
package com.yanzuoguang.util.thread; package com.yanzuoguang.util.thread;
import com.yanzuoguang.util.exception.CodeException;
/** /**
* 根据指定的线程数量, 执行多个Runnable对象 * 根据指定的线程数量, 执行多个Runnable对象
*
* @author 颜佐光 * @author 颜佐光
*/ */
public class RunnableList extends AbstractThreadList<Runnable> { public class RunnableList extends AbstractThreadList<Runnable> {
...@@ -28,7 +27,7 @@ public class RunnableList extends AbstractThreadList<Runnable> { ...@@ -28,7 +27,7 @@ public class RunnableList extends AbstractThreadList<Runnable> {
} catch (RuntimeException ex) { } catch (RuntimeException ex) {
throw ex; throw ex;
} catch (Exception ex) { } catch (Exception ex) {
throw new CodeException(ex.getMessage(), ex); throw new RuntimeException(ex.getMessage(), ex);
} }
} }
} }
package com.yanzuoguang.util.thread; package com.yanzuoguang.util.thread;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import java.util.Date; import java.util.Date;
...@@ -158,7 +157,7 @@ public class RunnableListAutoItem implements Comparable<RunnableListAutoItem> { ...@@ -158,7 +157,7 @@ public class RunnableListAutoItem implements Comparable<RunnableListAutoItem> {
if (ex instanceof RuntimeException) { if (ex instanceof RuntimeException) {
throw (RuntimeException) ex; throw (RuntimeException) ex;
} else { } else {
throw new CodeException(ex.getMessage(), ex); throw new RuntimeException(ex.getMessage(), ex);
} }
} }
......
...@@ -3,7 +3,6 @@ package com.yanzuoguang.util.vo; ...@@ -3,7 +3,6 @@ package com.yanzuoguang.util.vo;
import com.yanzuoguang.util.contants.ResultConstants; import com.yanzuoguang.util.contants.ResultConstants;
import com.yanzuoguang.util.exception.CodeException; import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
/** /**
......
package helper; package helper;
import base.DemoVo; import base.DemoVo;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.TypeHelper; import com.yanzuoguang.util.helper.TypeHelper;
import com.yanzuoguang.util.vo.ResponseResult; import com.yanzuoguang.util.vo.ResponseResult;
import helper.vo.ResponseDataMainResult; import helper.vo.ResponseDataMainResult;
...@@ -24,7 +23,7 @@ public class TestTypeHelper { ...@@ -24,7 +23,7 @@ public class TestTypeHelper {
TypeHelper.printSuperClass(returnType); TypeHelper.printSuperClass(returnType);
boolean isSub = TypeHelper.isSubType(returnType, ResponseResult.class); boolean isSub = TypeHelper.isSubType(returnType, ResponseResult.class);
if (!isSub) { if (!isSub) {
throw new CodeException("泛型继承检测错误"); throw new RuntimeException("泛型继承检测错误");
} }
} }
} }
package thread; package thread;
import com.yanzuoguang.util.exception.CodeException; import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.thread.RunnableListAuto; import com.yanzuoguang.util.thread.RunnableListAuto;
import com.yanzuoguang.util.thread.ThreadHelper; import com.yanzuoguang.util.thread.ThreadHelper;
import org.junit.Test; import org.junit.Test;
...@@ -28,7 +27,7 @@ public class TestRunnableListAuto { ...@@ -28,7 +27,7 @@ public class TestRunnableListAuto {
public void test() { public void test() {
try { try {
runTest(true); runTest(true);
throw new CodeException("没有抛出异常"); throw new RuntimeException("没有抛出异常");
} catch (Exception ex) { } catch (Exception ex) {
// Log.error(TestRunnableListAuto.class, ex); // Log.error(TestRunnableListAuto.class, ex);
} }
......
package com.yanzuoguang.cloud.aop; package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.util.exception.CodeException;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
...@@ -20,7 +19,7 @@ public class HttpAspectUtil { ...@@ -20,7 +19,7 @@ public class HttpAspectUtil {
public static HttpServletRequest getRequest() { public static HttpServletRequest getRequest() {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes == null) { if (attributes == null) {
throw new CodeException("监视错误"); throw new RuntimeException("监视错误");
} }
return attributes.getRequest(); return attributes.getRequest();
} }
......
...@@ -6,7 +6,6 @@ import com.yanzuoguang.excel.ExcelConsole; ...@@ -6,7 +6,6 @@ import com.yanzuoguang.excel.ExcelConsole;
import com.yanzuoguang.excel.ExcelRow; import com.yanzuoguang.excel.ExcelRow;
import com.yanzuoguang.excel.ExportBase; import com.yanzuoguang.excel.ExportBase;
import com.yanzuoguang.excel.ExportData; import com.yanzuoguang.excel.ExportData;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -75,7 +74,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -75,7 +74,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
public static <T extends Object, M extends Object> void export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao) { public static <T extends Object, M extends Object> void export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao) {
ExportData config = req.getConfig(); ExportData config = req.getConfig();
if (config == null) { if (config == null) {
throw new CodeException("导出时请传入配置信息"); throw new RuntimeException("导出时请传入配置信息");
} }
if (StringHelper.isEmpty(config.getServerPath())) { if (StringHelper.isEmpty(config.getServerPath())) {
config.setServerPath("/home/cache/"); config.setServerPath("/home/cache/");
...@@ -94,7 +93,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -94,7 +93,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
excel.down(response); excel.down(response);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new CodeException("下载失败", e); throw new RuntimeException("下载失败", e);
} finally { } finally {
// 删除生成的临时文件 // 删除生成的临时文件
excel.remove(); excel.remove();
......
...@@ -4,7 +4,6 @@ import com.yanzuoguang.dao.DaoConst; ...@@ -4,7 +4,6 @@ import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.dao.impl.SqlData; import com.yanzuoguang.dao.impl.SqlData;
import com.yanzuoguang.dao.impl.SqlDataField; import com.yanzuoguang.dao.impl.SqlDataField;
import com.yanzuoguang.util.base.ObjectHelper; import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -71,7 +70,7 @@ public abstract class SqlCondBase<T extends SqlCondBase> implements SqlCond<T> { ...@@ -71,7 +70,7 @@ public abstract class SqlCondBase<T extends SqlCondBase> implements SqlCond<T> {
@Override @Override
public String getSql(String sql, SqlData sqlData, SqlDataField sqlDataField, Object model, Map<String, List<String>> codeMap) { public String getSql(String sql, SqlData sqlData, SqlDataField sqlDataField, Object model, Map<String, List<String>> codeMap) {
if (sqlDataField.getCond() != this) { if (sqlDataField.getCond() != this) {
throw new CodeException("不能处理非本条件的字段"); throw new RuntimeException("不能处理非本条件的字段");
} }
int condType = getCondType(model, sqlDataField); int condType = getCondType(model, sqlDataField);
switch (condType) { switch (condType) {
...@@ -86,7 +85,7 @@ public abstract class SqlCondBase<T extends SqlCondBase> implements SqlCond<T> { ...@@ -86,7 +85,7 @@ public abstract class SqlCondBase<T extends SqlCondBase> implements SqlCond<T> {
String fieldName = this.fields.isEmpty() ? StringHelper.EMPTY : this.fields.get(0); String fieldName = this.fields.isEmpty() ? StringHelper.EMPTY : this.fields.get(0);
// 判断代码片段是否合法 // 判断代码片段是否合法
if (sqlDataField.getCodes().size() % 2 == 1) { if (sqlDataField.getCodes().size() % 2 == 1) {
throw new CodeException("代码片段" + this.getClass().getSimpleName() + ":" + sqlData.getName() + ":" + fieldName + "为单数"); throw new RuntimeException("代码片段" + this.getClass().getSimpleName() + ":" + sqlData.getName() + ":" + fieldName + "为单数");
} }
// 处理代码片段 // 处理代码片段
for (int i = 0; i < sqlDataField.getCodes().size(); i = i + DaoConst.CODE_UNIT) { for (int i = 0; i < sqlDataField.getCodes().size(); i = i + DaoConst.CODE_UNIT) {
......
...@@ -45,7 +45,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao { ...@@ -45,7 +45,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/ */
protected String getKey() { protected String getKey() {
if (this.table == null) { if (this.table == null) {
throw new CodeException("类" + this.getClass().getName() + "未发现表结构"); throw new RuntimeException("类" + this.getClass().getName() + "未发现表结构");
} }
return this.table.getTable().getKeyName(); return this.table.getTable().getKeyName();
} }
...@@ -165,13 +165,13 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao { ...@@ -165,13 +165,13 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
public String update(Object model) { public String update(Object model) {
String keyString = this.getKeyString(model); String keyString = this.getKeyString(model);
if (StringHelper.isEmpty(keyString)) { if (StringHelper.isEmpty(keyString)) {
throw new CodeException("表" + this.table.getTable().getName() + "主键值为空时不能更新"); throw new RuntimeException("表" + this.table.getTable().getName() + "主键值为空时不能更新");
} }
this.check(DaoConst.OPERATOR_TYPE_UPDATE, keyString, model); this.check(DaoConst.OPERATOR_TYPE_UPDATE, keyString, model);
SqlData sqlData = this.getSql(DaoConst.UPDATE); SqlData sqlData = this.getSql(DaoConst.UPDATE);
int ret = updateSql(sqlData, model); int ret = updateSql(sqlData, model);
if (ret == 0) { if (ret == 0) {
throw new CodeException("修改失败,请确认是否被其他人修改,版本号传入是否正确"); throw new RuntimeException("修改失败,请确认是否被其他人修改,版本号传入是否正确");
} }
String retVal = ret > 0 ? keyString : ""; String retVal = ret > 0 ? keyString : "";
return retVal; return retVal;
...@@ -851,7 +851,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao { ...@@ -851,7 +851,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
try { try {
from = cls.newInstance(); from = cls.newInstance();
} catch (Exception ex) { } catch (Exception ex) {
throw new CodeException("创建对象" + cls.getName() + "出错", ex); throw new RuntimeException("创建对象" + cls.getName() + "出错", ex);
} }
ObjectHelper.writeWithFrom(from, request); ObjectHelper.writeWithFrom(from, request);
return this.create(from); return this.create(from);
......
...@@ -7,7 +7,6 @@ import com.yanzuoguang.db.DbExecute; ...@@ -7,7 +7,6 @@ import com.yanzuoguang.db.DbExecute;
import com.yanzuoguang.db.impl.DbRow; import com.yanzuoguang.db.impl.DbRow;
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.exception.CodeException;
import com.yanzuoguang.util.helper.ArrayHelper; import com.yanzuoguang.util.helper.ArrayHelper;
import com.yanzuoguang.util.helper.StringFormatHandle; import com.yanzuoguang.util.helper.StringFormatHandle;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
...@@ -110,7 +109,7 @@ public abstract class BaseDaoSql { ...@@ -110,7 +109,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 CodeException("该页面未绑定表"); throw new RuntimeException("该页面未绑定表");
} }
return this.register(annotation.value(), clsModel); return this.register(annotation.value(), clsModel);
} }
...@@ -148,11 +147,11 @@ public abstract class BaseDaoSql { ...@@ -148,11 +147,11 @@ public abstract class BaseDaoSql {
*/ */
protected SqlData getSql(String name, boolean isThrow) { protected SqlData getSql(String name, boolean isThrow) {
if (this.table == null) { if (this.table == null) {
throw new CodeException("类" + this.getClass().getName() + "未发现表结构"); throw new RuntimeException("类" + 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 CodeException("类" + this.getClass().getName() + "未发现SQL语句" + name); throw new RuntimeException("类" + this.getClass().getName() + "未发现SQL语句" + name);
} }
return sql; return sql;
} }
...@@ -760,7 +759,7 @@ public abstract class BaseDaoSql { ...@@ -760,7 +759,7 @@ public abstract class BaseDaoSql {
sb.append("AVG"); sb.append("AVG");
break; break;
default: default:
throw new CodeException("统计类型[" + from.getGroupType() + "]不支持"); throw new RuntimeException("统计类型[" + from.getGroupType() + "]不支持");
} }
sb.append("( CASE WHEN "); sb.append("( CASE WHEN ");
sb.append(from.getCaseField()); sb.append(from.getCaseField());
......
...@@ -2,7 +2,6 @@ package com.yanzuoguang.dao.impl; ...@@ -2,7 +2,6 @@ package com.yanzuoguang.dao.impl;
import com.yanzuoguang.dao.DaoConst; import com.yanzuoguang.dao.DaoConst;
import com.yanzuoguang.util.cache.MemoryCache; import com.yanzuoguang.util.cache.MemoryCache;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -170,7 +169,7 @@ public class TableSqlCache { ...@@ -170,7 +169,7 @@ public class TableSqlCache {
for (String item : tableWhereField.getFields()) { for (String item : tableWhereField.getFields()) {
String name = item.toLowerCase(); String name = item.toLowerCase();
if (!sqlFieldHas.containsKey(name)) { if (!sqlFieldHas.containsKey(name)) {
throw new CodeException("SQL语句" + item + "不存在纬度" + item); throw new RuntimeException("SQL语句" + item + "不存在纬度" + item);
} }
sqlFieldWhere.put(name, true); sqlFieldWhere.put(name, true);
} }
...@@ -196,7 +195,7 @@ public class TableSqlCache { ...@@ -196,7 +195,7 @@ public class TableSqlCache {
} else if (!StringHelper.isEmpty(this.table.getMD5KeyName())) { } else if (!StringHelper.isEmpty(this.table.getMD5KeyName())) {
addString(map, "{Key}", this.table.getMD5KeyName()); addString(map, "{Key}", this.table.getMD5KeyName());
} else { } else {
throw new CodeException("表中未包含MD5字段"); throw new RuntimeException("表中未包含MD5字段");
} }
String lowerKey = this.table.getKeyName().toLowerCase(); String lowerKey = this.table.getKeyName().toLowerCase();
......
package com.yanzuoguang.excel; package com.yanzuoguang.excel;
import com.yanzuoguang.db.impl.DbRow; import com.yanzuoguang.db.impl.DbRow;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.CheckerHelper; import com.yanzuoguang.util.helper.CheckerHelper;
import com.yanzuoguang.util.helper.FileHelper; import com.yanzuoguang.util.helper.FileHelper;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
...@@ -164,7 +163,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -164,7 +163,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
*/ */
protected void initExcel(TableHead head) { protected void initExcel(TableHead head) {
if (this.workbook != null) { if (this.workbook != null) {
throw new CodeException("Excel已初始化"); throw new RuntimeException("Excel已初始化");
} }
// 创建合并对象数据检测 // 创建合并对象数据检测
mergerGroup = new HashMap<>(); mergerGroup = new HashMap<>();
...@@ -379,13 +378,13 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -379,13 +378,13 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
out.flush(); out.flush();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new CodeException("保存失败"); throw new RuntimeException("保存失败");
} finally { } finally {
out.close(); out.close();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new CodeException("保存失败"); throw new RuntimeException("保存失败");
} }
return this; return this;
} }
...@@ -402,7 +401,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -402,7 +401,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
File file = new File(this.getFileName()); File file = new File(this.getFileName());
if (file.exists()) { if (file.exists()) {
if (!file.delete()) { if (!file.delete()) {
throw new CodeException("文件删除失败"); throw new RuntimeException("文件删除失败");
} }
} }
return this; return this;
......
...@@ -2,7 +2,6 @@ package com.yanzuoguang.service.impl; ...@@ -2,7 +2,6 @@ package com.yanzuoguang.service.impl;
import com.yanzuoguang.dao.BaseDao; import com.yanzuoguang.dao.BaseDao;
import com.yanzuoguang.service.BaseService; import com.yanzuoguang.service.BaseService;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -186,7 +185,7 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> { ...@@ -186,7 +185,7 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> {
*/ */
private void check(String opTag, String serviceTag, Object id) { private void check(String opTag, String serviceTag, Object id) {
if (StringHelper.isEmpty(id)) { if (StringHelper.isEmpty(id)) {
throw new CodeException(opTag + serviceTag + "失败,该数据可能已被修改"); throw new RuntimeException(opTag + serviceTag + "失败,该数据可能已被修改");
} }
} }
......
...@@ -16,7 +16,6 @@ import com.yanzuoguang.mq.vo.QueueVo; ...@@ -16,7 +16,6 @@ import com.yanzuoguang.mq.vo.QueueVo;
import com.yanzuoguang.mq.vo.req.RegisterServerTokenReqVo; import com.yanzuoguang.mq.vo.req.RegisterServerTokenReqVo;
import com.yanzuoguang.mq.vo.req.ServerMessageReqVo; import com.yanzuoguang.mq.vo.req.ServerMessageReqVo;
import com.yanzuoguang.mq.vo.req.ServerQueueReqVo; import com.yanzuoguang.mq.vo.req.ServerQueueReqVo;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.DateHelper; import com.yanzuoguang.util.helper.DateHelper;
import com.yanzuoguang.util.helper.JsonHelper; import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
......
...@@ -2,7 +2,6 @@ package com.yanzuoguang.util; ...@@ -2,7 +2,6 @@ package com.yanzuoguang.util;
import com.yanzuoguang.util.base.ObjectHelper; import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.JsonHelper; import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.StringFormatHandle; import com.yanzuoguang.util.helper.StringFormatHandle;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
...@@ -68,7 +67,7 @@ public class PrinterHelper { ...@@ -68,7 +67,7 @@ public class PrinterHelper {
try { try {
pager = JsonHelper.deserialize(from.getPager(), PrinterPagerData.class); pager = JsonHelper.deserialize(from.getPager(), PrinterPagerData.class);
} catch (Exception ex) { } catch (Exception ex) {
throw new CodeException("不能识别模板", ex); throw new RuntimeException("不能识别模板", ex);
} }
// 设置偏移量 // 设置偏移量
pager.setMarginTop(pager.getMarginTop() + top); pager.setMarginTop(pager.getMarginTop() + top);
......
package com.yanzuoguang.util.printer.format; package com.yanzuoguang.util.printer.format;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
import java.util.HashMap; import java.util.HashMap;
...@@ -53,7 +52,7 @@ public class FormatCenter { ...@@ -53,7 +52,7 @@ public class FormatCenter {
private String format(String command, String formatValue) { private String format(String command, String formatValue) {
this.initDefault(); this.initDefault();
if (StringHelper.isEmpty(command)) { if (StringHelper.isEmpty(command)) {
throw new CodeException("你需要格式化的字符串格式为空"); throw new RuntimeException("你需要格式化的字符串格式为空");
} }
String[] commands = command.split(":"); String[] commands = command.split(":");
String name = commands[0]; String name = commands[0];
...@@ -63,7 +62,7 @@ public class FormatCenter { ...@@ -63,7 +62,7 @@ public class FormatCenter {
} }
FormatHandle formatHandle = cache.get(name); FormatHandle formatHandle = cache.get(name);
if (formatHandle == null) { if (formatHandle == null) {
throw new CodeException("需要格式化的字符串不支持"); throw new RuntimeException("需要格式化的字符串不支持");
} }
return formatHandle.getFormat(name, format, formatValue); return formatHandle.getFormat(name, format, formatValue);
} }
......
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