|
@ -10,9 +10,15 @@ import org.jfw.apt.web.annotation.operate.Post;
|
10
|
10
|
import org.jfw.apt.web.annotation.param.JdbcConn;
|
11
|
11
|
import org.jfw.util.PageQueryResult;
|
12
|
12
|
import org.jfw.util.StringUtil;
|
|
13
|
import org.jfw.util.jdbc.JdbcUtil;
|
|
14
|
import org.jfw.util.jdbc.PreparedStatementConfig;
|
13
|
15
|
|
14
|
16
|
import java.sql.Connection;
|
|
17
|
import java.sql.PreparedStatement;
|
15
|
18
|
import java.sql.SQLException;
|
|
19
|
import java.util.ArrayList;
|
|
20
|
import java.util.List;
|
|
21
|
import java.util.Map;
|
16
|
22
|
|
17
|
23
|
/**
|
18
|
24
|
* Created by TT on 2019/5/30.
|
|
@ -65,14 +71,61 @@ public class DepartmentService {
|
65
|
71
|
|
66
|
72
|
@Path("/pq")
|
67
|
73
|
@Get
|
68
|
|
public PageQueryResult<Department> pageQuery(@JdbcConn Connection con,@LoginUser SessionUser user, @Nullable Boolean active, @Nullable String name, int pageSize, int pageNo) throws SQLException {
|
69
|
|
return departmentDao.pageQuery(con,user.getId(), active, name == null ? null : "%" + name + "%", pageSize, pageNo);
|
|
74
|
public PageQueryResult<Department> pageQuery(@JdbcConn Connection con, @LoginUser SessionUser user, @Nullable Boolean active, @Nullable String name, int pageSize, int pageNo) throws SQLException {
|
|
75
|
return departmentDao.pageQuery(con, user.getId(), active, name == null ? null : "%" + name + "%", pageSize, pageNo);
|
70
|
76
|
}
|
71
|
77
|
|
72
|
78
|
@Path("/checkName")
|
73
|
79
|
@Get
|
74
|
|
public Department queryByName(@JdbcConn Connection con,@LoginUser SessionUser user, String name)throws SQLException {
|
|
80
|
public Department queryByName(@JdbcConn Connection con, @LoginUser SessionUser user, String name) throws SQLException {
|
75
|
81
|
return departmentDao.queryByName(con, user.getId(), name);
|
76
|
82
|
}
|
77
|
83
|
|
|
84
|
@Path("/name")
|
|
85
|
@Get
|
|
86
|
public List<TypeaheadItem> queryName(@JdbcConn Connection con, String name, int size) throws SQLException {
|
|
87
|
if (name != null) {
|
|
88
|
name = "%" + name + "%";
|
|
89
|
}
|
|
90
|
List<TypeaheadItem> ret = new ArrayList<>(size);
|
|
91
|
final String finalKey = name;
|
|
92
|
List<Map<String, Object>> typehead = JdbcUtil.queryMaps(con, "SELECT NAME,ID FROM DEPARTMENT WHERE NAME LIKE ? ", new PreparedStatementConfig() {
|
|
93
|
@Override
|
|
94
|
public void config(PreparedStatement preparedStatement) throws SQLException {
|
|
95
|
preparedStatement.setString(1, finalKey);
|
|
96
|
}
|
|
97
|
});
|
|
98
|
|
|
99
|
for (Map<String, Object> map : typehead) {
|
|
100
|
TypeaheadItem item = new TypeaheadItem();
|
|
101
|
item.setId((String) map.get("id"));
|
|
102
|
item.setName((String) map.get("name"));
|
|
103
|
ret.add(item);
|
|
104
|
}
|
|
105
|
return ret;
|
|
106
|
}
|
|
107
|
|
|
108
|
|
|
109
|
public static class TypeaheadItem {
|
|
110
|
private String id;
|
|
111
|
private String name;
|
|
112
|
|
|
113
|
public String getId() {
|
|
114
|
return id;
|
|
115
|
}
|
|
116
|
|
|
117
|
public void setId(String id) {
|
|
118
|
this.id = id;
|
|
119
|
}
|
|
120
|
|
|
121
|
public String getName() {
|
|
122
|
return name;
|
|
123
|
}
|
|
124
|
|
|
125
|
public void setName(String name) {
|
|
126
|
this.name = name;
|
|
127
|
}
|
|
128
|
|
|
129
|
}
|
|
130
|
|
78
|
131
|
}
|