From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/LabelClassAdminController.java | 635 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 318 insertions(+), 317 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/LabelClassAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/LabelClassAdminController.java index 89e9b6c..4684180 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/LabelClassAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/LabelClassAdminController.java @@ -1,317 +1,318 @@ -package com.yeshi.fanli.controller.admin; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; - -import net.sf.json.JSONObject; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.yeshi.fanli.entity.bus.clazz.GoodsClass; -import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; -import com.yeshi.fanli.entity.bus.lable.Label; -import com.yeshi.fanli.entity.bus.lable.LabelClass; -import com.yeshi.fanli.service.inter.goods.GoodsClassService; -import com.yeshi.fanli.service.inter.goods.GoodsSubClassService; -import com.yeshi.fanli.service.inter.lable.LabelClassService; -import com.yeshi.fanli.service.inter.lable.LabelService; -import com.yeshi.fanli.tag.PageEntity; -import com.yeshi.fanli.util.Constant; -import org.yeshi.utils.JsonUtil; - -@Controller -@RequestMapping("admin/new/api/v1/labelClass") -public class LabelClassAdminController { - - @Resource - private LabelService labelService; - @Resource - private LabelClassService labelClassService; - @Resource - private GoodsClassService goodsClassService; - @Resource - private GoodsSubClassService goodsSubClassService; - - - - /** - * 鍗曚釜鍒嗙被鎵归噺娣诲姞鏍囩-鍏宠仈lableId - * @param callback - * @param labIds - * @param id - * @param type - * @param request - * @param out - */ - @RequestMapping(value = "addBatch") - public void addBatch(String callback,String labIds, Long id, Integer type, HttpServletRequest request, - PrintWriter out) { - - try { - - if (id == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈�夋嫨绫诲埆")); - return; - } - - Gson gson = new Gson(); - List<Long> labIdList = gson.fromJson(labIds, new TypeToken<ArrayList<Long>>() {}.getType()); - - - /* 涓�绾у垎绫绘坊鍔犳爣绛� */ - if (type == 1) { - GoodsClass goodsClass = goodsClassService.getGoodsClass(id); - - if(goodsClass == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); - return; - } - - labelClassService.addBatchClass(goodsClass, labIdList); - - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); - } - - /* 瀛愬垎绫绘坊鍔犳爣绛� */ - if (type > 1) { - GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(id); - - if(goodsSubClass == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); - return; - } - - labelClassService.addBatchSubClass(goodsSubClass, labIdList); - - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); - } - - - } catch ( Exception e) { - // TODO Auto-generated catch block - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); - e.printStackTrace(); - } - } - - - /** - * 鍒犻櫎鍗曚釜鏍囩 - * @param callback - * @param rId - * @param request - * @param out - */ - @RequestMapping(value = "removeSingle") - public void removeSingle(String callback, Long rId, HttpServletRequest request, PrintWriter out) { - try { - - if (rId == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鍒犻櫎鐨勬爣绛�")); - } - - int count = labelClassService.deleteByPrimaryKey(rId); - - if (count > 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")); - } else { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触")); - } - - } catch ( Exception e) { - // TODO Auto-generated catch block - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); - e.printStackTrace(); - } - } - - - - - /** - * 鏌ヨ绫诲埆宸插叧鑱旀爣绛惧垪琛� - * @param callback - * @param pageIndex - * @param pageSize - * @param id - * @param type - * @param request - * @param out - */ - @RequestMapping(value = "queryMyLabels") - public void queryMyLabels(String callback, Integer pageIndex, Integer pageSize, Long id, - Integer type, HttpServletRequest request, PrintWriter out) { - - try { - - if (id == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈�夋嫨绫诲埆")); - return; - } - - int count = 0; - List<LabelClass> labelClassList = null; - - if (pageIndex == null) - pageIndex = 1; - - if (pageSize == null) - pageSize = Constant.PAGE_SIZE; - - - /* 涓�绾у垎绫绘坊鍔犳爣绛� */ - if (type == 1) { - GoodsClass goodsClass = goodsClassService.getGoodsClass(id); - - if(goodsClass == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); - return; - } - - labelClassList = labelClassService.queryByClassId((pageIndex - 1) * pageSize, pageSize, id); - if (labelClassList == null || labelClassList.size() == 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏍囩")); - return; - } - - count = labelClassService.getCountQueryByClassId(id); - } - - - /* 瀛愬垎绫绘坊鍔犳爣绛� */ - if (type > 1) { - GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(id); - - if(goodsSubClass == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); - return; - } - - labelClassList = labelClassService.queryBySubClassId((pageIndex - 1) * pageSize, pageSize, id); - if (labelClassList == null || labelClassList.size() == 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏍囩")); - return; - } - - count = labelClassService.getCountQueryBySubClassId(id); - } - - int totalPage = count % pageSize == 0 ? count / pageSize : count/ pageSize + 1; - PageEntity pe = new PageEntity(pageIndex, pageSize, count,totalPage); - - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.serializeNulls(); //閲嶇偣 - Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); - - JSONObject data = new JSONObject(); - data.put("pe", pe); - data.put("labelList", gson.toJson(labelClassList)); - - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - - } catch ( Exception e) { - // TODO Auto-generated catch block - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); - e.printStackTrace(); - } - } - - - /** - * 鏌ヨ鏍囩瀵瑰簲鐨勫�欓�夐」 - * @param callback - * @param pageIndex - * @param pageSize - * @param key - * @param id - * @param type - * @param request - * @param out - */ - @RequestMapping(value = "queryLabel") - public void queryLabel(String callback, Integer pageIndex, Integer pageSize, String key, Long id, - Integer type, HttpServletRequest request, PrintWriter out) { - - try { - - if (id == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈�夋嫨绫诲埆")); - return; - } - - int count = 0; - List<Label> labelList = null; - - if (pageIndex == null) - pageIndex = 1; - - if (pageSize == null) - pageSize = Constant.PAGE_SIZE; - - - /* 涓�绾у垎绫� 鏍囩 鍊欓�夐」 */ - if (type == 1) { - GoodsClass goodsClass = goodsClassService.getGoodsClass(id); - - if(goodsClass == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); - return; - } - - labelList = labelService.queryClassCandidate((pageIndex - 1) * pageSize, pageSize, key, id); - if (labelList == null || labelList.size() == 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏍囩")); - return; - } - - count = labelService.getCountQueryClassCandidate(key, id); - } - - - /* 瀛愬垎绫� 鏍囩鍊欓�夐」 */ - if (type > 1) { - GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(id); - - if(goodsSubClass == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); - return; - } - - labelList = labelService.querySubClassCandidate((pageIndex - 1) * pageSize, pageSize, key, id); - if (labelList == null || labelList.size() == 0) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏍囩")); - return; - } - - count = labelService.getCountQuerySubClassCandidate(key,id); - } - - int totalPage = count % pageSize == 0 ? count / pageSize : count/ pageSize + 1; - PageEntity pe = new PageEntity(pageIndex, pageSize, count,totalPage); - - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.serializeNulls(); //閲嶇偣 - Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); - - JSONObject data = new JSONObject(); - data.put("pe", pe); - data.put("labelList", gson.toJson(labelList)); - - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - - } catch ( Exception e) { - // TODO Auto-generated catch block - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); - e.printStackTrace(); - } - } - -} +package com.yeshi.fanli.controller.admin; + +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +import com.yeshi.fanli.entity.accept.AdminAcceptData; +import net.sf.json.JSONObject; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.yeshi.fanli.entity.bus.clazz.GoodsClass; +import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; +import com.yeshi.fanli.entity.bus.lable.Label; +import com.yeshi.fanli.entity.bus.lable.LabelClass; +import com.yeshi.fanli.service.inter.goods.GoodsClassService; +import com.yeshi.fanli.service.inter.goods.GoodsSubClassService; +import com.yeshi.fanli.service.inter.lable.LabelClassService; +import com.yeshi.fanli.service.inter.lable.LabelService; +import com.yeshi.common.entity.PageEntity; +import com.yeshi.fanli.util.Constant; +import org.yeshi.utils.JsonUtil; + +@Controller +@RequestMapping("admin/new/api/v1/labelClass") +public class LabelClassAdminController { + + @Resource + private LabelService labelService; + @Resource + private LabelClassService labelClassService; + @Resource + private GoodsClassService goodsClassService; + @Resource + private GoodsSubClassService goodsSubClassService; + + + + /** + * 鍗曚釜鍒嗙被鎵归噺娣诲姞鏍囩-鍏宠仈lableId + * @param callback + * @param labIds + * @param id + * @param type + * @param request + * @param out + */ + @RequestMapping(value = "addBatch") + public void addBatch(AdminAcceptData acceptData, String callback, String labIds, Long id, Integer type, HttpServletRequest request, + PrintWriter out) { + + try { + + if (id == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈�夋嫨绫诲埆")); + return; + } + + Gson gson = new Gson(); + List<Long> labIdList = gson.fromJson(labIds, new TypeToken<ArrayList<Long>>() {}.getType()); + + + /* 涓�绾у垎绫绘坊鍔犳爣绛� */ + if (type == 1) { + GoodsClass goodsClass = goodsClassService.getGoodsClass(id); + + if(goodsClass == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); + return; + } + + labelClassService.addBatchClass(goodsClass, labIdList); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); + } + + /* 瀛愬垎绫绘坊鍔犳爣绛� */ + if (type > 1) { + GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(id); + + if(goodsSubClass == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); + return; + } + + labelClassService.addBatchSubClass(goodsSubClass, labIdList); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); + } + + + } catch ( Exception e) { + // TODO Auto-generated catch block + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } + + + /** + * 鍒犻櫎鍗曚釜鏍囩 + * @param callback + * @param rId + * @param request + * @param out + */ + @RequestMapping(value = "removeSingle") + public void removeSingle(AdminAcceptData acceptData,String callback, Long rId, HttpServletRequest request, PrintWriter out) { + try { + + if (rId == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鍒犻櫎鐨勬爣绛�")); + } + + int count = labelClassService.deleteByPrimaryKey(rId); + + if (count > 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")); + } else { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触")); + } + + } catch ( Exception e) { + // TODO Auto-generated catch block + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } + + + + + /** + * 鏌ヨ绫诲埆宸插叧鑱旀爣绛惧垪琛� + * @param callback + * @param pageIndex + * @param pageSize + * @param id + * @param type + * @param request + * @param out + */ + @RequestMapping(value = "queryMyLabels") + public void queryMyLabels(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, Long id, + Integer type, HttpServletRequest request, PrintWriter out) { + + try { + + if (id == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈�夋嫨绫诲埆")); + return; + } + + int count = 0; + List<LabelClass> labelClassList = null; + + if (pageIndex == null) + pageIndex = 1; + + if (pageSize == null) + pageSize = Constant.PAGE_SIZE; + + + /* 涓�绾у垎绫绘坊鍔犳爣绛� */ + if (type == 1) { + GoodsClass goodsClass = goodsClassService.getGoodsClass(id); + + if(goodsClass == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); + return; + } + + labelClassList = labelClassService.queryByClassId((pageIndex - 1) * pageSize, pageSize, id); + if (labelClassList == null || labelClassList.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏍囩")); + return; + } + + count = labelClassService.getCountQueryByClassId(id); + } + + + /* 瀛愬垎绫绘坊鍔犳爣绛� */ + if (type > 1) { + GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(id); + + if(goodsSubClass == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); + return; + } + + labelClassList = labelClassService.queryBySubClassId((pageIndex - 1) * pageSize, pageSize, id); + if (labelClassList == null || labelClassList.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏍囩")); + return; + } + + count = labelClassService.getCountQueryBySubClassId(id); + } + + int totalPage = count % pageSize == 0 ? count / pageSize : count/ pageSize + 1; + PageEntity pe = new PageEntity(pageIndex, pageSize, count,totalPage); + + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.serializeNulls(); //閲嶇偣 + Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); + + JSONObject data = new JSONObject(); + data.put("pe", pe); + data.put("labelList", gson.toJson(labelClassList)); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + } catch ( Exception e) { + // TODO Auto-generated catch block + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } + + + /** + * 鏌ヨ鏍囩瀵瑰簲鐨勫�欓�夐」 + * @param callback + * @param pageIndex + * @param pageSize + * @param key + * @param id + * @param type + * @param request + * @param out + */ + @RequestMapping(value = "queryLabel") + public void queryLabel(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, String key, Long id, + Integer type, HttpServletRequest request, PrintWriter out) { + + try { + + if (id == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈�夋嫨绫诲埆")); + return; + } + + int count = 0; + List<Label> labelList = null; + + if (pageIndex == null) + pageIndex = 1; + + if (pageSize == null) + pageSize = Constant.PAGE_SIZE; + + + /* 涓�绾у垎绫� 鏍囩 鍊欓�夐」 */ + if (type == 1) { + GoodsClass goodsClass = goodsClassService.getGoodsClass(id); + + if(goodsClass == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); + return; + } + + labelList = labelService.queryClassCandidate((pageIndex - 1) * pageSize, pageSize, key, id); + if (labelList == null || labelList.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏍囩")); + return; + } + + count = labelService.getCountQueryClassCandidate(key, id); + } + + + /* 瀛愬垎绫� 鏍囩鍊欓�夐」 */ + if (type > 1) { + GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(id); + + if(goodsSubClass == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ュ垎绫诲凡涓嶅瓨鍦�")); + return; + } + + labelList = labelService.querySubClassCandidate((pageIndex - 1) * pageSize, pageSize, key, id); + if (labelList == null || labelList.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏍囩")); + return; + } + + count = labelService.getCountQuerySubClassCandidate(key,id); + } + + int totalPage = count % pageSize == 0 ? count / pageSize : count/ pageSize + 1; + PageEntity pe = new PageEntity(pageIndex, pageSize, count,totalPage); + + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.serializeNulls(); //閲嶇偣 + Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create(); + + JSONObject data = new JSONObject(); + data.put("pe", pe); + data.put("labelList", gson.toJson(labelList)); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + } catch ( Exception e) { + // TODO Auto-generated catch block + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } + +} -- Gitblit v1.8.0