调整目录结构
This commit is contained in:
parent
0d0f8d3845
commit
808cca7b5d
|
|
@ -41,7 +41,6 @@ import com.smallchill.core.constant.Cst;
|
|||
import com.smallchill.core.exception.NoPermissionException;
|
||||
import com.smallchill.core.exception.NoUserException;
|
||||
import com.smallchill.core.interfaces.IQuery;
|
||||
import com.smallchill.core.modules.support.BeanInjector;
|
||||
import com.smallchill.core.shiro.ShiroKit;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Record;
|
||||
|
|
@ -52,6 +51,7 @@ import com.smallchill.core.toolbox.kit.BeanKit;
|
|||
import com.smallchill.core.toolbox.kit.LogKit;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
import com.smallchill.core.toolbox.log.LogManager;
|
||||
import com.smallchill.core.toolbox.support.BeanInjector;
|
||||
|
||||
/**
|
||||
* @author James Zhan, Chill Zhuang
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl;
|
||||
package com.smallchill.core.beetl;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl;
|
||||
package com.smallchill.core.beetl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
|
@ -26,15 +26,15 @@ import org.beetl.core.GroupTemplate;
|
|||
import org.beetl.core.Template;
|
||||
import org.beetl.core.resource.StringTemplateResourceLoader;
|
||||
|
||||
import com.smallchill.core.beetl.func.BeetlExt;
|
||||
import com.smallchill.core.beetl.func.ShiroExt;
|
||||
import com.smallchill.core.beetl.tag.DropDownTag;
|
||||
import com.smallchill.core.beetl.tag.FootTag;
|
||||
import com.smallchill.core.beetl.tag.HotBlogsTag;
|
||||
import com.smallchill.core.beetl.tag.SelectTag;
|
||||
import com.smallchill.core.beetl.tag.SideBarTag;
|
||||
import com.smallchill.core.constant.ConstConfig;
|
||||
import com.smallchill.core.constant.Cst;
|
||||
import com.smallchill.core.modules.beetl.func.BeetlExt;
|
||||
import com.smallchill.core.modules.beetl.func.ShiroExt;
|
||||
import com.smallchill.core.modules.beetl.tag.DropDownTag;
|
||||
import com.smallchill.core.modules.beetl.tag.FootTag;
|
||||
import com.smallchill.core.modules.beetl.tag.HotBlogsTag;
|
||||
import com.smallchill.core.modules.beetl.tag.SelectTag;
|
||||
import com.smallchill.core.modules.beetl.tag.SideBarTag;
|
||||
|
||||
/**
|
||||
* @title Beetl模板绑值
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl;
|
||||
package com.smallchill.core.beetl;
|
||||
|
||||
import org.beetl.sql.core.NameConversion;
|
||||
import org.beetl.sql.core.annotatoin.Table;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl;
|
||||
package com.smallchill.core.beetl;
|
||||
|
||||
import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.smallchill.core.modules.beetl;
|
||||
package com.smallchill.core.beetl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl.func;
|
||||
package com.smallchill.core.beetl.func;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Array;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl.func;
|
||||
package com.smallchill.core.beetl.func;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl.tag;
|
||||
package com.smallchill.core.beetl.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.smallchill.core.modules.beetl.tag;
|
||||
package com.smallchill.core.beetl.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.smallchill.core.modules.beetl.tag;
|
||||
package com.smallchill.core.beetl.tag;
|
||||
|
||||
import org.beetl.core.GeneralVarTagBinding;
|
||||
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl.tag;
|
||||
package com.smallchill.core.beetl.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.beetl.tag;
|
||||
package com.smallchill.core.beetl.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -10,8 +10,8 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.smallchill.core.modules.support.Conver;
|
||||
import com.smallchill.core.toolbox.kit.BeanKit;
|
||||
import com.smallchill.core.toolbox.support.Conver;
|
||||
|
||||
/**
|
||||
* 扩充了HashMap中的方法
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.smallchill.core.toolbox.kit.JsonKit;
|
|||
|
||||
public class AjaxResult {
|
||||
|
||||
// 标记成功失败,默认0:成功,1:失败
|
||||
// 返回状态码 (默认0:成功,1:失败)
|
||||
private int code = 0;
|
||||
|
||||
// 返回的中文消息
|
||||
|
|
@ -40,7 +40,6 @@ public class AjaxResult {
|
|||
return this;
|
||||
}
|
||||
|
||||
// 添加成功,用于alertSuccess
|
||||
public AjaxResult addSuccess(String message) {
|
||||
this.message = message;
|
||||
this.code = 0;
|
||||
|
|
@ -48,7 +47,6 @@ public class AjaxResult {
|
|||
return this;
|
||||
}
|
||||
|
||||
// 添加错误,用于alertError
|
||||
public AjaxResult addError(String message) {
|
||||
this.message = message;
|
||||
this.code = 1;
|
||||
|
|
@ -56,7 +54,6 @@ public class AjaxResult {
|
|||
return this;
|
||||
}
|
||||
|
||||
// 添加错误,用于alertFail
|
||||
public AjaxResult addFail(String message) {
|
||||
this.message = message;
|
||||
this.code = 999;
|
||||
|
|
@ -64,7 +61,6 @@ public class AjaxResult {
|
|||
return this;
|
||||
}
|
||||
|
||||
// 添加警告,用于alertWarn
|
||||
public AjaxResult addWarn(String message) {
|
||||
this.message = message;
|
||||
this.code = 2;
|
||||
|
|
@ -72,14 +68,6 @@ public class AjaxResult {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 封装成功时的数据
|
||||
*
|
||||
* @param data
|
||||
*
|
||||
* @return AjaxResult
|
||||
*/
|
||||
public AjaxResult success(Object data) {
|
||||
this.message = "success";
|
||||
this.data = data;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import com.smallchill.core.exception.ToolBoxException;
|
||||
import com.smallchill.core.modules.support.Conver;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Record;
|
||||
import com.smallchill.core.toolbox.support.Conver;
|
||||
|
||||
/**
|
||||
* Bean工具类
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import java.nio.charset.Charset;
|
|||
import java.util.Collection;
|
||||
|
||||
import com.smallchill.core.exception.ToolBoxException;
|
||||
import com.smallchill.core.modules.support.Conver;
|
||||
import com.smallchill.core.toolbox.support.Conver;
|
||||
import com.smallchill.core.toolbox.support.FastByteArrayOutputStream;
|
||||
import com.smallchill.core.toolbox.support.StreamProgress;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.smallchill.core.modules.support.Conver;
|
||||
import com.smallchill.core.toolbox.support.Conver;
|
||||
import com.smallchill.core.toolbox.support.FieldValidator;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.smallchill.core.modules.support;
|
||||
package com.smallchill.core.toolbox.support;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package com.smallchill.core.modules.support;
|
||||
package com.smallchill.core.toolbox.support;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -9,7 +11,6 @@ import com.smallchill.core.exception.ToolBoxException;
|
|||
import com.smallchill.core.toolbox.kit.CollectionKit;
|
||||
import com.smallchill.core.toolbox.kit.DateTimeKit;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
import com.smallchill.core.toolbox.support.BasicType;
|
||||
|
||||
/**
|
||||
* 类型转换器
|
||||
|
|
@ -42,23 +43,26 @@ public class Conver {
|
|||
|
||||
if(Date.class.isAssignableFrom(clazz)) {
|
||||
//判断标准日期
|
||||
return DateTimeKit.parse(valueStr).toDate();
|
||||
} else if(clazz == BigDecimal.class) {
|
||||
return DateTimeKit.parse(valueStr);
|
||||
}else if(clazz == BigInteger.class){
|
||||
//数学计算数字
|
||||
return new BigInteger(valueStr);
|
||||
}else if(clazz == BigDecimal.class) {
|
||||
//数学计算数字
|
||||
return new BigDecimal(valueStr);
|
||||
}else if(clazz == byte[].class) {
|
||||
//流,由于有字符编码问题,在此使用系统默认
|
||||
return valueStr.getBytes();
|
||||
}
|
||||
|
||||
//未找到可转换的类型,返回原值
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换基本类型
|
||||
* @param clazz 转换到的类
|
||||
* 转换基本类型<br>
|
||||
* 讲字符串转换为原始类型或包装类型
|
||||
* @param clazz 转换到的类,可以是原始类型类,也可以是包装类型类
|
||||
* @param valueStr 被转换的字符串
|
||||
* @return 转换后的对象,如果非基本类型,返回null
|
||||
*/
|
||||
|
|
@ -67,6 +71,10 @@ public class Conver {
|
|||
return null;
|
||||
}
|
||||
|
||||
if(clazz.isAssignableFrom(String.class)){
|
||||
return valueStr;
|
||||
}
|
||||
|
||||
BasicType basicType = null;
|
||||
try {
|
||||
basicType = BasicType.valueOf(clazz.getSimpleName().toUpperCase());
|
||||
|
|
@ -76,8 +84,6 @@ public class Conver {
|
|||
}
|
||||
|
||||
switch (basicType) {
|
||||
case STRING:
|
||||
return valueStr;
|
||||
case BYTE:
|
||||
if(clazz == byte.class) {
|
||||
return Byte.parseByte(valueStr);
|
||||
|
|
@ -94,12 +100,12 @@ public class Conver {
|
|||
return Integer.valueOf(valueStr);
|
||||
case LONG:
|
||||
if(clazz == long.class) {
|
||||
return Long.parseLong(valueStr);
|
||||
return new BigDecimal(valueStr).longValue();
|
||||
}
|
||||
return Long.valueOf(valueStr);
|
||||
case DOUBLE:
|
||||
if(clazz == double.class) {
|
||||
return Double.parseDouble(valueStr);
|
||||
return new BigDecimal(valueStr).doubleValue();
|
||||
}
|
||||
case FLOAT:
|
||||
if(clazz == float.class) {
|
||||
|
|
@ -139,6 +145,18 @@ public class Conver {
|
|||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value) {
|
||||
return toStr(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
|
|
@ -156,10 +174,145 @@ public class Conver {
|
|||
return (Character)value;
|
||||
}
|
||||
|
||||
final String valueStr = value.toString();
|
||||
return StrKit.isBlank(valueStr) ? defaultValue : valueStr.charAt(0);
|
||||
final String valueStr = toStr(value, null);
|
||||
return StrKit.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value) {
|
||||
return toChar(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value, Byte defaultValue) {
|
||||
if (value == null){
|
||||
return defaultValue;
|
||||
}
|
||||
if(value instanceof Byte) {
|
||||
return (Byte)value;
|
||||
}
|
||||
if(value instanceof Number){
|
||||
return ((Number) value).byteValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Byte.parseByte(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value) {
|
||||
return toByte(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value, Short defaultValue) {
|
||||
if (value == null){
|
||||
return defaultValue;
|
||||
}
|
||||
if(value instanceof Short) {
|
||||
return (Short)value;
|
||||
}
|
||||
if(value instanceof Number){
|
||||
return ((Number) value).shortValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Short.parseShort(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value) {
|
||||
return toShort(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value, Number defaultValue) {
|
||||
if (value == null){
|
||||
return defaultValue;
|
||||
}
|
||||
if(value instanceof Number) {
|
||||
return (Number)value;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return NumberFormat.getInstance().parse(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value) {
|
||||
return toNumber(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
|
|
@ -179,7 +332,7 @@ public class Conver {
|
|||
if(value instanceof Number){
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
final String valueStr = value.toString();
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
|
|
@ -191,74 +344,24 @@ public class Conver {
|
|||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value, Byte defaultValue) {
|
||||
if (value == null){
|
||||
return defaultValue;
|
||||
}
|
||||
if(value instanceof Byte) {
|
||||
return (Byte)value;
|
||||
}
|
||||
if(value instanceof Number){
|
||||
return ((Number) value).byteValue();
|
||||
}
|
||||
final String valueStr = value.toString();
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Byte.parseByte(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value, Short defaultValue) {
|
||||
if (value == null){
|
||||
return defaultValue;
|
||||
}
|
||||
if(value instanceof Short) {
|
||||
return (Short)value;
|
||||
}
|
||||
if(value instanceof Number){
|
||||
return ((Number) value).shortValue();
|
||||
}
|
||||
final String valueStr = value.toString();
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Short.parseShort(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
public static Integer toInt(Object value) {
|
||||
return toInt(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
* @param <T>
|
||||
* @param isIgnoreConvertError 是否忽略转换错误,忽略则给值null
|
||||
* @param values 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> Integer[] toIntArray(boolean isIgnoreConvertError, T... values) {
|
||||
public static Integer[] toIntArray(boolean isIgnoreConvertError, Object... values) {
|
||||
if(CollectionKit.isEmpty(values)) {
|
||||
return new Integer[]{};
|
||||
}
|
||||
|
|
@ -292,26 +395,37 @@ public class Conver {
|
|||
if(value instanceof Number){
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
final String valueStr = value.toString();
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
//支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).longValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value) {
|
||||
return toLong(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
* @param <T>
|
||||
* @param isIgnoreConvertError 是否忽略转换错误,忽略则给值null
|
||||
* @param values 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> Long[] toLongArray(boolean isIgnoreConvertError, T... values) {
|
||||
public static Long[] toLongArray(boolean isIgnoreConvertError, Object... values) {
|
||||
if(CollectionKit.isEmpty(values)) {
|
||||
return new Long[]{};
|
||||
}
|
||||
|
|
@ -345,26 +459,37 @@ public class Conver {
|
|||
if(value instanceof Number){
|
||||
return ((Number) value).doubleValue();
|
||||
}
|
||||
final String valueStr = value.toString();
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
//支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).doubleValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value) {
|
||||
return toDouble(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Double数组<br>
|
||||
* @param <T>
|
||||
* @param isIgnoreConvertError 是否忽略转换错误,忽略则给值null
|
||||
* @param values 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> Double[] toDoubleArray(boolean isIgnoreConvertError, T... values) {
|
||||
public static Double[] toDoubleArray(boolean isIgnoreConvertError, Object... values) {
|
||||
if(CollectionKit.isEmpty(values)) {
|
||||
return new Double[]{};
|
||||
}
|
||||
|
|
@ -398,7 +523,7 @@ public class Conver {
|
|||
if(value instanceof Number){
|
||||
return ((Number) value).floatValue();
|
||||
}
|
||||
final String valueStr = value.toString();
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
|
|
@ -409,15 +534,25 @@ public class Conver {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value) {
|
||||
return toFloat(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float数组<br>
|
||||
* @param <T>
|
||||
* @param isIgnoreConvertError 是否忽略转换错误,忽略则给值null
|
||||
* @param values 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> Float[] toFloatArray(boolean isIgnoreConvertError, T... values) {
|
||||
public static <T> Float[] toFloatArray(boolean isIgnoreConvertError, Object... values) {
|
||||
if(CollectionKit.isEmpty(values)) {
|
||||
return new Float[]{};
|
||||
}
|
||||
|
|
@ -448,7 +583,7 @@ public class Conver {
|
|||
if(value instanceof Boolean) {
|
||||
return (Boolean)value;
|
||||
}
|
||||
final String valueStr = value.toString();
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
|
|
@ -459,15 +594,25 @@ public class Conver {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value) {
|
||||
return toBool(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Boolean数组<br>
|
||||
* @param <T>
|
||||
* @param isIgnoreConvertError 是否忽略转换错误,忽略则给值null
|
||||
* @param values 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> Boolean[] toBooleanArray(boolean isIgnoreConvertError, T... values) {
|
||||
public static Boolean[] toBooleanArray(boolean isIgnoreConvertError, Object... values) {
|
||||
if(CollectionKit.isEmpty(values)) {
|
||||
return new Boolean[]{};
|
||||
}
|
||||
|
|
@ -481,6 +626,135 @@ public class Conver {
|
|||
}
|
||||
return bools;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @param defaultValue 默认值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
|
||||
if (value == null){
|
||||
return defaultValue;
|
||||
}
|
||||
if (clazz.isAssignableFrom(value.getClass())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E myE = (E) value;
|
||||
return myE;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Enum.valueOf(clazz,valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
|
||||
return toEnum(clazz, value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
|
||||
if (value == null){
|
||||
return defaultValue;
|
||||
}
|
||||
if(value instanceof BigInteger) {
|
||||
return (BigInteger)value;
|
||||
}
|
||||
if(value instanceof Long) {
|
||||
return BigInteger.valueOf((Long)value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigInteger(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value) {
|
||||
return toBigInteger(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
|
||||
if (value == null){
|
||||
return defaultValue;
|
||||
}
|
||||
if(value instanceof BigDecimal) {
|
||||
return (BigDecimal)value;
|
||||
}
|
||||
if(value instanceof Long) {
|
||||
return new BigDecimal((Long)value);
|
||||
}
|
||||
if(value instanceof Double) {
|
||||
return new BigDecimal((Double)value);
|
||||
}
|
||||
if(value instanceof Integer) {
|
||||
return new BigDecimal((Integer)value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StrKit.isBlank(valueStr)){
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value) {
|
||||
return toBigDecimal(value, null);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- 全角半角转换
|
||||
/**
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.smallchill.core.modules.support;
|
||||
package com.smallchill.core.toolbox.support;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -16,9 +16,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.smallchill.core.base.controller.CurdController;
|
||||
import com.smallchill.core.beetl.BeetlMaker;
|
||||
import com.smallchill.core.constant.Cst;
|
||||
import com.smallchill.core.interfaces.IMeta;
|
||||
import com.smallchill.core.modules.beetl.BeetlMaker;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.toolbox.Record;
|
||||
import com.smallchill.core.toolbox.ajax.AjaxResult;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd ">
|
||||
|
||||
<!-- beetl主配置 -->
|
||||
<bean id="beetlConfig" class="com.smallchill.core.modules.beetl.MyBeetlGroupUtilConfiguration" init-method="init">
|
||||
<bean id="beetlConfig" class="com.smallchill.core.beetl.MyBeetlGroupUtilConfiguration" init-method="init">
|
||||
<property name="root" value="/" />
|
||||
</bean>
|
||||
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
</property>
|
||||
<property name="interceptors">
|
||||
<list>
|
||||
<bean class="com.smallchill.core.modules.beetl.ReportInterceptor"></bean>
|
||||
<bean class="com.smallchill.core.beetl.ReportInterceptor"></bean>
|
||||
</list>
|
||||
</property>
|
||||
<property name="cs">
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
<bean id="stopListener" class="com.smallchill.core.listener.StopListener"></bean>
|
||||
|
||||
<!-- 全局application -->
|
||||
<bean id="springAcaHolder" class="com.smallchill.core.modules.support.SpringAcaHolder"></bean>
|
||||
<bean id="springAcaHolder" class="com.smallchill.core.toolbox.support.SpringAcaHolder"></bean>
|
||||
|
||||
<!-- blade框架自定义config -->
|
||||
<bean id="bladeConfig" class="com.smallchill.core.config.BladeConfig">
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import org.beetl.sql.core.SQLManager;
|
|||
import org.beetl.sql.core.db.MySqlStyle;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.smallchill.core.modules.beetl.ReportInterceptor;
|
||||
import com.smallchill.core.beetl.ReportInterceptor;
|
||||
import com.smallchill.platform.model.Notice;
|
||||
|
||||
public class BeetlTest {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user