Просмотр исходного кода

--add isRegOrg();update orgLogin();

zzy.zhiyuan.foxmail лет назад: 8
Родитель
Сommit
54d0bf8724
1 измененных файлов с 45 добавлено и 25 удалено
  1. 45 25
      src/main/java/com/ekexiu/portal/service/SysService.java

+ 45 - 25
src/main/java/com/ekexiu/portal/service/SysService.java

28
import org.jfw.util.state.StateCode;
28
import org.jfw.util.state.StateCode;
29
29
30
import com.ekexiu.portal.dao.OrgDao;
30
import com.ekexiu.portal.dao.OrgDao;
31
import com.ekexiu.portal.dao.OrgUserDao;
31
import com.ekexiu.portal.dao.ProfessorDao;
32
import com.ekexiu.portal.dao.ProfessorDao;
32
import com.ekexiu.portal.dao.UserDao;
33
import com.ekexiu.portal.dao.UserDao;
33
import com.ekexiu.portal.mail.MailService;
34
import com.ekexiu.portal.mail.MailService;
34
import com.ekexiu.portal.mobile.MobilePhoneService;
35
import com.ekexiu.portal.mobile.MobilePhoneService;
36
import com.ekexiu.portal.po.OrgUser;
35
import com.ekexiu.portal.po.Organization;
37
import com.ekexiu.portal.po.Organization;
36
import com.ekexiu.portal.po.Professor;
38
import com.ekexiu.portal.po.Professor;
37
import com.ekexiu.portal.po.User;
39
import com.ekexiu.portal.po.User;
46
	@Autowrie
48
	@Autowrie
47
	private UserDao userDao;
49
	private UserDao userDao;
48
	@Autowrie
50
	@Autowrie
51
	private OrgUserDao orgUserDao;
52
	@Autowrie
49
	private OrgDao orgDao;
53
	private OrgDao orgDao;
50
	@Autowrie
54
	@Autowrie
51
	private OrgService orgService;
55
	private OrgService orgService;
329
		this.userDao = userDao;
333
		this.userDao = userDao;
330
	}
334
	}
331
335
336
	public OrgUserDao getOrgUserDao() {
337
		return orgUserDao;
338
	}
339
340
	public void setOrgUserDao(OrgUserDao orgUserDao) {
341
		this.orgUserDao = orgUserDao;
342
	}
343
332
	public OrgDao getOrgDao() {
344
	public OrgDao getOrgDao() {
333
		return orgDao;
345
		return orgDao;
334
	}
346
	}
421
		}
433
		}
422
	}
434
	}
423
	
435
	
436
	@Get
437
	@Path("/isRegOrg")
438
	public boolean isRegOrg(@JdbcConn Connection con,String email)throws SQLException{
439
		OrgUser orgUser = this.orgUserDao.queryByEmail(con, email);
440
		if(null != orgUser){
441
			return false;
442
		}else{
443
			return true;
444
		}
445
	}
446
	
424
	@Get
447
	@Get
425
	@Path("/isOrgUser")
448
	@Path("/isOrgUser")
