Commit 68295482 authored by Junling Bu's avatar Junling Bu
Browse files

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

parent 653cf50f
...@@ -57,12 +57,7 @@ public class LitemallAdService { ...@@ -57,12 +57,7 @@ public class LitemallAdService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallAd ad = adMapper.selectByPrimaryKey(id); adMapper.logicalDeleteByPrimaryKey(id);
if(ad == null){
return;
}
ad.setDeleted(true);
adMapper.updateByPrimaryKey(ad);
} }
public void add(LitemallAd ad) { public void add(LitemallAd ad) {
......
...@@ -34,12 +34,7 @@ public class LitemallAddressService { ...@@ -34,12 +34,7 @@ public class LitemallAddressService {
} }
public void delete(Integer id) { public void delete(Integer id) {
LitemallAddress address = addressMapper.selectByPrimaryKey(id); addressMapper.logicalDeleteByPrimaryKey(id);
if(address == null){
return;
}
address.setDeleted(true);
addressMapper.updateByPrimaryKey(address);
} }
public LitemallAddress findDefault(Integer userId) { public LitemallAddress findDefault(Integer userId) {
......
...@@ -53,12 +53,7 @@ public class LitemallAdminService { ...@@ -53,12 +53,7 @@ public class LitemallAdminService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallAdmin admin = adminMapper.selectByPrimaryKey(id); adminMapper.logicalDeleteByPrimaryKey(id);
if(admin == null){
return;
}
admin.setDeleted(true);
adminMapper.updateByPrimaryKey(admin);
} }
public void add(LitemallAdmin admin) { public void add(LitemallAdmin admin) {
......
...@@ -75,12 +75,7 @@ public class LitemallBrandService { ...@@ -75,12 +75,7 @@ public class LitemallBrandService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallBrand brand = brandMapper.selectByPrimaryKey(id); brandMapper.logicalDeleteByPrimaryKey(id);
if(brand == null){
return;
}
brand.setDeleted(true);
brandMapper.updateByPrimaryKey(brand);
} }
public void add(LitemallBrand brand) { public void add(LitemallBrand brand) {
......
...@@ -50,9 +50,7 @@ public class LitemallCartService { ...@@ -50,9 +50,7 @@ public class LitemallCartService {
public int delete(List<Integer> productIdList, int userId) { public int delete(List<Integer> productIdList, int userId) {
LitemallCartExample example = new LitemallCartExample(); LitemallCartExample example = new LitemallCartExample();
example.or().andUserIdEqualTo(userId).andProductIdIn(productIdList); example.or().andUserIdEqualTo(userId).andProductIdIn(productIdList);
LitemallCart cart = new LitemallCart(); return cartMapper.logicalDeleteByExample(example);
cart.setDeleted(true);
return cartMapper.updateByExampleSelective(cart, example);
} }
public LitemallCart findById(Integer id) { public LitemallCart findById(Integer id) {
...@@ -107,11 +105,6 @@ public class LitemallCartService { ...@@ -107,11 +105,6 @@ public class LitemallCartService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallCart cart = cartMapper.selectByPrimaryKey(id); cartMapper.logicalDeleteByPrimaryKey(id);
if(cart == null){
return;
}
cart.setDeleted(true);
cartMapper.updateByPrimaryKey(cart);
} }
} }
...@@ -87,12 +87,7 @@ public class LitemallCategoryService { ...@@ -87,12 +87,7 @@ public class LitemallCategoryService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallCategory category = categoryMapper.selectByPrimaryKey(id); categoryMapper.logicalDeleteByPrimaryKey(id);
if(category == null){
return;
}
category.setDeleted(true);
categoryMapper.updateByPrimaryKey(category);
} }
public void add(LitemallCategory category) { public void add(LitemallCategory category) {
......
...@@ -42,12 +42,7 @@ public class LitemallCollectService { ...@@ -42,12 +42,7 @@ public class LitemallCollectService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallCollect collect = collectMapper.selectByPrimaryKey(id); collectMapper.logicalDeleteByPrimaryKey(id);
if(collect == null){
return;
}
collect.setDeleted(true);
collectMapper.updateByPrimaryKey(collect);
} }
public int add(LitemallCollect collect) { public int add(LitemallCollect collect) {
......
...@@ -107,12 +107,7 @@ public class LitemallCommentService { ...@@ -107,12 +107,7 @@ public class LitemallCommentService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallComment comment = commentMapper.selectByPrimaryKey(id); commentMapper.logicalDeleteByPrimaryKey(id);
if(comment == null){
return;
}
comment.setDeleted(true);
commentMapper.updateByPrimaryKey(comment);
} }
public void add(LitemallComment comment) { public void add(LitemallComment comment) {
......
...@@ -34,12 +34,7 @@ public class LitemallFootprintService { ...@@ -34,12 +34,7 @@ public class LitemallFootprintService {
} }
public void deleteById(Integer id){ public void deleteById(Integer id){
LitemallFootprint footprint = footprintMapper.selectByPrimaryKey(id); footprintMapper.logicalDeleteByPrimaryKey(id);
if(footprint == null){
return;
}
footprint.setDeleted(true);
footprintMapper.updateByPrimaryKey(footprint);
} }
public void add(LitemallFootprint footprint) { public void add(LitemallFootprint footprint) {
......
...@@ -50,12 +50,7 @@ public class LitemallGoodsAttributeService { ...@@ -50,12 +50,7 @@ public class LitemallGoodsAttributeService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallGoodsAttribute goodsAttribute = goodsAttributeMapper.selectByPrimaryKey(id); goodsAttributeMapper.logicalDeleteByPrimaryKey(id);
if(goodsAttribute == null){
return;
}
goodsAttribute.setDeleted(true);
goodsAttributeMapper.updateByPrimaryKey(goodsAttribute);
} }
public void add(LitemallGoodsAttribute goodsAttribute) { public void add(LitemallGoodsAttribute goodsAttribute) {
......
...@@ -169,12 +169,7 @@ public class LitemallGoodsService { ...@@ -169,12 +169,7 @@ public class LitemallGoodsService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallGoods goods = goodsMapper.selectByPrimaryKey(id); goodsMapper.logicalDeleteByPrimaryKey(id);
if(goods == null){
return;
}
goods.setDeleted(true);
goodsMapper.updateByPrimaryKeySelective(goods);
} }
public void add(LitemallGoods goods) { public void add(LitemallGoods goods) {
......
...@@ -57,12 +57,7 @@ public class LitemallGoodsSpecificationService { ...@@ -57,12 +57,7 @@ public class LitemallGoodsSpecificationService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallGoodsSpecification goodsSpecification = goodsSpecificationMapper.selectByPrimaryKey(id); goodsSpecificationMapper.logicalDeleteByPrimaryKey(id);
if(goodsSpecification == null){
return;
}
goodsSpecification.setDeleted(true);
goodsSpecificationMapper.updateByPrimaryKey(goodsSpecification);
} }
public void add(LitemallGoodsSpecification goodsSpecification) { public void add(LitemallGoodsSpecification goodsSpecification) {
......
...@@ -22,12 +22,7 @@ public class LitemallIssueService { ...@@ -22,12 +22,7 @@ public class LitemallIssueService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallIssue issue = issueMapper.selectByPrimaryKey(id); issueMapper.logicalDeleteByPrimaryKey(id);
if(issue == null){
return;
}
issue.setDeleted(true);
issueMapper.updateByPrimaryKey(issue);
} }
public void add(LitemallIssue issue) { public void add(LitemallIssue issue) {
......
...@@ -86,11 +86,6 @@ public class LitemallKeywordService { ...@@ -86,11 +86,6 @@ public class LitemallKeywordService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallKeyword keywords = keywordsMapper.selectByPrimaryKey(id); keywordsMapper.logicalDeleteByPrimaryKey(id);
if(keywords == null){
return;
}
keywords.setDeleted(true);
keywordsMapper.updateByPrimaryKey(keywords);
} }
} }
...@@ -136,12 +136,7 @@ public class LitemallOrderService { ...@@ -136,12 +136,7 @@ public class LitemallOrderService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallOrder order = orderMapper.selectByPrimaryKey(id); orderMapper.logicalDeleteByPrimaryKey(id);
if(order == null){
return;
}
order.setDeleted(true);
orderMapper.updateByPrimaryKey(order);
} }
public int count() { public int count() {
......
...@@ -54,12 +54,7 @@ public class LitemallProductService { ...@@ -54,12 +54,7 @@ public class LitemallProductService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallProduct product = productMapper.selectByPrimaryKey(id); productMapper.logicalDeleteByPrimaryKey(id);
if(product == null){
return;
}
product.setDeleted(true);
productMapper.updateByPrimaryKey(product);
} }
public void add(LitemallProduct product) { public void add(LitemallProduct product) {
......
...@@ -29,9 +29,7 @@ public class LitemallSearchHistoryService { ...@@ -29,9 +29,7 @@ public class LitemallSearchHistoryService {
public void deleteByUid(int uid) { public void deleteByUid(int uid) {
LitemallSearchHistoryExample example = new LitemallSearchHistoryExample(); LitemallSearchHistoryExample example = new LitemallSearchHistoryExample();
example.or().andUserIdEqualTo(uid); example.or().andUserIdEqualTo(uid);
LitemallSearchHistory searchHistory = new LitemallSearchHistory(); searchHistoryMapper.logicalDeleteByExample(example);
searchHistory.setDeleted(true);
searchHistoryMapper.updateByExampleSelective(searchHistory, example);
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
...@@ -40,7 +38,7 @@ public class LitemallSearchHistoryService { ...@@ -40,7 +38,7 @@ public class LitemallSearchHistoryService {
return; return;
} }
searchHistory.setDeleted(true); searchHistory.setDeleted(true);
searchHistoryMapper.updateByPrimaryKey(searchHistory); searchHistoryMapper.logicalDeleteByPrimaryKey(id);
} }
public void add(LitemallSearchHistory searchHistory) { public void add(LitemallSearchHistory searchHistory) {
......
...@@ -18,9 +18,7 @@ public class LitemallStorageService { ...@@ -18,9 +18,7 @@ public class LitemallStorageService {
public void deleteByKey(String key) { public void deleteByKey(String key) {
LitemallStorageExample example = new LitemallStorageExample(); LitemallStorageExample example = new LitemallStorageExample();
example.or().andKeyEqualTo(key); example.or().andKeyEqualTo(key);
LitemallStorage storage = new LitemallStorage(); storageMapper.logicalDeleteByExample(example);
storage.setDeleted(true);
storageMapper.updateByExampleSelective(storage, example);
} }
public void add(LitemallStorage storageInfo) { public void add(LitemallStorage storageInfo) {
......
...@@ -92,12 +92,7 @@ public class LitemallTopicService { ...@@ -92,12 +92,7 @@ public class LitemallTopicService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallTopic topic = topicMapper.selectByPrimaryKey(id); topicMapper.logicalDeleteByPrimaryKey(id);
if(topic == null){
return;
}
topic.setDeleted(true);
topicMapper.updateByPrimaryKeySelective(topic);
} }
public void add(LitemallTopic topic) { public void add(LitemallTopic topic) {
......
...@@ -83,11 +83,6 @@ public class LitemallUserService { ...@@ -83,11 +83,6 @@ public class LitemallUserService {
} }
public void deleteById(Integer id) { public void deleteById(Integer id) {
LitemallUser user = userMapper.selectByPrimaryKey(id); userMapper.logicalDeleteByPrimaryKey(id);
if(user == null){
return;
}
user.setDeleted(true);
userMapper.updateByPrimaryKey(user);
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment