Browse Source

专家合作历史及评价接口,注册验证相关的接口添加验证失败的提示信息。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
533663ec12

+ 91 - 0
src/main/java/com/ekexiu/portal/dao/ConsultDao.java

@ -133,6 +133,97 @@ public abstract class ConsultDao {
133 133
        }
134 134
	}
135 135
	
136
	/**
137
	 * 查询专家合作历史及评价接口
138
	 * @param con
139
	 * @param professorId 专家ID
140
	 * @param pageSize
141
	 * @param pageNo
142
	 * @return 返回所有已评价的咨询及评价详情
143
	 * @throws SQLException
144
	 */
145
	public PageQueryResult<Consult> queryAssessHis(Connection con,String professorId,int pageSize,int pageNo) throws SQLException{
146
        int _m_1 = 0;
147
        PageQueryResult<Consult> _result = new PageQueryResult<Consult>();
148
        int _m_2 = 1;
149
        String sql = null;
150
        sql = "  WHERE PROFESSOR_ID = ? AND ASSESS_STATUS = 1 ";
151
        String _m_3 = sql;
152
        sql = "SELECT COUNT(1) FROM CONSULT";
153
        sql = sql + _m_3;
154
        PreparedStatement ps = con.prepareStatement(sql);
155
        try{
156
            ps.setString(_m_2++,professorId);
157
            _result.setPageSize(pageSize);
158
            ResultSet _pageRs = ps.executeQuery();
159
            try{
160
                _pageRs.next();
161
                _m_1 = _pageRs.getInt(1);
162
            }finally{
163
                try{_pageRs.close();}catch(Exception _m_4){}
164
            }
165
        }finally{
166
            try{ps.close();}catch(Exception _m_5){}
167
        }
168
        _result.setTotal(_m_1);
169
        if(0== _m_1){
170
            _result.setPageNo(1);
171
            _result.setData(java.util.Collections.<Consult>emptyList());
172
            return _result;
173
        }
174
        _m_2 = 1;
175
        boolean _m_6 = (1 == pageNo);
176
        if(_m_6){
177
            _result.setPageNo(1);
178
            sql = "SELECT CONSULT_ID,CONSULT_TITLE,CONSULTANT_ID,ASSESS_STAR,ASSESS_CONTANT,ASSESS_TIME,CREATE_TIME FROM CONSULT";
179
            sql = sql + _m_3;
180
            sql = sql + " ORDER BY ASSESS_TIME DESC ";
181
            sql = sql + " LIMIT " + pageSize;
182
        }else{
183
            int _m_7 = _m_1 / pageSize;
184
            if(_m_1 % pageSize != 0){
185
                ++_m_7;
186
            }
187
            if(pageNo > _m_7){
188
                pageNo = _m_7;
189
            }
190
            _result.setPageNo(pageNo);
191
            --pageNo;
192
            int _m_8 = (pageNo * pageSize);
193
            sql = "SELECT CONSULT_ID,CONSULT_TITLE,CONSULTANT_ID,ASSESS_STAR,ASSESS_CONTANT,ASSESS_TIME,CREATE_TIME FROM CONSULT";
194
            sql = sql + _m_3;
195
            sql = sql + " ORDER BY ASSESS_TIME DESC ";
196
            sql = sql + " LIMIT " + pageSize+ " OFFSET "+_m_8;
197
        }
198
        ps = con.prepareStatement(sql);
199
        try{
200
            ps.setString(_m_2++,professorId);
201
            ResultSet rs = ps.executeQuery();
202
            try{
203
                java.util.List<Consult> _m_9 = new java.util.ArrayList<Consult>();
204
                _result.setData(_m_9);
205
                int _m_10 = 0;
206
                while((_m_10<pageSize) && rs.next()){
207
                    ++_m_10;
208
                    Consult consult =  new Consult();
209
                    consult.setConsultId(rs.getString(1));
210
                    consult.setConsultTitle(rs.getString(2));
211
                    consult.setConsultantId(rs.getString(3));
212
                    consult.setAssessStar(rs.getInt(4));
213
                    consult.setAssessContant(rs.getString(5));
214
                    consult.setAssessTime(rs.getString(6));
215
                    consult.setCreateTime(rs.getString(7));
216
                    _m_9.add(consult);
217
                }
218
                return _result;
219
            }finally{
220
                try{rs.close();}catch(Exception _m_11){}
221
            }
222
        }finally{
223
            try{ps.close();}catch(Exception _m_12){}
224
        }
225
    }
226
	
136 227
	@SelectOne
137 228
	@Nullable
138 229
	public abstract Consult query(Connection con, String consultId) throws SQLException;

