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.Column;
import org.jfw.apt.orm.annotation.dao.DAO;
import org.jfw.apt.orm.annotation.dao.Dynamic;
import org.jfw.apt.orm.annotation.dao.method.From;
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.LimitQuery;
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
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.Update;
import org.jfw.apt.orm.annotation.dao.param.Like;
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
import org.jfw.util.PageQueryResult;

import com.ekexiu.portal.basepo.BaseOrganization;
import com.ekexiu.portal.po.Organization;

@DAO
public interface OrgDao {
	
	@Insert
	int insert(Connection con, Organization org)throws SQLException;
	
	@Dynamic
	@Update
	int update(Connection con,Organization org)throws SQLException;
	

	@Nullable
	@SelectOne
	Organization query(Connection con,String id) throws SQLException;
	
	@SelectList
	List<Organization> query(Connection con)throws SQLException;
	@LimitQuery
	List<Organization> limitQuery(Connection con, @Like String name,int rows)throws SQLException;
	
	@Nullable
	@QueryVal
	@Column(handlerClass=StringHandler.class,value="id")
	@From(Organization.class)
	String queryByName(Connection con,String name)throws SQLException;
	
	@PageSelect
	PageQueryResult<Organization> query(Connection con,@Nullable  @Like String name,@Nullable String orgType,int pageSize,int pageNo) throws SQLException;

	@From(Organization.class)
	@LimitQuery
	List<BaseOrganization> query(Connection con,@Nullable @Like String name,int rows) throws SQLException;
	
	@From(Organization.class)
	@DeleteWith
	int delete(Connection con,String id)throws SQLException;
}
