package com.palmnest.dao.impl;

import com.palmnest.dao.UserActiveDao;
import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.model.UserActiveCount;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author HIAPAD
 * @Description TODO
 * @Date 2019/1/11 11:19
 **/
@Slf4j
@Repository("userActiveDao")
public class UserActiveDaoImpl extends GenericDaoHibernate<UserActiveCount, Long> implements UserActiveDao {


	public UserActiveDaoImpl() {
		super(UserActiveCount.class);
	}


	@Override
	public UserActiveCount getCountByDateAndOrgAndserviceCode(String date, String orgId, String serviceCode) {

		String sql = " select * " +
				"	from tb_user_active_count " +
				"	where " +
				"		serviceCode='" + serviceCode + "' " +
				"		and date='" + date + "' " +
				"		and orgId=" + orgId;

		List<UserActiveCount> list = getSession().createSQLQuery(sql).addEntity(UserActiveCount.class).list();

		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}


	@Override
	public int getCountByOrgCodeAndDate(String orgId, String serviceCode,
										int type, String date, String endDate) {

		return 0;
	}
}
