|
@ -8,11 +8,14 @@ import org.jfw.apt.web.annotation.param.JdbcConn;
|
8
|
8
|
import org.jfw.util.PageQueryResult;
|
9
|
9
|
import org.jfw.util.jdbc.JdbcUtil;
|
10
|
10
|
import org.jfw.util.jdbc.PreparedStatementConfig;
|
|
11
|
import org.jfw.util.jdbc.ResultSetExtractor;
|
11
|
12
|
|
12
|
13
|
import java.sql.Connection;
|
13
|
14
|
import java.sql.PreparedStatement;
|
|
15
|
import java.sql.ResultSet;
|
14
|
16
|
import java.sql.SQLException;
|
15
|
17
|
import java.util.ArrayList;
|
|
18
|
import java.util.HashMap;
|
16
|
19
|
import java.util.List;
|
17
|
20
|
import java.util.Map;
|
18
|
21
|
|
|
@ -47,8 +50,43 @@ public class DepartmentService {
|
47
|
50
|
|
48
|
51
|
@Path("/hospital")
|
49
|
52
|
@Get
|
50
|
|
public PageQueryResult<Department> pqgeQuery(@JdbcConn Connection con,@Nullable Boolean active,String hospital,int pageSize,int pageNo)throws SQLException {
|
51
|
|
return departmentDao.pageQuery(con, hospital, active, pageSize, pageNo);
|
|
53
|
public List<Department> listQuery(@JdbcConn Connection con, @Nullable Boolean active, String hospital) throws SQLException {
|
|
54
|
return departmentDao.listQuery(con, hospital, active);
|
|
55
|
}
|
|
56
|
|
|
57
|
@Path("/classify")
|
|
58
|
@Get
|
|
59
|
public List<Map<String, Object>> classify(@JdbcConn Connection con, final Boolean active, String hospital) throws SQLException {
|
|
60
|
final String finalkey = hospital;
|
|
61
|
List<Map<String, Object>> result = JdbcUtil.queryList(con, "select id,name,type from department where hospital = ? and active = ?", new ResultSetExtractor<Map<String, Object>>() {
|
|
62
|
@Override
|
|
63
|
public Map<String, Object> extractData(ResultSet resultSet) throws SQLException {
|
|
64
|
Map<String, Object> map = new HashMap<>();
|
|
65
|
map.put("id", resultSet.getInt(1));
|
|
66
|
map.put("name", resultSet.getInt(2));
|
|
67
|
map.put("type", resultSet.getInt(3));
|
|
68
|
return map;
|
|
69
|
}
|
|
70
|
}, new PreparedStatementConfig() {
|
|
71
|
@Override
|
|
72
|
public void config(PreparedStatement preparedStatement) throws SQLException {
|
|
73
|
preparedStatement.setString(1, finalkey);
|
|
74
|
preparedStatement.setBoolean(2, active);
|
|
75
|
}
|
|
76
|
});
|
|
77
|
|
|
78
|
for (Map<String, Object> map : result) {
|
|
79
|
final String id = (String) map.get("id");
|
|
80
|
map.put("num", JdbcUtil.queryInt(con, "select count(*) from doctor where hospital = ? and department = ? and active = ?", new PreparedStatementConfig() {
|
|
81
|
@Override
|
|
82
|
public void config(PreparedStatement preparedStatement) throws SQLException {
|
|
83
|
preparedStatement.setString(1, finalkey);
|
|
84
|
preparedStatement.setString(2, id);
|
|
85
|
preparedStatement.setBoolean(3, active);
|
|
86
|
}
|
|
87
|
}, 0));
|
|
88
|
}
|
|
89
|
return result;
|
52
|
90
|
}
|
53
|
91
|
|
54
|
92
|
@Path("/name")
|