Przeglądaj źródła

--update insertImg();insert realNameAuth();insert expertAuth()

zzy.zhiyuan.foxmail 8 lat temu
rodzic
commit
0562cc4cb9

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

@ -41,7 +41,7 @@ public class AuthApply implements CreateTimeSupported {
41 41
		this.applyType = applyType;
42 42
	}
43 43
	
44
	@Column(handlerClass=WIntHandler.class,dbType="INT",insertable=false,nullable=false,renewable=false,queryable=true)
44
	@Column(handlerClass=WIntHandler.class,dbType="INT",insertable=true,nullable=false,renewable=false,queryable=true)
45 45
	public Integer getSolveStatus() {
46 46
		return solveStatus;
47 47
	}

+ 28 - 13
src/main/java/com/ekexiu/portal/service/AuthApplyService.java

@ -6,14 +6,12 @@ import java.sql.SQLException;
6 6
import java.util.List;
7 7

8 8
import org.jfw.apt.annotation.Autowrie;
9
import org.jfw.apt.annotation.Nullable;
10 9
import org.jfw.apt.web.annotation.Path;
11 10
import org.jfw.apt.web.annotation.operate.Get;
12 11
import org.jfw.apt.web.annotation.operate.Post;
13 12
import org.jfw.apt.web.annotation.param.JdbcConn;
14 13
import org.jfw.apt.web.annotation.param.PathVar;
15 14
import org.jfw.util.StringUtil;
16
import org.jfw.util.exception.JfwBaseException;
17 15

18 16
import com.ekexiu.portal.dao.AuthApplyDao;
19 17
import com.ekexiu.portal.dao.ProfessorDao;
@ -54,25 +52,42 @@ public class AuthApplyService {
54 52
	}
55 53

56 54
	@Post
57
	@Path
58
	public String insert(@JdbcConn(true) Connection con, AuthApply authApply) throws SQLException, IOException{
55
	@Path("/realName")
56
	public void realNameAuth(@JdbcConn(true) Connection con,AuthApply authApply,String[] fns) throws SQLException, IOException{
59 57
		String authApplyId = StringUtil.buildUUID();
60
		authApply.setSolveStatus(0);
61 58
		authApply.setAuthApplyId(authApplyId);
59
		authApply.setApplyType(1);
60
		authApply.setSolveStatus(1);
62 61
		this.authApplyDao.insert(con, authApply);
63
		return authApplyId;
62
		this.professorDao.updateAuthStatus(con, authApply.getProfessorId(), 1);
63
		for (String fn : fns) {
64
			this.authImageService.insertImg(con, authApplyId, fn);
65
		}
64 66
	}
65 67
	
66 68
	@Post
67
	@Path("/state")
68
	public void updateState(@JdbcConn(true) Connection con,String id,Integer state,@Nullable Integer auth,@Nullable String professorId)throws SQLException, JfwBaseException{
69
		if(state==2){
70
			if(auth==null) throw new JfwBaseException(10);
71
			if(professorId==null) throw new JfwBaseException(10);
72
			if(auth>4 || auth <1) throw new JfwBaseException(11);
73
			this.professorDao.updateAuthentication(con, professorId, auth);
69
	@Path("/expert")
70
	public void expertAuth(@JdbcConn(true) Connection con,AuthApply authApply,String[] fns)throws SQLException, IOException{
71
		String authApplyId = StringUtil.buildUUID();
72
		authApply.setAuthApplyId(authApplyId);
73
		authApply.setApplyType(2);
74
		authApply.setSolveStatus(1);
75
		this.authApplyDao.insert(con, authApply);
76
		this.professorDao.updateAuthStatus(con, authApply.getProfessorId(), 1);
77
		for (String fn : fns) {
78
			this.authImageService.insertImg(con, authApplyId, fn);
74 79
		}
80
	}
81
	
82
	@Post
83
	@Path("/state")
84
	public void updateState(@JdbcConn(true) Connection con,String id,Integer state,Integer auth,String professorId) throws SQLException{
75 85
		this.authApplyDao.updateSolveStatus(con,state,id);
86
		if(auth==1){
87
			this.professorDao.updateAuthStatus(con, professorId, state);
88
		}else if(auth==2){
89
			this.professorDao.updateAuthType(con, professorId, state);
90
		}
76 91
	}
77 92
	
78 93
	@Get

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

@ -75,13 +75,13 @@ public class AuthImageService {
75 75
		this.authApplyDao = authApplyDao;
76 76
	}
77 77
	
78
	public String insertImg(@JdbcConn(true) Connection con, String authApplyId, String fn) throws SQLException, IOException{
78
	public void insertImg(@JdbcConn(true) Connection con, String authApplyId, String fn) throws SQLException, IOException{
79 79
		String authImageId = StringUtil.buildUUID();
80 80
		SimpleDateFormat df = new SimpleDateFormat(this.dateFormat);
81 81
		String date = df.format(new Date());
82 82
		File dateFile = new File(this.authImgPath + "/" + date);
83 83
		if (!dateFile.exists()) {
84
			dateFile.mkdir();
84
			dateFile.mkdirs();
85 85
		}
86 86
		InputStream in = new FileInputStream(new File(this.tmpPath, fn));
87 87
		try {
@ -94,7 +94,6 @@ public class AuthImageService {
94 94
		authImage.setAuthApplyId(authApplyId);
95 95
		authImage.setAuthSrc(date + "/" + authImageId + ".jpg");
96 96
		this.authImageDao.insert(con, authImage);
97
		return authImageId;
98 97
	}
99 98

100 99
	@Post
@ -105,7 +104,7 @@ public class AuthImageService {
105 104
		String date = df.format(new Date());
106 105
		File dateFile = new File(this.authImgPath + "/" + date);
107 106
		if (!dateFile.exists()) {
108
			dateFile.mkdir();
107
			dateFile.mkdirs();
109 108
		}
110 109
		Base64 bs64 = new Base64();
111 110
		byte[] bs = bs64.decode(base64.getBytes("UTF-8"));
@ -120,7 +119,7 @@ public class AuthImageService {
120 119
		AuthImage authImage = new AuthImage();
121 120
		authImage.setAuthImageId(authImageId);
122 121
		authImage.setAuthApplyId(authApplyId);
123
		authImage.setAuthSrc(imageSrc);
122
		authImage.setAuthSrc(date + "/" + imageSrc);
124 123
		this.authImageDao.insert(con, authImage);
125 124
		return authImageId;
126 125
	}