package com.uas.platform.b2b.manage.service;

import com.uas.platform.b2b.manage.model.User;
import com.uas.platform.b2b.manage.support.MyException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * 用户接口
 *
 * @author hejq
 * @date 2018-04-23
 */
public interface UserService {

    /**
     * 通过电话号码查询用户信息
     *
     * @param tel 电话
     * @return User
     */
    User findByTel(String tel);

    /**
     * 通过邮箱查询用户信息
     *
     * @param email 邮箱
     * @return User
     */
    User findUserByUserEmail(String email);

    /**
     * 通过用户名查询用户信息
     *
     * @param name 用户名
     * @return User
     */
    User findUserByName(String name);

    /**
     * 通过账号密码登录
     *
     * @param userName 账号
     * @param passWord 密码
     * @param request request
     * @param response response
     * @throws MyException 自定义异常
     * @throws UnsupportedEncodingException 编码异常
     */
    void login(String userName, String passWord, HttpServletRequest request, HttpServletResponse response) throws MyException, UnsupportedEncodingException;

    /**
     * 注册用户
     *
     * @param user 用户信息
     * @return User
     */
    User register(User user);

    /**
     * 根据填写邮箱发送修改密码链接
     *
     * @param email 邮箱
     */
    void sendResetPwdUrl(String email);

    /**
     * 通过访问链接修改密码
     *
     * @param secretKey 秘钥
     * @param response 请求
     * @param request request
     * @return User
     * @throws IOException IO异常
     * @throws MyException 自定义异常
     * @throws ServletException 服务器异常
     */
    User resetPwd(String secretKey, HttpServletResponse response, HttpServletRequest request) throws IOException, MyException, ServletException;

    /**
     * 修改密码
     *
     * @param id 用户id
     * @param password 密码
     * @param response  response
     * @throws IOException IO异常
     */
    void resetPassword(Long id, String password, HttpServletResponse response) throws IOException;
}
