admin
2020-07-16 be67478cae6bf9308f15949a21e7d0a57a3f0ecb
fanli/src/main/java/com/yeshi/fanli/controller/admin/shop/BanLiShopGoodsSetAdminController.java
@@ -5,7 +5,9 @@
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.yeshi.fanli.entity.accept.AdminAcceptData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
@@ -14,8 +16,9 @@
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.shop.BanLiShopGoodsSets;
import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetException;
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.common.entity.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
@@ -29,6 +32,45 @@
   private BanLiShopGoodsSetService banLiShopGoodsSetService;
   
   
   /**
    * 保存信息
    *
    * @param callback
    * @param special
    * @param out
    */
   @RequestMapping(value = "save")
   public void save(AdminAcceptData acceptData, String callback, BanLiShopGoodsSets record, HttpServletRequest request, PrintWriter out) {
      try {
         banLiShopGoodsSetService.saveObject(record);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
      } catch (BanLiShopGoodsSetException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
      } catch (Exception e) {
         e.printStackTrace();
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
      }
   }
   /**
    * 修改状态
    * @param callback
    * @param id
    * @param out
    */
   @RequestMapping(value = "switchState")
   public void switchState(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) {
      try {
         banLiShopGoodsSetService.switchState(id);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
      } catch (BanLiShopGoodsSetException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
         e.printStackTrace();
      }
   }
    /** 
    * 删除
    * @param callback
@@ -36,7 +78,7 @@
    * @param out
    */
   @RequestMapping(value = "delete")
   public void delete(String callback, String idArray, PrintWriter out) {
   public void delete(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) {
      try {
         if (StringUtil.isNullOrEmpty(idArray)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
@@ -68,7 +110,7 @@
    * @param out
    */
   @RequestMapping(value = "query")
   public void query(String callback, Integer pageIndex, Integer pageSize, String key, PrintWriter out) {
   public void query(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Long goodsId, PrintWriter out) {
      try {
         if (pageIndex == null || pageIndex < 1)
            pageIndex = 1;
@@ -76,13 +118,13 @@
         if (pageSize == null || pageSize < 1) 
            pageSize = Constant.PAGE_SIZE;
   
         List<BanLiShopGoodsSets> list = banLiShopGoodsSetService.listQuery(pageIndex, pageSize, key);
         List<BanLiShopGoodsSets> list = banLiShopGoodsSetService.listQuery(pageIndex, pageSize, key, goodsId);
         if (list == null || list.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
            return;
         }
         
         long count = banLiShopGoodsSetService.countQuery(key);
         long count = banLiShopGoodsSetService.countQuery(key, goodsId);
         
         int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
         PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);