Browse Source

chore[litemall-admin-api]: 简化代码

Junling Bu 7 years ago
parent
commit
618a8b98b7
26 changed files with 12 additions and 291 deletions
  1. 4 0
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/annotation/support/LoginAdminHandlerMethodArgumentResolver.java
  2. 0 17
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdController.java
  3. 0 3
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAddressController.java
  4. 0 18
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java
  5. 0 4
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAuthController.java
  6. 0 17
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminBrandController.java
  7. 0 21
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCategoryController.java
  8. 0 4
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCollectController.java
  9. 0 7
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCommentController.java
  10. 0 21
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCouponController.java
  11. 0 4
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminDashbordController.java
  12. 0 3
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminFeedbackController.java
  13. 0 4
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminFootprintController.java
  14. 0 23
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGoodsController.java
  15. 0 20
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.java
  16. 0 4
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminHistoryController.java
  17. 0 17
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminIssueController.java
  18. 0 17
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminKeywordController.java
  19. 0 17
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminOrderController.java
  20. 0 4
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminProfileController.java
  21. 0 9
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminRegionController.java
  22. 0 15
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStatController.java
  23. 0 12
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStorageController.java
  24. 0 17
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminTopicController.java
  25. 0 13
      litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminUserController.java
  26. 8 0
      litemall-core/src/main/java/org/linlinjava/litemall/core/config/GlobalExceptionHandler.java

+ 4 - 0
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/annotation/support/LoginAdminHandlerMethodArgumentResolver.java

@@ -1,6 +1,7 @@
 package org.linlinjava.litemall.admin.annotation.support;
 
 import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.authc.AuthenticationException;
 import org.apache.shiro.subject.Subject;
 import org.linlinjava.litemall.admin.annotation.LoginAdmin;
 import org.linlinjava.litemall.db.domain.LitemallAdmin;
@@ -23,6 +24,9 @@ public class LoginAdminHandlerMethodArgumentResolver implements HandlerMethodArg
                                   NativeWebRequest request, WebDataBinderFactory factory) throws Exception {
         Subject currentUser = SecurityUtils.getSubject();
         LitemallAdmin admin = (LitemallAdmin) currentUser.getPrincipal();
+        if (admin == null) {
+            throw new AuthenticationException();
+        }
 
         return admin.getId();
     }

+ 0 - 17
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdController.java

