Ejemplo n.º 1
0
  @RequestMapping(
      value = {
        "/mi/shop/view/json/{id}",
        "/mi/shop/add/view/json/{id}",
        "/mi/shop/update/view/json/{id}"
      },
      method = {RequestMethod.GET})
  @ResponseBody
  public Object getMiViewJson(HttpServletRequest request, @PathVariable String id) {
    Map<String, Object> resultMap = new HashMap<String, Object>();

    try {
      ShopModel shop = shopService.get(id);
      if (shop != null) {
        //				PermissionQueryModel pqm = new PermissionQueryModel();
        //				pqm.setTargetPage(PageUtil.BEGIN_PAGE);
        //				pqm.setPageSize(PageUtil.MAX_PAGE_SIZE);
        //				pqm.setShopId(id);
        //				List<PermissionModel> permissions = permissionService
        //						.strictList(pqm);
        shop.setPreViewUrl(
            aossService.addImgParams(
                shop.getPreViewUrl(), Constants.ALIYUN_OSS_IMAGE_PARAMS_TYPE_HEAD_IMG));
        resultMap.put("shop", shop);
        //				resultMap.put("relations", permissions);
      }
    } catch (Exception e) {

      resultMap.put("shop", null);
      LOG.error(LoginUtil.SEARCH_DISPLAY + permissionObjectName + "详细信息出错!", e);
    }
    return resultMap;
  }
Ejemplo n.º 2
0
 @RequestMapping(
     value = "/shop/search/-{searchKeyword}-",
     method = {RequestMethod.GET})
 public String toSearch(HttpServletRequest request, @PathVariable String searchKeyword) {
   ShopQueryModel command = new ShopQueryModel();
   command.setTargetPage(PageUtil.BEGIN_PAGE);
   command.setPageSize(PageUtil.DEFAULT_PAGE_SIZE);
   command.setSearchKeyword(searchKeyword);
   List<ShopModel> list = shopService.strictList(command);
   for (ShopModel shop : list) {
     shop.setPreViewUrl(
         aossService.addImgParams(
             shop.getPreViewUrl(), Constants.ALIYUN_OSS_IMAGE_PARAMS_TYPE_NORMAL_PRE_IMG));
   }
   int total = shopService.strictCount(command);
   request.setAttribute("results", list);
   request.setAttribute("total", total);
   return "ui/shop/search";
 }
Ejemplo n.º 3
0
 @RequestMapping(
     value = "/shop/view/preView/{id}",
     method = {RequestMethod.GET})
 public void toViewPreView(
     HttpServletRequest request, HttpServletResponse response, @PathVariable String id)
     throws IOException {
   ShopModel shop = shopService.get(id);
   shop.setPreViewUrl(
       aossService.addImgParams(shop.getPreViewUrl(), Constants.ALIYUN_OSS_IMAGE_WATER_MARK));
   response.sendRedirect(shop.getPreViewUrl());
 }
Ejemplo n.º 4
0
 @RequestMapping(
     value = {"/mi/shop/search/page/json/{curPage}"},
     method = {RequestMethod.GET})
 @ResponseBody
 public Object getMiSearchPageJson(
     HttpServletRequest request, @PathVariable Integer curPage, Integer pageSize, String name) {
   ShopQueryModel command = new ShopQueryModel();
   command.setTargetPage(curPage);
   command.setPageSize(pageSize);
   command.setSearchKeyword(name);
   CommonPageObject<ShopModel> shops = shopService.strictQuery(command);
   return PageUtil.convert2ResultMap(shops);
 }
Ejemplo n.º 5
0
 @RequestMapping(
     value = "/mi/shop/delete/batch/json",
     method = {RequestMethod.POST})
 @ResponseBody
 public Object miBatchDelete(HttpServletRequest request, String shopIds) {
   String actionName = LoginUtil.DELETE_DISPLAY;
   if (StringUtils.isNotBlank(shopIds)) {
     String[] rids = shopIds.split(Constants.MI_IDS_SPLIT_STRING);
     if (rids.length > 0) {
       List<String> idList = Arrays.asList(rids);
       shopService.deleteBatch(idList);
       return ResultMapUtil.getResultMap(actionName + permissionObjectName + "成功!");
     }
   }
   return ResultMapUtil.getResultMap(actionName + "对象不能为空!", false);
 }
