package jp.agentec.sinaburocast.service;

import java.util.List;

import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;

import jp.agentec.sinaburocast.entity.AdminUser;
import jp.agentec.sinaburocast.entity.GiftExchangeInfo;

@Component(instance=InstanceType.SINGLETON)
public class GiftExchangeInfoService extends AbstractService<GiftExchangeInfo> {

	private static final String ID_SEQ_NAME = "gift_exchange_info_id_seq";
	/**
	 * IDを発行して、登録する。
	 *
	 */
	public int insertGiftExchangeInfo(GiftExchangeInfo giftExchangeInfo, AdminUser adminUserInfo) {
		giftExchangeInfo.giftExchangeInfoId = getSeqNextVal(Integer.class, ID_SEQ_NAME);
		return super.insert(giftExchangeInfo, adminUserInfo.loginId);
	}

	public GiftExchangeInfo findGiftExchangeInfo() {
		return select().getSingleResult();
	}
	
	// 全検索
	public List<GiftExchangeInfo> findGiftExchangeInfoList() {
		return select().orderBy("giftExchangeInfoId asc").getResultList();
	}

	// IDで検索
	public GiftExchangeInfo findGiftExchangeInfoById(Integer giftExchangeInfoId) {
		return select().where(new SimpleWhere().eq("giftExchangeInfoId",giftExchangeInfoId )).getSingleResult();
	}
	
}