Pārlūkot izejas kodu

--update Authapply.applyType to Integer.

zzy.zhiyuan.foxmail 8 gadi atpakaļ
vecāks
revīzija
19becae297

+ 1 - 3
src/main/java/com/ekexiu/portal/dao/AuthApplyDao.java

@ -17,8 +17,6 @@ import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
17 17
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
18 18
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
19 19
import org.jfw.apt.orm.annotation.dao.param.Set;
20
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
21
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
22 20

23 21
import com.ekexiu.portal.po.AuthApply;
24 22
import com.ekexiu.portal.pojo.AuthApplyInfo;
@ -49,7 +47,7 @@ public abstract class AuthApplyDao {
49 47
                    AuthApply _result = new AuthApply();
50 48
                    _result.setAuthApplyId(rs.getString(1));
51 49
                    _result.setProfessorId(rs.getString(2));
52
                    _result.setApplyType(rs.getString(3));
50
                    _result.setApplyType(rs.getInt(3));
53 51
                    _result.setSolveStatus(rs.getInt(4));
54 52
                    return _result;
55 53
                }else{

+ 4 - 4
src/main/java/com/ekexiu/portal/po/AuthApply.java

@ -13,7 +13,7 @@ import com.ekexiu.portal.basepo.CreateTimeSupported;
13 13
public class AuthApply implements CreateTimeSupported {
14 14
	private String authApplyId;
15 15
	private String professorId;
16
	private String applyType;
16
	private Integer applyType;
17 17
	private Integer solveStatus;
18 18
	private String createTime;
19 19
	
@ -33,11 +33,11 @@ public class AuthApply implements CreateTimeSupported {
33 33
		this.professorId = professorId;
34 34
	}
35 35
	
36
	@Column(DE.string_de)
37
	public String getApplyType() {
36
	@Column(handlerClass=WIntHandler.class,dbType="INT",insertable=true,nullable=false,renewable=false,queryable=true)
37
	public Integer getApplyType() {
38 38
		return applyType;
39 39
	}
40
	public void setApplyType(String applyType) {
40
	public void setApplyType(Integer applyType) {
41 41
		this.applyType = applyType;
42 42
	}
43 43
	

+ 2 - 1
src/main/java/com/ekexiu/portal/service/AuthApplyService.java

@ -1,5 +1,6 @@
1 1
package com.ekexiu.portal.service;
2 2

3
import java.io.IOException;
3 4
import java.sql.Connection;
4 5
import java.sql.SQLException;
5 6
import java.util.List;
@ -52,7 +53,7 @@ public class AuthApplyService {
52 53

53 54
	@Post
54 55
	@Path
55
	public String insert(@JdbcConn(true) Connection con, AuthApply authApply) throws SQLException{
56
	public String insert(@JdbcConn(true) Connection con, AuthApply authApply) throws SQLException, IOException{
56 57
		String authApplyId = StringUtil.buildUUID();
57 58
		authApply.setAuthApplyId(authApplyId);
58 59
		this.authApplyDao.insert(con, authApply);

+ 52 - 4
src/main/java/com/ekexiu/portal/service/AuthImageService.java

@ -1,10 +1,14 @@
1 1
package com.ekexiu.portal.service;
2 2

3 3
import java.io.File;
4
import java.io.FileInputStream;
4 5
import java.io.FileOutputStream;
5 6
import java.io.IOException;
7
import java.io.InputStream;
6 8
import java.sql.Connection;
7 9
import java.sql.SQLException;
10
import java.text.SimpleDateFormat;
11
import java.util.Date;
8 12

9 13
import org.jfw.apt.annotation.Autowrie;
10 14
import org.jfw.apt.web.annotation.Path;
@ -12,6 +16,7 @@ import org.jfw.apt.web.annotation.operate.Post;
12 16
import org.jfw.apt.web.annotation.param.JdbcConn;
13 17
import org.jfw.util.StringUtil;
14 18
import org.jfw.util.codec.Base64;
19
import org.jfw.util.io.IoUtil;
15 20

16 21
import com.ekexiu.portal.dao.AuthApplyDao;
17 22
import com.ekexiu.portal.dao.AuthImageDao;
@ -20,6 +25,8 @@ import com.ekexiu.portal.po.AuthImage;
20 25
@Path("/authImage")
21 26
public class AuthImageService {
22 27
	private File authImgPath;
28
	private File tmpPath;
29
	private String dateFormat = "yyyyMMdd";
23 30
	@Autowrie
24 31
	private AuthImageDao authImageDao;
25 32
	@Autowrie
@ -33,6 +40,22 @@ public class AuthImageService {
33 40
		this.authImgPath = authImgPath;
34 41
	}
35 42

43
	public File getTmpPath() {
44
		return tmpPath;
45
	}
46

47
	public void setTmpPath(File tmpPath) {
48
		this.tmpPath = tmpPath;
49
	}
50

51
	public String getDateFormat() {
52
		return dateFormat;
53
	}
54

55
	public void setDateFormat(String dateFormat) {
56
		this.dateFormat = dateFormat;
57
	}
58

36 59
	public AuthImageDao getAuthImageDao() {
37 60
		return authImageDao;
38 61
	}
@ -48,18 +71,43 @@ public class AuthImageService {
48 71
	public void setAuthApplyDao(AuthApplyDao authApplyDao) {
49 72
		this.authApplyDao = authApplyDao;
50 73
	}
74
	
75
	public String insertImg(@JdbcConn(true) Connection con, String authApplyId, String fn) throws SQLException, IOException{
76
		String authImageId = StringUtil.buildUUID();
77
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
78
		String date = df.format(new Date());
79
		File dateFile = new File(this.authImgPath + "/" + date);
80
		if (!dateFile.exists()) {
81
			dateFile.mkdir();
82
		}
83
		InputStream in = new FileInputStream(new File(this.tmpPath, fn));
84
		try {
85
			IoUtil.copy(in, new FileOutputStream(new File(dateFile, authImageId + ".jpg")), false, true);
86
		} finally {
87
			in.close();
88
		}
89
		AuthImage authImage = new AuthImage();
90
		authImage.setAuthImageId(authImageId);
91
		authImage.setAuthApplyId(authApplyId);
92
		authImage.setAuthSrc(date + "/" + authImageId + ".jpg");
93
		this.authImageDao.insert(con, authImage);
94
		return authImageId;
95
	}
51 96

52 97
	@Post
53 98
	@Path
54 99
	public String insert(@JdbcConn(true) Connection con, String authApplyId, String base64) throws SQLException, IOException{
55 100
		String authImageId = StringUtil.buildUUID();
56
		if(!this.authImgPath.exists()){
57
			this.authImgPath.mkdir();
101
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
102
		String date = df.format(new Date());
103
		File dateFile = new File(this.authImgPath + "/" + date);
104
		if (!dateFile.exists()) {
105
			dateFile.mkdir();
58 106
		}
59 107
		Base64 bs64 = new Base64();
60 108
		byte[] bs = bs64.decode(base64.getBytes("UTF-8"));
61
		String imageSrc = this.authImgPath + "/" + authImageId + ".jpg";
62
		FileOutputStream fos = new FileOutputStream(imageSrc);
109
		String imageSrc = authImageId + ".jpg";
110
		FileOutputStream fos = new FileOutputStream(dateFile + "/" + imageSrc);
63 111
		try {
64 112
			fos.write(bs);
65 113
			fos.flush();