Ver Código Fonte

Merge branch 'dev' of http://121.42.53.174:3000/jiapeng/jFrameWork.git into dev

zzy.zhiyuan.foxmail 8 anos atrás
pai
commit
959d8645cb

+ 2 - 2
jfwAptOrm/src/main/java/org/jfw/apt/orm/core/enums/DE.java

6
public enum DE {
6
public enum DE {
7
	invalid_de(AbstractColumnHandler.class, null, false,false,false, false, null, null),
7
	invalid_de(AbstractColumnHandler.class, null, false,false,false, false, null, null),
8
8
9
	boolean_de(BooleanHandler.class, "CHAR",false,true,true,true,null,null),
10
	Boolean_de(WBooleanHandler.class, "CHAR", true,true,true,true,null,null),
9
	boolean_de(BooleanHandler.class, "CHAR(1)",false,true,true,true,null,null),
10
	Boolean_de(WBooleanHandler.class, "CHAR(1)", true,true,true,true,null,null),
11
	
11
	
12
	byte_de(ByteHandler.class, "BYTE",false,true,true,true,null,null),
12
	byte_de(ByteHandler.class, "BYTE",false,true,true,true,null,null),
13
	Byte_de(WByteHandler.class,"BYTE",true,true,true,true,null,null),
13
	Byte_de(WByteHandler.class,"BYTE",true,true,true,true,null,null),

+ 2 - 0
jfwAptWeb/src/main/java/org/jfw/apt/web/AptWebHandler.java

26
import org.jfw.apt.web.handlers.ChangeResultHandler;
26
import org.jfw.apt.web.handlers.ChangeResultHandler;
27
import org.jfw.apt.web.handlers.CharacterEncodingHandler;
27
import org.jfw.apt.web.handlers.CharacterEncodingHandler;
28
import org.jfw.apt.web.handlers.ExecuteHandler;
28
import org.jfw.apt.web.handlers.ExecuteHandler;
29
import org.jfw.apt.web.handlers.InvalidSessionHandler;
29
import org.jfw.apt.web.handlers.JdbcConnectionHandler;
30
import org.jfw.apt.web.handlers.JdbcConnectionHandler;
30
import org.jfw.apt.web.handlers.LastScriptHandler;
31
import org.jfw.apt.web.handlers.LastScriptHandler;
31
import org.jfw.apt.web.handlers.LoginUserHandler;
32
import org.jfw.apt.web.handlers.LoginUserHandler;
363
		supportedClass.add(ExecuteHandler.class);
364
		supportedClass.add(ExecuteHandler.class);
364
		supportedClass.add(SetSessionHandler.class);
365
		supportedClass.add(SetSessionHandler.class);
365
		supportedClass.add(SetCookieHandler.class);
366
		supportedClass.add(SetCookieHandler.class);
367
		supportedClass.add(InvalidSessionHandler.class);
366
		supportedClass.add(ChangeResultHandler.class);
368
		supportedClass.add(ChangeResultHandler.class);
367
		supportedClass.add(LastScriptHandler.class);
369
		supportedClass.add(LastScriptHandler.class);
368
		supportedClass.add(ResultToNullHandler.class);
370
		supportedClass.add(ResultToNullHandler.class);

+ 11 - 0
jfwAptWeb/src/main/java/org/jfw/apt/web/annotation/method/InvalidSession.java

1
package org.jfw.apt.web.annotation.method;
2

3
import java.lang.annotation.ElementType;
4
import java.lang.annotation.Retention;
5
import java.lang.annotation.RetentionPolicy;
6
import java.lang.annotation.Target;
7

8
@Target(ElementType.METHOD)
9
@Retention(RetentionPolicy.SOURCE)
10
public @interface InvalidSession {
11
}

+ 21 - 0
jfwAptWeb/src/main/java/org/jfw/apt/web/handlers/InvalidSessionHandler.java

1
package org.jfw.apt.web.handlers;
2

3
import org.jfw.apt.exception.AptException;
4
import org.jfw.apt.out.ClassWriter;
5
import org.jfw.apt.web.RequestHandler;
6
import org.jfw.apt.web.annotation.method.InvalidSession;
7

8
public class InvalidSessionHandler  extends RequestHandler {
9

10
	@Override
11
	public void init() {
12
	}
13
	@Override
14
	public void appendBeforCode(ClassWriter cw) throws AptException {
15
		InvalidSession ss = this.aptWebHandler.getMe().getRef().getAnnotation(InvalidSession.class);
16
		if(ss!=null){
17
			this.aptWebHandler.readSession();
18
			cw.l("session.invalidate();");
19
		}
20
	}
21
}

+ 1 - 1
jfwAptWeb/src/main/java/org/jfw/apt/web/handlers/buildParam/RequestParamHandler.java

56
		private void initTargetType(MethodParamEntry mpe) throws AptException {
56
		private void initTargetType(MethodParamEntry mpe) throws AptException {
57
			this.mpe = mpe;
57
			this.mpe = mpe;
58
			TypeName tn = annotation.getRealClass();
58
			TypeName tn = annotation.getRealClass();
59
			if (TypeName.OBJECT.equals(tn))
59
			if (null== tn || TypeName.OBJECT.equals(tn))
60
				tn = TypeName.get(this.mpe.getRef().asType());
60
				tn = TypeName.get(this.mpe.getRef().asType());
61
61
62
			if (!tn.getClass().equals(ClassName.class)) {
62
			if (!tn.getClass().equals(ClassName.class)) {

+ 42 - 5
jfwUtil/src/main/java/org/jfw/util/PageQueryResult.java

7
	private int total;
7
	private int total;
8
	private int pageNo = 1;
8
	private int pageNo = 1;
9
	private int pageSize;
9
	private int pageSize;
10
	
10
11
	public int getTotal() {
11
	public int getTotal() {
12
		return total;
12
		return total;
13
	}
13
	}
14
14
	public void setTotal(int total) {
15
	public void setTotal(int total) {
15
		this.total = total;
16
		this.total = total;
16
	}
17
	}
18
17
	public int getPageNo() {
19
	public int getPageNo() {
18
		return pageNo;
20
		return pageNo;
19
	}
21
	}
22
20
	public void setPageNo(int pageNo) {
23
	public void setPageNo(int pageNo) {
21
		this.pageNo = pageNo;
24
		this.pageNo = pageNo;
22
	}
25
	}
26
23
	public int getPageSize() {
27
	public int getPageSize() {
24
		return pageSize;
28
		return pageSize;
25
	}
29
	}
30
26
	public void setPageSize(int pageSize) {
31
	public void setPageSize(int pageSize) {
27
		this.pageSize = pageSize;
32
		this.pageSize = pageSize;
28
	}
33
	}
34
29
	public List<T> getData() {
35
	public List<T> getData() {
30
		return data;
36
		return data;
31
	}
37
	}
38
32
	public void setData(List<T> data) {
39
	public void setData(List<T> data) {
33
		this.data = data;
40
		this.data = data;
34
	}
41
	}
42
35
	private List<T> data;
43
	private List<T> data;
36
	
37
	public static void main(String[] args){
38
		new PageQueryResult<String>().setData(Collections.<String>emptyList());
39
		
44
45
	public static <T> PageQueryResult<T> build(List<T> list, int pageSize, int pageNo) {
46
		PageQueryResult<T> ret = new PageQueryResult<T>();
47
		ret.setTotal(list.size());
48
		pageSize = Math.max(1, pageSize);
49
		pageNo = Math.max(1, pageNo);
50
		if (list.isEmpty()) {
51
			ret.setData(list);
52
			ret.setPageNo(pageNo);
53
			ret.setPageSize(1);
54
		} else if (pageNo == 1) {
55
			ret.setPageNo(pageNo);
56
			ret.setPageSize(pageSize);
57
			ret.setData(list.subList(0,Math.min(list.size(), pageSize)));
58
		} else {
59
			int tps = list.size() / pageSize;
60
			if (list.size() % pageSize != 0) {
61
				++tps;
62
			}
63
			if (pageNo > tps) {
64
				pageNo = tps;
65
			}
66
			ret.setPageNo(pageNo);
67
			ret.setPageSize(pageSize);
68
			int begin = pageNo * pageSize - pageNo;
69
			ret.setData(list.subList(begin,Math.min(list.size(), begin + pageSize)));
70
		}
71
		return ret;
72
	}
73
74
	public static void main(String[] args) {
75
		new PageQueryResult<String>().setData(Collections.<String> emptyList());
76
40
	}
77
	}
41
}
78
}

+ 61 - 12
jfwUtil/src/main/java/org/jfw/util/auth/AuthUtil.java

1
package org.jfw.util.auth;
1
package org.jfw.util.auth;
2
2
3
import java.util.Arrays;
3
import java.util.Arrays;
4
import java.util.Random;
5
4
6
import org.jfw.util.codec.Base64;
5
import org.jfw.util.codec.Base64;
7
6
27
		int ind = auth % 32;
26
		int ind = auth % 32;
28
		return 0 != (auths[bIndex] & AUTH_BIT[ind]);
27
		return 0 != (auths[bIndex] & AUTH_BIT[ind]);
29
	}
28
	}
29
	
30
	public static int[] compress(int[] auths){
31
		if(auths==null || auths.length ==0  ) return new int[]{0};		
32
		 Arrays.sort(auths);
33
		int max = auths[auths.length-1];
34
		int bIndex = max>>5;
35
		int[] ret = new int[bIndex+1];
36
		Arrays.fill(ret,0);
37
		for(int auth:auths){
38
			int ind = auth % 32;
39
			ret[bIndex] = ret[bIndex] | AUTH_BIT[ind];
40
		}
41
		return ret;
42
	}
43
	
44
	public static int[] unCompress(int[] auths){
45
		if(auths==null || auths.length ==0  ) return new int[]{0};		
46
		int[] ret = new int[16];
47
		int ina = 0;
48
		int max = auths.length*32;
49
		for(int i =1 ; i < max;++i){
50
			int bIndex = i >> 5;
51
			int ind = i % 32;
52
			if( 0 != (auths[bIndex] & AUTH_BIT[ind])){
53
				if(ina>= ret.length){
54
					int[] nret = new int[ret.length*2];
55
					System.arraycopy(ret,0,nret, 0,ret.length);
56
					ret = nret;
57
				}
58
				ret[ina]= i;
59
				++ina;
60
			}
61
		}
62
		if(ret.length> ina) {
63
			int[] nret = new int[ina];
64
			System.arraycopy(ret,0,nret, 0,ina);
65
			return nret;
66
		}
67
		return ret;
68
	}
30
69
31
	public static int[] grant(int[] auths, int auth) {
70
	public static int[] grant(int[] auths, int auth) {
32
		if (auth < 1)
71
		if (auth < 1)
141
	}
180
	}
142
	
181
	
143
	public static void main(String main[]) {
182
	public static void main(String main[]) {
144
		System.out.println(System.currentTimeMillis());
145
		int[] iss = new int[100];
146
		for (int i = 0; i < iss.length; ++i)
147
		{
148
			iss[i] = (new Random()).nextInt();
149
		}
150
		byte[] bs = conver(iss);
151
		int[] ins = conver(bs);
152
		for (int ii = 0; ii < ins.length; ++ii) {
153
			System.out.println("" + iss[ii] + ":" + ins[ii]);
183
//		System.out.println(System.currentTimeMillis());
184
//		int[] iss = new int[100];
185
//		for (int i = 0; i < iss.length; ++i)
186
//		{
187
//			iss[i] = (new Random()).nextInt();
188
//		}
189
//		byte[] bs = conver(iss);
190
//		int[] ins = conver(bs);
191
//		for (int ii = 0; ii < ins.length; ++ii) {
192
//			System.out.println("" + iss[ii] + ":" + ins[ii]);
193
//		}
194
//		System.out.println(System.currentTimeMillis());
195
		
196
		
197
		int[] ii = new int[5];
198
		for(int i = 0 ; i < ii.length;++i){
199
			ii[i]=5-i;
154
		}
200
		}
155
		System.out.println(System.currentTimeMillis());
201
		for(int i = 0 ; i < ii.length;++i) System.out.println(ii[i]);
202
		
203
		Arrays.sort(ii);
204
		for(int i = 0 ; i < ii.length;++i) System.out.println(ii[i]);
156
	}
205
	}
157
206
158
}
207
}