+ 5 - 5
src/main/java/com/ekexiu/portal/po/Tidings.java

@ -3,8 +3,8 @@ package com.ekexiu.portal.po;
3 3
import org.jfw.apt.orm.annotation.entry.Column;
4 4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5 5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
7 6
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
7
import org.jfw.apt.orm.core.defaultImpl.WIntHandler;
8 8
import org.jfw.apt.orm.core.enums.DE;
9 9

10 10
import com.ekexiu.portal.basepo.CreateTimeSupported;
@ -17,7 +17,7 @@ public class Tidings implements CreateTimeSupported {
17 17
	private String senderId;
18 18
	private String consultId;
19 19
	private String createTime;
20
	private int readStatus;
20
	private Integer readStatus;
21 21
	private Professor professor;
22 22
	private Consult consult;
23 23
	
@ -74,11 +74,11 @@ public class Tidings implements CreateTimeSupported {
74 74
		this.createTime = createTime;
75 75
	}
76 76
	
77
	@Column(handlerClass=IntHandler.class,dbType="INT",nullable=false,insertable=false,renewable=true,queryable=true)
78
	public int getReadStatus() {
77
	@Column(handlerClass=WIntHandler.class,dbType="INT",nullable=false,insertable=false,renewable=true,queryable=true)
78
	public Integer getReadStatus() {
79 79
		return readStatus;
80 80
	}
81
	public void setReadStatus(int readStatus) {
81
	public void setReadStatus(Integer readStatus) {
82 82
		this.readStatus = readStatus;
83 83
	}
84 84
	

+ 15 - 0
src/main/java/com/ekexiu/portal/service/ConsultService.java

@ -99,6 +99,21 @@ public class ConsultService {
99 99
		return false;
100 100
	}
101 101
	
102
	@Get
103
	@Path("/pqAssessHis")
104
	public PageQueryResult<Consult> queryAssessHis(@JdbcConn Connection con, String professorId,@DefaultValue("5") int pageSize,@DefaultValue("1") int pageNo) throws SQLException {
105
		PageQueryResult<Consult> queryResult = this.consultDao.queryAssessHis(con, professorId, pageSize, pageNo);
106
		List<Consult> consults = queryResult.getData();
107
		if(consults != null){
108
			for (Consult consult : consults) {
109
				EditProfessor professor = this.professorDao.queryBaseInfo(con, consult.getConsultantId());
110
				professor.setHasHeadImage(this.imageService.hasProfessorImage(consult.getConsultantId()));
111
				consult.setProfessor(professor);
112
			}
113
		}
114
		return queryResult;
115
	}
116
	
102 117
	@Get
103 118
	@Path("/qaReadStatus")
104 119
	public int queryReadStatus(@JdbcConn Connection con, String professorId) throws SQLException {

+ 28 - 18
src/main/java/com/ekexiu/portal/service/SysService.java

@ -312,23 +312,30 @@ public class SysService {
312 312
	 *            注册密码
313 313
	 * @return
314 314
	 * @throws SQLException
315
	 * @throws JfwBaseException 
315 316
	 */
316 317
	@Post
317 318
	@Path("/regmobile")
318 319
	public String regMobile(@JdbcConn(true) Connection con, String state,
319 320
			String mobilePhone, String validateCode, String password)
320
			throws SQLException {
321
			throws SQLException, JfwBaseException {
321 322
		@SuppressWarnings("unchecked")
322 323
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
323 324
				.getCachedObject(state);
324 325
		if (sc == null)
325
			return null;
326
			return "state码错误!";
327
//			throw new JfwBaseException("state码错误!");
326 328
		if (sc.getExpiredTime() < System.currentTimeMillis())
327
			return null;
329
			return "验证超时!";
330
//			throw new JfwBaseException("验证超时!");
328 331
		try {
329
			if (!sc.getKey().equals(mobilePhone)
330
					|| !sc.getValue().equals(validateCode)) {
331
				return null;
332
			if (!sc.getKey().equals(mobilePhone)) {
333
				return "手机号与验证手机不匹配!";
334
//				throw new JfwBaseException("手机号与验证手机不匹配!");
335
			}
336
			if (!sc.getValue().equals(validateCode)) {
337
				return "验证码错误!";
338
//				throw new JfwBaseException("验证码错误!");
332 339
			}
333 340
			User user = new User();
334 341
			user.setId(StringUtil.buildUUID());
@ -353,6 +360,7 @@ public class SysService {
353 360
	 *            验证的邮箱地址
354 361
	 * @return 验证成功 用户登录并返回用户信息 验证失败返回null
355 362
	 * @throws SQLException
363
	 * @throws JfwBaseException 
356 364
	 */
357 365
	@SetCookie(checkResultNull = true, path = "/", value = {
358 366
			"userid=result.getId()", "userMobilePhone=result.getMobilePhone()",
@ -364,17 +372,17 @@ public class SysService {
364 372
	@Post
365 373
	@Path("/regmail/{key}")
366 374
	public SessionUser regeMail(@JdbcConn(true) Connection con, @PathVar String key, String mail, 
367
			String userId) throws SQLException {
375
			String userId) throws SQLException, JfwBaseException {
368 376
		@SuppressWarnings("unchecked")
369 377
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
370 378
				.getCachedObject(key);
371 379
		if (sc == null) {
372 380
			this.userDao.delete(con, userId);
373
			return null;
381
			throw new JfwBaseException("state码错误!");
374 382
		}
375 383
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
376 384
			this.userDao.delete(con, userId);
377
			return null;
385
			throw new JfwBaseException("验证超时!");
378 386
		}
379 387
		try {
380 388
			User user = userDao.queryByEmailOrMobilePhone(con, mail);
@ -496,7 +504,7 @@ public class SysService {
496 504
			throws SQLException {
497 505
		User user = userDao.queryByEmailOrMobilePhone(con, lk);
498 506
		if (null == user)
499
			return null;
507
			throw new SQLException("该用户还未注册!");
500 508
		if (DEFAULT_PASS_WORD.equals(user.getPasswd()))
501 509
			return null;
502 510
		if (!StringUtil.md5(pw).equals(user.getPasswd()))
@ -574,7 +582,7 @@ public class SysService {
574 582
	@Get
575 583
	@Path("/bindMail/{key}")
576 584
	public boolean bindMail(@JdbcConn(true) Connection con, @PathVar String key)
577
			throws SQLException {
585
			throws SQLException, JfwBaseException {
578 586
		@SuppressWarnings("unchecked")
579 587
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
580 588
				.getCachedObject(key);
@ -599,7 +607,8 @@ public class SysService {
599 607
			return null;
600 608
		user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
601 609
		if (null != user)
602
			return null;
610
			return "该手机号已经绑定用户!";
611
//			throw new JfwBaseException("该手机号已经绑定用户!");
603 612
604 613
		StateCode<String, String> sc = new StateCode<String, String>();
605 614
@ -692,7 +701,7 @@ public class SysService {
692 701
	@Path("/bindMobilePhone")
693 702
	public boolean bindMobilePhone(@JdbcConn(true) Connection con,
694 703
			String state, String userid, String mobilePhone, String validateCode)
695
			throws SQLException {
704
			throws SQLException, JfwBaseException {
696 705
		@SuppressWarnings("unchecked")
697 706
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
698 707
				.getCachedObject(state);
@ -717,7 +726,8 @@ public class SysService {
717 726
718 727
		User user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
719 728
		if (null == user)
720
			return null;
729
			return "该手机号还未注册!";
730
//			throw new JfwBaseException("该手机号还未注册!");
721 731
722 732
		StateCode<String, String> sc = new StateCode<String, String>();
723 733
		final String key = JfwAppContext.cacheObjectAndGenKey(sc);
@ -758,10 +768,10 @@ public class SysService {
758 768
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
759 769
				.getCachedObject(state);
760 770
		if (sc == null) {
761
			throw new JfwBaseException("Verification state error(state码错误)!");
771
			throw new JfwBaseException("state码错误");
762 772
		}
763 773
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
764
			throw new JfwBaseException("Validation timeout(验证超时)!");
774
			throw new JfwBaseException("验证超时");
765 775
		}
766 776
		return sc.getValue().equals(vc);
767 777
	}
@ -769,7 +779,7 @@ public class SysService {
769 779
	@Post
770 780
	@Path("/resetPasswordWithMobilePhone")
771 781
	public boolean resetPassword(@JdbcConn(true) Connection con, String state,
772
			String mobilePhone, String pw, String vc) throws SQLException {
782
			String mobilePhone, String pw, String vc) throws SQLException, JfwBaseException {
773 783
		@SuppressWarnings("unchecked")
774 784
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
775 785
				.getCachedObject(state);
@ -842,7 +852,7 @@ public class SysService {
842 852
	@Post
843 853
	@Path("/resetPasswordWith")
844 854
	public boolean resetPassword(@JdbcConn(true) Connection con, String state,
845
			String pw) throws SQLException {
855
			String pw) throws SQLException, JfwBaseException {
846 856
		@SuppressWarnings("unchecked")
847 857
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
848 858
				.getCachedObject(state);