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

import com.ssj.dao.sys.feedback.dao.FeedbackQueryDao;
import com.ssj.framework.core.persistence.PagingHibernateJdbcDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 类名称：ConfigDao<br>
 * 类描述：系统参数数据访问接口<br>
 * 
 * @version v1.0
 */
@Repository
public class FeedbackQueryDaoImpl implements FeedbackQueryDao {

    @Autowired
	private PagingHibernateJdbcDao dao;

	@Override
	public List<Map<String, Object>> findTextFeedbackByProblemIds(List<String> problemIds) {
		StringBuilder selSql = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSql.append(" select sf.id,sf.biz_id,sf.create_time as answer_time,stf.create_time as feedback_time,stf.content from scon_feedback sf ");
		selSql.append(" left join scon_text_feedback_detail stf on sf.id = stf.feedback_id");
		selSql.append(" where stf.type = 4 and sf.biz_id in('");
		for (String str : problemIds) {
			selSql.append(str).append("','");
		}
		
		String sql = selSql.substring(0, selSql.length()-2);
		sql += ")";
		
		return dao.findMap(sql, queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> findKnowFeedbackByProblemId(String pid) {
		StringBuilder sb = new StringBuilder();
		sb.append("select t3.id, t3.name text from scon_feedback t1 left join scon_know_feedback_detail t2 on t1.id=t2.feedback_id")
			.append(" left join zyb_know_how_details t3 on t2.know_how_details_id=t3.id where t1.biz_id='").append(pid)
			.append("'");
		return dao.findMap(sb.toString(), null);
	}
}
