@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); }
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; }
@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; }