新版
This commit is contained in:
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,8 @@ public interface UserEbookBuyService extends IService<UserEbookBuyEntity> {
|
||||
|
||||
PageUtils queryPages(Map<String, Object> params);
|
||||
|
||||
void addBookForUser(Integer userId, List<Integer> bookIds);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -45,23 +47,17 @@ public class UserEbookBuyServiceImpl extends ServiceImpl<UserEbookBuyDao, UserEb
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void addBookForUser(Integer userId, List<Integer> bookIds) {
|
||||
for (Integer i:bookIds){
|
||||
List<UserEbookBuyEntity> userEbookBuyEntities = this.getBaseMapper().selectList(new LambdaQueryWrapper<UserEbookBuyEntity>().eq(UserEbookBuyEntity::getUserId, userId).eq(UserEbookBuyEntity::getBookId, i));
|
||||
if(userEbookBuyEntities.size()==0){
|
||||
UserEbookBuyEntity userEbookBuyEntity = new UserEbookBuyEntity();
|
||||
userEbookBuyEntity.setUserId(userId);
|
||||
userEbookBuyEntity.setBookId(i);
|
||||
userEbookBuyEntity.setPayTime(new Date());
|
||||
this.save(userEbookBuyEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user