Browse Source

咨询聊天接口。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
c2fd8e7825

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

@ -0,0 +1,49 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.DAO;
9
import org.jfw.apt.orm.annotation.dao.method.From;
10
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
11
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
12
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
13
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
14
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
15
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
16
import org.jfw.apt.orm.annotation.dao.param.Set;
17

18
import com.ekexiu.portal.po.Consult;
19

20
@DAO
21
public abstract class ConsultDao {
22
	@Insert
23
	public abstract int insert(Connection con, Consult consult) throws SQLException;
24
	
25
	@Update
26
	public abstract int update(Connection con, Consult consult) throws SQLException;
27
	
28
	@UpdateWith
29
	@From(Consult.class)
30
	public abstract int updateFinishTime(Connection con, String consultId, @Set String finishTime) throws SQLException;
31
	
32
	@UpdateWith
33
	@From(Consult.class)
34
	public abstract int updateRevoveryTime(Connection con, String consultId, @Set String revoveryTime) throws SQLException;
35
	
36
	@SelectOne
37
	@Nullable
38
	public abstract Consult query(Connection con, String consultId) throws SQLException;
39
	
40
	@SelectList
41
	@OrderBy(" ORDER BY CONSULT.CREATE_TIME DESC ")
42
	public abstract List<Consult> queryPro(Connection con, String professorId) throws SQLException;
43
	
44
	@SelectList
45
	@OrderBy(" ORDER BY CONSULT.CREATE_TIME DESC ")
46
	public abstract List<Consult> queryCon(Connection con, String consultantId) throws SQLException;
47
	
48
	
49
}

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

@ -0,0 +1,77 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
8

9
import com.ekexiu.portal.po.Professor;
10
import com.ekexiu.portal.po.Tidings;
11

12
@DAO
13
public abstract class TidingsDao {
14
	@Insert
15
	public abstract int insert(Connection con, Tidings tidings) throws SQLException;
16
	
17
	public com.ekexiu.portal.po.Tidings query(java.sql.Connection con,java.lang.String tidingsId) throws java.sql.SQLException{
18
        int _m_1 = 1;
19
        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 = ?";
20
        java.sql.PreparedStatement ps = con.prepareStatement(sql);
21
        try{
22
            ps.setString(_m_1++,tidingsId);
23
            java.sql.ResultSet rs = ps.executeQuery();
24
            try{
25
                if(rs.next()){
26
                    com.ekexiu.portal.po.Tidings _result = new com.ekexiu.portal.po.Tidings();
27
                    _result.setTidingsId(rs.getString(1));
28
                    _result.setTidingsContant(rs.getString(2));
29
                    Professor professor = new Professor();
30
                    professor.setId(rs.getString(3));
31
                    _result.setConsultId(rs.getString(4));
32
                    _result.setCreateTime(rs.getString(5));
33
                    professor.setName(rs.getString(6));
34
                    _result.setProfessor(professor);
35
                    return _result;
36
                }else{
37
                    return null;
38
                }
39
            }finally{
40
                try{rs.close();}catch(Exception _m_2){}
41
            }
42
        }finally{
43
            try{ps.close();}catch(Exception _m_3){}
44
        }
45
    }
46
	
47
	public java.util.List<com.ekexiu.portal.po.Tidings> queryCon(java.sql.Connection con,java.lang.String consultId) throws java.sql.SQLException{
48
        int _m_1 = 1;
49
        String sql = "SELECT TIDINGS_ID,TIDINGS_CONTANT,SENDER_ID,TIDINGS.CONSULT_ID,TIDINGS.CREATE_TIME,PROFESSOR.NAME FROM TIDINGS LEFT JOIN PROFESSOR ON SENDER_ID = PROFESSOR.ID WHERE TIDINGS.CONSULT_ID = ?";
50
        java.sql.PreparedStatement ps = con.prepareStatement(sql);
51
        try{
52
            ps.setString(_m_1++,consultId);
53
            java.sql.ResultSet rs = ps.executeQuery();
54
            try{
55
                java.util.List<com.ekexiu.portal.po.Tidings> _result = new java.util.ArrayList<com.ekexiu.portal.po.Tidings>();
56
                while(rs.next()){
57
                    com.ekexiu.portal.po.Tidings _obj =  new com.ekexiu.portal.po.Tidings();
58
                    _obj.setTidingsId(rs.getString(1));
59
                    _obj.setTidingsContant(rs.getString(2));
60
                    Professor professor = new Professor();
61
                    professor.setId(rs.getString(3));
62
                    _obj.setConsultId(rs.getString(4));
63
                    _obj.setCreateTime(rs.getString(5));
64
                    professor.setName(rs.getString(6));
65
                    _obj.setProfessor(professor);
66
                    _result.add(_obj);
67
                }
68
                return _result;
69
            }finally{
70
                try{rs.close();}catch(Exception _m_2){}
71
            }
72
        }finally{
73
            try{ps.close();}catch(Exception _m_3){}
74
        }
75
    }
76
	
77
}

