package com.ekexiu.portal.dao;

import java.sql.Connection;
import java.sql.SQLException;

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.Or;
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.SelectOne;
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
import org.jfw.apt.orm.annotation.dao.param.Alias;
import org.jfw.apt.orm.annotation.dao.param.Set;

import com.ekexiu.portal.po.User;

@DAO
public interface UserDao {

	@Nullable
	@SelectOne
	User query(Connection con,String id)throws SQLException;
	
	@Or
	@Nullable
	@SelectOne
	User queryByEmailOrMobilePhone(Connection con,@Alias({"email","mobilePhone"}) String key)throws SQLException;
	
	@DeleteWith
	@From(User.class)
	int delete(Connection con, String id) throws SQLException;
	
	@Insert
	int insert(Connection con,User user)throws SQLException;
	
	@UpdateWith
	@From(User.class)
	int updateEmail(Connection con,@Set String email,String id)throws SQLException;
	@UpdateWith
	@From(User.class)
	int updateMobilePhone(Connection con,@Set String mobilePhone,String id)throws SQLException;
	
	@UpdateWith
	@From(User.class)
	int updatePassword(Connection con,@Set String passwd,String id)throws SQLException;
	
	@Or
	@UpdateWith
	@From(User.class)
	int updatePasswordWithMobileOrEmail(Connection con,@Set String passwd,@Alias({"email","mobilePhone"})  String key)throws SQLException;
}
