Пример #1
0
 @RequestMapping(params = "method=setCategoryPage")
 public void setCategoryPage(HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   String jsonStr = "[]";
   StringBuffer sb = new StringBuffer("[");
   Long shopId = WebUtil.getShopId(request);
   Long startPageNo = 1l;
   RFITxnService txnService = ServiceManager.getService(RFITxnService.class);
   CategoryServiceSearchDTO categoryServiceSearchDTO = new CategoryServiceSearchDTO();
   categoryServiceSearchDTO.setServiceDTOs(
       txnService.getServicesByCategory(
           shopId,
           categoryServiceSearchDTO.getServiceName(),
           categoryServiceSearchDTO.getCategoryName(),
           CategoryType.BUSINESS_CLASSIFICATION,
           startPageNo,
           PAGE_SIZE));
   for (ServiceDTO service : categoryServiceSearchDTO.getServiceDTOs()) {
     String name = service.getName() == null ? "" : service.getName();
     String id = service.getId() == null ? "" : service.getId().toString();
     sb.append("{\"name\":\"" + name + "\",");
     sb.append("\"id\":\"" + id + "\"},");
   }
   sb.replace(sb.length() - 1, sb.length(), "]");
   jsonStr = sb.toString();
   PrintWriter writer = response.getWriter();
   writer.write(jsonStr);
   writer.close();
 }
Пример #2
0
 @ResponseBody
 @RequestMapping(params = "method=getCategoryItemSearch")
 public Object getCategoryItemSearch(
     ModelMap model,
     HttpServletRequest request,
     CategoryServiceSearchDTO categoryServiceSearchDTO) {
   RFITxnService txnService = ServiceManager.getService(RFITxnService.class);
   Long shopId = WebUtil.getShopId(request);
   Long startPageNo = 1l;
   if (StringUtils.isNotBlank(request.getParameter("startPageNo"))
       && NumberUtil.isNumber(request.getParameter("startPageNo"))) {
     startPageNo = NumberUtil.longValue(request.getParameter("startPageNo"));
   }
   Map<String, Object> returnMap = new HashMap<String, Object>();
   try {
     if (categoryServiceSearchDTO == null) {
       categoryServiceSearchDTO = new CategoryServiceSearchDTO();
     }
     Pager pager = null;
     // 全部
     if (categoryServiceSearchDTO.getCategoryServiceType() == null) {
       categoryServiceSearchDTO.setServiceDTOs(
           txnService.getServicesByCategory(
               shopId,
               categoryServiceSearchDTO.getServiceName(),
               categoryServiceSearchDTO.getCategoryName(),
               CategoryType.BUSINESS_CLASSIFICATION,
               startPageNo,
               PAGE_SIZE));
       pager =
           new Pager(
               txnService.countServiceByCategory(
                   shopId,
                   categoryServiceSearchDTO.getServiceName(),
                   categoryServiceSearchDTO.getCategoryName(),
                   CategoryType.BUSINESS_CLASSIFICATION),
               startPageNo.intValue(),
               (int) PAGE_SIZE);
     }
     categoryServiceSearchDTO.setCategoryDTOs(txnService.getCategoryByShopId(shopId));
     returnMap.put("pager", pager);
     returnMap.put("categoryServiceSearchDTO", categoryServiceSearchDTO);
     returnMap.put("result", new Result(true));
     return returnMap;
   } catch (Exception e) {
     LOG.debug("/category.do");
     LOG.debug("method=getCategoryItemSearch");
     LOG.error(e.getMessage(), e);
     returnMap.put("result", new Result(false));
     return returnMap;
   }
 }