package cn.com.ty.lift.ud.question.service.impl;

import cn.com.ty.lift.ud.question.service.IQuestionOperateService;
import cn.com.ty.lift.ud.question.mapper.QuestionOperateMapper;
import cn.com.ty.lift.ud.question.mapper.entity.QuestionOperateEntity;
import cn.com.xwy.util.collection.ListUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 题库操作记录 -ServiceImpl
 *
 * @author Xson
 * @date 2020-04-30
 */
@Service
@Transactional
public class QuestionOperateServiceImpl extends ServiceImpl<QuestionOperateMapper, QuestionOperateEntity>
        implements IQuestionOperateService {

    @Autowired
    private QuestionOperateMapper questionOperateMapper;

    /**
     * 查询是否操作过
     *
     * @param qoEntity
     * @return
     */
    @Override
    public QuestionOperateEntity isCollect(QuestionOperateEntity qoEntity) {
        QuestionOperateEntity select = null;
        List<QuestionOperateEntity> selectList = questionOperateMapper.select(qoEntity);
        if(ListUtil.isNotEmpty(selectList)){
            select = selectList.get(0);
        }
        return select;
    }

    /**
     * 删除操作记录
     * @param operateEntity
     */
    @Override
    public void deleteOne(QuestionOperateEntity operateEntity) {
        questionOperateMapper.deleteOne(operateEntity);
    }
}
