package com.palmnest.dao.notice.impl;

import com.palmnest.application.bean.Page;
import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.dao.notice.AppNoticeReminderRecordDao;
import com.palmnest.model.notice.AppNoticeReminderDetailModel;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import java.util.Map;
@Repository("appNoticeReminderRecordDao")
public class appNoticeReminderRecordDaoImpl extends GenericDaoHibernate<AppNoticeReminderDetailModel, Integer> implements AppNoticeReminderRecordDao {

    public appNoticeReminderRecordDaoImpl() {
        super(AppNoticeReminderDetailModel.class);

    }
    private Logger LOG = Logger.getLogger(appNoticeReminderRecordDaoImpl.class);


    @Override
    public Page<AppNoticeReminderDetailModel,String> getReminderRecord(Integer id, int pageNo, int pageSize) {
        LOG.info("appNoticeReminderRecordDaoImpl getReminderRecord======");
        StringBuffer sbf = new StringBuffer();
        sbf.append("  select n_id,content,createTime from tb_app_notice_reminder_record where n_id="+id +" ORDER BY createTime DESC");

        LOG.info("appNoticeReminderRecordDaoImpl getReminderRecord sql" + sbf.toString());
        return pagedQueryByJdbcTemplate(sbf.toString(), pageNo, pageSize);
    }

    @Override
    public void addReminderRecord(Map<String, Object> map) {
        LOG.info("appNoticeReminderRecordDaoImpl addReminderRecord======");
        StringBuilder sql = new StringBuilder();
        sql.append(" insert into tb_app_notice_reminder_record (n_id,content)  values ("+map.get("id").toString()+",'"+map.get("content").toString()+"')");
        LOG.info("appNoticeReminderRecordDaoImpl addReminderRecord sql" + sql.toString());
        int count = getSession().createSQLQuery(sql.toString()).executeUpdate();
    }
}
