Parcourir la Source

--add OrgRetrieve.java;add OrgRetrieveImg.java

zzy.zhiyuan.foxmail 8 ans auparavant
Parent
commit
801d5afa85

+ 21 - 0
src/main/java/com/ekexiu/portal/dao/OrgRetrieveDao.java

@ -0,0 +1,21 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.Nullable;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
9
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
10

11
import com.ekexiu.portal.po.OrgRetrieve;
12

13
@DAO
14
public abstract class OrgRetrieveDao {
15
	@Insert
16
	public abstract int insert(Connection con,OrgRetrieve orgRetrieve)throws SQLException;
17
	
18
	@SelectOne
19
	@Nullable
20
	public abstract OrgRetrieve queryOne(Connection con,String id)throws SQLException;
21
}

+ 20 - 0
src/main/java/com/ekexiu/portal/dao/OrgRetrieveImgDao.java

@ -0,0 +1,20 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
9
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
10

11
import com.ekexiu.portal.po.OrgRetrieveImg;
12

13
@DAO
14
public abstract class OrgRetrieveImgDao {
15
	@Insert
16
	public abstract int insert(Connection con,OrgRetrieveImg orgRetrieveImg)throws SQLException;
17
	
18
	@SelectList
19
	public abstract List<OrgRetrieveImg> query(Connection con,String orgRetrieveId)throws SQLException;
20
}

+ 70 - 0
src/main/java/com/ekexiu/portal/po/OrgRetrieve.java

@ -0,0 +1,70 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
7
import org.jfw.apt.orm.core.enums.DE;
8

9
import com.ekexiu.portal.basepo.CreateTimeSupported;
10

11
@Table
12
@PrimaryKey("id")
13
public class OrgRetrieve implements CreateTimeSupported {
14
	private String id;
15
	private String Name;
16
	private String orgId;
17
	private String Email;
18
	private String passwd;
19
	private String solveStatus;
20
	private String createTime;
21
	@Column(DE.id_32)
22
	public String getId() {
23
		return id;
24
	}
25
	public void setId(String id) {
26
		this.id = id;
27
	}
28
	@Column(DE.String_de)
29
	public String getName() {
30
		return Name;
31
	}
32
	public void setName(String name) {
33
		Name = name;
34
	}
35
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(32)",nullable=true,renewable=false)
36
	public String getOrgId() {
37
		return orgId;
38
	}
39
	public void setOrgId(String orgId) {
40
		this.orgId = orgId;
41
	}
42
	@Column(DE.Email_de)
43
	public String getEmail() {
44
		return Email;
45
	}
46
	public void setEmail(String email) {
47
		Email = email;
48
	}
49
	@Column(DE.Md5_de)
50
	public String getPasswd() {
51
		return passwd;
52
	}
53
	public void setPasswd(String passwd) {
54
		this.passwd = passwd;
55
	}
56
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(2)",nullable=false)
57
	public String getSolveStatus() {
58
		return solveStatus;
59
	}
60
	public void setSolveStatus(String solveStatus) {
61
		this.solveStatus = solveStatus;
62
	}
63
	public String getCreateTime() {
64
		return createTime;
65
	}
66
	public void setCreateTime(String createTime) {
67
		this.createTime = createTime;
68
	}
69
	
70
}

+ 36 - 0
src/main/java/com/ekexiu/portal/po/OrgRetrieveImg.java

@ -0,0 +1,36 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
@Table
9
@PrimaryKey("id")
10
public class OrgRetrieveImg {
11
	private String id;
12
	private String orgRetrieveId;
13
	private String src;
14
	@Column(DE.id_32)
15
	public String getId() {
16
		return id;
17
	}
18
	public void setId(String id) {
19
		this.id = id;
20
	}
21
	@Column(DE.id_32)
22
	public String getOrgRetrieveId() {
23
		return orgRetrieveId;
24
	}
25
	public void setOrgRetrieveId(String orgRetrieveId) {
26
		this.orgRetrieveId = orgRetrieveId;
27
	}
28
	@Column(DE.string_de)
29
	public String getSrc() {
30
		return src;
31
	}
32
	public void setSrc(String src) {
33
		this.src = src;
34
	}
35
	
36
}

