Browse Source

咨询页面查询当前咨询有几条未读消息。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
978a6b8b71

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

@ -1,6 +1,8 @@
1 1
package com.ekexiu.portal.dao;
2 2

3 3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
4 6
import java.sql.SQLException;
5 7

6 8
import org.jfw.apt.orm.annotation.dao.DAO;
@ -14,6 +16,25 @@ public abstract class TidingsDao {
14 16
	@Insert
15 17
	public abstract int insert(Connection con, Tidings tidings) throws SQLException;
16 18
	
19
	/**
20
	 * 查询未查看信息条数的接口 
21
	 * @param con
22
	 * @param consultId 咨询ID
23
	 * @param senderId 登录者ID
24
	 * @return 返回该咨询中对方发送过来未查看的信息条数
25
	 * @throws SQLException
26
	 */
27
	public int queryNotReadTidings(Connection con, String consultId, String senderId) throws SQLException {
28
		String sql = " SELECT COUNT(1) FROM TIDINGS WHERE READ_STATUS = 0 AND CONSULT_ID = ? AND SENDER_ID != ? ";
29
		PreparedStatement ps = con.prepareStatement(sql);
30
		ps.setString(1, consultId);
31
		ps.setString(2, senderId);
32
		ResultSet rs = ps.executeQuery();
33
		rs.next();
34
		int count = rs.getInt(1);
35
		return count;
36
	}
37
	
17 38
	public com.ekexiu.portal.po.Tidings query(java.sql.Connection con,java.lang.String tidingsId) throws java.sql.SQLException{
18 39
        int _m_1 = 1;
19 40
        String sql = "SELECT TIDINGS_ID,TIDINGS_CONTANT,SENDER_ID,CONSULT_ID,TIDINGS.CREATE_TIME,PROFESSOR.NAME FROM TIDINGS LEFT JOIN PROFESSOR ON SENDER_ID = PROFESSOR.ID WHERE TIDINGS_ID = ?";

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

@ -3,6 +3,7 @@ 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;
6 7
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
7 8
import org.jfw.apt.orm.core.enums.DE;
8 9

@ -16,6 +17,7 @@ public class Tidings implements CreateTimeSupported {
16 17
	private String senderId;
17 18
	private String consultId;
18 19
	private String createTime;
20
	private int readStatus;
19 21
	private Professor professor;
20 22
	private Consult consult;
21 23
	
@ -72,4 +74,12 @@ public class Tidings implements CreateTimeSupported {
72 74
		this.createTime = createTime;
73 75
	}
74 76
	
77
	@Column(handlerClass=IntHandler.class,dbType="INT",nullable=false,insertable=false,renewable=true,queryable=true)
78
	public int getReadStatus() {
79
		return readStatus;
80
	}
81
	public void setReadStatus(int readStatus) {
82
		this.readStatus = readStatus;
83
	}
84
	
75 85
}

+ 6 - 0
src/main/java/com/ekexiu/portal/service/TidingsService.java

@ -47,6 +47,12 @@ public class TidingsService {
47 47
		return tidingsId;
48 48
	}
49 49
	
50
	@Get
51
	@Path("/qaNotReadTidings")
52
	public int queryNotReadTidings(@JdbcConn Connection con, String consultId, String senderId) throws SQLException {
53
		return this.tidingsDao.queryNotReadTidings(con, consultId, senderId);
54
	}
55
	
50 56
	@Get
51 57
	@Path("/{tidingsId}")
52 58
	public Tidings query(@JdbcConn Connection con, @PathVar String tidingsId) throws SQLException {