|
@ -1,7 +1,10 @@
|
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;
|
|
7
|
import java.util.ArrayList;
|
5
|
8
|
import java.util.List;
|
6
|
9
|
|
7
|
10
|
import org.jfw.apt.annotation.Nullable;
|
|
@ -14,7 +17,6 @@ import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
|
14
|
17
|
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
|
15
|
18
|
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
|
16
|
19
|
import org.jfw.apt.orm.annotation.dao.method.operator.QueryOne;
|
17
|
|
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
|
18
|
20
|
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
|
19
|
21
|
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
|
20
|
22
|
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
|
|
@ -23,12 +25,12 @@ import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
|
23
|
25
|
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
|
24
|
26
|
import org.jfw.util.PageQueryResult;
|
25
|
27
|
|
|
28
|
import com.ekexiu.portal.po.Organization;
|
26
|
29
|
import com.ekexiu.portal.po.Professor;
|
27
|
30
|
import com.ekexiu.portal.pojo.ProfessorInfo;
|
28
|
31
|
|
29
|
32
|
@DAO
|
30
|
33
|
public abstract class ProfessorDao {
|
31
|
|
|
32
|
34
|
@Insert
|
33
|
35
|
public abstract int insert(Connection con, Professor professor) throws SQLException;
|
34
|
36
|
|
|
@ -46,14 +48,70 @@ public abstract class ProfessorDao {
|
46
|
48
|
@UpdateWith
|
47
|
49
|
@From(Professor.class)
|
48
|
50
|
public abstract int updateIndustry(Connection con, String id, @Set String industry) throws SQLException;
|
49
|
|
|
|
51
|
|
|
52
|
@UpdateWith
|
|
53
|
@From(Professor.class)
|
|
54
|
public abstract int updateAddress(Connection con, String id, @Set String address) throws SQLException;
|
|
55
|
|
50
|
56
|
@Nullable
|
51
|
57
|
@SelectOne
|
52
|
58
|
public abstract Professor query(Connection con, String id) throws SQLException;
|
53
|
59
|
|
54
|
|
@SelectList
|
55
|
|
public abstract List<Professor> query(Connection con) throws SQLException;
|
56
|
|
|
|
60
|
|
|
61
|
|
|
62
|
|
|
63
|
public List<Professor> query(Connection con) throws SQLException{
|
|
64
|
String sql = "SELECT OFFICE,SUBJECT,INDUSTRY,ADDRESS,DEPARTMENT,ORG_ID,organization.NAME AS ONAME,TITLE,AUTHENTICATION,professor.ID,professor.NAME,professor.DESCP,professor.CREATE_TIME,professor.MODIFY_TIME FROM PROFESSOR LEFT JOIN ORGANIZATION ON professor.ORG_ID=organization.ID ORDER BY ONAME";
|
|
65
|
PreparedStatement ps = con.prepareStatement(sql);
|
|
66
|
try{
|
|
67
|
ResultSet rs = ps.executeQuery();
|
|
68
|
try{
|
|
69
|
List<Professor> _result = new ArrayList<Professor>();
|
|
70
|
while(rs.next()){
|
|
71
|
Professor _obj = new Professor();
|
|
72
|
String _m_1 = rs.getString(1);
|
|
73
|
if(rs.wasNull()){
|
|
74
|
_m_1 = null;
|
|
75
|
}
|
|
76
|
_obj.setOffice(_m_1);
|
|
77
|
String _m_2 = rs.getString(2);
|
|
78
|
if(rs.wasNull()){
|
|
79
|
_m_2 = null;
|
|
80
|
}
|
|
81
|
_obj.setSubject(_m_2);
|
|
82
|
String _m_3 = rs.getString(3);
|
|
83
|
if(rs.wasNull()){
|
|
84
|
_m_3 = null;
|
|
85
|
}
|
|
86
|
_obj.setIndustry(_m_3);
|
|
87
|
_obj.setAddress(rs.getString(4));
|
|
88
|
_obj.setDepartment(rs.getString(5));
|
|
89
|
Organization organization = new Organization();
|
|
90
|
organization.setId(rs.getString(6));
|
|
91
|
organization.setName(rs.getString(7));
|
|
92
|
_obj.setOrganization(organization);
|
|
93
|
_obj.setTitle(rs.getString(8));
|
|
94
|
_obj.setAuthentication("1".equals(rs.getString(9)));
|
|
95
|
_obj.setId(rs.getString(10));
|
|
96
|
_obj.setName(rs.getString(11));
|
|
97
|
String _m_4 = rs.getString(12);
|
|
98
|
if(rs.wasNull()){
|
|
99
|
_m_4 = null;
|
|
100
|
}
|
|
101
|
_obj.setDescp(_m_4);
|
|
102
|
_obj.setCreateTime(rs.getString(13));
|
|
103
|
_obj.setModifyTime(rs.getString(14));
|
|
104
|
_result.add(_obj);
|
|
105
|
}
|
|
106
|
return _result;
|
|
107
|
}finally{
|
|
108
|
try{rs.close();}catch(Exception _m_5){}
|
|
109
|
}
|
|
110
|
}finally{
|
|
111
|
try{ps.close();}catch(Exception _m_6){}
|
|
112
|
}
|
|
113
|
}
|
|
114
|
|
57
|
115
|
@Nullable
|
58
|
116
|
@QueryOne
|
59
|
117
|
@From(Professor.class)
|
|
@ -140,10 +198,11 @@ public abstract class ProfessorDao {
|
140
|
198
|
if (1 == pageNo) {
|
141
|
199
|
_result.setPageNo(1);
|
142
|
200
|
sql = new StringBuilder();
|
143
|
|
sql.append("SELECT OFFICE,SUBJECT,INDUSTRY,DEPARTMENT,ORG_ID,TITLE,AUTHENTICATION,ID,NAME,DESCP,CREATE_TIME,MODIFY_TIME FROM PROFESSOR");
|
|
201
|
sql.append("SELECT OFFICE,SUBJECT,INDUSTRY,ADDRESS,DEPARTMENT,ORG_ID,organization.NAME AS ONAME,TITLE,AUTHENTICATION,professor.ID,professor.NAME,professor.DESCP,professor.CREATE_TIME,professor.MODIFY_TIME FROM PROFESSOR LEFT JOIN ORGANIZATION ON professor.ORG_ID=organization.ID ORDER BY ONAME");
|
144
|
202
|
if (whereSql.length() > 0) {
|
145
|
203
|
sql.append(whereSql);
|
146
|
204
|
}
|
|
205
|
sql.append(" ORDER BY ONAME");
|
147
|
206
|
sql.append(" LIMIT ").append(pageSize);
|
148
|
207
|
} else {
|
149
|
208
|
int _pageSize = totalSize / pageSize;
|
|
@ -157,11 +216,11 @@ public abstract class ProfessorDao {
|
157
|
216
|
--pageNo;
|
158
|
217
|
int _m_10 = (pageNo * pageSize);
|
159
|
218
|
sql = new StringBuilder();
|
160
|
|
sql.append("SELECT OFFICE,SUBJECT,INDUSTRY,DEPARTMENT,ORG_ID,TITLE,AUTHENTICATION,ID,NAME,DESCP,CREATE_TIME,MODIFY_TIME FROM PROFESSOR");
|
|
219
|
sql.append("SELECT OFFICE,SUBJECT,INDUSTRY,ADDRESS,DEPARTMENT,ORG_ID,organization.NAME AS ONAME,TITLE,AUTHENTICATION,professor.ID,professor.NAME,professor.DESCP,professor.CREATE_TIME,professor.MODIFY_TIME FROM PROFESSOR LEFT JOIN ORGANIZATION ON professor.ORG_ID=organization.ID ORDER BY ONAME");
|
161
|
220
|
if (whereSql.length() > 0) {
|
162
|
221
|
sql.append(whereSql);
|
163
|
222
|
}
|
164
|
|
sql.append(" ORDER BY ID");
|
|
223
|
sql.append(" ORDER BY ONAME");
|
165
|
224
|
sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(_m_10);
|
166
|
225
|
}
|
167
|
226
|
ps = con.prepareStatement(sql.toString());
|