+ 177 - 0
src/main/java/com/ekexiu/portal/po/Consult.java

@ -0,0 +1,177 @@
1
package com.ekexiu.portal.po;
2

3
import java.math.BigDecimal;
4

5
import org.jfw.apt.orm.annotation.entry.Column;
6
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
7
import org.jfw.apt.orm.annotation.entry.Table;
8
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
9
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
10
import org.jfw.apt.orm.core.enums.DE;
11

12
@PrimaryKey("consultId")
13
@Table
14
public class Consult {
15
	private String consultId;
16
	private String consultType;
17
	private String consultTitle;
18
	private String consultContant;
19
	private String createTime;
20
	private String professorId;
21
	private String consultantId;
22
	private int consultStatus;
23
	private String finishTime;
24
	private int assessStatus;
25
	private int assessStar;
26
	private String assessContant;
27
	private String assessTime;
28
	private int thanksStatus;
29
	private BigDecimal thanksMoney;
30
	private String thanksTime;
31
	private String revoveryTime;
32
	private Professor professor;
33
	
34
	public Professor getProfessor() {
35
		return professor;
36
	}
37
	public void setProfessor(Professor professor) {
38
		this.professor = professor;
39
	}
40
	
41
	@Column(DE.id_32)
42
	public String getConsultId() {
43
		return consultId;
44
	}
45
	public void setConsultId(String consultId) {
46
		this.consultId = consultId;
47
	}
48
	
49
	@Column(DE.string_de)
50
	public String getConsultType() {
51
		return consultType;
52
	}
53
	public void setConsultType(String consultType) {
54
		this.consultType = consultType;
55
	}
56
	
57
	@Column(DE.string_de)
58
	public String getConsultTitle() {
59
		return consultTitle;
60
	}
61
	public void setConsultTitle(String consultTitle) {
62
		this.consultTitle = consultTitle;
63
	}
64
	
65
	@Column(handlerClass=StringHandler.class,dbType="TEXT",nullable=false,insertable=true,renewable=false,queryable=true)
66
	public String getConsultContant() {
67
		return consultContant;
68
	}
69
	public void setConsultContant(String consultContant) {
70
		this.consultContant = consultContant;
71
	}
72
	
73
	@Column(handlerClass=StringHandler.class,dbType="VARCHAR",nullable=false,insertable=false,renewable=false,queryable=true)
74
	public String getCreateTime() {
75
		return createTime;
76
	}
77
	public void setCreateTime(String createTime) {
78
		this.createTime = createTime;
79
	}
80
	
81
	@Column(DE.id_32)
82
	public String getProfessorId() {
83
		return professorId;
84
	}
85
	public void setProfessorId(String professorId) {
86
		this.professorId = professorId;
87
	}
88
	
89
	@Column(DE.id_32)
90
	public String getConsultantId() {
91
		return consultantId;
92
	}
93
	public void setConsultantId(String consultantId) {
94
		this.consultantId = consultantId;
95
	}
96
	
97
	@Column(handlerClass=IntHandler.class,dbType="INT",nullable=true,insertable=true,renewable=true,queryable=true)
98
	public int getConsultStatus() {
99
		return consultStatus;
100
	}
101
	public void setConsultStatus(int consultStatus) {
102
		this.consultStatus = consultStatus;
103
	}
104
	
105
	@Column(handlerClass=StringHandler.class,dbType="VARCHAR",nullable=true,insertable=false,renewable=true,queryable=true)
106
	public String getFinishTime() {
107
		return finishTime;
108
	}
109
	public void setFinishTime(String finishTime) {
110
		this.finishTime = finishTime;
111
	}
112
	
113
	@Column(handlerClass=IntHandler.class,dbType="INT",nullable=true,insertable=true,renewable=true,queryable=true)
114
	public int getAssessStatus() {
115
		return assessStatus;
116
	}
117
	public void setAssessStatus(int assessStatus) {
118
		this.assessStatus = assessStatus;
119
	}
120
	
121
	@Column(handlerClass=IntHandler.class,dbType="INT",nullable=true,insertable=false,renewable=true,queryable=true)
122
	public int getAssessStar() {
123
		return assessStar;
124
	}
125
	public void setAssessStar(int assessStar) {
126
		this.assessStar = assessStar;
127
	}
128
	
129
	@Column(handlerClass=StringHandler.class,dbType="TEXT",nullable=true,insertable=false,renewable=true,queryable=true)
130
	public String getAssessContant() {
131
		return assessContant;
132
	}
133
	public void setAssessContant(String assessContant) {
134
		this.assessContant = assessContant;
135
	}
136
	
137
	@Column(handlerClass=StringHandler.class,dbType="VARCHAR", nullable=true,insertable=false,renewable=false,queryable=true)
138
	public String getAssessTime() {
139
		return assessTime;
140
	}
141
	public void setAssessTime(String assessTime) {
142
		this.assessTime = assessTime;
143
	}
144
	
145
	@Column(handlerClass=IntHandler.class,dbType="INT",nullable=true,insertable=true,renewable=true,queryable=true)
146
	public int getThanksStatus() {
147
		return thanksStatus;
148
	}
149
	public void setThanksStatus(int thanksStatus) {
150
		this.thanksStatus = thanksStatus;
151
	}
152
	
153
	@Column(DE.BigDecmimal_de)
154
	public BigDecimal getThanksMoney() {
155
		return thanksMoney;
156
	}
157
	public void setThanksMoney(BigDecimal thanksMoney) {
158
		this.thanksMoney = thanksMoney;
159
	}
160
	
161
	@Column(handlerClass=StringHandler.class,dbType="VARCHAR", nullable=true,insertable=false,renewable=true,queryable=true)
162
	public String getThanksTime() {
163
		return thanksTime;
164
	}
165
	public void setThanksTime(String thanksTime) {
166
		this.thanksTime = thanksTime;
167
	}
168
	
169
	@Column(handlerClass=StringHandler.class,dbType="VARCHAR", nullable=false,insertable=true,renewable=true,queryable=true)
170
	public String getRevoveryTime() {
171
		return revoveryTime;
172
	}
173
	public void setRevoveryTime(String revoveryTime) {
174
		this.revoveryTime = revoveryTime;
175
	}
176
	
177
}