426
	public boolean isOrgUser(@JdbcConn Connection con,String orgName)throws SQLException, JfwBaseException{
449
	public boolean isOrgUser(@JdbcConn Connection con,String orgName)throws SQLException, JfwBaseException{
428
		if(orgId == null){
451
		if(orgId == null){
429
			return true;
452
			return true;
430
		}else{
453
		}else{
431
			if(this.userDao.query(con, orgId) == null){
454
			if(this.orgUserDao.queryOne(con, orgId) == null){
432
				return true;
455
				return true;
433
			}else{
456
			}else{
434
				if("3".equals(this.orgDao.query(con, orgId).getAuthStatus())){
457
				if("3".equals(this.orgDao.query(con, orgId).getAuthStatus())){
603
			throw new JfwBaseException(-1, "验证链接已失效");
626
			throw new JfwBaseException(-1, "验证链接已失效");
604
		}
627
		}
605
		String orgId = this.orgDao.queryByName(con, sc.getValue());
628
		String orgId = this.orgDao.queryByName(con, sc.getValue());
606
		if((orgId != null) && (this.userDao.query(con, orgId) != null)){
629
		if((orgId != null) && (this.orgUserDao.queryOne(con, orgId)!= null)){
607
			throw new JfwBaseException(2, "该企业已注册科袖账号");
630
			throw new JfwBaseException(2, "该企业已注册科袖账号");
608
		}
631
		}
609
		try {
632
		try {
610
			User user = new User();
611
			user.setEmail(sc.getCode());
633
			OrgUser orgUser = new OrgUser();
634
			orgUser.setEmail(sc.getCode());
612
			if(orgId != null){
635
			if(orgId != null){
613
				user.setId(orgId);
636
				orgUser.setId(orgId);
614
			}else{
637
			}else{
615
				user.setId(this.orgService.createOrganization(con, sc.getValue()));
638
				orgUser.setId(this.orgService.createOrganization(con, sc.getValue()));
616
			}
639
			}
617
			user.setSendMailStatus(0);
618
			user.setPasswd(StringUtil.md5(sc.getKey()));
619
			user.setUserType("1");
620
			user.setActiveTime(DATE.format(new Date()));
621
			this.userDao.insert(con, user);
622
			this.orgDao.updateIsJoin(con, user.getId(), "1");
640
			orgUser.setPasswd(StringUtil.md5(sc.getKey()));
641
			orgUser.setUserType("1");
642
			this.orgUserDao.insert(con, orgUser);
643
			this.orgDao.updateIsJoin(con, orgUser.getId(), "1");
623
			con.commit();
644
			con.commit();
624
		} catch (SQLException e) {
645
		} catch (SQLException e) {
625
			try {
646
			try {
647
	@Post
668
	@Post
648
	@Path("/regOrgMail")
669
	@Path("/regOrgMail")
649
	public void regOrgMail(@JdbcConn(false) Connection con,String orgName,String mail,String password)throws JfwBaseException, SQLException {
670
	public void regOrgMail(@JdbcConn(false) Connection con,String orgName,String mail,String password)throws JfwBaseException, SQLException {
650
		User user = this.userDao.queryByEmailOrMobilePhone(con, mail);
651
		if (null != user) {
671
		OrgUser orgUser = this.orgUserDao.queryByEmail(con, mail);
672
		if (null != orgUser) {
652
			throw new JfwBaseException(-1, "邮箱[" + mail + "]已被注册过了");
673
			throw new JfwBaseException(-1, "邮箱[" + mail + "]已被注册过了");
653
		} else {
674
		} else {
654
675
776
		return ret;
797
		return ret;
777
	}
798
	}
778
	
799
	
779
	@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userType=result.getType()",
780
			"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
781
			"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")","userAuthStatus=result.getAuthStatus()"})
800
	@SetCookie(checkResultNull = true, path = "/", value = { "orgId=result.getId()", "orgType=result.getType()",
801
			"orgAuth=String.valueOf(result.isAuth())", "orgEmail=result.getEmail()==null?\"\":result.getEmail()",
802
			"orgName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
782
	@Post
803
	@Post
783
	@Path("/orgLogin")
804
	@Path("/orgLogin")
784
	public SessionUser orgLogin(@JdbcConn Connection con, String lk, String pw) throws SQLException, JfwBaseException {
805
	public SessionUser orgLogin(@JdbcConn Connection con, String lk, String pw) throws SQLException, JfwBaseException {
785
		User user = userDao.queryByEmailOrMobilePhone(con, lk);
786
		if (null == user)
806
		OrgUser orgUser = this.orgUserDao.queryByEmail(con, lk);
807
		if (null == orgUser)
787
			throw new JfwBaseException(-1, "该用户还未注册");
808
			throw new JfwBaseException(-1, "该用户还未注册");
788
		if (!StringUtil.md5(pw).equals(user.getPasswd()))
809
		if (!StringUtil.md5(pw).equals(orgUser.getPasswd()))
789
			return null;
810
			return null;
790
811
791
		SessionUser ret = new SessionUser();
812
		SessionUser ret = new SessionUser();
792
		ret.setId(user.getId());
793
		Organization org = this.orgDao.query(con, user.getId());
813
		ret.setId(orgUser.getId());
814
		Organization org = this.orgDao.query(con, orgUser.getId());
794
		if(org != null){
815
		if(org != null){
795
			ret.setName(org.getName());
816
			ret.setName(org.getName());
796
		}
817
		}
797
		ret.setAuthStatus(org.getAuthStatus());
798
		ret.setType(user.getUserType());
799
		ret.setEmail(user.getEmail());
818
		ret.setType(orgUser.getUserType());
819
		ret.setEmail(orgUser.getEmail());
800
		ret.setAuth(true);
820
		ret.setAuth(true);
801
		return ret;
821
		return ret;
802
	}
822
	}