diff --git a/litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.java b/litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.java index 92bc7797..d367d666 100644 --- a/litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.java +++ b/litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.java @@ -50,17 +50,21 @@ public class AdminGrouponController { List> records = new ArrayList<>(); for (LitemallGroupon groupon : grouponList) { - Map RecordData = new HashMap<>(); - List subGrouponList = grouponService.queryJoinRecord(groupon.getId()); - LitemallGrouponRules rules = rulesService.queryById(groupon.getRulesId()); - LitemallGoods goods = goodsService.findById(rules.getGoodsId()); + try { + Map RecordData = new HashMap<>(); + List subGrouponList = grouponService.queryJoinRecord(groupon.getId()); + LitemallGrouponRules rules = rulesService.queryById(groupon.getRulesId()); + LitemallGoods goods = goodsService.findById(rules.getGoodsId()); - RecordData.put("groupon", groupon); - RecordData.put("subGroupons", subGrouponList); - RecordData.put("rules", rules); - RecordData.put("goods", goods); + RecordData.put("groupon", groupon); + RecordData.put("subGroupons", subGrouponList); + RecordData.put("rules", rules); + RecordData.put("goods", goods); - records.add(RecordData); + records.add(RecordData); + } catch (Exception e) { + e.printStackTrace(); + } } Map data = new HashMap<>(); diff --git a/litemall-core/src/main/java/org/linlinjava/litemall/core/qcode/QCodeBase.java b/litemall-core/src/main/java/org/linlinjava/litemall/core/qcode/QCodeBase.java index a9452892..57490b01 100644 --- a/litemall-core/src/main/java/org/linlinjava/litemall/core/qcode/QCodeBase.java +++ b/litemall-core/src/main/java/org/linlinjava/litemall/core/qcode/QCodeBase.java @@ -22,16 +22,6 @@ public abstract class QCodeBase { protected abstract String getKeyName(String id); - /** - * 获取图片地址 - * - * @param id - * @return - */ - public String getShareImageUrl(String id) { - return storageService.generateUrl(getKeyName(id)); - } - protected BufferedImage getQCode(String scene, String page) { //创建该商品的二维码 File file = null; diff --git a/litemall-core/src/main/java/org/linlinjava/litemall/core/storage/StorageService.java b/litemall-core/src/main/java/org/linlinjava/litemall/core/storage/StorageService.java index 4bea80c9..20d368fd 100644 --- a/litemall-core/src/main/java/org/linlinjava/litemall/core/storage/StorageService.java +++ b/litemall-core/src/main/java/org/linlinjava/litemall/core/storage/StorageService.java @@ -95,7 +95,7 @@ public class StorageService { storage.delete(keyName); } - public String generateUrl(String keyName) { + private String generateUrl(String keyName) { return storage.generateUrl(keyName); } } diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java index 7f080b8e..e54aca6c 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java @@ -17,7 +17,7 @@ public class LitemallGoodsService { @Resource private LitemallGoodsMapper goodsMapper; - Column[] columns = new Column[]{Column.id, Column.name, Column.brief, Column.picUrl, Column.counterPrice, Column.retailPrice}; + Column[] columns = new Column[]{Column.id, Column.name, Column.brief, Column.picUrl, Column.isHot, Column.isNew, Column.counterPrice, Column.retailPrice}; /** * 获取热卖商品 diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java index 19c83216..5d0ff730 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java @@ -189,7 +189,7 @@ public class WxGoodsController { if (cur.getPid() == 0) { parent = cur; children = categoryService.queryByPid(cur.getId()); - cur = children.size()>0?children.get(0):cur; + cur = children.size() > 0 ? children.get(0) : cur; } else { parent = categoryService.findById(cur.getPid()); children = categoryService.queryByPid(cur.getPid()); @@ -258,8 +258,7 @@ public class WxGoodsController { List categoryList = null; if (goodsCatIds.size() != 0) { categoryList = categoryService.queryL2ByIds(goodsCatIds); - } - else { + } else { categoryList = new ArrayList<>(0); } diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java index 583bbdfb..800a6fde 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java @@ -96,7 +96,7 @@ public class WxHomeController { data.put("topicList", topicList); //优惠专区 - List grouponRules = grouponRulesService.queryByIndex(0, 4); + List grouponRules = grouponRulesService.queryByIndex(0, 5); List grouponGoods = new ArrayList<>(); List> grouponList = new ArrayList<>(); for (LitemallGrouponRules rule : grouponRules) { diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java index d9695663..d0a67cf5 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java @@ -71,7 +71,6 @@ public class WxOrderController { @Autowired private PlatformTransactionManager txManager; - @Autowired private LitemallUserService userService; @Autowired diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxStorageController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxStorageController.java index b5f40c2f..ddb3701c 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxStorageController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxStorageController.java @@ -15,10 +15,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -import java.io.InputStream; -import java.time.LocalDateTime; import java.util.HashMap; -import java.util.List; import java.util.Map; @RestController @@ -31,18 +28,18 @@ public class WxStorageController { @Autowired private LitemallStorageService litemallStorageService; - private String generateKey(String originalFilename){ + private String generateKey(String originalFilename) { int index = originalFilename.lastIndexOf('.'); String suffix = originalFilename.substring(index); String key = null; LitemallStorage storageInfo = null; - do{ + do { key = CharUtil.getRandomString(20) + suffix; storageInfo = litemallStorageService.findByKey(key); } - while(storageInfo != null); + while (storageInfo != null); return key; } @@ -50,40 +47,24 @@ public class WxStorageController { @PostMapping("/upload") public Object upload(@RequestParam("file") MultipartFile file) throws IOException { String originalFilename = file.getOriginalFilename(); - InputStream inputStream = null; - try { - inputStream = file.getInputStream(); - } catch (IOException e) { - e.printStackTrace(); - return ResponseUtil.badArgumentValue(); - } - String key = generateKey(originalFilename); - storageService.store(file.getInputStream(), file.getSize(), file.getContentType(), key); + String url = storageService.store(file.getInputStream(), file.getSize(), file.getContentType(), originalFilename); - String url = storageService.generateUrl(key); - LitemallStorage storageInfo = new LitemallStorage(); - storageInfo.setName(originalFilename); - storageInfo.setSize((int)file.getSize()); - storageInfo.setType(file.getContentType()); - storageInfo.setAddTime(LocalDateTime.now()); - storageInfo.setModified(LocalDateTime.now()); - storageInfo.setKey(key); - storageInfo.setUrl(url); - litemallStorageService.add(storageInfo); - return ResponseUtil.ok(storageInfo); + Map data = new HashMap<>(); + data.put("url", url); + return ResponseUtil.ok(data); } @GetMapping("/fetch/{key:.+}") public ResponseEntity fetch(@PathVariable String key) { LitemallStorage litemallStorage = litemallStorageService.findByKey(key); - if(key == null){ + if (key == null) { ResponseEntity.notFound(); } String type = litemallStorage.getType(); MediaType mediaType = MediaType.parseMediaType(type); Resource file = storageService.loadAsResource(key); - if(file == null) { + if (file == null) { ResponseEntity.notFound(); } return ResponseEntity.ok().contentType(mediaType).body(file); @@ -92,14 +73,14 @@ public class WxStorageController { @GetMapping("/download/{key:.+}") public ResponseEntity download(@PathVariable String key) { LitemallStorage litemallStorage = litemallStorageService.findByKey(key); - if(key == null){ + if (key == null) { ResponseEntity.notFound(); } String type = litemallStorage.getType(); MediaType mediaType = MediaType.parseMediaType(type); Resource file = storageService.loadAsResource(key); - if(file == null) { + if (file == null) { ResponseEntity.notFound(); } return ResponseEntity.ok().contentType(mediaType).header(HttpHeaders.CONTENT_DISPOSITION,