mirror of https://gitee.com/jeecg/jeecg.git
parent
f5cfb168f6
commit
07998acf94
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_43">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>jeecg-framework</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.maven.ide.eclipse.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.maven.ide.eclipse.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,26 @@
|
||||
package org.jeecgframework.core.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target( { ElementType.METHOD })
|
||||
@Documented
|
||||
public @interface Ehcache {
|
||||
// 缓存名称,默认为空
|
||||
String cacheName() default "";
|
||||
|
||||
// 增加缓存还是删除缓存,默认为增加缓存
|
||||
boolean addOrdel() default true;
|
||||
|
||||
//临时缓存还是永久缓存,默认为永久缓存
|
||||
boolean eternal() default true;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.jeecgframework.core.annotation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface JeecgEntityTitle {
|
||||
String name();
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package org.jeecgframework.core.annotation.config;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
/**
|
||||
* 菜单注释标签
|
||||
* 系统启动自动加载菜单配置
|
||||
* Class级别
|
||||
* @author 张代浩
|
||||
*/
|
||||
public @interface AutoMenu {
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
* @return
|
||||
*/
|
||||
public String name();
|
||||
/**
|
||||
* 等级
|
||||
* @return
|
||||
*/
|
||||
public String level() default "0";
|
||||
/**
|
||||
* 菜单地址
|
||||
* @return
|
||||
*/
|
||||
public String url();
|
||||
|
||||
/**
|
||||
* 图标
|
||||
* @return
|
||||
*/
|
||||
public String icon() default "402880e740ec1fd70140ec2064ec0002";
|
||||
/**
|
||||
* 顺序
|
||||
* @return
|
||||
*/
|
||||
public int order() default 0;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,46 @@
|
||||
package org.jeecgframework.core.annotation.config;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
/**
|
||||
* 菜单操作按钮注释标签
|
||||
* 系统启动自动加载菜单对应的操作权限
|
||||
* Method级别
|
||||
* @author 张代浩
|
||||
*/
|
||||
public @interface AutoMenuOperation {
|
||||
|
||||
/**
|
||||
* 操作名称
|
||||
* @return
|
||||
*/
|
||||
public String name();
|
||||
/**
|
||||
* 操作码
|
||||
* @return
|
||||
*/
|
||||
public String code();
|
||||
|
||||
/**
|
||||
* 操作码类型
|
||||
* @return
|
||||
*/
|
||||
public MenuCodeType codeType() default MenuCodeType.TAG;
|
||||
|
||||
/**
|
||||
* 图标
|
||||
* @return
|
||||
*/
|
||||
public String icon() default "";
|
||||
/**
|
||||
* 状态
|
||||
* @return
|
||||
*/
|
||||
public int status() default 0;
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package org.jeecgframework.core.annotation.config;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
public enum MenuCodeType {
|
||||
TAG, //采用Jeecg tag标签
|
||||
ID, //采用控件ID方式
|
||||
CSS //采用Css样式方式
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.jeecgframework.core.annotation.query;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 前台的查询时间空间的格式
|
||||
* @author JueYue
|
||||
* @date 2014年1月17日
|
||||
* @version 1.0
|
||||
*/
|
||||
@Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface QueryTimeFormat {
|
||||
|
||||
public String format();
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package org.jeecgframework.core.aop;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
public class Wrapper extends HttpServletResponseWrapper {
|
||||
public static final int OT_NONE = 0, OT_WRITER = 1, OT_STREAM = 2;
|
||||
private int outputType = OT_NONE;
|
||||
private ServletOutputStream output = null;
|
||||
private PrintWriter writer = null;
|
||||
private ByteArrayOutputStream buffer = null;
|
||||
|
||||
public Wrapper(HttpServletResponse resp) throws IOException {
|
||||
super(resp);
|
||||
buffer = new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
public PrintWriter getWriter() throws IOException {
|
||||
if (outputType == OT_STREAM)
|
||||
throw new IllegalStateException();
|
||||
else if (outputType == OT_WRITER)
|
||||
return writer;
|
||||
else {
|
||||
outputType = OT_WRITER;
|
||||
writer = new PrintWriter(new OutputStreamWriter(buffer,
|
||||
getCharacterEncoding()));
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
|
||||
public ServletOutputStream getOutputStream() throws IOException {
|
||||
if (outputType == OT_WRITER)
|
||||
throw new IllegalStateException();
|
||||
else if (outputType == OT_STREAM)
|
||||
return output;
|
||||
else {
|
||||
outputType = OT_STREAM;
|
||||
output = new WrappedOutputStream(buffer);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
public void flushBuffer() throws IOException {
|
||||
if (outputType == OT_WRITER)
|
||||
writer.flush();
|
||||
if (outputType == OT_STREAM)
|
||||
output.flush();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
outputType = OT_NONE;
|
||||
buffer.reset();
|
||||
}
|
||||
|
||||
public byte[] getResponseData() throws IOException {
|
||||
flushBuffer();
|
||||
return buffer.toByteArray();
|
||||
|
||||
}
|
||||
|
||||
class WrappedOutputStream extends ServletOutputStream {
|
||||
private ByteArrayOutputStream buffer;
|
||||
|
||||
public WrappedOutputStream(ByteArrayOutputStream buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
public void write(int b) throws IOException {
|
||||
buffer.write(b);
|
||||
}
|
||||
|
||||
public byte[] toByteArray() {
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package org.jeecgframework.core.common.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
@MappedSuperclass
|
||||
public abstract class IdEntity {
|
||||
private String id;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(generator = "paymentableGenerator")
|
||||
@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
|
||||
@Column(name ="ID",nullable=false,length=32)
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.jeecgframework.core.common.exception;
|
||||
|
||||
public class BusinessException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BusinessException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BusinessException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public BusinessException(String message,Throwable cause)
|
||||
{
|
||||
super(message,cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.jeecgframework.core.common.exception;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jeecgframework.core.common.model.json.AjaxJson;
|
||||
import org.jeecgframework.core.util.ExceptionUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* spring mvc异常捕获类
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class MyExceptionHandler implements HandlerExceptionResolver {
|
||||
|
||||
private static final Logger logger = Logger
|
||||
.getLogger(MyExceptionHandler.class);
|
||||
|
||||
public ModelAndView resolveException(HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler, Exception ex) {
|
||||
String exceptionMessage = ExceptionUtil.getExceptionMessage(ex);
|
||||
logger.error(exceptionMessage);
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("exceptionMessage", exceptionMessage);
|
||||
model.put("ex", ex);
|
||||
return new ModelAndView("common/error", model);
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class DB2Dialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String getRowNumber(String sql)
|
||||
{
|
||||
StringBuffer rownumber = new StringBuffer(50).append("rownumber() over(");
|
||||
int orderByIndex = sql.toLowerCase().indexOf("order by");
|
||||
if ((orderByIndex > 0) && (!hasDistinct(sql)))
|
||||
{
|
||||
rownumber.append(sql.substring(orderByIndex));
|
||||
}
|
||||
rownumber.append(") as rownumber_,");
|
||||
return rownumber.toString();
|
||||
}
|
||||
|
||||
private static boolean hasDistinct(String sql)
|
||||
{
|
||||
return sql.toLowerCase().indexOf("select distinct") >= 0;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
int startOfSelect = sql.toLowerCase().indexOf("select");
|
||||
StringBuffer pagingSelect = new StringBuffer(sql.length() + 100).append(sql.substring(0, startOfSelect)).append("select * from ( select ").append(getRowNumber(sql));
|
||||
|
||||
if (hasDistinct(sql))
|
||||
{
|
||||
pagingSelect.append(" row_.* from ( ").append(sql.substring(startOfSelect)).append(" ) as row_");
|
||||
}
|
||||
else
|
||||
{
|
||||
pagingSelect.append(sql.substring(startOfSelect + 6));
|
||||
}
|
||||
pagingSelect.append(" ) as temp_ where rownumber_ ");
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
String endString = offsetPlaceholder + "+" + limitPlaceholder;
|
||||
pagingSelect.append("between " + offsetPlaceholder + "+1 and " + endString);
|
||||
}
|
||||
else
|
||||
{
|
||||
pagingSelect.append("<= " + limitPlaceholder);
|
||||
}
|
||||
return pagingSelect.toString();
|
||||
}
|
||||
|
||||
public String getCountSql(String sql)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class DerbyDialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
throw new UnsupportedOperationException("paged queries not supported");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
public class Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return supportsLimit();
|
||||
}
|
||||
|
||||
public String getCountSql(String sql)
|
||||
{
|
||||
String tmp = "select count(1) amount from (" + sql + ") a";
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, int limit)
|
||||
{
|
||||
return getLimitString(sql, offset, Integer.toString(offset), limit, Integer.toString(limit));
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
throw new UnsupportedOperationException("paged queries not supported");
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
||||
public class DialectFactoryBean implements FactoryBean<Dialect> {
|
||||
public static final String ORACLE = "oracle";
|
||||
public static final String MYSQL = "mysql";
|
||||
public static final String SQLSERVER = "sqlserver";
|
||||
public static final String DB2 = "db2";
|
||||
public static final String POSTGRES = "postgres";
|
||||
private Dialect dialect;
|
||||
private String dbType = "mysql";
|
||||
|
||||
public void setDbType(String dbType) {
|
||||
this.dbType = dbType;
|
||||
}
|
||||
|
||||
public Dialect getObject() throws Exception {
|
||||
if (this.dbType.equals("oracle")) {
|
||||
this.dialect = new OracleDialect();
|
||||
} else if (this.dbType.equals("sqlserver")) {
|
||||
this.dialect = new SQLServer2005Dialect();
|
||||
} else if (this.dbType.equals("db2")) {
|
||||
this.dialect = new DB2Dialect();
|
||||
} else if (this.dbType.equals("mysql")) {
|
||||
this.dialect = new MySQLDialect();
|
||||
} else if (this.dbType.equals("postgres")) {
|
||||
this.dialect = new PostgreSQLDialect();
|
||||
} else {
|
||||
throw new Exception("没有设置合适的数据库类型");
|
||||
}
|
||||
return this.dialect;
|
||||
}
|
||||
|
||||
public Class<?> getObjectType() {
|
||||
return Dialect.class;
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class H2Dialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
return new StringBuffer(sql.length() + 40).append(sql).append(" limit " + limitPlaceholder).toString();
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class HSQLDialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
boolean hasOffset = offset > 0;
|
||||
return new StringBuffer(sql.length() + 10).append(sql).insert(sql.toLowerCase().indexOf("select") + 6, " top " + limitPlaceholder).toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
|
||||
public class MyPostgreSQLDialect extends PostgreSQLDialect {
|
||||
|
||||
|
||||
public boolean useInputStreamToInsertBlob() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class MySQLDialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
if (offset > 0)
|
||||
{
|
||||
return sql + " limit " + offsetPlaceholder + "," + limitPlaceholder;
|
||||
}
|
||||
|
||||
return sql + " limit " + limitPlaceholder;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class OracleDialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
sql = sql.trim();
|
||||
boolean isForUpdate = false;
|
||||
if (sql.toLowerCase().endsWith(" for update"))
|
||||
{
|
||||
sql = sql.substring(0, sql.length() - 11);
|
||||
isForUpdate = true;
|
||||
}
|
||||
StringBuffer pagingSelect = new StringBuffer(sql.length() + 100);
|
||||
if (offset > 0)
|
||||
{
|
||||
pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
|
||||
}
|
||||
else
|
||||
{
|
||||
pagingSelect.append("select * from ( ");
|
||||
}
|
||||
pagingSelect.append(sql);
|
||||
if (offset > 0)
|
||||
{
|
||||
String endString = offsetPlaceholder + "+" + limitPlaceholder;
|
||||
pagingSelect.append(" ) row_ ) where rownum_ <= " + endString + " and rownum_ > " + offsetPlaceholder);
|
||||
}
|
||||
else
|
||||
{
|
||||
pagingSelect.append(" ) where rownum <= " + limitPlaceholder);
|
||||
}
|
||||
if (isForUpdate)
|
||||
{
|
||||
pagingSelect.append(" for update");
|
||||
}
|
||||
return pagingSelect.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class PostgreSQLDialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
return new StringBuffer(sql.length() + 20).append(sql).append(" limit " + limitPlaceholder).toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class SQLServer2005Dialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getLimitString(String querySqlString, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
int start = offset + 1;
|
||||
StringBuffer pagingBuilder = new StringBuffer();
|
||||
String orderby = getOrderByPart(querySqlString);
|
||||
String distinctStr = "";
|
||||
String loweredString = querySqlString.toLowerCase();
|
||||
String sqlPartString = querySqlString;
|
||||
if (loweredString.trim().startsWith("select"))
|
||||
{
|
||||
int index = 6;
|
||||
if (loweredString.startsWith("select distinct"))
|
||||
{
|
||||
distinctStr = "DISTINCT ";
|
||||
index = 15;
|
||||
}
|
||||
sqlPartString = sqlPartString.substring(index);
|
||||
}
|
||||
pagingBuilder.append(sqlPartString);
|
||||
|
||||
if ((orderby == null) || (orderby.length() == 0))
|
||||
{
|
||||
orderby = "ORDER BY CURRENT_TIMESTAMP";
|
||||
}
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append("WITH query AS (SELECT ").append(distinctStr).append("TOP 100 PERCENT ").append(" ROW_NUMBER() OVER (").append(orderby).append(") as __row_number__, ").append(pagingBuilder).append(") SELECT * FROM query WHERE __row_number__ BETWEEN ").append(start).append(" AND ").append(offset + limit).append(" ORDER BY __row_number__");
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
static String getOrderByPart(String sql)
|
||||
{
|
||||
String loweredString = sql.toLowerCase();
|
||||
int orderByIndex = loweredString.indexOf("order by");
|
||||
if (orderByIndex != -1)
|
||||
{
|
||||
return sql.substring(orderByIndex);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class SQLServerDialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static int getAfterSelectInsertPoint(String sql)
|
||||
{
|
||||
int selectIndex = sql.toLowerCase().indexOf("select");
|
||||
int selectDistinctIndex = sql.toLowerCase().indexOf("select distinct");
|
||||
return selectIndex + (selectDistinctIndex == selectIndex ? 15 : 6);
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, int limit)
|
||||
{
|
||||
return getLimitString(sql, offset, null, limit, null);
|
||||
}
|
||||
|
||||
public String getLimitString(String querySelect, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
if (offset > 0)
|
||||
{
|
||||
throw new UnsupportedOperationException("sql server has no offset");
|
||||
}
|
||||
|
||||
return new StringBuffer(querySelect.length() + 8).append(querySelect).insert(getAfterSelectInsertPoint(querySelect), " top " + limit).toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.jeecgframework.core.common.hibernate.dialect;
|
||||
|
||||
|
||||
public class SybaseDialect extends Dialect
|
||||
{
|
||||
public boolean supportsLimit()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsLimitOffset()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder)
|
||||
{
|
||||
throw new UnsupportedOperationException("paged queries not supported");
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package org.jeecgframework.core.common.hibernate.qbc;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ognl.Ognl;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.transform.ResultTransformer;
|
||||
|
||||
import com.opensymphony.xwork2.ognl.OgnlUtil;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
|
||||
|
||||
/**
|
||||
* 此版本运行在xwork-core-2.1.6.jar
|
||||
* 支持属性为自定义对象的结果集转换的部份属性查询
|
||||
* 2009-3-30
|
||||
* @author 苍鹰
|
||||
*/
|
||||
public class AliasToBean implements ResultTransformer {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final OgnlUtil ognlUntil = new OgnlUtil();
|
||||
private static final Map<String,Boolean> context = new HashMap<String,Boolean>(1);
|
||||
static{
|
||||
context.put(ReflectionContextState.CREATE_NULL_OBJECTS, true);
|
||||
}
|
||||
|
||||
/** POJO的class */
|
||||
private final Class<?> resultClass;
|
||||
|
||||
public AliasToBean(Class<?> pojoClass) {
|
||||
if(pojoClass==null) throw new IllegalArgumentException("resultClass cannot be null");
|
||||
this.resultClass = pojoClass;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
public List transformList(List collection) {
|
||||
return collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结果集转换
|
||||
* 2009-4-7
|
||||
* @author 苍鹰
|
||||
* @param tuple 属性值集合
|
||||
* @param aliases 属性名集合
|
||||
* @return 单个POJO实例--查询结果
|
||||
*/
|
||||
|
||||
public Object transformTuple(Object[] tuple, String[] aliases) {
|
||||
try {
|
||||
Object root = resultClass.newInstance();
|
||||
for (int i = 0; i < aliases.length; i++) {
|
||||
if(aliases[i]!=null && !aliases[i].equals(""))
|
||||
{
|
||||
Ognl.setValue(ognlUntil.compile(aliases[i]), context, root, tuple[i]);
|
||||
}
|
||||
}
|
||||
return root;
|
||||
} catch (Exception e) {
|
||||
throw new HibernateException(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package org.jeecgframework.core.common.hibernate.qbc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.hibernate.criterion.Criterion;
|
||||
/**
|
||||
* @ClassName: CriterionList
|
||||
* @Description: TODO(查询条件集合)
|
||||
* @author jeecg
|
||||
* @date 2012-10-25 上午09:32:20
|
||||
*
|
||||
*/
|
||||
public class CriterionList extends ArrayList<Object> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public final Criterion getParas(final int index) {
|
||||
return (Criterion) super.get(index);
|
||||
}
|
||||
|
||||
public final void addPara(final int index, final Criterion p) {
|
||||
super.add(index, p);
|
||||
}
|
||||
|
||||
public final void addPara(final Criterion p) {
|
||||
super.add(p);
|
||||
}
|
||||
|
||||
public final int indexofPara(final Criterion p) {
|
||||
return super.indexOf(p);
|
||||
}
|
||||
|
||||
public final void removePara(final int index) {
|
||||
super.remove(index);
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package org.jeecgframework.core.common.hibernate.qbc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.type.Type;
|
||||
import org.jeecgframework.core.common.model.json.DataGrid;
|
||||
|
||||
public class HqlQuery {
|
||||
private int curPage =1;
|
||||
private int pageSize = 10;
|
||||
private String myaction;
|
||||
private String myform;
|
||||
private String queryString;
|
||||
private Object[] param;
|
||||
private Type[] types;
|
||||
private Map<String, Object> map;
|
||||
private DataGrid dataGrid;
|
||||
private String field="";//查询需要显示的字段
|
||||
private Class class1;
|
||||
private List results;// 结果集
|
||||
private int total;
|
||||
public List getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setResults(List rsults) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public Class getClass1() {
|
||||
return class1;
|
||||
}
|
||||
|
||||
public void setClass1(Class class1) {
|
||||
this.class1 = class1;
|
||||
}
|
||||
public DataGrid getDataGrid() {
|
||||
return dataGrid;
|
||||
}
|
||||
|
||||
public void setDataGrid(DataGrid dataGrid) {
|
||||
this.dataGrid = dataGrid;
|
||||
}
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public Map<String, Object> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map<String, Object> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public HqlQuery(String queryString, Object[] param, Map<String, Object> map) {
|
||||
this.queryString = queryString;
|
||||
this.param = param;
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public HqlQuery(String queryString, Map<String, Object> map) {
|
||||
this.queryString = queryString;
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public HqlQuery(String myaction) {
|
||||
this.myaction = myaction;
|
||||
}
|
||||
|
||||
public Object[] getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public HqlQuery(String myaction, String queryString, Object[] param, Type[] types) {
|
||||
this.myaction = myaction;
|
||||
this.queryString = queryString;
|
||||
this.param = param;
|
||||
this.types = types;
|
||||
}
|
||||
public HqlQuery(Class class1,String hqlString,DataGrid dataGrid) {
|
||||
this.dataGrid=dataGrid;
|
||||
this.queryString=hqlString;
|
||||
this.pageSize=dataGrid.getRows();
|
||||
this.field=dataGrid.getField();
|
||||
this.class1=class1;
|
||||
}
|
||||
|
||||
public void setParam(Object[] param) {
|
||||
this.param = param;
|
||||
}
|
||||
public int getCurPage() {
|
||||
return curPage;
|
||||
}
|
||||
|
||||
public void setCurPage(int curPage) {
|
||||
this.curPage = curPage;
|
||||
}
|
||||
|
||||
public String getMyaction() {
|
||||
return myaction;
|
||||
}
|
||||
|
||||
public void setMyaction(String myaction) {
|
||||
this.myaction = myaction;
|
||||
}
|
||||
|
||||
public String getMyform() {
|
||||
return myform;
|
||||
}
|
||||
|
||||
public void setMyform(String myform) {
|
||||
this.myform = myform;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public String getQueryString() {
|
||||
return queryString;
|
||||
}
|
||||
|
||||
public void setQueryString(String queryString) {
|
||||
this.queryString = queryString;
|
||||
}
|
||||
|
||||
public Type[] getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(Type[] types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package org.jeecgframework.core.common.model.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
/**
|
||||
*
|
||||
* @author Hank
|
||||
* 修改于2014-01-25 添加List<T> 注入查询到的表数据 修改class1-->tableEntityClass
|
||||
* @param <T>
|
||||
*/
|
||||
public class DBTable<T> implements Serializable {
|
||||
|
||||
public String tableName;
|
||||
public String entityName;
|
||||
public String tableTitle;
|
||||
public Class<T> tableEntityClass;
|
||||
public List<T> tableData;
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
public void setEntityName(String entityName) {
|
||||
this.entityName = entityName;
|
||||
}
|
||||
public String getTableTitle() {
|
||||
return tableTitle;
|
||||
}
|
||||
public void setTableTitle(String tableTitle) {
|
||||
this.tableTitle = tableTitle;
|
||||
}
|
||||
public Class<T> getClass1() {
|
||||
return tableEntityClass;
|
||||
}
|
||||
public void setClass1(Class<T> class1) {
|
||||
this.tableEntityClass = class1;
|
||||
}
|
||||
public List<T> getTableData() {
|
||||
return tableData;
|
||||
}
|
||||
public void setTableData(List<T> tableData) {
|
||||
this.tableData = tableData;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
package org.jeecgframework.core.common.model.common;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jeecgframework.core.util.StringUtil;
|
||||
import org.jeecgframework.core.util.oConvertUtils;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
|
||||
/**
|
||||
* 上传下载模型类
|
||||
*
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
public class UploadFile {
|
||||
private String byteField = "attachmentcontent";// 二进制文件内容保存到数据库的对应实体类字段
|
||||
private String titleField = "attachmenttitle";// 文件名(标题)保存到数据库的对应实体类字段
|
||||
private String basePath = "upload";// 文件保存目录根路径
|
||||
private String realPath = "realpath";// 文件保存在硬盘的全路径对应实体字段
|
||||
private String extend = "extend";// 扩展名
|
||||
private boolean view = false;// 是否是预览
|
||||
private boolean rename =true;// 是否重命名
|
||||
private String swfpath;// 转换SWF
|
||||
private String cusPath;// 文件物理路径自定义子目录
|
||||
private byte[] content;// 预览或下载时传入的文件二进制内容
|
||||
private Object object;// 文件对应实体对象
|
||||
private String fileKey;// 上传文件ID
|
||||
private MultipartHttpServletRequest multipartRequest;
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
|
||||
/**
|
||||
* @param response
|
||||
* the response to set
|
||||
*/
|
||||
public void setResponse(HttpServletResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public UploadFile(HttpServletRequest request, Object object) {
|
||||
String fileKey = oConvertUtils.getString(request.getParameter("fileKey"));// 文件ID
|
||||
if (StringUtil.isNotEmpty(fileKey)) {
|
||||
this.fileKey = fileKey;
|
||||
this.request = request;
|
||||
} else {
|
||||
this.multipartRequest = (MultipartHttpServletRequest) request;
|
||||
}
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public UploadFile(HttpServletRequest request) {
|
||||
this.multipartRequest = (MultipartHttpServletRequest) request;
|
||||
|
||||
}
|
||||
|
||||
public UploadFile(HttpServletRequest request, HttpServletResponse response) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public UploadFile() {
|
||||
|
||||
}
|
||||
|
||||
public String getSwfpath() {
|
||||
return swfpath;
|
||||
}
|
||||
|
||||
public void setSwfpath(String swfpath) {
|
||||
this.swfpath = swfpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the realPath
|
||||
*/
|
||||
public String getRealPath() {
|
||||
return realPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param realPath
|
||||
* the realPath to set
|
||||
*/
|
||||
public void setRealPath(String realPath) {
|
||||
this.realPath = realPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the response
|
||||
*/
|
||||
public HttpServletResponse getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the request
|
||||
*/
|
||||
public HttpServletRequest getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* the request to set
|
||||
*/
|
||||
public void setRequest(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the multipartRequest
|
||||
*/
|
||||
public MultipartHttpServletRequest getMultipartRequest() {
|
||||
return multipartRequest;
|
||||
}
|
||||
|
||||
public String get(String name) {
|
||||
return getMultipartRequest().getParameter(name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multipartRequest
|
||||
* the multipartRequest to set
|
||||
*/
|
||||
public void setMultipartRequest(MultipartHttpServletRequest multipartRequest) {
|
||||
this.multipartRequest = multipartRequest;
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public void setBasePath(String basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
public void setObject(Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public String getByteField() {
|
||||
return byteField;
|
||||
}
|
||||
|
||||
public void setByteField(String byteField) {
|
||||
this.byteField = byteField;
|
||||
}
|
||||
|
||||
public String getTitleField() {
|
||||
return titleField;
|
||||
}
|
||||
|
||||
public void setTitleField(String titleField) {
|
||||
this.titleField = titleField;
|
||||
}
|
||||
|
||||
public String getCusPath() {
|
||||
return cusPath;
|
||||
}
|
||||
|
||||
public void setCusPath(String cusPath) {
|
||||
this.cusPath = cusPath;
|
||||
}
|
||||
|
||||
public String getExtend() {
|
||||
return extend;
|
||||
}
|
||||
|
||||
public void setExtend(String extend) {
|
||||
this.extend = extend;
|
||||
}
|
||||
|
||||
public boolean isView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setView(boolean view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public byte[] getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(byte[] content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getFileKey() {
|
||||
return fileKey;
|
||||
}
|
||||
|
||||
public void setFileKey(String fileKey) {
|
||||
this.fileKey = fileKey;
|
||||
}
|
||||
public boolean isRename() {
|
||||
return rename;
|
||||
}
|
||||
|
||||
public void setRename(boolean rename) {
|
||||
this.rename = rename;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* $.ajax后需要接受的JSON
|
||||
*
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public class AjaxJson {
|
||||
|
||||
private boolean success = true;// 是否成功
|
||||
private String msg = "操作成功";// 提示信息
|
||||
private Object obj = null;// 其他信息
|
||||
private Map<String, Object> attributes;// 其他参数
|
||||
public Map<String, Object> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void setAttributes(Map<String, Object> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Object getObj() {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public void setObj(Object obj) {
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
public String getJsonStr(){
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("success", this.isSuccess());
|
||||
obj.put("msg", this.getMsg());
|
||||
obj.put("obj", this.obj);
|
||||
obj.put("attributes", this.attributes);
|
||||
return obj.toJSONString();
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class ComboTree implements java.io.Serializable {
|
||||
|
||||
private String id;
|
||||
private String text;// 树节点名称
|
||||
private String iconCls;// 前面的小图标样式
|
||||
private Boolean checked = false;// 是否勾选状态
|
||||
private Map<String, Object> attributes;// 其他参数
|
||||
private List<ComboTree> children;// 子节点
|
||||
private String state = "open";// 是否展开(open,closed)
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(Boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public Map<String, Object> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void setAttributes(Map<String, Object> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public List<ComboTree> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<ComboTree> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getIconCls() {
|
||||
return iconCls;
|
||||
}
|
||||
|
||||
public void setIconCls(String iconCls) {
|
||||
this.iconCls = iconCls;
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecgframework.core.util.ContextHolderUtils;
|
||||
import org.jeecgframework.core.util.ResourceUtil;
|
||||
import org.jeecgframework.tag.vo.datatable.SortDirection;
|
||||
|
||||
|
||||
/**
|
||||
* easyui的datagrid向后台传递参数使用的model
|
||||
*
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public class DataGrid {
|
||||
|
||||
private int page = 1;// 当前页
|
||||
private int rows = 10;// 每页显示记录数
|
||||
private String sort = null;// 排序字段名
|
||||
private SortDirection order = SortDirection.asc;// 按什么排序(asc,desc)
|
||||
private String field;//字段
|
||||
private String treefield;//树形数据表文本字段
|
||||
private List results;// 结果集
|
||||
private int total;//总记录数
|
||||
private String footer;//合计列
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public List getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setResults(List results) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getRows() {
|
||||
if(ContextHolderUtils.getRequest()!=null&&ResourceUtil.getParameter("rows")!=null){
|
||||
return rows;
|
||||
}
|
||||
return 10000;
|
||||
}
|
||||
|
||||
public void setRows(int rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public String getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(String sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public SortDirection getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(SortDirection order) {
|
||||
this.order = order;
|
||||
}
|
||||
public String getTreefield() {
|
||||
return treefield;
|
||||
}
|
||||
|
||||
public void setTreefield(String treefield) {
|
||||
this.treefield = treefield;
|
||||
}
|
||||
|
||||
public String getFooter() {
|
||||
return footer;
|
||||
}
|
||||
|
||||
public void setFooter(String footer) {
|
||||
this.footer = footer;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 统计报表模型
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
public class Highchart {
|
||||
private String name;
|
||||
private String type;//类型
|
||||
private List data;//数据
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public List getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(List data) {
|
||||
this.data = data;
|
||||
}
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
/**
|
||||
* 上传下载模型类
|
||||
*
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
public class ImportFile {
|
||||
private Object object;// 导出实体对象
|
||||
private String fileName;// 文件保存在硬盘的全路径对应实体字段
|
||||
private String entityName;//导出实体名
|
||||
private String field;
|
||||
private Class entityClass;
|
||||
private MultipartHttpServletRequest multipartRequest;
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
public Object getObject() {
|
||||
return object;
|
||||
}
|
||||
public void setObject(Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public Class getEntityClass() {
|
||||
return entityClass;
|
||||
}
|
||||
public void setEntityClass(Class entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
}
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
public void setEntityName(String entityName) {
|
||||
this.entityName = entityName;
|
||||
}
|
||||
public MultipartHttpServletRequest getMultipartRequest() {
|
||||
return multipartRequest;
|
||||
}
|
||||
public void setMultipartRequest(MultipartHttpServletRequest multipartRequest) {
|
||||
this.multipartRequest = multipartRequest;
|
||||
}
|
||||
public HttpServletRequest getRequest() {
|
||||
return request;
|
||||
}
|
||||
public void setRequest(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
public HttpServletResponse getResponse() {
|
||||
return response;
|
||||
}
|
||||
public void setResponse(HttpServletResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public ImportFile(HttpServletRequest request, HttpServletResponse response) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
}
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
/**
|
||||
* @author pengjin
|
||||
* @version 2.1
|
||||
* @since 2.1
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface LogAnnotation {
|
||||
String operateModelNm();
|
||||
String operateFuncNm();
|
||||
String operateDescribe();
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer" })
|
||||
public class ProjectDeclare {
|
||||
|
||||
private Integer detialid;//明细编号
|
||||
private Integer declareid;//申报编号
|
||||
private String constructionunit;//建设单位
|
||||
private String projectname;//项目名称
|
||||
private String statusid;//状态
|
||||
private String buildingno;//栋号
|
||||
private Double undergroundconstructionarea;//地下建筑面积
|
||||
private String geom;
|
||||
public Integer getDetialid() {
|
||||
return detialid;
|
||||
}
|
||||
public void setDetialid(Integer detialid) {
|
||||
this.detialid = detialid;
|
||||
}
|
||||
public Integer getDeclareid() {
|
||||
return declareid;
|
||||
}
|
||||
public void setDeclareid(Integer declareid) {
|
||||
this.declareid = declareid;
|
||||
}
|
||||
public String getConstructionunit() {
|
||||
return constructionunit;
|
||||
}
|
||||
public void setConstructionunit(String constructionunit) {
|
||||
this.constructionunit = constructionunit;
|
||||
}
|
||||
public String getProjectname() {
|
||||
return projectname;
|
||||
}
|
||||
public void setProjectname(String projectname) {
|
||||
this.projectname = projectname;
|
||||
}
|
||||
public String getStatusid() {
|
||||
return statusid;
|
||||
}
|
||||
public void setStatusid(String statusid) {
|
||||
this.statusid = statusid;
|
||||
}
|
||||
public String getBuildingno() {
|
||||
return buildingno;
|
||||
}
|
||||
public void setBuildingno(String buildingno) {
|
||||
this.buildingno = buildingno;
|
||||
}
|
||||
public Double getUndergroundconstructionarea() {
|
||||
return undergroundconstructionarea;
|
||||
}
|
||||
public void setUndergroundconstructionarea(Double undergroundconstructionarea) {
|
||||
this.undergroundconstructionarea = undergroundconstructionarea;
|
||||
}
|
||||
public String getGeom() {
|
||||
return geom;
|
||||
}
|
||||
public void setGeom(String geom) {
|
||||
this.geom = geom;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer" })
|
||||
public class ProjectInfo {
|
||||
|
||||
private Integer gid;//
|
||||
private String name;//名称(项目)
|
||||
private String geom;
|
||||
public Integer getGid() {
|
||||
return gid;
|
||||
}
|
||||
public void setGid(Integer gid) {
|
||||
this.gid = gid;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getGeom() {
|
||||
return geom;
|
||||
}
|
||||
public void setGeom(String geom) {
|
||||
this.geom = geom;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.jeecgframework.core.common.model.json;
|
||||
|
||||
|
||||
/**
|
||||
* $.ajax后需要接受的JSON
|
||||
*
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public class ValidForm {
|
||||
|
||||
private String status ="y";// 是否成功
|
||||
private String info = "验证通过";//提示信息
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package org.jeecgframework.core.extend.datasource;
|
||||
|
||||
public enum DataSourceType {
|
||||
dataSource_jeecg,dataSource_enter,dataSource4,mapdataSource
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package org.jeecgframework.core.extend.hqlsearch;
|
||||
|
||||
import org.jeecgframework.core.extend.hqlsearch.parse.vo.HqlRuleEnum;
|
||||
import org.jeecgframework.core.util.ResourceUtil;
|
||||
import org.jeecgframework.web.system.pojo.base.TSDataRule;
|
||||
|
||||
/**
|
||||
* 数据库列表序列化转换sql
|
||||
*
|
||||
* @ClassName: SqlJsonConvert
|
||||
* @Description: TODO
|
||||
* @author Comsys-skyCc cmzcheng@gmail.com
|
||||
* @date 2014-8-25 下午7:12:41
|
||||
*
|
||||
*/
|
||||
public class SysContextSqlConvert {
|
||||
|
||||
enum Signal {
|
||||
GREEN, YELLOW, RED
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* setSqlModel sql行列转换
|
||||
*
|
||||
* @Title: setSqlModel
|
||||
* @Description: TODO
|
||||
* @param @param dataRule
|
||||
* @param @return 设定文件
|
||||
* @return String 返回类型
|
||||
* @throws
|
||||
*/
|
||||
public static String setSqlModel(TSDataRule dataRule){
|
||||
if(dataRule == null)
|
||||
return "";
|
||||
String sqlValue="";
|
||||
HqlRuleEnum ruleEnum=HqlRuleEnum.getByValue(dataRule.getRuleConditions());
|
||||
String ValueTemp = "";
|
||||
|
||||
//针对特殊标示处理#{sysOrgCode},判断替换
|
||||
if (dataRule.getRuleValue().contains("{")) {
|
||||
ValueTemp = dataRule.getRuleValue().substring(2,dataRule.getRuleValue().length() - 1);
|
||||
} else {
|
||||
ValueTemp = dataRule.getRuleValue();
|
||||
}
|
||||
|
||||
String TempValue = ResourceUtil.getUserSystemData(ValueTemp) == null ? ValueTemp: ResourceUtil.getUserSystemData(ValueTemp);//将系统变量
|
||||
switch (ruleEnum) {
|
||||
case GT:
|
||||
sqlValue+=" and "+dataRule.getRuleColumn()+" <'"+TempValue+"'";
|
||||
break;
|
||||
case GE:
|
||||
sqlValue+=" and "+dataRule.getRuleColumn()+" >='"+TempValue+"'";
|
||||
break;
|
||||
case LT:
|
||||
sqlValue+=" and "+dataRule.getRuleColumn()+" <'"+TempValue+"'";
|
||||
break;
|
||||
case LE:
|
||||
sqlValue+=" and "+dataRule.getRuleColumn()+" =>'"+TempValue+"'";
|
||||
break;
|
||||
case EQ:
|
||||
sqlValue+=" and "+dataRule.getRuleColumn()+" ='"+TempValue+"'";
|
||||
break;
|
||||
case LIKE:
|
||||
sqlValue+=" and "+dataRule.getRuleColumn()+" like %'"+TempValue+"'%";
|
||||
break;
|
||||
case NE:
|
||||
sqlValue+=" and "+dataRule.getRuleColumn()+" !='"+TempValue+"'";
|
||||
break;
|
||||
case IN:
|
||||
sqlValue+=" and "+dataRule.getRuleColumn()+" IN('"+TempValue+"')";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return sqlValue;
|
||||
}
|
||||
|
||||
// /**
|
||||
// *
|
||||
// * setSqlIn sql为in的方法
|
||||
// *
|
||||
// * @Title: setSqlIn
|
||||
// * @Description: TODO
|
||||
// * @param @param dataRule
|
||||
// * @param @param sqlValue
|
||||
// * @param @return 设定文件
|
||||
// * @return String 返回类型
|
||||
// * @throws
|
||||
// */
|
||||
// public static String setSqlIn(List<DSDataRule>T dataRule,String
|
||||
// sqlValue){
|
||||
// sqlValue+="'"+dataRule.getRuleValue()+"',";
|
||||
// return sqlValue;
|
||||
// }
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package org.jeecgframework.core.extend.hqlsearch.parse;
|
||||
|
||||
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
|
||||
import org.jeecgframework.core.extend.hqlsearch.parse.vo.HqlParseEnum;
|
||||
import org.jeecgframework.core.extend.hqlsearch.parse.vo.HqlRuleEnum;
|
||||
|
||||
/**
|
||||
* 判断类型,拼接字符串
|
||||
*
|
||||
* @author JueYue
|
||||
* @date 2014年8月23日 下午4:07:34
|
||||
*/
|
||||
public class ObjectParseUtil {
|
||||
|
||||
public static void addCriteria(CriteriaQuery cq, String name,
|
||||
HqlRuleEnum rule, Object value) {
|
||||
if (value == null || rule == null) {
|
||||
return;
|
||||
}
|
||||
switch (rule) {
|
||||
case GT:
|
||||
cq.gt(name, value);
|
||||
break;
|
||||
case GE:
|
||||
cq.ge(name, value);
|
||||
break;
|
||||
case LT:
|
||||
cq.lt(name, value);
|
||||
break;
|
||||
case LE:
|
||||
cq.le(name, value);
|
||||
break;
|
||||
case EQ:
|
||||
cq.eq(name, value);
|
||||
break;
|
||||
case NE:
|
||||
cq.notEq(name, value);
|
||||
break;
|
||||
case IN:
|
||||
cq.in(name, (Object[]) value);
|
||||
break;
|
||||
case LIKE:
|
||||
cq.like(name, HqlParseEnum.SUFFIX_ASTERISK_VAGUE.getValue() + value
|
||||
+ HqlParseEnum.SUFFIX_ASTERISK_VAGUE.getValue());
|
||||
break;
|
||||
case LEFT_LIKE:
|
||||
cq.like(name, HqlParseEnum.SUFFIX_ASTERISK_VAGUE.getValue() + value);
|
||||
break;
|
||||
case RIGHT_LIKE:
|
||||
cq.like(name, value + HqlParseEnum.SUFFIX_ASTERISK_VAGUE.getValue());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package org.jeecgframework.core.extend.hqlsearch.parse;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jeecgframework.core.extend.hqlsearch.parse.vo.HqlParseEnum;
|
||||
import org.jeecgframework.core.extend.hqlsearch.parse.vo.HqlRuleEnum;
|
||||
|
||||
/**
|
||||
* 界面可视化数组转化为枚举
|
||||
*
|
||||
* @author JueYue
|
||||
* @date 2014年8月23日 下午3:30:00
|
||||
*/
|
||||
public class PageValueConvertRuleEnum {
|
||||
|
||||
public static HqlRuleEnum convert(Object value) {
|
||||
// 避免空数据
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
String val = (value + "").toString().trim();
|
||||
if (val.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
// step 1 .> <
|
||||
HqlRuleEnum rule = HqlRuleEnum.getByValue(val.substring(0, 1));
|
||||
// step 2 .>= =<
|
||||
if (rule == null && val.length() >= 2) {
|
||||
rule = HqlRuleEnum.getByValue(val.substring(0, 2));
|
||||
}
|
||||
// step 3 like
|
||||
if (rule == null
|
||||
&& val.contains(HqlParseEnum.SUFFIX_ASTERISK.getValue())) {
|
||||
if (val.startsWith(HqlParseEnum.SUFFIX_ASTERISK.getValue())
|
||||
&& val.endsWith(HqlParseEnum.SUFFIX_ASTERISK.getValue())) {
|
||||
rule = HqlRuleEnum.LIKE;
|
||||
} else if (val.startsWith(HqlParseEnum.SUFFIX_ASTERISK.getValue())) {
|
||||
rule = HqlRuleEnum.LEFT_LIKE;
|
||||
} else {
|
||||
rule = HqlRuleEnum.RIGHT_LIKE;
|
||||
}
|
||||
}
|
||||
// step 4 in
|
||||
if (rule == null && val.contains(HqlParseEnum.SUFFIX_COMMA.getValue())) {
|
||||
rule = HqlRuleEnum.IN;
|
||||
}
|
||||
// step 5 !=
|
||||
if(rule == null && val.startsWith(HqlParseEnum.SUFFIX_NOT_EQUAL.getValue())){
|
||||
rule = HqlRuleEnum.NE;
|
||||
}
|
||||
return rule != null ? rule : HqlRuleEnum.EQ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换掉关键字字符
|
||||
*
|
||||
* @param rule
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static Object replaceValue(HqlRuleEnum rule, Object value) {
|
||||
if (rule == null) {
|
||||
return null;
|
||||
}
|
||||
if (! (value instanceof String)){
|
||||
return value;
|
||||
}
|
||||
String val = (value + "").toString().trim();
|
||||
if (rule == HqlRuleEnum.LIKE) {
|
||||
value = val.substring(1, val.length() - 1);
|
||||
} else if (rule == HqlRuleEnum.LEFT_LIKE || rule == HqlRuleEnum.NE) {
|
||||
value = val.substring(1);
|
||||
} else if (rule == HqlRuleEnum.RIGHT_LIKE) {
|
||||
value = val.substring(0, val.length() - 1);
|
||||
} else if (rule != HqlRuleEnum.IN) {
|
||||
value = val.replace(rule.getValue(),
|
||||
HqlParseEnum.SUFFIX_NULL_STRING.getValue());
|
||||
} else {
|
||||
value = val.split(",");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package org.jeecgframework.core.extend.hqlsearch.parse.vo;
|
||||
|
||||
/**
|
||||
* HQL 解析 常量
|
||||
* Created by jue on 14-8-23.
|
||||
*/
|
||||
public enum HqlParseEnum {
|
||||
|
||||
SUFFIX_COMMA(",","多条数据"),
|
||||
SUFFIX_ASTERISK("*","模糊查询条件"),
|
||||
SUFFIX_REG_ASTERISK("[*]","模糊查询条件"),
|
||||
SUFFIX_ASTERISK_VAGUE("%","模糊查询值"),
|
||||
SUFFIX_NOT_EQUAL("!","不等于"),
|
||||
SUFFIX_NOT_EQUAL_NULL("!NULL","不等于空"),
|
||||
SUFFIX_KG(" ","空格"),
|
||||
SUFFIX_NULL_STRING("","空格");
|
||||
|
||||
private String value;
|
||||
|
||||
private String msg;
|
||||
|
||||
HqlParseEnum(String value,String msg){
|
||||
this.value = value;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package org.jeecgframework.core.extend.hqlsearch.parse.vo;
|
||||
|
||||
/**
|
||||
* HQL 规则 常量
|
||||
* Created by jue on 14-8-23.
|
||||
*/
|
||||
public enum HqlRuleEnum {
|
||||
|
||||
GT(">","大于"),
|
||||
GE(">=","大于等于"),
|
||||
LT("<","小于"),
|
||||
LE("<=","小于等于"),
|
||||
EQ("=","等于"),
|
||||
NE("!=","不等于"),
|
||||
IN("IN","包含"),
|
||||
LIKE("LIKE","左右模糊"),
|
||||
LEFT_LIKE("LEFT_LIKE","左模糊"),
|
||||
RIGHT_LIKE("RIGHT_LIKE","右模糊");
|
||||
|
||||
private String value;
|
||||
|
||||
private String msg;
|
||||
|
||||
HqlRuleEnum(String value, String msg){
|
||||
this.value = value;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static HqlRuleEnum getByValue(String value){
|
||||
for(HqlRuleEnum val :values()){
|
||||
if (val.getValue().equals(value)){
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package org.jeecgframework.core.extend.swftools;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.jeecgframework.core.util.ContextHolderUtils;
|
||||
import org.jeecgframework.core.util.ResourceUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 常量类
|
||||
*/
|
||||
public class ConStant {
|
||||
/**OpenOffice安装根目录*/
|
||||
public static final String OFFICE_HOME;
|
||||
static{
|
||||
OFFICE_HOME = ResourceUtil.getSessionattachmenttitle("office_home");
|
||||
}
|
||||
/**文件上传保存根目录*/
|
||||
public static final String UPLOAD_BASE_DIR = "upload";
|
||||
/**文件转换工具根目录*/
|
||||
public static final String SWFTOOLS_BASE_DIR = "swftools";
|
||||
/**PDF-SWF*/
|
||||
public static final String SWFTOOLS_PDF2SWF_PATH ="pdf2swf.exe";
|
||||
/**GIF-SWF*/
|
||||
public static final String SWFTOOLS_GIF2SWF_PATH ="gif2swf.exe";
|
||||
/**PNG-SWF*/
|
||||
public static final String SWFTOOLS_PNG2SWF_PATH ="png2swf.exe";
|
||||
/**JPEG-SWF*/
|
||||
public static final String SWFTOOLS_JPEG2SWF_PATH ="jpeg2swf.exe";
|
||||
/**WAV-SWF*/
|
||||
public static final String SWFTOOLS_WAV2SWF_PATH = "wav2swf.exe";
|
||||
/**PDF合并*/
|
||||
public static final String SWFTOOLS_PDFCOMBINE_PATH ="swfcombine.exe";
|
||||
/**SWF文件后缀*/
|
||||
public static final String SWF_STUFFIX = "swf";
|
||||
public static String SWFTOOLS_HOME="";
|
||||
/**
|
||||
* 根据扩展名获取转换工具
|
||||
* @param extend
|
||||
* @return
|
||||
*/
|
||||
public static String getSWFToolsPath(String extend)
|
||||
{
|
||||
HttpServletRequest request=ContextHolderUtils.getRequest();
|
||||
SWFTOOLS_HOME=request.getSession().getServletContext().getRealPath("/") + SWFTOOLS_BASE_DIR + "/";
|
||||
if(extend.equals("pdf"))
|
||||
{
|
||||
SWFTOOLS_HOME+=SWFTOOLS_PDF2SWF_PATH;
|
||||
}
|
||||
if(extend.equals("gif"))
|
||||
{
|
||||
SWFTOOLS_HOME+=SWFTOOLS_GIF2SWF_PATH;
|
||||
}
|
||||
if(extend.equals("png"))
|
||||
{
|
||||
SWFTOOLS_HOME+=SWFTOOLS_PNG2SWF_PATH;
|
||||
}
|
||||
if(extend.equals("jpeg"))
|
||||
{
|
||||
SWFTOOLS_HOME+=SWFTOOLS_JPEG2SWF_PATH;
|
||||
}
|
||||
if(extend.equals("wav"))
|
||||
{
|
||||
SWFTOOLS_HOME+=SWFTOOLS_WAV2SWF_PATH;
|
||||
}
|
||||
return SWFTOOLS_HOME;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.jeecgframework.core.extend.swftools;
|
||||
import org.jeecgframework.core.util.FileUtils;
|
||||
public class DocConverter {
|
||||
|
||||
private PDFConverter pdfConverter;
|
||||
private SWFConverter swfConverter;
|
||||
|
||||
|
||||
public DocConverter(PDFConverter pdfConverter, SWFConverter swfConverter) {
|
||||
super();
|
||||
this.pdfConverter = pdfConverter;
|
||||
this.swfConverter = swfConverter;
|
||||
}
|
||||
|
||||
|
||||
public void convert(String inputFile,String swfFile,String extend){
|
||||
this.pdfConverter.convert2PDF(inputFile,extend);
|
||||
String pdfFile = FileUtils.getFilePrefix(inputFile)+".pdf";
|
||||
this.swfConverter.convert2SWF(pdfFile, swfFile);
|
||||
}
|
||||
|
||||
public void convert(String inputFile,String extend){
|
||||
this.pdfConverter.convert2PDF(inputFile,extend);
|
||||
String pdfFile = FileUtils.getFilePrefix2(inputFile)+".pdf";
|
||||
extend=FileUtils.getExtend(pdfFile);
|
||||
this.swfConverter.convert2SWF(pdfFile,extend);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package org.jeecgframework.core.extend.swftools;
|
||||
|
||||
/**
|
||||
* PDF文档转换接口
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
public interface PDFConverter {
|
||||
public void convert2PDF(String inputFile,String pdfFile,String extend);
|
||||
public void convert2PDF(String inputFile,String extend);
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package org.jeecgframework.core.extend.swftools;
|
||||
|
||||
public interface SWFConverter {
|
||||
public void convert2SWF(String inputFile,String swfFile,String extend);
|
||||
public void convert2SWF(String inputFile,String extend);
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.jeecgframework.core.extend.swftools;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class StreamGobbler extends Thread {
|
||||
|
||||
InputStream is;
|
||||
String type;
|
||||
|
||||
public StreamGobbler(InputStream is, String type) {
|
||||
this.is = is;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (type.equals("Error")) {
|
||||
org.jeecgframework.core.util.LogUtil.info("Error :" + line);
|
||||
} else {
|
||||
org.jeecgframework.core.util.LogUtil.info("文件转换:" + line);
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package org.jeecgframework.core.extend.swftools;
|
||||
|
||||
import org.jeecgframework.core.util.FileUtils;
|
||||
/**
|
||||
* 文件转换调用接口
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
public class SwfToolsUtil {
|
||||
public static void convert2SWF(String inputFile) {
|
||||
|
||||
String extend=FileUtils.getExtend(inputFile);
|
||||
PDFConverter pdfConverter = new OpenOfficePDFConverter();
|
||||
SWFConverter swfConverter = new SWFToolsSWFConverter();
|
||||
if(extend.equals("pdf"))
|
||||
{
|
||||
swfConverter.convert2SWF(inputFile,extend);
|
||||
}
|
||||
if(extend.equals("doc")||extend.equals("docx")||extend.equals("xls")||extend.equals("pptx")||extend.equals("xlsx")||extend.equals("ppt")||extend.equals("txt")||extend.equals("odt"))
|
||||
{
|
||||
DocConverter converter = new DocConverter(pdfConverter,swfConverter);
|
||||
converter.convert(inputFile,extend);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package org.jeecgframework.core.extend.template;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class DataSourceMap {
|
||||
private static Map<Object,Object> dsm;
|
||||
|
||||
static{
|
||||
InputStream is=Thread.currentThread().getContextClassLoader().getResourceAsStream("dataSourceMap.properties");
|
||||
Properties p=new Properties();
|
||||
try {
|
||||
p.load(is);
|
||||
dsm=(HashMap<Object,Object>) new HashMap<Object,Object>();
|
||||
Set ps=p.entrySet();
|
||||
for (Iterator iterator = ps.iterator(); iterator.hasNext();) {
|
||||
Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>) iterator.next();
|
||||
dsm.put(entry.getKey().toString(), entry.getValue()==null?"":entry.getValue().toString().trim());
|
||||
}
|
||||
is.close();//关闭
|
||||
is=null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static Map<Object,Object> getDataSourceMap() {
|
||||
Map<Object,Object> datadsm=new HashMap<Object,Object>();
|
||||
datadsm.putAll(dsm);
|
||||
return datadsm;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package org.jeecgframework.core.extend.template;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Template {
|
||||
public HashMap<String, String> teprems = null;
|
||||
public String templatecCode;
|
||||
public String parameterName;
|
||||
public String parameterValue;
|
||||
public String parameterTagName;
|
||||
public String parameterTagValue;
|
||||
public Object templatecObject;
|
||||
public String templatePath;
|
||||
public Class templateClass;
|
||||
public Map<String, String> dataSourceMap;
|
||||
public List dataSet;
|
||||
|
||||
public List getDataSet() {
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
public void setDataSet(List dataSet) {
|
||||
this.dataSet = dataSet;
|
||||
}
|
||||
|
||||
public String getTemplatePath() {
|
||||
return templatePath;
|
||||
}
|
||||
|
||||
public void setTemplatePath(String templatePath) {
|
||||
this.templatePath = templatePath;
|
||||
}
|
||||
|
||||
public Map<String, String> getDataSourceMap() {
|
||||
return dataSourceMap;
|
||||
}
|
||||
|
||||
public void setDataSourceMap(Map<String, String> dataSourceMap) {
|
||||
this.dataSourceMap = dataSourceMap;
|
||||
}
|
||||
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
public Class getTemplateClass() {
|
||||
return templateClass;
|
||||
}
|
||||
|
||||
public void setTemplateClass(Class templateClass) {
|
||||
this.templateClass = templateClass;
|
||||
}
|
||||
|
||||
public void setParameterName(String parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
|
||||
public String getParameterTagName() {
|
||||
return parameterTagName;
|
||||
}
|
||||
|
||||
public void setParameterTagName(String parameterTagName) {
|
||||
this.parameterTagName = parameterTagName;
|
||||
}
|
||||
|
||||
public String getParameterTagValue() {
|
||||
return parameterTagValue;
|
||||
}
|
||||
|
||||
public void setParameterTagValue(String parameterTagValue) {
|
||||
this.parameterTagValue = parameterTagValue;
|
||||
}
|
||||
|
||||
public String getParameterValue() {
|
||||
return parameterValue;
|
||||
}
|
||||
|
||||
public void setParameterValue(String parameterValue) {
|
||||
this.parameterValue = parameterValue;
|
||||
}
|
||||
|
||||
public Object getTemplatecObject() {
|
||||
return templatecObject;
|
||||
}
|
||||
|
||||
public void setTemplatecObject(Object templatecObject) {
|
||||
this.templatecObject = templatecObject;
|
||||
}
|
||||
|
||||
public String getTemplatecCode() {
|
||||
return templatecCode;
|
||||
}
|
||||
|
||||
public void setTemplatecCode(String templatecCode) {
|
||||
this.templatecCode = templatecCode;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getTeprems() {
|
||||
return teprems;
|
||||
}
|
||||
|
||||
public void setTeprems(HashMap<String, String> teprems) {
|
||||
this.teprems = teprems;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package org.jeecgframework.core.groovy;
|
||||
|
||||
import groovy.lang.Binding;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class GroovyBinding extends Binding {
|
||||
private static ThreadLocal<Map<String, Object>> localVars = new ThreadLocal<Map<String, Object>>();
|
||||
|
||||
private static Map<String, Object> propertyMap = new ConcurrentHashMap<String, Object>();
|
||||
|
||||
public GroovyBinding() {
|
||||
}
|
||||
|
||||
public GroovyBinding(Map<String, Object> variables) {
|
||||
localVars.set(variables);
|
||||
}
|
||||
|
||||
public GroovyBinding(String[] args) {
|
||||
this();
|
||||
setVariable("args", args);
|
||||
}
|
||||
|
||||
public Object getVariable(String name) {
|
||||
Map<String, Object> map = localVars.get();
|
||||
Object result = null;
|
||||
if ((map != null) && (map.containsKey(name))) {
|
||||
result = map.get(name);
|
||||
} else {
|
||||
result = propertyMap.get(name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setVariable(String name, Object value) {
|
||||
if (localVars.get() == null) {
|
||||
Map<String, Object> vars = new LinkedHashMap<String, Object>();
|
||||
vars.put(name, value);
|
||||
localVars.set(vars);
|
||||
} else {
|
||||
(localVars.get()).put(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> getVariables() {
|
||||
if (localVars.get() == null) {
|
||||
return new LinkedHashMap<String, Object>();
|
||||
}
|
||||
|
||||
return localVars.get();
|
||||
}
|
||||
|
||||
public void clearVariables() {
|
||||
localVars.remove();
|
||||
}
|
||||
|
||||
public Object getProperty(String property) {
|
||||
return propertyMap.get(property);
|
||||
}
|
||||
|
||||
public void setProperty(String property, Object newValue) {
|
||||
propertyMap.put(property, newValue);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.jeecgframework.core.groovy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jeecgframework.core.util.ApplicationContextUtil;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
|
||||
/**
|
||||
* 公式计算
|
||||
*
|
||||
*/
|
||||
public class GroovyParse {
|
||||
/**
|
||||
* 公式解析计算
|
||||
*/
|
||||
public static Object formulaParse(String formula, Map<String, Object> map) {
|
||||
ApplicationContext context = ApplicationContextUtil.getContext();
|
||||
GroovyScriptEngine groovyScriptEngine = context.getBean(GroovyScriptEngine.class);
|
||||
Object value = groovyScriptEngine.executeObject(formula, map);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String formula = "println 'Hello World!';po = '9s00';return (a * b);";
|
||||
Map map = new HashMap();
|
||||
map.put("a", 900);
|
||||
map.put("b", 10);
|
||||
GroovyScriptEngine groovyScriptEngine = new GroovyScriptEngine();
|
||||
Object value = groovyScriptEngine.executeObject(formula, map);
|
||||
System.out.println(value);
|
||||
System.out.println(groovyScriptEngine.binding.getVariable("po"));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package org.jeecgframework.core.groovy;
|
||||
|
||||
import groovy.lang.GroovyShell;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
|
||||
/**
|
||||
* Groovy脚本引擎
|
||||
* @author zhangdaihao
|
||||
*
|
||||
*/
|
||||
public class GroovyScriptEngine implements BeanPostProcessor {
|
||||
private Log logger = LogFactory.getLog(GroovyScriptEngine.class);
|
||||
public GroovyBinding binding = new GroovyBinding();
|
||||
|
||||
public void execute(String script, Map<String, Object> vars) {
|
||||
executeObject(script, vars);
|
||||
}
|
||||
|
||||
private void setParameters(GroovyShell shell, Map<String, Object> vars) {
|
||||
if (vars == null)
|
||||
return;
|
||||
Set<?> set = vars.entrySet();
|
||||
for (Iterator<?> it = set.iterator(); it.hasNext();) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
shell.setVariable((String) entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean executeBoolean(String script, Map<String, Object> vars) {
|
||||
Boolean rtn = (Boolean) executeObject(script, vars);
|
||||
return rtn.booleanValue();
|
||||
}
|
||||
|
||||
public String executeString(String script, Map<String, Object> vars) {
|
||||
String str = (String) executeObject(script, vars);
|
||||
return str;
|
||||
}
|
||||
|
||||
public int executeInt(String script, Map<String, Object> vars) {
|
||||
Integer rtn = (Integer) executeObject(script, vars);
|
||||
return rtn.intValue();
|
||||
}
|
||||
|
||||
public float executeFloat(String script, Map<String, Object> vars) {
|
||||
Float rtn = (Float) executeObject(script, vars);
|
||||
return rtn.floatValue();
|
||||
}
|
||||
|
||||
public Object executeObject(String script, Map<String, Object> vars) {
|
||||
this.logger.debug("执行:" + script);
|
||||
this.binding.clearVariables();
|
||||
GroovyShell shell = new GroovyShell(this.binding);
|
||||
setParameters(shell, vars);
|
||||
|
||||
script = script.replace("'", "'").replace(""", "\"").replace(">", ">").replace("<", "<").replace("&nuot;", "\n").replace("&", "&");
|
||||
|
||||
Object rtn = shell.evaluate(script);
|
||||
//this.binding.clearVariables();
|
||||
return rtn;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
boolean isImplScript = bean.getClass().isInstance(IScript.class);
|
||||
if (isImplScript) {
|
||||
this.binding.setProperty(beanName, bean);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package org.jeecgframework.core.groovy;
|
||||
|
||||
/**
|
||||
* ISCPIPT接口
|
||||
* 实现这个接口的类就成脚本引擎BEAN,公式里能引用的bean只需实现iscript接口
|
||||
* @author zhangdaihao
|
||||
*
|
||||
*/
|
||||
public abstract interface IScript
|
||||
{
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.jeecgframework.core.groovy.impl;
|
||||
|
||||
import org.jeecgframework.core.groovy.IScript;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 公式脚本
|
||||
*/
|
||||
@Component
|
||||
public class FormulaImpl implements IScript {
|
||||
public Double add(Double a,Double b) {
|
||||
return a*b;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.jeecgframework.core.groovy.impl;
|
||||
|
||||
import org.jeecgframework.core.groovy.IScript;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 系统脚本
|
||||
*/
|
||||
@Component
|
||||
public class ScriptImpl implements IScript {
|
||||
public String getCurrentUserId() {
|
||||
return "1";
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package org.jeecgframework.core.interceptors;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
public class DateConvertEditor extends PropertyEditorSupport {
|
||||
private SimpleDateFormat datetimeFormat = new SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss");
|
||||
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
if (StringUtils.hasText(text)) {
|
||||
try {
|
||||
if (text.indexOf(":") == -1 && text.length() == 10) {
|
||||
setValue(this.dateFormat.parse(text));
|
||||
} else if (text.indexOf(":") > 0 && text.length() == 19) {
|
||||
setValue(this.datetimeFormat.parse(text));
|
||||
} else if (text.indexOf(":") > 0 && text.length() == 21) {
|
||||
text = text.replace(".0", "");
|
||||
setValue(this.datetimeFormat.parse(text));
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not parse date, date format is error ");
|
||||
}
|
||||
} catch (ParseException ex) {
|
||||
IllegalArgumentException iae = new IllegalArgumentException(
|
||||
"Could not parse date: " + ex.getMessage());
|
||||
iae.initCause(ex);
|
||||
throw iae;
|
||||
}
|
||||
} else {
|
||||
setValue(null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package org.jeecgframework.core.interceptors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* 字符集拦截器
|
||||
*
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
public class EncodingInterceptor implements HandlerInterceptor {
|
||||
|
||||
/**
|
||||
* 在controller后拦截
|
||||
*/
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object object, Exception exception) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object object, ModelAndView modelAndView) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 在controller前拦截
|
||||
*/
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) throws Exception {
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package org.jeecgframework.core.interceptors;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.jeecgframework.core.common.model.json.LogAnnotation;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 张代浩
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@Aspect
|
||||
public class LogInterceptor {
|
||||
@Before("execution(* com.renfang.controller.*.*(..))")
|
||||
public void beforeMethod(JoinPoint joinPoint) throws Exception {
|
||||
String temp = joinPoint.getStaticPart().toShortString();
|
||||
String longTemp = joinPoint.getStaticPart().toLongString();
|
||||
joinPoint.getStaticPart().toString();
|
||||
String classType = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = temp.substring(10, temp.length() - 1);
|
||||
Class<?> className = Class.forName(classType);
|
||||
Class[] args = new Class[joinPoint.getArgs().length];
|
||||
String[] sArgs = (longTemp.substring(longTemp.lastIndexOf("(") + 1,
|
||||
longTemp.length() - 2)).split(",");
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (sArgs[i].endsWith("String[]")) {
|
||||
args[i] = Array.newInstance(Class.forName("java.lang.String"),
|
||||
1).getClass();
|
||||
} else if (sArgs[i].endsWith("Long[]")) {
|
||||
args[i] = Array.newInstance(Class.forName("java.lang.Long"), 1)
|
||||
.getClass();
|
||||
} else if (sArgs[i].indexOf(".") == -1) {
|
||||
if (sArgs[i].equals("int")) {
|
||||
args[i] = int.class;
|
||||
} else if (sArgs[i].equals("char")) {
|
||||
args[i] = char.class;
|
||||
} else if (sArgs[i].equals("float")) {
|
||||
args[i] = float.class;
|
||||
} else if (sArgs[i].equals("long")) {
|
||||
args[i] = long.class;
|
||||
}
|
||||
} else {
|
||||
args[i] = Class.forName(sArgs[i]);
|
||||
}
|
||||
}
|
||||
Method method = className.getMethod(
|
||||
methodName.substring(methodName.indexOf(".") + 1,
|
||||
methodName.indexOf("(")), args);
|
||||
if (method.isAnnotationPresent(LogAnnotation.class)) {
|
||||
LogAnnotation logAnnotation = method
|
||||
.getAnnotation(LogAnnotation.class);
|
||||
String operateModelNm = logAnnotation.operateModelNm();
|
||||
String operateDescribe = logAnnotation.operateDescribe();
|
||||
String operateFuncNm = logAnnotation.operateFuncNm();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.jeecgframework.core.interceptors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.support.WebBindingInitializer;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
public class MyWebBinding implements WebBindingInitializer {
|
||||
|
||||
public void initBinder(WebDataBinder binder, WebRequest request) {
|
||||
// 1. 使用spring自带的CustomDateEditor
|
||||
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// binder.registerCustomEditor(Date.class, new
|
||||
// CustomDateEditor(dateFormat, true));
|
||||
//2. 自定义的PropertyEditorSupport
|
||||
binder.registerCustomEditor(Date.class, new DateConvertEditor());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
package org.jeecgframework.core.servlet;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
|
||||
public class UploadTmpPhotoServlet extends HttpServlet {
|
||||
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
|
||||
throws ServletException, IOException {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
|
||||
throws ServletException, IOException {
|
||||
|
||||
DiskFileItemFactory factory = new DiskFileItemFactory();
|
||||
|
||||
// 设置内存缓冲区,超过后写入临时文件
|
||||
|
||||
factory.setSizeThreshold(10240000);
|
||||
|
||||
// 设置临时文件存储位置
|
||||
|
||||
String base = "";// this.getServletContext().getRealPath("/")+"files";
|
||||
|
||||
File file = new File(base);
|
||||
|
||||
if (!file.exists())
|
||||
|
||||
file.mkdirs();
|
||||
|
||||
factory.setRepository(file);
|
||||
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
|
||||
// 设置单个文件的最大上传值
|
||||
|
||||
upload.setFileSizeMax(10002400000l);
|
||||
|
||||
// 设置整个request的最大值
|
||||
|
||||
upload.setSizeMax(10002400000l);
|
||||
|
||||
upload.setHeaderEncoding("UTF-8");
|
||||
|
||||
request.setCharacterEncoding("utf-8");
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
try {
|
||||
|
||||
List<?> items = upload.parseRequest(request);
|
||||
|
||||
FileItem item = null;
|
||||
|
||||
String tpmFilePathName = null;
|
||||
|
||||
String savePath = "";
|
||||
|
||||
Map<String, String> fileNames = new HashMap<String, String>();
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
|
||||
item = (FileItem) items.get(i);
|
||||
|
||||
// 保存文件
|
||||
|
||||
if (!item.isFormField() && item.getName().length() > 0) {
|
||||
|
||||
fileNames.put("oldName", item.getName());
|
||||
|
||||
String suffixName = item.getName().substring(item.getName().lastIndexOf("."));
|
||||
|
||||
String newName = "";
|
||||
|
||||
fileNames.put("newName", newName);
|
||||
|
||||
fileNames.put("fileSize", "");
|
||||
|
||||
// org.jeecgframework.core.util.LogUtil.info(item.getName()+"=="+UploadTool.createPhotoID()+suffixName+"=="+UploadTool.FormetFileSize(item.getSize())+"savePath"+savePath);
|
||||
|
||||
tpmFilePathName = base + newName;// File.separator
|
||||
|
||||
item.write(new File(tpmFilePathName));
|
||||
|
||||
// UploadTool.removeFile(tpmFilePathName);
|
||||
|
||||
BufferedImage bufImg = ImageIO.read(new File(tpmFilePathName));
|
||||
|
||||
// System.out.print("======"+bufImg.getHeight()+"====="+bufImg.getWidth());
|
||||
|
||||
// 数据库操作,包图片的路径及其相应的信息保存到数据库,
|
||||
|
||||
out.print(newName + "^" + bufImg.getHeight() + "^" + bufImg.getWidth());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Map<String,String> fileNames =
|
||||
// UploadTool.WorkGroupFileUpload(request,
|
||||
// Config.getInstance().getLinkfiletmpPath(),
|
||||
// Config.getInstance().getLinkfilesavePath());
|
||||
|
||||
} catch (FileUploadException e) {
|
||||
|
||||
out.print(-1);
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
out.print(-1);
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
} finally {
|
||||
|
||||
out.flush();
|
||||
|
||||
out.close();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package org.jeecgframework.core.timer;
|
||||
|
||||
import org.jeecgframework.web.system.pojo.base.TSTimeTaskEntity;
|
||||
import org.jeecgframework.web.system.service.TimeTaskServiceI;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.quartz.CronTriggerBean;
|
||||
/**
|
||||
* 在原有功能的基础上面增加数据库的读取
|
||||
* @author JueYue
|
||||
* @date 2013-9-22
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DataBaseCronTriggerBean extends CronTriggerBean{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
private TimeTaskServiceI timeTaskService;
|
||||
/**
|
||||
* 读取数据库更新文件
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.afterPropertiesSet();
|
||||
TSTimeTaskEntity task = timeTaskService.findUniqueByProperty
|
||||
(TSTimeTaskEntity.class,"taskId",this.getName());
|
||||
if(task!=null&&task.getIsEffect().equals("1")
|
||||
&&!task.getCronExpression().equals(this.getCronExpression())){
|
||||
this.setCronExpression(task.getCronExpression());
|
||||
DynamicTask.updateSpringMvcTaskXML(this,task.getCronExpression());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue