| | |
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/brand")
|
| | | public class BrandShopAdminController {
|
| | | |
| | |
|
| | | @Resource
|
| | | private BrandClassService brandClassService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private BrandClassShopService brandClassShopService;
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 保存信息
|
| | | *
|
| | |
| | | @RequestMapping(value = "save")
|
| | | public void save(String callback, BrandClass brandClass, PrintWriter out) {
|
| | | try {
|
| | | brandClassService.saveObject(brandClass);
|
| | | brandClassService.saveObject(brandClass);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (BrandClassException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | |
| | | /**
|
| | | * 修改排序
|
| | | *
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | |
| | | /**
|
| | | * 查询
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key 模糊查询:说明、标识
|
| | | * @param key
|
| | | * 模糊查询:说明、标识
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "query")
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, String key,
|
| | | Integer state, PrintWriter out) {
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
|
| | | PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | long count = brandClassService.countQuery(key, state);
|
| | | |
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls(); |
| | | gsonBuilder.serializeNulls();
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 删除
|
| | | * |
| | | * @param callback
|
| | | * @param idArray
|
| | | * @param out
|
| | |
| | | return;
|
| | | }
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | | int count = brandClassService.deleteBatchByPrimaryKey(list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除["+ count +"]条数据"));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 筛选列表
|
| | | * |
| | | * @param callback
|
| | | * @param out
|
| | | */
|
| | |
| | |
|
| | | List<Object> result_list = new ArrayList<Object>();
|
| | | if (list != null && list.size() > 0) {
|
| | | for (BrandClass record: list) {
|
| | | Map<String,Object> map =new HashMap<String,Object>();
|
| | | for (BrandClass record : list) {
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | | map.put("key", record.getId());
|
| | | map.put("value", record.getName());
|
| | | result_list.add(map);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result_list", result_list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 查询
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key 模糊查询:说明、标识
|
| | | * @param key
|
| | | * 模糊查询:说明、标识
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "queryTaoBaoShop")
|
| | |
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | | |
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | TaoBaoShopInfoDTO taoBaoShopInfoDTO = TaoKeApiUtil.searchShop(key, pageIndex, pageSize);
|
| | | |
| | | TaoBaoShopInfoDTO taoBaoShopInfoDTO = TaoKeApiUtil.searchShop(key, pageIndex, pageSize);
|
| | |
|
| | | List<TaoBaoShopInfo> listInfo = taoBaoShopInfoDTO.getListInfo();
|
| | | if (listInfo == null || listInfo.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | List<Long> listShopId = new ArrayList<Long>();
|
| | | for (TaoBaoShopInfo taoBaoShopInfo: listInfo) {
|
| | | for (TaoBaoShopInfo taoBaoShopInfo : listInfo) {
|
| | | listShopId.add(taoBaoShopInfo.getUserId());
|
| | | }
|
| | | |
| | |
|
| | | // 已存在数据库中
|
| | | List<BrandClassShop> listExist = brandClassShopService.getExistByShopIds(listShopId);
|
| | | |
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | for (TaoBaoShopInfo taoBaoShopInfo: listInfo) {
|
| | | for (TaoBaoShopInfo taoBaoShopInfo : listInfo) {
|
| | | String name = "";
|
| | | if (listExist != null && listExist.size() > 0) {
|
| | | Long userId = taoBaoShopInfo.getUserId();
|
| | | for (BrandClassShop brandClassShop: listExist) {
|
| | | for (BrandClassShop brandClassShop : listExist) {
|
| | | TaoBaoShop shop = brandClassShop.getShop();
|
| | | if (shop !=null && userId == shop.getId() || userId.equals(shop.getId()) ) {
|
| | | if (shop != null && userId == shop.getId() || userId.equals(shop.getId())) {
|
| | | BrandClass brandClass = brandClassShop.getBrandClass();
|
| | | name = brandClass.getName();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | JSONObject innerData = new JSONObject();
|
| | | innerData.put("cname", name);
|
| | | innerData.put("shopInfo", taoBaoShopInfo);
|
| | | array.add(innerData);
|
| | | }
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", taoBaoShopInfoDTO.getPage());
|
| | | data.put("result_list",array);
|
| | | data.put("result_list", array);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 添加店铺入库
|
| | | *
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveShopInfo")
|
| | | public void saveShopInfo(String callback,Long cid, String idArray, PrintWriter out) {
|
| | | public void saveShopInfo(String callback, Long cid, String idArray, PrintWriter out) {
|
| | | try {
|
| | | if (StringUtil.isNullOrEmpty(idArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
|
| | | return;
|
| | | }
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | String shopIds = brandClassShopService.saveShopInfo(cid,list);
|
| | | String shopIds = brandClassShopService.saveShopInfo(cid, list);
|
| | | if (StringUtil.isNullOrEmpty(shopIds)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } else {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("以下店铺ID:"+ shopIds + ",未添加成功"));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("以下店铺ID:" + shopIds + ",未添加成功"));
|
| | | }
|
| | | } catch (BrandClassShopException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 查询
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key 模糊查询:说明、标识
|
| | | * @param key
|
| | | * 模糊查询:说明、标识
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "queryClassShop")
|
| | | public void queryClassShop(String callback, Integer pageIndex, Integer pageSize, String key,
|
| | | Long cid , Integer state, PrintWriter out) {
|
| | | public void queryClassShop(String callback, Integer pageIndex, Integer pageSize, String key, Long cid,
|
| | | Integer state, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | List<BrandClassShop> list = brandClassShopService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid, state);
|
| | | List<BrandClassShop> list = brandClassShopService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid,
|
| | | state);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | long count = brandClassShopService.countQuery(key, cid, state);
|
| | | |
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls(); |
| | | gsonBuilder.serializeNulls();
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 保存信息
|
| | | *
|
| | |
| | | */
|
| | | @RequestMapping(value = "saveClassShop")
|
| | | public void saveClassShop(String callback, Long id, Long cid, String shopName, Integer state, Integer top,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | String key, HttpServletRequest request, PrintWriter out) {
|
| | | try {
|
| | | if (request instanceof MultipartHttpServletRequest) {
|
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
|
| | | brandClassShopService.changeShopInfo(fileRequest.getFile("file"), id, cid, shopName, state, top);
|
| | | }else{
|
| | | brandClassShopService.changeShopInfo(null, id, cid, shopName, state, top);
|
| | | }
|
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
|
| | | brandClassShopService.changeShopInfo(fileRequest.getFile("file"), id, cid, shopName, state, top, key);
|
| | | } else {
|
| | | brandClassShopService.changeShopInfo(null, id, cid, shopName, state, top, key);
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (BrandClassShopException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 修改排序
|
| | | *
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 删除
|
| | | * |
| | | * @param callback
|
| | | * @param idArray
|
| | | * @param out
|
| | |
| | | return;
|
| | | }
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | brandClassShopService.deleteBatchByPrimaryKey(list);
|
| | | |
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|