ソースを参照

update[litemall-db]: 基于mybatis generator的逻辑删除插件来进行删除操作。

Junling Bu 7 年 前
コミット
68295482dd
20 ファイル変更22 行追加118 行削除
  1. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdService.java
  2. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java
  3. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdminService.java
  4. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java
  5. 2 9
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java
  6. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCategoryService.java
  7. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCollectService.java
  8. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java
  9. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java
  10. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsAttributeService.java
  11. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java
  12. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsSpecificationService.java
  13. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallIssueService.java
  14. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallKeywordService.java
  15. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderService.java
  16. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallProductService.java
  17. 2 4
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSearchHistoryService.java
  18. 1 3
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallStorageService.java
  19. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java
  20. 1 6
      litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallUserService.java

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdService.java

@@ -57,12 +57,7 @@ public class LitemallAdService {
     }
 
     public void deleteById(Integer id) {
-        LitemallAd ad = adMapper.selectByPrimaryKey(id);
-        if(ad == null){
-            return;
-        }
-        ad.setDeleted(true);
-        adMapper.updateByPrimaryKey(ad);
+        adMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallAd ad) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java

@@ -34,12 +34,7 @@ public class LitemallAddressService {
     }
 
     public void delete(Integer id) {
-        LitemallAddress address = addressMapper.selectByPrimaryKey(id);
-        if(address == null){
-            return;
-        }
-        address.setDeleted(true);
-        addressMapper.updateByPrimaryKey(address);
+        addressMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public LitemallAddress findDefault(Integer userId) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAdminService.java

@@ -53,12 +53,7 @@ public class LitemallAdminService {
     }
 
     public void deleteById(Integer id) {
-        LitemallAdmin admin = adminMapper.selectByPrimaryKey(id);
-        if(admin == null){
-            return;
-        }
-        admin.setDeleted(true);
-        adminMapper.updateByPrimaryKey(admin);
+        adminMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallAdmin admin) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallBrandService.java

@@ -75,12 +75,7 @@ public class LitemallBrandService {
     }
 
     public void deleteById(Integer id) {
-        LitemallBrand brand = brandMapper.selectByPrimaryKey(id);
-        if(brand == null){
-            return;
-        }
-        brand.setDeleted(true);
-        brandMapper.updateByPrimaryKey(brand);
+        brandMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallBrand brand) {

+ 2 - 9
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java

@@ -50,9 +50,7 @@ public class LitemallCartService {
     public int delete(List<Integer> productIdList, int userId) {
         LitemallCartExample example = new LitemallCartExample();
         example.or().andUserIdEqualTo(userId).andProductIdIn(productIdList);
-        LitemallCart cart = new LitemallCart();
-        cart.setDeleted(true);
-        return cartMapper.updateByExampleSelective(cart, example);
+        return cartMapper.logicalDeleteByExample(example);
     }
 
     public LitemallCart findById(Integer id) {
@@ -107,11 +105,6 @@ public class LitemallCartService {
     }
 
     public void deleteById(Integer id) {
-        LitemallCart cart = cartMapper.selectByPrimaryKey(id);
-        if(cart == null){
-            return;
-        }
-        cart.setDeleted(true);
-        cartMapper.updateByPrimaryKey(cart);
+        cartMapper.logicalDeleteByPrimaryKey(id);
     }
 }

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCategoryService.java

@@ -87,12 +87,7 @@ public class LitemallCategoryService {
     }
 
     public void deleteById(Integer id) {
-        LitemallCategory category = categoryMapper.selectByPrimaryKey(id);
-        if(category == null){
-            return;
-        }
-        category.setDeleted(true);
-        categoryMapper.updateByPrimaryKey(category);
+        categoryMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallCategory category) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCollectService.java

@@ -42,12 +42,7 @@ public class LitemallCollectService {
     }
 
     public void deleteById(Integer id) {
-        LitemallCollect collect = collectMapper.selectByPrimaryKey(id);
-        if(collect == null){
-            return;
-        }
-        collect.setDeleted(true);
-        collectMapper.updateByPrimaryKey(collect);
+        collectMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public int add(LitemallCollect collect) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java

@@ -107,12 +107,7 @@ public class LitemallCommentService {
     }
 
     public void deleteById(Integer id) {
-        LitemallComment comment = commentMapper.selectByPrimaryKey(id);
-        if(comment == null){
-            return;
-        }
-        comment.setDeleted(true);
-        commentMapper.updateByPrimaryKey(comment);
+        commentMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallComment comment) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java

@@ -34,12 +34,7 @@ public class LitemallFootprintService {
     }
 
     public void deleteById(Integer id){
-        LitemallFootprint footprint = footprintMapper.selectByPrimaryKey(id);
-        if(footprint == null){
-            return;
-        }
-        footprint.setDeleted(true);
-        footprintMapper.updateByPrimaryKey(footprint);
+        footprintMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallFootprint footprint) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsAttributeService.java

@@ -50,12 +50,7 @@ public class LitemallGoodsAttributeService {
     }
 
     public void deleteById(Integer id) {
-        LitemallGoodsAttribute goodsAttribute = goodsAttributeMapper.selectByPrimaryKey(id);
-        if(goodsAttribute == null){
-            return;
-        }
-        goodsAttribute.setDeleted(true);
-        goodsAttributeMapper.updateByPrimaryKey(goodsAttribute);
+        goodsAttributeMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallGoodsAttribute goodsAttribute) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsService.java

@@ -169,12 +169,7 @@ public class LitemallGoodsService {
     }
 
     public void deleteById(Integer id) {
-        LitemallGoods goods = goodsMapper.selectByPrimaryKey(id);
-        if(goods == null){
-            return;
-        }
-        goods.setDeleted(true);
-        goodsMapper.updateByPrimaryKeySelective(goods);
+        goodsMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallGoods goods) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGoodsSpecificationService.java

@@ -57,12 +57,7 @@ public class LitemallGoodsSpecificationService {
     }
 
     public void deleteById(Integer id) {
-        LitemallGoodsSpecification goodsSpecification = goodsSpecificationMapper.selectByPrimaryKey(id);
-        if(goodsSpecification == null){
-            return;
-        }
-        goodsSpecification.setDeleted(true);
-        goodsSpecificationMapper.updateByPrimaryKey(goodsSpecification);
+        goodsSpecificationMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallGoodsSpecification goodsSpecification) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallIssueService.java

@@ -22,12 +22,7 @@ public class LitemallIssueService {
     }
 
     public void deleteById(Integer id) {
-        LitemallIssue issue = issueMapper.selectByPrimaryKey(id);
-        if(issue == null){
-            return;
-        }
-        issue.setDeleted(true);
-        issueMapper.updateByPrimaryKey(issue);
+        issueMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallIssue issue) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallKeywordService.java

@@ -86,11 +86,6 @@ public class LitemallKeywordService {
     }
 
     public void deleteById(Integer id) {
-        LitemallKeyword keywords = keywordsMapper.selectByPrimaryKey(id);
-        if(keywords == null){
-            return;
-        }
-        keywords.setDeleted(true);
-        keywordsMapper.updateByPrimaryKey(keywords);
+        keywordsMapper.logicalDeleteByPrimaryKey(id);
     }
 }

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderService.java

@@ -136,12 +136,7 @@ public class LitemallOrderService {
     }
 
     public void deleteById(Integer id) {
-        LitemallOrder order = orderMapper.selectByPrimaryKey(id);
-        if(order == null){
-            return;
-        }
-        order.setDeleted(true);
-        orderMapper.updateByPrimaryKey(order);
+        orderMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public int count() {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallProductService.java

@@ -54,12 +54,7 @@ public class LitemallProductService {
     }
 
     public void deleteById(Integer id) {
-        LitemallProduct product = productMapper.selectByPrimaryKey(id);
-        if(product == null){
-            return;
-        }
-        product.setDeleted(true);
-        productMapper.updateByPrimaryKey(product);
+        productMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallProduct product) {

+ 2 - 4
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSearchHistoryService.java

@@ -29,9 +29,7 @@ public class LitemallSearchHistoryService {
     public void deleteByUid(int uid) {
         LitemallSearchHistoryExample example = new LitemallSearchHistoryExample();
         example.or().andUserIdEqualTo(uid);
-        LitemallSearchHistory searchHistory = new LitemallSearchHistory();
-        searchHistory.setDeleted(true);
-        searchHistoryMapper.updateByExampleSelective(searchHistory, example);
+        searchHistoryMapper.logicalDeleteByExample(example);
     }
 
     public void deleteById(Integer id) {
@@ -40,7 +38,7 @@ public class LitemallSearchHistoryService {
             return;
         }
         searchHistory.setDeleted(true);
-        searchHistoryMapper.updateByPrimaryKey(searchHistory);
+        searchHistoryMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallSearchHistory searchHistory) {

+ 1 - 3
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallStorageService.java

@@ -18,9 +18,7 @@ public class LitemallStorageService {
     public void deleteByKey(String key) {
         LitemallStorageExample example = new LitemallStorageExample();
         example.or().andKeyEqualTo(key);
-        LitemallStorage storage = new LitemallStorage();
-        storage.setDeleted(true);
-        storageMapper.updateByExampleSelective(storage, example);
+        storageMapper.logicalDeleteByExample(example);
     }
 
     public void add(LitemallStorage storageInfo) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallTopicService.java

@@ -92,12 +92,7 @@ public class LitemallTopicService {
     }
 
     public void deleteById(Integer id) {
-        LitemallTopic topic = topicMapper.selectByPrimaryKey(id);
-        if(topic == null){
-            return;
-        }
-        topic.setDeleted(true);
-        topicMapper.updateByPrimaryKeySelective(topic);
+        topicMapper.logicalDeleteByPrimaryKey(id);
     }
 
     public void add(LitemallTopic topic) {

+ 1 - 6
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallUserService.java

@@ -83,11 +83,6 @@ public class LitemallUserService {
     }
 
     public void deleteById(Integer id) {
-        LitemallUser user = userMapper.selectByPrimaryKey(id);
-        if(user == null){
-            return;
-        }
-        user.setDeleted(true);
-        userMapper.updateByPrimaryKey(user);
+        userMapper.logicalDeleteByPrimaryKey(id);
     }
 }