+ 2 - 2
src/main/java/com/ekexiu/portal/po/Operation.java

@ -106,7 +106,7 @@ public class Operation {
106 106
		this.detailDemand = detailDemand;
107 107
	}
108 108
	
109
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(8)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDD')", fixSqlValueWithUpdate = "TO_CHAR(NOW(),'YYYYMMDD')", insertable = true, nullable = false, queryable = true, renewable = true)
109
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(8)", insertable = true, nullable = false, queryable = true, renewable = true)
110 110
	public String getDeliverTime() {
111 111
		return deliverTime;
112 112
	}
@ -130,7 +130,7 @@ public class Operation {
130 130
		this.dealPrice = dealPrice;
131 131
	}
132 132
	
133
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = false)
133
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithUpdate = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = false, nullable = true, queryable = true, renewable = true)
134 134
	public String getDealTime() {
135 135
		return dealTime;
136 136
	}

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

@ -0,0 +1,74 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
7
import org.jfw.apt.orm.core.enums.DE;
8

9
@PrimaryKey("tidingsId")
10
@Table
11
public class Tidings {
12
	private String tidingsId;
13
	private String tidingsContant;
14
	private String senderId;
15
	private String consultId;
16
	private String createTime;
17
	private Professor professor;
18
	private Consult consult;
19
	
20
	public Professor getProfessor() {
21
		return professor;
22
	}
23
	public void setProfessor(Professor professor) {
24
		this.professor = professor;
25
	}
26
	
27
	public Consult getConsult() {
28
		return consult;
29
	}
30
	public void setConsult(Consult consult) {
31
		this.consult = consult;
32
	}
33
	
34
	@Column(DE.id_32)
35
	public String getTidingsId() {
36
		return tidingsId;
37
	}
38
	public void setTidingsId(String tidingsId) {
39
		this.tidingsId = tidingsId;
40
	}
41
	
42
	@Column(handlerClass=StringHandler.class,dbType="TEXT",nullable=false,insertable=true,renewable=false,queryable=true)
43
	public String getTidingsContant() {
44
		return tidingsContant;
45
	}
46
	public void setTidingsContant(String tidingsContant) {
47
		this.tidingsContant = tidingsContant;
48
	}
49
	
50
	@Column(DE.id_32)
51
	public String getSenderId() {
52
		return senderId;
53
	}
54
	public void setSenderId(String senderId) {
55
		this.senderId = senderId;
56
	}
57
	
58
	@Column(DE.id_32)
59
	public String getConsultId() {
60
		return consultId;
61
	}
62
	public void setConsultId(String consultId) {
63
		this.consultId = consultId;
64
	}
65
	
66
	@Column(handlerClass=StringHandler.class,dbType="VARCHAR",nullable=false,insertable=false,renewable=false,queryable=true)
67
	public String getCreateTime() {
68
		return createTime;
69
	}
70
	public void setCreateTime(String createTime) {
71
		this.createTime = createTime;
72
	}
73
	
74
}

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

