package com.yzdx.AiInterviewer.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.yzdx.AiInterviewer.entity.BaseEntity; import com.yzdx.AiInterviewer.entity.QuestionBank; import com.yzdx.AiInterviewer.entity.SharedQuestionBank; import com.yzdx.AiInterviewer.mapper.SharedQuestionBankMapper; import com.yzdx.AiInterviewer.service.SharedQuestionBankService; import com.yzdx.AiInterviewer.utiles.TimeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class SharedQuestionBankServiceImpl extends ServiceImpl implements SharedQuestionBankService{ @Autowired private SharedQuestionBankMapper sharedQuestionBankMapper; @Override public SharedQuestionBank addSharedQuestionBank(String typeName, Integer type, String description, Integer userId) { LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>(); queryWrapper.eq(SharedQuestionBank::getTypeName,typeName).eq(BaseEntity::getCreateUser,userId); SharedQuestionBank sharedQuestionBank = sharedQuestionBankMapper.selectOne(queryWrapper); if (sharedQuestionBank!=null){ return null; } SharedQuestionBank newSharedBank=new SharedQuestionBank(); newSharedBank.setTypeName(typeName); newSharedBank.setType(type); newSharedBank.setDescription(description); newSharedBank.setCreateUser(userId); newSharedBank.setCreateTime(TimeUtil.getTime()); sharedQuestionBankMapper.insert(newSharedBank); LambdaQueryWrapper bankLambdaQueryWrapper=new LambdaQueryWrapper<>(); bankLambdaQueryWrapper.eq(SharedQuestionBank::getTypeName,typeName).eq(BaseEntity::getCreateUser,userId); return sharedQuestionBankMapper.selectOne(bankLambdaQueryWrapper); } }