+ 2 - 0
jfwUtil/src/main/java/org/jfw/util/exception/JfwBaseException.java

19
	 */
19
	 */
20
20
21
	private static final Map<Integer,String> reasons = new HashMap<Integer,String>();
21
	private static final Map<Integer,String> reasons = new HashMap<Integer,String>();
22
	public static final int MIN_APP_ERROR_CODE=50000;
23
	public static final int MIN_LOGIC_ERROR_CODE = 60000;
22
	
24
	
23
	private static String convert(int code){
25
	private static String convert(int code){
24
		String result = reasons .get(code);
26
		String result = reasons .get(code);

+ 7 - 0
jfwUtil/src/main/java/org/jfw/util/jdbc/JdbcTask.java

1
package org.jfw.util.jdbc;
2

3
import java.sql.SQLException;
4

5
public interface JdbcTask {
6
	void exec() throws SQLException;
7
}

+ 29 - 0
jfwUtil/src/main/java/org/jfw/util/jdbc/JdbcUtil.java

24
	private JdbcUtil() {
24
	private JdbcUtil() {
25
	}
25
	}
26
26
27
	public  static void executeAutoCommit(Connection con,JdbcTask task)throws SQLException{
28
		boolean old = con.getAutoCommit();
29
		try{
30
			con.setAutoCommit(false);
31
			task.exec();
32
			con.commit();
33
		}catch(SQLException e){
34
			rollback(con);
35
			throw e;
36
		}finally{
37
			con.setAutoCommit(old);
38
		}
39
	}
40
	public  static void executeAutoClose(Connection con,JdbcTask task,boolean commit)throws SQLException{
41
		boolean old = con.getAutoCommit();
42
		try{
43
		if(commit) 	con.setAutoCommit(false);
44
			task.exec();
45
		if(commit)	con.commit();
46
		}catch(SQLException e){
47
			rollback(con);
48
			throw e;
49
		}finally{
50
			if(commit)con.setAutoCommit(old);
51
			close(con);
52
		}
53
	}
54
	
55
	
27
	public static void close(Connection con) {
56
	public static void close(Connection con) {
28
		try {
57
		try {
29
			con.close();
58
			con.close();

+ 1 - 1
jfwWebUtil/src/main/java/org/jfw/util/web/WebUtil.java

71
    			begin=i+1;
71
    			begin=i+1;
72
    		}
72
    		}
73
    	}
73
    	}
74
    	if(clen - begin == 1){
74
    	if(clen == begin){
75
    		list.add(ConstData.EMPTY_STRING);
75
    		list.add(ConstData.EMPTY_STRING);
76
    	}else{
76
    	}else{
77
    		list.add(new String(cs,begin,clen - begin));
77
    		list.add(new String(cs,begin,clen - begin));