@Test public void list() throws Exception { SearchQueryJS queryJs = new SearchQueryJS(); WMap query = new WMap(); queryJs.setQuery(query); String json = mapper.writeValueAsString(queryJs); MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/dict/type/unit").contentType(MediaType.APPLICATION_JSON).content(json)).andReturn(); int status = mvcResult.getResponse().getStatus(); String content = mvcResult.getResponse().getContentAsString(); System.out.println(status + "--" + content); }
@RequestMapping(value="list") public ActionResultObj list(@RequestBody SearchQueryJS queryJs){ ActionResultObj result = new ActionResultObj(); try{ Pager pager = queryJs.toPager(); WMap query = queryJs.getQuery(); Criteria cnd = Cnd.cri(); if(query.get("type") != null && StringUtil.isNotBlank(query.get("type").toString())){ cnd.where().andEquals("type", query.get("type").toString()); } cnd.getGroupBy().groupBy("type"); cnd.getOrderBy().desc("sort"); List<EDict> projectList = dictDao.query(cnd, pager); WMap map = new WMap(); if(queryJs.getQuery() != null){ map.putAll(queryJs.getQuery()); } map.put("data", projectList); map.put("page", queryJs.toWPage(pager)); result.ok(map); result.okMsg("查询成功！"); }catch(Exception e){ e.printStackTrace(); LOG.error("查询失败，原因："+e.getMessage()); result.error(e); } return result; }
DictController { @RequestMapping(value="list") public ActionResultObj list(@RequestBody SearchQueryJS queryJs){ ActionResultObj result = new ActionResultObj(); try{ Pager pager = queryJs.toPager(); WMap query = queryJs.getQuery(); Criteria cnd = Cnd.cri(); if(query.get("type") != null && StringUtil.isNotBlank(query.get("type").toString())){ cnd.where().andEquals("type", query.get("type").toString()); } cnd.getGroupBy().groupBy("type"); cnd.getOrderBy().desc("sort"); List<EDict> projectList = dictDao.query(cnd, pager); WMap map = new WMap(); if(queryJs.getQuery() != null){ map.putAll(queryJs.getQuery()); } map.put("data", projectList); map.put("page", queryJs.toWPage(pager)); result.ok(map); result.okMsg("查询成功！"); }catch(Exception e){ e.printStackTrace(); LOG.error("查询失败，原因："+e.getMessage()); result.error(e); } return result; } }
DictController { @RequestMapping(value="list") public ActionResultObj list(@RequestBody SearchQueryJS queryJs){ ActionResultObj result = new ActionResultObj(); try{ Pager pager = queryJs.toPager(); WMap query = queryJs.getQuery(); Criteria cnd = Cnd.cri(); if(query.get("type") != null && StringUtil.isNotBlank(query.get("type").toString())){ cnd.where().andEquals("type", query.get("type").toString()); } cnd.getGroupBy().groupBy("type"); cnd.getOrderBy().desc("sort"); List<EDict> projectList = dictDao.query(cnd, pager); WMap map = new WMap(); if(queryJs.getQuery() != null){ map.putAll(queryJs.getQuery()); } map.put("data", projectList); map.put("page", queryJs.toWPage(pager)); result.ok(map); result.okMsg("查询成功！"); }catch(Exception e){ e.printStackTrace(); LOG.error("查询失败，原因："+e.getMessage()); result.error(e); } return result; }  }
DictController { @RequestMapping(value="list") public ActionResultObj list(@RequestBody SearchQueryJS queryJs){ ActionResultObj result = new ActionResultObj(); try{ Pager pager = queryJs.toPager(); WMap query = queryJs.getQuery(); Criteria cnd = Cnd.cri(); if(query.get("type") != null && StringUtil.isNotBlank(query.get("type").toString())){ cnd.where().andEquals("type", query.get("type").toString()); } cnd.getGroupBy().groupBy("type"); cnd.getOrderBy().desc("sort"); List<EDict> projectList = dictDao.query(cnd, pager); WMap map = new WMap(); if(queryJs.getQuery() != null){ map.putAll(queryJs.getQuery()); } map.put("data", projectList); map.put("page", queryJs.toWPage(pager)); result.ok(map); result.okMsg("查询成功！"); }catch(Exception e){ e.printStackTrace(); LOG.error("查询失败，原因："+e.getMessage()); result.error(e); } return result; }  @RequestMapping(value="list") ActionResultObj list(@RequestBody SearchQueryJS queryJs); @RequestMapping(value="type/{type}") ActionResultObj findByType(@PathVariable String type); @RequestMapping(value="/{id}") ActionResultObj get(@PathVariable Long id); @RequestMapping(value="save") ActionResultObj save(@RequestBody EDict dict); @RequestMapping(value="delete") ActionResultObj delete(@RequestBody Long id); }
DictController { @RequestMapping(value="list") public ActionResultObj list(@RequestBody SearchQueryJS queryJs){ ActionResultObj result = new ActionResultObj(); try{ Pager pager = queryJs.toPager(); WMap query = queryJs.getQuery(); Criteria cnd = Cnd.cri(); if(query.get("type") != null && StringUtil.isNotBlank(query.get("type").toString())){ cnd.where().andEquals("type", query.get("type").toString()); } cnd.getGroupBy().groupBy("type"); cnd.getOrderBy().desc("sort"); List<EDict> projectList = dictDao.query(cnd, pager); WMap map = new WMap(); if(queryJs.getQuery() != null){ map.putAll(queryJs.getQuery()); } map.put("data", projectList); map.put("page", queryJs.toWPage(pager)); result.ok(map); result.okMsg("查询成功！"); }catch(Exception e){ e.printStackTrace(); LOG.error("查询失败，原因："+e.getMessage()); result.error(e); } return result; }  @RequestMapping(value="list") ActionResultObj list(@RequestBody SearchQueryJS queryJs); @RequestMapping(value="type/{type}") ActionResultObj findByType(@PathVariable String type); @RequestMapping(value="/{id}") ActionResultObj get(@PathVariable Long id); @RequestMapping(value="save") ActionResultObj save(@RequestBody EDict dict); @RequestMapping(value="delete") ActionResultObj delete(@RequestBody Long id); @Autowired
	public DictService dictService; @Autowired
	public DictDao dictDao; }