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.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.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.QueryList;
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.util.PageQueryResult;

import com.ekexiu.portal.basepo.LogicDict;
import com.ekexiu.portal.po.DataDict;

@DAO
public interface DataDictDao {

	@Insert
	int insert(Connection con, DataDict dict) throws SQLException;

	@Update
	int update(Connection con, DataDict dict) throws SQLException;

	@From(DataDict.class)
	@DeleteWith
	int delete(Connection con, String dictCode, String code) throws SQLException;

	@From(DataDict.class)
	@Nullable
	@SelectOne
	public DataDict query(Connection con, String dictCode, String code) throws SQLException;

	@SelectList
	List<DataDict> query(Connection con, String dictCode) throws SQLException;

	@PageSelect
	PageQueryResult<DataDict> query(Connection con, String dictCode, @Nullable @Like String code,
			@Nullable @Like String caption, @Nullable String parentCode, int pageSize, int pageNo) throws SQLException;

	@QueryList
	@From(DataDict.class)
	List<LogicDict> queryLogicDict(Connection con, String dictCode) throws SQLException;

	@LimitQuery
	@From(DataDict.class)
	@OrderBy("ORDER BY CODE")
	List<LogicDict> limitQuery(Connection con, String dictCode, int rows) throws SQLException;
	
	@LimitQuery
	@From(DataDict.class)
	@OrderBy("ORDER BY CODE")
	List<LogicDict> limitQuery(Connection con, String dictCode, @Nullable @Like String caption, int rows) throws SQLException;

}