Ejemplo n.º 6
0
 @RequestMapping(
     value = "/shop/search/json/{searchKeyword}-{targetPage}-{pageSize}",
     method = {RequestMethod.GET})
 @ResponseBody
 public Object toSearchJson(
     HttpServletRequest request,
     @PathVariable String searchKeyword,
     @PathVariable Integer targetPage,
     @PathVariable Integer pageSize) {
   ShopQueryModel command = new ShopQueryModel();
   command.setTargetPage(targetPage);
   command.setPageSize(pageSize);
   command.setSearchKeyword(searchKeyword);
   List<ShopModel> list = shopService.strictList(command);
   for (ShopModel shop : list) {
     shop.setPreViewUrl(
         aossService.addImgParams(
             shop.getPreViewUrl(), Constants.ALIYUN_OSS_IMAGE_PARAMS_TYPE_NORMAL_PRE_IMG));
   }
   Map<String, Object> result = ResultMapUtil.getResultMap();
   result.put("results", list);
   return result;
 }
Ejemplo n.º 7
0
  @RequestMapping(
      value = "/shop/view/{id}",
      method = {RequestMethod.GET})
  public String toView(HttpServletRequest request, @PathVariable String id) {

    ShopModel shop = shopService.get(id);
    shop.setPreViewUrl(
        aossService.addImgParams(
            shop.getPreViewUrl(), Constants.ALIYUN_OSS_IMAGE_PARAMS_TYPE_BANNER));
    ProductQueryModel pqm = new ProductQueryModel();
    pqm.setTargetPage(PageUtil.BEGIN_PAGE);
    pqm.setPageSize(PageUtil.MAX_PAGE_SIZE);
    pqm.setShopId(id);
    List<ProductModel> list = productService.strictList(pqm);
    for (ProductModel product : list) {
      product.setPreViewUrl(
          aossService.addImgParams(
              product.getPreViewUrl(), Constants.ALIYUN_OSS_IMAGE_PARAMS_TYPE_NORMAL_PRE_IMG));
    }
    shop.setProducts(list);
    request.setAttribute("shop", shop);
    return "ui/shop/view";
  }
Ejemplo n.º 8
0
  private Object saveOrUpdateUser(
      HttpServletRequest request, ShopModel shop, String newPermissionIds) {
    Map<String, Object> resultMap = null;
    String actionName;
    if (StringUtils.isBlank(shop.getId())) {
      actionName = LoginUtil.ADD_DISPLAY;
      shop.setCreaterId(LoginUtil.getCurrentUserId(request));
    } else {
      actionName = LoginUtil.UPDATE_DISPLAY;
    }
    shop.setEditorId(LoginUtil.getCurrentUserId(request));
    shop.setPreViewUrl(aossService.clearImgParams(shop.getPreViewUrl()));

    try {
      shopService.saveOrUpdate(shop);
      resultMap = ResultMapUtil.getResultMap(actionName + permissionObjectName + "成功!");
    } catch (ConstraintViolationException e) {
      Set<ConstraintViolation<?>> constraintViolations = e.getConstraintViolations();
      Iterator<ConstraintViolation<?>> iter = constraintViolations.iterator();
      while (iter.hasNext()) {
        ConstraintViolation<?> cv = iter.next();
        resultMap = ResultMapUtil.getResultMap(cv.getMessage(), cv.getPropertyPath().toString());
        break;
      }
      if (resultMap == null) {
        resultMap = ResultMapUtil.getResultMap(actionName + permissionObjectName + "失败!", false);
      }
      LOG.error(actionName + permissionObjectName + "失败!", e);
    } catch (DataIntegrityViolationException e) {
      LOG.error(actionName + permissionObjectName + "失败!", e);
      resultMap = ResultMapUtil.getResultMap("name", permissionObjectName + "名重复!");
    } catch (Exception e) {
      LOG.error(actionName + permissionObjectName + "失败!", e);
      resultMap = ResultMapUtil.getResultMap(actionName + permissionObjectName + "失败!", false);
    }
    return resultMap;
  }