@ -0,0 +1,75 @@
1
package com.ekexiu.portal.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.text.SimpleDateFormat;
6
import java.util.Date;
7
import java.util.List;
8

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

18
import com.ekexiu.portal.dao.ConsultDao;
19
import com.ekexiu.portal.po.Consult;
20

21
@Path("/consult")
22
public class ConsultService {
23
	@Autowrie
24
	private ConsultDao consultDao;
25
	public ConsultDao getConsultDao() {
26
		return consultDao;
27
	}
28
	public void setConsultDao(ConsultDao consultDao) {
29
		this.consultDao = consultDao;
30
	}
31
	
32
	@Post
33
	@Path
34
	public String insert(@JdbcConn(true) Connection con, Consult consult) throws SQLException {
35
		String consultId = StringUtil.buildUUID();
36
		consult.setConsultId(consultId);
37
		String revoveryTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
38
		consult.setRevoveryTime(revoveryTime);
39
		this.consultDao.insert(con, consult);
40
		return consultId;
41
	}
42
	
43
	@Put
44
	@Path
45
	public void update(@JdbcConn(true) Connection con, Consult consult) throws SQLException {
46
		this.consultDao.update(con, consult);
47
	}
48
	
49
	@Post
50
	@Path("/finishTime")
51
	public void updateFinishTime(@JdbcConn(true) Connection con, String consultId, int consultStatus) throws SQLException {
52
		if(5 == consultStatus) {
53
			String finishTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
54
			this.consultDao.updateFinishTime(con, consultId, finishTime);
55
		}
56
	}
57
	
58
	@Get
59
	@Path("/{consultId}")
60
	public Consult query(@JdbcConn Connection con, @PathVar String consultId) throws SQLException {
61
		return this.consultDao.query(con, consultId);
62
	}
63
	
64
	@Get
65
	@Path("/qapro")
66
	public List<Consult> queryPro(@JdbcConn Connection con, String professorId) throws SQLException {
67
		return this.consultDao.queryPro(con, professorId);
68
	}
69
	
70
	@Get
71
	@Path("/qacon")
72
	public List<Consult> queryCon(@JdbcConn Connection con, String consultantId) throws SQLException {
73
		return this.consultDao.queryCon(con, consultantId);
74
	}
75
}

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

@ -0,0 +1,64 @@
1
package com.ekexiu.portal.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.text.SimpleDateFormat;
6
import java.util.Date;
7
import java.util.List;
8

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

17
import com.ekexiu.portal.dao.ConsultDao;
18
import com.ekexiu.portal.dao.TidingsDao;
19
import com.ekexiu.portal.po.Tidings;
20

21
@Path("/tidings")
22
public class TidingsService {
23
	@Autowrie
24
	private TidingsDao tidingsDao;
25
	@Autowrie
26
	private ConsultDao consultDao;
27
	
28
	public TidingsDao getTidingsDao() {
29
		return tidingsDao;
30
	}
31
	public void setTidingsDao(TidingsDao tidingsDao) {
32
		this.tidingsDao = tidingsDao;
33
	}
34
	public ConsultDao getConsultDao() {
35
		return consultDao;
36
	}
37
	public void setConsultDao(ConsultDao consultDao) {
38
		this.consultDao = consultDao;
39
	}
40
	
41
	@Post
42
	@Path
43
	public String insert(@JdbcConn(true) Connection con, Tidings tidings) throws SQLException {
44
		String tidingsId = StringUtil.buildUUID();
45
		tidings.setTidingsId(tidingsId);
46
		this.tidingsDao.insert(con, tidings);
47
		String consultId = tidings.getConsultId();
48
		String revoveryTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
49
		this.consultDao.updateRevoveryTime(con, consultId, revoveryTime);
50
		return tidingsId;
51
	}
52
	
53
	@Get
54
	@Path("/{tidingsId}")
55
	public Tidings query(@JdbcConn Connection con, @PathVar String tidingsId) throws SQLException {
56
		return this.tidingsDao.query(con, tidingsId);
57
	}
58
	
59
	@Get
60
	@Path("/qacon")
61
	public List<Tidings> queryCon(@JdbcConn Connection con, String consultId) throws SQLException {
62
		return this.tidingsDao.queryCon(con, consultId);
63
	}
64
}