jiapeng 8 lat temu
rodzic
commit
1644aa5fe9

+ 8 - 0
src/main/java/com/ekexiu/portal/pojo/AuthApplyInfo.java

@ -14,7 +14,15 @@ public class AuthApplyInfo extends AuthApply {
14 14
	private String office;
15 15
	private String title;
16 16
	private String authentication;
17
	private String department;
17 18
	
19
	@CalcColumn(handlerClass=StringHandler.class,column="p.department")
20
	public String getDepartment() {
21
		return department;
22
	}
23
	public void setDepartment(String department) {
24
		this.department = department;
25
	}
18 26
	@CalcColumn(handlerClass=StringHandler.class,column="p.name")
19 27
	public String getName() {
20 28
		return name;

+ 4 - 3
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);
@ -66,12 +67,12 @@ public class AuthApplyService {
66 67
	}
67 68
	
68 69
	@Get
69
	@Path()
70
	@Path("/info")
70 71
	public List<AuthApplyInfo> query(@JdbcConn Connection con) throws SQLException{
71 72
		return this.authApplyDao.queryInfo(con);
72 73
	}
73 74
	@Get
74
	@Path("/{id}")
75
	@Path("/info/{id}")
75 76
	public AuthApplyInfo query(@JdbcConn Connection con,@PathVar String id) throws SQLException{
76 77
		return this.authApplyDao.queryInfo(con, id);
77 78
	}

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

@ -1,17 +1,24 @@
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.util.List;
11
import java.text.SimpleDateFormat;
12
import java.util.Date;
8 13

9 14
import org.jfw.apt.annotation.Autowrie;
10 15
import org.jfw.apt.web.annotation.Path;
16
import org.jfw.apt.web.annotation.operate.Get;
11 17
import org.jfw.apt.web.annotation.operate.Post;
12 18
import org.jfw.apt.web.annotation.param.JdbcConn;
13 19
import org.jfw.util.StringUtil;
14 20
import org.jfw.util.codec.Base64;
21
import org.jfw.util.io.IoUtil;
15 22

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

45
	public File getTmpPath() {
46
		return tmpPath;
47
	}
48

49
	public void setTmpPath(File tmpPath) {
50
		this.tmpPath = tmpPath;
51
	}
52

53
	public String getDateFormat() {
54
		return dateFormat;
55
	}
56

57
	public void setDateFormat(String dateFormat) {
58
		this.dateFormat = dateFormat;
59
	}
60

36 61
	public AuthImageDao getAuthImageDao() {
37 62
		return authImageDao;
38 63
	}
@ -53,13 +78,16 @@ public class AuthImageService {
53 78
	@Path
54 79
	public String insert(@JdbcConn(true) Connection con, String authApplyId, String base64) throws SQLException, IOException{
55 80
		String authImageId = StringUtil.buildUUID();
56
		if(!this.authImgPath.exists()){
57
			this.authImgPath.mkdir();
81
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
82
		String date = df.format(new Date());
83
		File dateFile = new File(this.authImgPath + "/" + date);
84
		if (!dateFile.exists()) {
85
			dateFile.mkdir();
58 86
		}
59 87
		Base64 bs64 = new Base64();
60 88
		byte[] bs = bs64.decode(base64.getBytes("UTF-8"));
61
		String imageSrc = this.authImgPath + "/" + authImageId + ".jpg";
62
		FileOutputStream fos = new FileOutputStream(imageSrc);
89
		String imageSrc = authImageId + ".jpg";
90
		FileOutputStream fos = new FileOutputStream(dateFile + "/" + imageSrc);
63 91
		try {
64 92
			fos.write(bs);
65 93
			fos.flush();
@ -73,4 +101,9 @@ public class AuthImageService {
73 101
		this.authImageDao.insert(con, authImage);
74 102
		return authImageId;
75 103
	}
104
	@Get
105
	@Path("/byApply/{id}")
106
	public List<AuthImage> query(@JdbcConn Connection con,String id)throws SQLException{
107
		return this.authImageDao.query(con,id);
108
	}
76 109
}