package com.ssj.dao.sys.wrongbook.dao.impl;

import com.ssj.dao.sys.wrongbook.dao.WrongBookQueryDao;
import com.ssj.framework.core.persistence.PagingHibernateJdbcDao;
import com.ssj.service.conch.conch.vo.WrongQuestionRecordsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class WrongBookQueryDaoImpl implements WrongBookQueryDao {

    @Autowired
    private PagingHibernateJdbcDao pagingHibernateJdbcDao;

    @Override
    public List<WrongQuestionRecordsVO> findByDerver(String derver) {
        String sql =
                "select scon_homework_wrong_question.id homework_wrong_question_id, scon_homework_wrong_question.image, scon_homework_wrong_question.create_time create_time_date\n" +
                "from scon_homework_wrong_question,\n" +
                "     scon_homework,\n" +
                "     scon_homework_picture,\n" +
                "     tb_lib_vip\n" +
                "where scon_homework_wrong_question.homework_id = scon_homework.id\n" +
                "  and scon_homework_wrong_question.homework_picture_id = scon_homework_picture.id\n" +
                "  and scon_homework.vip_id = tb_lib_vip.id\n" +
                "  and tb_lib_vip.derver = '" + derver + "'\n" +
                "  and scon_homework_picture.derver_file_key is not null\n" +
                "order by scon_homework_wrong_question.create_time desc\n";

        return pagingHibernateJdbcDao.findList(sql, WrongQuestionRecordsVO.class);
    }

}
