package com.ekexiu.portal.service;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import org.jfw.apt.annotation.Autowrie;
import org.jfw.apt.web.annotation.Path;
import org.jfw.apt.web.annotation.operate.Get;
import org.jfw.apt.web.annotation.operate.Post;
import org.jfw.apt.web.annotation.param.JdbcConn;
import org.jfw.apt.web.annotation.param.PathVar;
import org.jfw.util.StringUtil;
import org.jfw.util.exception.JfwBaseException;

import com.ekexiu.portal.dao.PayHistoryDao;
import com.ekexiu.portal.po.PayHistory;

@Path("/payhistory")
public class PayHistoryService {
	@Autowrie
	private PayHistoryDao payHistoryDao;

	public PayHistoryDao getPayHistoryDao() {
		return payHistoryDao;
	}

	public void setPayHistoryDao(PayHistoryDao payHistoryDao) {
		this.payHistoryDao = payHistoryDao;
	}
	
	@Post
	@Path
	public String insert(@JdbcConn(true) Connection con, PayHistory payHistory) throws SQLException {
		String payHistoryId = StringUtil.buildUUID();
		payHistory.setPayHistoryId(payHistoryId);
		this.payHistoryDao.insert(con, payHistory);
		return payHistoryId;
	}
	
	@Post
	@Path("/status")
	public void updatePayStatus(@JdbcConn(true) Connection con, String payHistoryId, int payStatus) throws SQLException {
		this.payHistoryDao.update(con, payHistoryId, payStatus);
	}
	
	@Get
	@Path("/{payHistoryId}")
	public PayHistory query(@JdbcConn Connection con, @PathVar String payHistoryId) throws SQLException, JfwBaseException {
		return this.payHistoryDao.query(con, payHistoryId);
	}
	
	@Get
	@Path("/qadetail")
	public List<PayHistory> queryDetail(@JdbcConn Connection con, String operationId) throws SQLException {
		return this.payHistoryDao.queryDetail(con, operationId);
	}
	
}
