yujian
2020-01-03 c9cbdfa41d645d42eeaa7e06d550d4ef8ac328e7
fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java
@@ -114,7 +114,6 @@
      try {
         List<BrandClass> list = brandClassService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
         if (list == null || list.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
            return;
@@ -445,9 +444,15 @@
    * @param out
    */
   @RequestMapping(value = "saveBrand")
   public void saveBrand(String callback, BrandInfo brandInfo, PrintWriter out) {
   public void saveBrand(String callback, BrandInfo brandInfo, HttpServletRequest request, PrintWriter out) {
      try {
         brandInfoService.saveObject(brandInfo);
         // 1. 先判断httpRequest 是否含有文件类型
         if (request instanceof MultipartHttpServletRequest) {
              MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
              brandInfoService.saveObject(fileRequest.getFile("file"), brandInfo);
           }else{
              brandInfoService.saveObject(null, brandInfo);
           }
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
      } catch (BrandInfoException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
@@ -489,6 +494,26 @@
   }
   
   /**
    * 修改排序
    *
    * @param callback
    * @param goodsClass
    * @param out
    */
   @RequestMapping(value = "updateOrderBrand")
   public void updateOrderBrand(String callback, Long id, Integer moveType, PrintWriter out) {
      try {
         brandInfoService.updateOrder(id, moveType);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
      } catch (BrandInfoException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
         e.printStackTrace();
      }
   }
   /**
    * 品牌信息查询
    * @param callback
    * @param pageIndex
@@ -499,8 +524,8 @@
    * @param out
    */
   @RequestMapping(value = "queryBrand")
   public void query(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
         PrintWriter out) {
   public void queryBrand(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
         Integer showState, PrintWriter out) {
      if (pageIndex == null || pageIndex < 1) {
         pageIndex = 1;
@@ -509,16 +534,37 @@
      if (pageSize == null || pageSize < 1) {
         pageSize = Constant.PAGE_SIZE;
      }
      List<String> keys = null;
      if (!StringUtil.isNullOrEmpty(key)) {
         String[] array = key.split("\\s+");
         if (array != null && array.length > 0) {
            keys = new ArrayList<String>();
            for (int i= 0; i < array.length; i++) {
               keys.add(array[i].toString());
            }
         }
      }
      try {
         List<BrandInfo> list = brandInfoService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid, state);
         List<BrandInfo> list = brandInfoService.listQuery((pageIndex - 1) * pageSize, pageSize, keys, cid, state, showState);
         if (list == null || list.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
            return;
         }
         for (BrandInfo brandInfo: list) {
            BrandClass brandClass = brandInfo.getBrandClass();
            if (brandClass != null && StringUtil.isNullOrEmpty(brandClass.getName())) {
               BrandClass bclass = brandClassService.selectByPrimaryKey(brandClass.getId());
               if (bclass != null) {
                  brandInfo.setBrandClass(bclass);
               }
            }
         }
         long count = brandInfoService.countQuery(key, cid, state);
         long count = brandInfoService.countQuery(keys, cid, state, showState);
         int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
         PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);