package com.iamberry.app.mapper;

import org.apache.ibatis.annotations.Param;

import com.iamberry.app.core.entity.User;

/**
 *
 * @author Moon Cheng
 * @date 2016年1月16日 下午12:25:05
 */
public interface UserMapper {

	// ================================================================================================
	// ------------------------------------------User----------------------------------------------
	// ================================================================================================
	/**
	 * 根据id查询user所有信息
	 *
	 * @param id
	 * @return User Information
	 */
	public User selectUserById(Long id);

	/**
	 * 根据username查询user所有信息
	 *
	 * @param username
	 * @return User Information
	 */
	public User selectUserByUsername(String username);

	/**
	 * 通过ext_open_id查询user所有信息
	 *
	 * @param extOpenId
	 * @return User Information
	 */
	public User selectUserByExtOpenId(String extOpenId);

	/**
	 * 添加用户信息到user表中
	 *
	 * @param user
	 */
	public void insertUser(User user);

	/**
	 * 根据id修改user表数据
	 *
	 * @param user
	 */
	public int updateUser(User user);

	/**
	 * 根据id修改user表的个人头像
	 *
	 * @author Moon Cheng
	 * @param image
	 * @param id
	 */
	public int updateDisplayPicture(String imageUrl, Long id);

	/**
	 * 根据用户名和密码查询用户表信息
	 *
	 * @param username
	 * @param password
	 * @return User Information
	 */
	public User validateUser(String username, String password);

	/**
	 * 通过id修改用户表密码
	 *
	 * @param id
	 * @param newPassword
	 * @return update row count
	 */
	public int changePassword(Long id, String newPassword);

	// ================================================================================================
	// ------------------------------------------UserToken----------------------------------------------
	// ================================================================================================
	/**
	 * 通过token查询user表所有信息
	 *
	 * @param userId
	 * @return
	 */
	public User selectUserByToken(String token);

	/**
	 * 根据id修改token值
	 *
	 * @param token
	 * @param userId
	 * @return int
	 */
	public int updateUserToken(String token, Long userId);

	/**
	 * 根据id修改user表的用户名
	 *
	 * @author Moon Cheng
	 * @param username
	 * @param userId
	 * @return
	 */
	public int updateUserName(String username, Long userId);

	/**
	 * 通过key_查询sys_config表数据
	 *
	 * @param key
	 * @return String
	 */
	public String selectConfig(String key);

	// ================================================================================================
	// ------------------------------------------UserAvator----------------------------------------------
	// ================================================================================================
	/**
	 * USER_AVATOR表中添加数据
	 *
	 * @param id
	 * @param avator
	 *            void
	 */
	public void insertUserAvator(Long id, String avator);

	/**
	 * 通过user_id修改USER_AVATOR表数据
	 *
	 * @param id
	 * @param avator
	 * @return int
	 */
	public int updateUserAvator(Long id, String avator);

	/**
	 * 根据user_id查询USER_AVATOR表数据
	 *
	 * @param id
	 * @return String
	 */
	public String selectUserAvator(Long id);
	
	@Deprecated
	public java.util.List<User> getAll(@Param("start") int start, @Param("end") int end);
}