前端收到的是一个list,“a,b,c,d,e,f”这样,但是想要得到“字段名1:a,字段名2:b,字段名1:c 字段名1:d,字段名1:e,字段名1:f,”的结果,不知道怎么写,请各位大佬教教我
@POST
@Ok("json")
@At
@AdaptBy(type = JsonAdaptor.class)
@Filters
public Object check(@Param("projectId")String projectId, HttpServletResponse response) {
try {
log.info("查询成功");
Sql sql = Sqls.create("SELECT a.name,a.realname,b.name as projectName from sys_project_user c LEFT JOIN sys_user a on a.id = c.u_id LEFT JOIN sys_project b on b.id = c.p_id where b.id = @A");
sql.params().set("A", projectId);
sql.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
List<String> list = new LinkedList<String>();
while (rs.next()) {
list.add(rs.getString("name"));
list.add(rs.getString("realname"));
list.add(rs.getString("projectName"));
}
return list;
}
});
dao.execute(sql);
return sql.getObject(String.class);
} catch (Exception e) {
log.info("查询失败");
e.printStackTrace();
}
return Messager.instance(CommResultEnum.QUERY_FAIL).res();
}