| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.modules.exam.service.ExamSubjectChoicesService; |
| | | import org.springblade.modules.training.entity.TrainingRegistration; |
| | | import org.springblade.modules.vip.entity.VipTopic; |
| | | import org.springblade.modules.vip.mapper.VipTopicMapper; |
| | | import org.springblade.modules.vip.service.VipTopicService; |
| | | import org.springblade.modules.vip.vo.VipTopicVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户会员题库服务实现类 |
| | |
| | | @Service |
| | | public class VipTopticServiceImpl extends ServiceImpl<VipTopicMapper, VipTopic> implements VipTopicService { |
| | | |
| | | @Autowired |
| | | private ExamSubjectChoicesService examSubjectChoicesService; |
| | | |
| | | /** |
| | | * 自定义分页查询用户会员数据 |
| | | * @param page |
| | |
| | | public IPage<VipTopicVO> selectVipTopicPage(IPage<VipTopicVO> page, VipTopicVO vipTopic) { |
| | | return page.setRecords(baseMapper.selectVipTopicPage(page, vipTopic)); |
| | | } |
| | | |
| | | /** |
| | | * 新增会员题库 |
| | | * @param trainingRegistration |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean insertVipTopicInfo(TrainingRegistration trainingRegistration) { |
| | | //先查询是否已经交过费的 |
| | | VipTopic vipTopic1 = new VipTopic(); |
| | | vipTopic1.setUserId(Long.parseLong(trainingRegistration.getUserId())); |
| | | List<VipTopic> list1 = this.list(Condition.getQueryWrapper(vipTopic1)); |
| | | boolean status =false; |
| | | if (list1.size()>0){ |
| | | //1.获取vipTopic |
| | | VipTopic vipTopic = list1.get(0); |
| | | //2. 随机查询120道题目信息,只要题目 id 集合即可 |
| | | List<String> list = examSubjectChoicesService.getExamSubjectChoicesList(); |
| | | //3. 数据处理,封装 |
| | | String collect = list.stream().collect(Collectors.joining(",")); |
| | | vipTopic.setTopicIds(collect); |
| | | vipTopic.setUpdateTime(new Date()); |
| | | //4.更新 |
| | | status = this.updateById(vipTopic); |
| | | }else { |
| | | //1. 创建会员题库对象 |
| | | VipTopic vipTopic = new VipTopic(); |
| | | //2. 随机查询120道题目信息,只要题目 id 集合即可 |
| | | List<String> list = examSubjectChoicesService.getExamSubjectChoicesList(); |
| | | //3. 数据处理,封装 |
| | | String collect = list.stream().collect(Collectors.joining(",")); |
| | | vipTopic.setTopicIds(collect); |
| | | vipTopic.setApplyId(trainingRegistration.getId()); |
| | | vipTopic.setCreateTime(new Date()); |
| | | vipTopic.setUpdateTime(new Date()); |
| | | vipTopic.setUserId(Long.parseLong(trainingRegistration.getUserId())); |
| | | //4. 新增并返回 |
| | | status = this.save(vipTopic); |
| | | } |
| | | return status; |
| | | } |
| | | } |