package com.ekexiu.portal.dao;

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

import org.jfw.apt.annotation.Nullable;
import org.jfw.apt.orm.annotation.dao.Batch;
import org.jfw.apt.orm.annotation.dao.DAO;
import org.jfw.apt.orm.annotation.dao.method.From;
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
import org.jfw.apt.orm.annotation.dao.param.Set;

import com.ekexiu.portal.po.ResearchArea;

@DAO
public interface ResearchAreaDao {

	@OrderBy("ORDER BY SORT_NUM ASC")
	@SelectList
	List<ResearchArea> query(Connection con,String professorId)throws SQLException;
	@Nullable
	@SelectOne
	ResearchArea query(Connection con,String professorId,String caption)throws SQLException;
	
	@Insert
	int insert(Connection con,ResearchArea area) throws SQLException;
	
	@Insert
	@Batch
	int[] insert(Connection con,ResearchArea[] areas) throws SQLException;
	
	@DeleteWith
	@From(ResearchArea.class)
	int delete(Connection con,String professorId) throws SQLException;
	
	@DeleteWith
	@From(ResearchArea.class)
	int delete(Connection con,String professorId,String caption)throws SQLException;;
	
	@UpdateWith
	@From(ResearchArea.class)
	@SetSentence("COUNT = COUNT+1")
	int inc(Connection con,String professorId,String caption)throws SQLException;
	@UpdateWith
	@From(ResearchArea.class)
	@SetSentence("COUNT = COUNT - 1")
	int dec(Connection con,String professorId,String caption)throws SQLException;
	
	@UpdateWith
	@From(ResearchArea.class)
	int updateDescp(Connection con,String professorId,String caption,@Set String descp,@Set int sortNum) throws SQLException;
	
}
