package sikd.sikd5.sikd5ejb.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import sikd.sikd5.sikd5bean.tabel.transaksi.Headerapbdskpd;

/**
*@oleh    : agus
*@tanggal : Sep 16, 2019
*/
@SuppressWarnings("el-syntax")
public interface HeaderapbdskpdMapper {
	@Insert({
		"INSERT INTO transaksi.headerapbdskpd\n" + 
		"(headerapbdid, namaskpd, sha256skpd)\n" + 
		"VALUES(#{record.headerapbdid}, #{record.namaskpd},#{record.sha256skpd})\n"
	})
	int inserHeaderapbdskpd(@Param("record") Headerapbdskpd headerapbdskpd);
	
	@Update({
		"UPDATE transaksi.headerapbdskpd\n" + 
		"SET sha256skpd=#{record.sha256skpd}\n" + 
		"WHERE headerapbdid=#{record.headerapbdid} AND namaskpd=#{record.namaskpd}\n" 
	})
	int updateHeaderapbdskpd(@Param("record") Headerapbdskpd headerapbdskpd);
	
	@Select({
		"SELECT a.headerapbdid, a.namaskpd, a.sha256skpd\n",
		"FROM transaksi.headerapbdskpd a \n", 
		"left join transaksi.headerapbd b on a.headerapbdid=b.headerapbdid ", 
	    "where ",
        "kodesatker=#{kodesatker,jdbcType=VARCHAR} and tahunanggaran=#{tahunanggaran,jdbcType=INTEGER} ",
        "and kodedata=#{kodedata,jdbcType=INTEGER} and jeniscoa=#{jeniscoa,jdbcType=INTEGER} ",
        "and a.namaskpd=#{namaskpd,jdbcType=VARCHAR}"
	})
	Headerapbdskpd selectHeaderapbdskpd(@Param("tahunanggaran") int tahunanggaran,
            @Param("kodesatker") String kodesatker, @Param("kodedata") int kodedata, @Param("jeniscoa") int jeniscoa,
            @Param("namaskpd") String namaskpd);
}