+ 0 - 11
src/main/java/com/ekexiu/portal/service/AuthImageService.java

@ -21,7 +21,6 @@ import org.jfw.util.StringUtil;
21 21
import org.jfw.util.codec.Base64;
22 22
import org.jfw.util.io.IoUtil;
23 23

24
import com.ekexiu.portal.dao.AuthApplyDao;
25 24
import com.ekexiu.portal.dao.AuthImageDao;
26 25
import com.ekexiu.portal.po.AuthImage;
27 26

@ -32,8 +31,6 @@ public class AuthImageService {
32 31
	private String dateFormat = "yyyyMMdd";
33 32
	@Autowrie
34 33
	private AuthImageDao authImageDao;
35
	@Autowrie
36
	private AuthApplyDao authApplyDao;
37 34

38 35
	public File getAuthImgPath() {
39 36
		return authImgPath;
@ -67,14 +64,6 @@ public class AuthImageService {
67 64
		this.authImageDao = authImageDao;
68 65
	}
69 66
	
70
	public AuthApplyDao getAuthApplyDao() {
71
		return authApplyDao;
72
	}
73

74
	public void setAuthApplyDao(AuthApplyDao authApplyDao) {
75
		this.authApplyDao = authApplyDao;
76
	}
77
	
78 67
	public void insertImg(@JdbcConn(true) Connection con, String authApplyId, String fn) throws SQLException, IOException{
79 68
		String authImageId = StringUtil.buildUUID();
80 69
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);

+ 83 - 0
src/main/java/com/ekexiu/portal/service/OrgRetrieveImgService.java

@ -0,0 +1,83 @@
1
package com.ekexiu.portal.service;
2

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

14
import org.jfw.apt.annotation.Autowrie;
15
import org.jfw.apt.web.annotation.Path;
16
import org.jfw.apt.web.annotation.operate.Get;
17
import org.jfw.apt.web.annotation.param.JdbcConn;
18
import org.jfw.apt.web.annotation.param.PathVar;
19
import org.jfw.util.StringUtil;
20
import org.jfw.util.io.IoUtil;
21

22
import com.ekexiu.portal.dao.OrgRetrieveImgDao;
23
import com.ekexiu.portal.po.OrgRetrieveImg;
24

25
@Path("/orgRetrieveImg")
26
public class OrgRetrieveImgService {
27
	private File orgRetrieveImgPath;
28
	private File tmpPath;
29
	private String dateFormat = "yyyyMMdd";
30
	@Autowrie
31
	private OrgRetrieveImgDao orgRetrieveImgDao;
32
	public File getOrgRetrieveImgPath() {
33
		return orgRetrieveImgPath;
34
	}
35
	public void setOrgRetrieveImgPath(File orgRetrieveImgPath) {
36
		this.orgRetrieveImgPath = orgRetrieveImgPath;
37
	}
38
	public File getTmpPath() {
39
		return tmpPath;
40
	}
41
	public void setTmpPath(File tmpPath) {
42
		this.tmpPath = tmpPath;
43
	}
44
	public String getDateFormat() {
45
		return dateFormat;
46
	}
47
	public void setDateFormat(String dateFormat) {
48
		this.dateFormat = dateFormat;
49
	}
50
	public OrgRetrieveImgDao getOrgRetrieveImgDao() {
51
		return orgRetrieveImgDao;
52
	}
53
	public void setOrgRetrieveImgDao(OrgRetrieveImgDao orgRetrieveImgDao) {
54
		this.orgRetrieveImgDao = orgRetrieveImgDao;
55
	}
56
	
57
	public void insertImg(@JdbcConn(true) Connection con, String orgRetrieveId, String fn) throws SQLException, IOException{
58
		String id = StringUtil.buildUUID();
59
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
60
		String date = df.format(new Date());
61
		File dateFile = new File(this.orgRetrieveImgPath + "/" + date);
62
		if (!dateFile.exists()) {
63
			dateFile.mkdirs();
64
		}
65
		InputStream in = new FileInputStream(new File(this.tmpPath, fn));
66
		try {
67
			IoUtil.copy(in, new FileOutputStream(new File(dateFile, id + ".jpg")), false, true);
68
		} finally {
69
			in.close();
70
		}
71
		OrgRetrieveImg orgRetrieveImg = new OrgRetrieveImg();
72
		orgRetrieveImg.setId(id);
73
		orgRetrieveImg.setOrgRetrieveId(orgRetrieveId);
74
		orgRetrieveImg.setSrc(date + "/" + id + ".jpg");
75
		this.orgRetrieveImgDao.insert(con, orgRetrieveImg);
76
	}
77
	
78
	@Get
79
	@Path("/byRetId/{id}")
80
	public List<OrgRetrieveImg> query(@JdbcConn Connection con,@PathVar String id)throws SQLException{
81
		return this.orgRetrieveImgDao.query(con, id);
82
	}
83
}

+ 61 - 0
src/main/java/com/ekexiu/portal/service/OrgRetrieveService.java

@ -0,0 +1,61 @@
1
package com.ekexiu.portal.service;
2

3
import java.io.IOException;
4
import java.sql.Connection;
5
import java.sql.SQLException;
6

7
import org.jfw.apt.annotation.Autowrie;
8
import org.jfw.apt.web.annotation.Path;
9
import org.jfw.apt.web.annotation.operate.Post;
10
import org.jfw.apt.web.annotation.param.JdbcConn;
11
import org.jfw.util.StringUtil;
12

13
import com.ekexiu.portal.dao.OrgDao;
14
import com.ekexiu.portal.dao.OrgRetrieveDao;
15
import com.ekexiu.portal.po.OrgRetrieve;
16

17
@Path("/orgRetrieve")
18
public class OrgRetrieveService {
19
	@Autowrie
20
	private OrgRetrieveDao orgRetrieveDao;
21
	@Autowrie
22
	private OrgDao orgDao;
23
	@Autowrie
24
	private OrgRetrieveImgService orgRetrieveImgService;
25

26
	public OrgRetrieveDao getOrgRetrieveDao() {
27
		return orgRetrieveDao;
28
	}
29

30
	public void setOrgRetrieveDao(OrgRetrieveDao orgRetrieveDao) {
31
		this.orgRetrieveDao = orgRetrieveDao;
32
	}
33
	
34
	public OrgDao getOrgDao() {
35
		return orgDao;
36
	}
37

38
	public void setOrgDao(OrgDao orgDao) {
39
		this.orgDao = orgDao;
40
	}
41

42
	public OrgRetrieveImgService getOrgRetrieveImgService() {
43
		return orgRetrieveImgService;
44
	}
45

46
	public void setOrgRetrieveImgService(OrgRetrieveImgService orgRetrieveImgService) {
47
		this.orgRetrieveImgService = orgRetrieveImgService;
48
	}
49

50
	@Post
51
	@Path
52
	public void insert(@JdbcConn(true) Connection con,OrgRetrieve orgRetrieve,String[] fns)throws SQLException, IOException{
53
		String id = StringUtil.buildUUID();
54
		orgRetrieve.setOrgId(this.orgDao.queryByName(con, orgRetrieve.getName()));
55
		orgRetrieve.setId(id);
56
		this.orgRetrieveDao.insert(con, orgRetrieve);
57
		for (String fn : fns) {
58
			this.orgRetrieveImgService.insertImg(con, id, fn);
59
		}
60
	}
61
}