Quellcode durchsuchen

用户设置绑定手机号和邮箱之后,如果用户信息表没存联系方式则自动添加到信息表。

zzy.zhiyuan.foxmail vor 8 Jahren
Ursprung
Commit
7201b70ca7

+ 8 - 0
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

@ -40,6 +40,14 @@ public abstract class ProfessorDao {
40 40
	@Update
41 41
	public abstract int update(Connection con, Professor professor) throws SQLException;
42 42
	
43
	@UpdateWith
44
	@From(Professor.class)
45
	public abstract int updatePhone(Connection con, String id, @Set String phone) throws SQLException;
46
	
47
	@UpdateWith
48
	@From(Professor.class)
49
	public abstract int updateEmail(Connection con, String id, @Set String email) throws SQLException;
50
	
43 51
	@UpdateWith
44 52
	@From(Professor.class)
45 53
	public abstract int updateSortFirst(Connection con, String id, @Set Integer sortFirst) throws SQLException;

+ 38 - 2
src/main/java/com/ekexiu/portal/service/InitUserService.java

@ -14,24 +14,34 @@ import org.jfw.apt.web.annotation.param.JdbcConn;
14 14
import org.jfw.apt.web.annotation.param.PathVar;
15 15
import org.jfw.apt.web.annotation.param.RequestBody;
16 16
17
import com.ekexiu.portal.dao.ProfessorDao;
17 18
import com.ekexiu.portal.dao.UserDao;
19
import com.ekexiu.portal.po.Professor;
18 20
import com.ekexiu.portal.po.User;
19 21
20 22
@Path("/init")
21 23
public class InitUserService {
22 24
	@Autowrie
23 25
	private UserDao userDao;
26
	@Autowrie
27
	private ProfessorDao professorDao;
24 28
	
25 29
	
26 30
	public UserDao getUserDao() {
27 31
		return userDao;
28 32
	}
29 33
30
31 34
	public void setUserDao(UserDao userDao) {
32 35
		this.userDao = userDao;
33 36
	}
34 37
38
	public ProfessorDao getProfessorDao() {
39
		return professorDao;
40
	}
41
42
	public void setProfessorDao(ProfessorDao professorDao) {
43
		this.professorDao = professorDao;
44
	}
35 45
36 46
	@Get
37 47
	@Path("/user/{id}")
@ -42,6 +52,12 @@ public class InitUserService {
42 52
	@Path("/user")
43 53
	public void modifyMobilePhone(@JdbcConn(true) Connection con,String id,@Nullable String mobilePhone,
44 54
			@Nullable String email)throws SQLException{
55
		if(mobilePhone.isEmpty()){
56
			mobilePhone = null;
57
		}
58
		if(email.isEmpty()){
59
			email = null;
60
		}
45 61
		Random rd = new Random();
46 62
		int code = rd.nextInt(1000000);
47 63
		String inviteCode = String.format("%06d", code);
@ -52,13 +68,33 @@ public class InitUserService {
52 68
		user.setPasswd(SysService.DEFAULT_PASS_WORD);
53 69
		user.setUserType("0");
54 70
		user.setInviteCode(inviteCode);
55
		this.userDao.insert(con, user);		
71
		this.userDao.insert(con, user);
72
		Professor professor = this.professorDao.queryOne(con, id);
73
		if(mobilePhone != null && (professor.getPhone() == null || professor.getPhone().isEmpty())){
74
			this.professorDao.updatePhone(con, id, mobilePhone);
75
		}
76
		if(email != null && (professor.getEmail() == null || professor.getEmail().isEmpty())){
77
			this.professorDao.updateEmail(con, id, email);
78
		}
56 79
	}
57 80
	@Put
58 81
	@Path("/user")
59 82
	public void modifyMobilePhone(@JdbcConn(true) Connection con ,@RequestBody User user)throws SQLException{
83
		if(user.getMobilePhone().isEmpty()){
84
			user.setMobilePhone(null);
85
		}
86
		if(user.getEmail().isEmpty()){
87
			user.setEmail(null);
88
		}
60 89
		this.userDao.updateMobilePhone(con, user.getMobilePhone(), user.getId());
61 90
		this.userDao.updateEmail(con, user.getEmail(), user.getId());
91
		Professor professor = this.professorDao.queryOne(con, user.getId());
92
		if(user.getMobilePhone() != null && (professor.getPhone() == null || professor.getPhone().isEmpty())){
93
			this.professorDao.updatePhone(con, user.getId(), user.getMobilePhone());
94
		}
95
		if(user.getEmail() != null && (professor.getEmail() == null || professor.getEmail().isEmpty())){
96
			this.professorDao.updateEmail(con, user.getId(), user.getEmail());
97
		}
62 98
		Random rd = new Random();
63 99
		int code = rd.nextInt(1000000);
64 100
		String inviteCode = String.format("%06d", code);

+ 9 - 1
src/main/java/com/ekexiu/portal/service/SysService.java

@ -627,6 +627,10 @@ public class SysService {
627 627
		if (sc.getExpiredTime() < System.currentTimeMillis())
628 628
			return false;
629 629
		try {
630
			Professor professor = this.professorDao.queryOne(con, sc.getKey());
631
			if(professor.getPhone() == null || professor.getPhone().isEmpty()){
632
				this.professorDao.updateEmail(con, sc.getKey(), sc.getValue());
633
			}
630 634
			return this.userDao.updateEmail(con, sc.getValue(), sc.getKey()) > 0;
631 635
		} finally {
632 636
			JfwAppContext.removeCachedObject(key);
@ -748,6 +752,10 @@ public class SysService {
748 752
			if (!sc.getKey().equals(mobilePhone)
749 753
					|| !sc.getValue().equals(validateCode))
750 754
				return false;
755
			Professor professor = this.professorDao.queryOne(con, userid);
756
			if(professor.getPhone() == null || professor.getPhone().isEmpty()){
757
				this.professorDao.updatePhone(con, userid, mobilePhone);
758
			}
751 759
			return this.userDao.updateMobilePhone(con, mobilePhone, userid) > 0;
752 760
		} finally {
753 761
			JfwAppContext.removeCachedObject(state);
@ -909,7 +917,7 @@ public class SysService {
909 917
			JfwAppContext.removeCachedObject(state);
910 918
		}
911 919
	}
912
920
	
913 921
	public static void main(String[] args) {
914 922
		System.out.println(String.format("%04d", new Random().nextInt(10000)));
915 923
	}

+ 2 - 1
src/main/webapp/page/professor.html

@ -687,7 +687,7 @@
687 687
			}
688 688
689 689
			var addJob = function($data) {
690
				gtbody($data, $("#job_tbody"), [ "startMonth", "stopMonth:--",
690
				gtbody($data, $("#job_tbody"), [ "startMonth", "stopMonth",
691 691
						"company", "department", "title", "descp" ], "job");
692 692
			};
693 693
			var addHonor = function($data) {
@ -930,6 +930,7 @@
930 930
										$("#job_startMonth").val($info.startMonth);
931 931
										$("#job_stopMonth").val($info.stopMonth ? $info.stopMonth: "");
932 932
										$("#job_company").val($info.company ? $info.company: "");
933
										$("#job_department").val($info.department ? $info.department: "");
933 934
										$("#job_title").val($info.title ? $info.title: "");
934 935
										$("#job_descp").val($info.descp ? $info.descp: "");
935 936
										$("#jobModal").modal();