@@ -34,10 +34,6 @@ public class AdminAdController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallAd> adList = adService.querySelective(name, content, page, limit, sort, order);
         int total = adService.countSelective(name, content, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -61,9 +57,6 @@ public class AdminAdController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallAd ad) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(ad);
         if (error != null) {
             return error;
@@ -74,19 +67,12 @@ public class AdminAdController {
 
     @GetMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallAd brand = adService.findById(id);
         return ResponseUtil.ok(brand);
     }
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallAd ad) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(ad);
         if (error != null) {
             return error;
@@ -100,9 +86,6 @@ public class AdminAdController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallAd ad) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer id = ad.getId();
         if (id == null) {
             return ResponseUtil.badArgument();

+ 0 - 3
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAddressController.java

@@ -59,9 +59,6 @@ public class AdminAddressController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
 
         List<LitemallAddress> addressList = addressService.querySelective(userId, name, page, limit, sort, order);
         int total = addressService.countSelective(userId, name, page, limit, sort, order);

+ 0 - 18
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java

@@ -39,10 +39,6 @@ public class AdminAdminController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallAdmin> adminList = adminService.querySelective(username, page, limit, sort, order);
         int total = adminService.countSelective(username, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -69,9 +65,6 @@ public class AdminAdminController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallAdmin admin) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(admin);
         if (error != null) {
             return error;
@@ -93,19 +86,12 @@ public class AdminAdminController {
 
     @GetMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallAdmin admin = adminService.findById(id);
         return ResponseUtil.ok(admin);
     }
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallAdmin admin) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(admin);
         if (error != null) {
             return error;
@@ -130,10 +116,6 @@ public class AdminAdminController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallAdmin admin) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         Integer anotherAdminId = admin.getId();
         if (anotherAdminId == null) {
             return ResponseUtil.badArgument();

+ 0 - 4
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAuthController.java

@@ -62,10 +62,6 @@ public class AdminAuthController {
      */
     @PostMapping("/logout")
     public Object login(@LoginAdmin Integer adminId) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         Subject currentUser = SecurityUtils.getSubject();
         currentUser.logout();
         return ResponseUtil.ok();

+ 0 - 17
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminBrandController.java

@@ -35,10 +35,6 @@ public class AdminBrandController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallBrand> brandList = brandService.querySelective(id, name, page, limit, sort, order);
         int total = brandService.countSelective(id, name, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -68,9 +64,6 @@ public class AdminBrandController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallBrand brand) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(brand);
         if (error != null) {
             return error;
@@ -81,19 +74,12 @@ public class AdminBrandController {
 
     @GetMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallBrand brand = brandService.findById(id);
         return ResponseUtil.ok(brand);
     }
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallBrand brand) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(brand);
         if (error != null) {
             return error;
@@ -106,9 +92,6 @@ public class AdminBrandController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallBrand brand) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer id = brand.getId();
         if (id == null) {
             return ResponseUtil.badArgument();

+ 0 - 21
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCategoryController.java

@@ -35,10 +35,6 @@ public class AdminCategoryController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallCategory> collectList = categoryService.querySelective(id, name, page, limit, sort, order);
         int total = categoryService.countSelective(id, name, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -72,9 +68,6 @@ public class AdminCategoryController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallCategory category) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(category);
         if (error != null) {
             return error;
@@ -85,19 +78,12 @@ public class AdminCategoryController {
 
     @GetMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallCategory category = categoryService.findById(id);
         return ResponseUtil.ok(category);
     }
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallCategory category) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(category);
         if (error != null) {
             return error;
@@ -111,9 +97,6 @@ public class AdminCategoryController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallCategory category) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer id = category.getId();
         if (id == null) {
             return ResponseUtil.badArgument();
@@ -124,10 +107,6 @@ public class AdminCategoryController {
 
     @GetMapping("/l1")
     public Object catL1(@LoginAdmin Integer adminId) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         // 所有一级分类目录
         List<LitemallCategory> l1CatList = categoryService.queryL1();
         List<Map<String, Object>> data = new ArrayList<>(l1CatList.size());

+ 0 - 4
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCollectController.java

@@ -35,10 +35,6 @@ public class AdminCollectController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallCollect> collectList = collectService.querySelective(userId, valueId, page, limit, sort, order);
         int total = collectService.countSelective(userId, valueId, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();

+ 0 - 7
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCommentController.java

@@ -32,10 +32,6 @@ public class AdminCommentController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallComment> brandList = commentService.querySelective(userId, valueId, page, limit, sort, order);
         int total = commentService.countSelective(userId, valueId, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -47,9 +43,6 @@ public class AdminCommentController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallComment comment) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer id = comment.getId();
         if (id == null) {
             return ResponseUtil.badArgument();

+ 0 - 21
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCouponController.java

@@ -41,10 +41,6 @@ public class AdminCouponController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallCoupon> couponList = couponService.querySelective(name, type, status, page, limit, sort, order);
         int total = couponService.countSelective(name, type, status, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -61,10 +57,6 @@ public class AdminCouponController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallCouponUser> couponList = couponUserService.queryList(userId, couponId, status, page, limit, sort, order);
         int total = couponUserService.countList(userId, couponId, status, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -84,9 +76,6 @@ public class AdminCouponController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallCoupon coupon) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(coupon);
         if (error != null) {
             return error;
@@ -104,19 +93,12 @@ public class AdminCouponController {
 
     @GetMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallCoupon coupon = couponService.findById(id);
         return ResponseUtil.ok(coupon);
     }
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallCoupon coupon) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(coupon);
         if (error != null) {
             return error;
@@ -129,9 +111,6 @@ public class AdminCouponController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallCoupon coupon) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         couponService.deleteById(coupon.getId());
         return ResponseUtil.ok();
     }

+ 0 - 4
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminDashbordController.java

@@ -34,10 +34,6 @@ public class AdminDashbordController {
 
     @GetMapping("")
     public Object info(@LoginAdmin Integer adminId) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         int userTotal = userService.count();
         int goodsTotal = goodsService.count();
         int productTotal = productService.count();

+ 0 - 3
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminFeedbackController.java

@@ -39,9 +39,6 @@ public class AdminFeedbackController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         List<LitemallFeedback> feedbackList = feedbackService.querySelective(userId, username, page, limit, sort, order);
         int total = feedbackService.countSelective(userId, username, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();

+ 0 - 4
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminFootprintController.java

@@ -35,10 +35,6 @@ public class AdminFootprintController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallFootprint> footprintList = footprintService.querySelective(userId, goodsId, page, limit, sort, order);
         int total = footprintService.countSelective(userId, goodsId, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();

+ 0 - 23
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGoodsController.java

@@ -66,10 +66,6 @@ public class AdminGoodsController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallGoods> goodsList = goodsService.querySelective(goodsSn, name, page, limit, sort, order);
         int total = goodsService.countSelective(goodsSn, name, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -167,10 +163,6 @@ public class AdminGoodsController {
      */
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody GoodsAllinone goodsAllinone) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         Object error = validate(goodsAllinone);
         if (error != null) {
             return error;
@@ -242,9 +234,6 @@ public class AdminGoodsController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallGoods goods) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer id = goods.getId();
         if (id == null) {
             return ResponseUtil.badArgument();
@@ -272,10 +261,6 @@ public class AdminGoodsController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody GoodsAllinone goodsAllinone) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         Object error = validate(goodsAllinone);
         if (error != null) {
             return error;
@@ -339,10 +324,6 @@ public class AdminGoodsController {
 
     @GetMapping("/catAndBrand")
     public Object list2(@LoginAdmin Integer adminId) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         // http://element-cn.eleme.io/#/zh-CN/component/cascader
         // 管理员设置“所属分类”
         List<LitemallCategory> l1CatList = categoryService.queryL1();
@@ -385,10 +366,6 @@ public class AdminGoodsController {
 
     @GetMapping("/detail")
     public Object detail(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallGoods goods = goodsService.findById(id);
         List<LitemallGoodsProduct> products = productService.queryByGid(id);
         List<LitemallGoodsSpecification> specifications = specificationService.queryByGid(id);

+ 0 - 20
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.java

@@ -43,10 +43,6 @@ public class AdminGrouponController {
                              @RequestParam(defaultValue = "10") Integer limit,
                              @Sort @RequestParam(defaultValue = "add_time") String sort,
                              @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallGroupon> grouponList = grouponService.querySelective(grouponId, page, limit, sort, order);
         int total = grouponService.countSelective(grouponId, page, limit, sort, order);
 
@@ -83,10 +79,6 @@ public class AdminGrouponController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallGrouponRules> rulesList = rulesService.querySelective(goodsId, page, limit, sort, order);
         int total = rulesService.countSelective(goodsId, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -119,10 +111,6 @@ public class AdminGrouponController {
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallGrouponRules grouponRules) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         Object error = validate(grouponRules);
         if (error != null) {
             return error;
@@ -147,10 +135,6 @@ public class AdminGrouponController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallGrouponRules grouponRules) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         Object error = validate(grouponRules);
         if (error != null) {
             return error;
@@ -173,10 +157,6 @@ public class AdminGrouponController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallGrouponRules grouponRules) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         Integer id = grouponRules.getId();
         if (id == null) {
             return ResponseUtil.badArgument();

+ 0 - 4
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminHistoryController.java

@@ -33,10 +33,6 @@ public class AdminHistoryController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallSearchHistory> footprintList = searchHistoryService.querySelective(userId, keyword, page, limit, sort, order);
         int total = searchHistoryService.countSelective(userId, keyword, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();

+ 0 - 17
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminIssueController.java

@@ -34,10 +34,6 @@ public class AdminIssueController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallIssue> issueList = issueService.querySelective(question, page, limit, sort, order);
         int total = issueService.countSelective(question, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -61,9 +57,6 @@ public class AdminIssueController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(issue);
         if (error != null) {
             return error;
@@ -74,19 +67,12 @@ public class AdminIssueController {
 
     @GetMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallIssue issue = issueService.findById(id);
         return ResponseUtil.ok(issue);
     }
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(issue);
         if (error != null) {
             return error;
@@ -100,9 +86,6 @@ public class AdminIssueController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer id = issue.getId();
         if (id == null) {
             return ResponseUtil.badArgument();

+ 0 - 17
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminKeywordController.java

@@ -34,10 +34,6 @@ public class AdminKeywordController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallKeyword> brandList = keywordService.querySelective(keyword, url, page, limit, sort, order);
         int total = keywordService.countSelective(keyword, url, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -61,9 +57,6 @@ public class AdminKeywordController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keywords) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(keywords);
         if (error != null) {
             return error;
@@ -74,19 +67,12 @@ public class AdminKeywordController {
 
     @GetMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallKeyword brand = keywordService.findById(id);
         return ResponseUtil.ok(brand);
     }
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keywords) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(keywords);
         if (error != null) {
             return error;
@@ -99,9 +85,6 @@ public class AdminKeywordController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keyword) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer id = keyword.getId();
         if (id == null) {
             return ResponseUtil.badArgument();

+ 0 - 17
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminOrderController.java

@@ -68,9 +68,6 @@ public class AdminOrderController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         List<LitemallOrder> orderList = orderService.querySelective(userId, orderSn, orderStatusArray, page, limit, sort, order);
         int total = orderService.countSelective(userId, orderSn, orderStatusArray, page, limit, sort, order);
 
@@ -83,10 +80,6 @@ public class AdminOrderController {
 
     @GetMapping("/detail")
     public Object detail(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallOrder order = orderService.findById(id);
         List<LitemallOrderGoods> orderGoods = orderGoodsService.queryByOid(id);
         UserVo user = userService.findUserVoById(order.getUserId());
@@ -117,9 +110,6 @@ public class AdminOrderController {
      */
     @PostMapping("refund")
     public Object refund(@LoginAdmin Integer adminId, @RequestBody String body) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer orderId = JacksonUtil.parseInteger(body, "orderId");
         String refundMoney = JacksonUtil.parseString(body, "refundMoney");
         if (orderId == null) {
@@ -217,9 +207,6 @@ public class AdminOrderController {
      */
     @PostMapping("ship")
     public Object ship(@LoginAdmin Integer adminId, @RequestBody String body) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Integer orderId = JacksonUtil.parseInteger(body, "orderId");
         String shipSn = JacksonUtil.parseString(body, "shipSn");
         String shipChannel = JacksonUtil.parseString(body, "shipChannel");
@@ -265,10 +252,6 @@ public class AdminOrderController {
      */
     @PostMapping("reply")
     public Object reply(@LoginAdmin Integer adminId, @RequestBody String body) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         Integer commentId = JacksonUtil.parseInteger(body, "commentId");
         if (commentId == null || commentId == 0) {
             return ResponseUtil.badArgument();

+ 0 - 4
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminProfileController.java

@@ -30,10 +30,6 @@ public class AdminProfileController {
 
     @PostMapping("/password")
     public Object create(@LoginAdmin Integer adminId, @RequestBody String body) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         String oldPassword = JacksonUtil.parseString(body, "oldPassword");
         String newPassword = JacksonUtil.parseString(body, "newPassword");
         if (StringUtils.isEmpty(oldPassword)) {

+ 0 - 9
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminRegionController.java

@@ -31,12 +31,7 @@ public class AdminRegionController {
 
     @GetMapping("/clist")
     public Object clist(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallRegion> regionList = regionService.queryByPid(id);
-
         return ResponseUtil.ok(regionList);
     }
 
@@ -47,10 +42,6 @@ public class AdminRegionController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort(accepts = {"id"}) @RequestParam(defaultValue = "id") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallRegion> regionList = regionService.querySelective(name, code, page, limit, sort, order);
         int total = regionService.countSelective(name, code, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();

+ 0 - 15
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStatController.java

@@ -26,25 +26,16 @@ public class AdminStatController {
 
     @GetMapping("/user")
     public Object statUser(@LoginAdmin Integer adminId) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<Map> rows = statService.statUser();
         String[] columns = new String[]{"day", "users"};
         StatVo statVo = new StatVo();
         statVo.setColumns(columns);
         statVo.setRows(rows);
-
         return ResponseUtil.ok(statVo);
     }
 
     @GetMapping("/order")
     public Object statOrder(@LoginAdmin Integer adminId) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<Map> rows = statService.statOrder();
         String[] columns = new String[]{"day", "orders", "customers", "amount", "pcr"};
         StatVo statVo = new StatVo();
@@ -56,17 +47,11 @@ public class AdminStatController {
 
     @GetMapping("/goods")
     public Object statGoods(@LoginAdmin Integer adminId) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<Map> rows = statService.statGoods();
         String[] columns = new String[]{"day", "orders", "products", "amount"};
         StatVo statVo = new StatVo();
         statVo.setColumns(columns);
         statVo.setRows(rows);
-
-
         return ResponseUtil.ok(statVo);
     }
 

+ 0 - 12
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStorageController.java

@@ -50,9 +50,6 @@ public class AdminStorageController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestParam("file") MultipartFile file) throws IOException {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         String originalFilename = file.getOriginalFilename();
         String url = storageService.store(file.getInputStream(), file.getSize(), file.getContentType(), originalFilename);
         Map<String, Object> data = new HashMap<>();
@@ -62,9 +59,6 @@ public class AdminStorageController {
 
     @PostMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         LitemallStorage storageInfo = litemallStorageService.findById(id);
         if (storageInfo == null) {
             return ResponseUtil.badArgumentValue();
@@ -74,9 +68,6 @@ public class AdminStorageController {
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallStorage litemallStorage) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         if (litemallStorageService.update(litemallStorage) == 0) {
             return ResponseUtil.updatedDataFailed();
         }
@@ -85,9 +76,6 @@ public class AdminStorageController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallStorage litemallStorage) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         String key = litemallStorage.getKey();
         if (StringUtils.isEmpty(key)) {
             return ResponseUtil.badArgument();

+ 0 - 17
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminTopicController.java

@@ -35,10 +35,6 @@ public class AdminTopicController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         List<LitemallTopic> topicList = topicService.querySelective(title, subtitle, page, limit, sort, order);
         int total = topicService.countSelective(title, subtitle, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -66,9 +62,6 @@ public class AdminTopicController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(topic);
         if (error != null) {
             return error;
@@ -79,19 +72,12 @@ public class AdminTopicController {
 
     @GetMapping("/read")
     public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         LitemallTopic topic = topicService.findById(id);
         return ResponseUtil.ok(topic);
     }
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(topic);
         if (error != null) {
             return error;
@@ -104,9 +90,6 @@ public class AdminTopicController {
 
     @PostMapping("/delete")
     public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         topicService.deleteById(topic.getId());
         return ResponseUtil.ok();
     }

+ 0 - 13
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminUserController.java

@@ -38,9 +38,6 @@ public class AdminUserController {
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         List<LitemallUser> userList = userService.querySelective(username, mobile, page, limit, sort, order);
         int total = userService.countSeletive(username, mobile, page, limit, sort, order);
         Map<String, Object> data = new HashMap<>();
@@ -52,10 +49,6 @@ public class AdminUserController {
 
     @GetMapping("/username")
     public Object username(@LoginAdmin Integer adminId, @NotEmpty String username) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
-
         int total = userService.countSeletive(username, null, null, null, null, null);
         if (total == 0) {
             return ResponseUtil.ok("不存在");
@@ -87,9 +80,6 @@ public class AdminUserController {
 
     @PostMapping("/create")
     public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallUser user) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(user);
         if (error != null) {
             return error;
@@ -119,9 +109,6 @@ public class AdminUserController {
 
     @PostMapping("/update")
     public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallUser user) {
-        if (adminId == null) {
-            return ResponseUtil.unlogin();
-        }
         Object error = validate(user);
         if (error != null) {
             return error;

+ 8 - 0
litemall-core/src/main/java/org/linlinjava/litemall/core/config/GlobalExceptionHandler.java

@@ -1,5 +1,6 @@
 package org.linlinjava.litemall.core.config;
 
+import org.apache.shiro.authc.AuthenticationException;
 import org.apache.shiro.authz.AuthorizationException;
 import org.apache.shiro.authz.UnauthorizedException;
 import org.hibernate.validator.internal.engine.path.PathImpl;
@@ -47,6 +48,13 @@ public class GlobalExceptionHandler {
         return ResponseUtil.badArgumentValue();
     }
 
+    @ExceptionHandler(AuthenticationException.class)
+    @ResponseBody
+    public Object unauthenticatedHandler(AuthenticationException e) {
+        e.printStackTrace();
+        return ResponseUtil.unlogin();
+    }
+
     @ExceptionHandler(AuthorizationException.class)
     @ResponseBody
     public Object unauthorizedHandler(AuthorizationException e) {