package com.zhiqiyun.open.service;

import com.zhiqiyun.open.enmus.AccountType;
import com.zhiqiyun.open.enmus.PasswordType;
import com.zhiqiyun.open.models.*;
import com.zhiqiyun.open.mybatis.paginator.domain.PageBounds;
import com.zhiqiyun.open.mybatis.paginator.domain.PageResult;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @date 2017-6-5
 */
public interface UserBaseInfoService {
    /**
     * 查询用户基本信息
     *
     * @param id
     * @return
     */
    UserBaseInfo findById(Long id);

    /**
     * 分页查询用户基本信息
     *
     * @param bounds
     * @param queryWrapper
     * @return
     */
    PageResult<UserBaseInfo> findPage(PageBounds bounds, Map<String, Object> queryWrapper);

    /**
     * 更新用户基本信息
     *
     * @param userInfo
     */
    void updateById(UserBaseInfo userInfo);

    /**
     * 查询用户单个的登录账号
     *
     * @param loginAccount
     * @param accountType
     * @return
     */
    UserLoginAccount findLoginAccount(String loginAccount, AccountType accountType);

    /**
     * 查询用户登录密码
     *
     * @param uid
     * @param passwordType
     * @return
     */
    UserPassword findPassword(Long uid, PasswordType passwordType);

    /**
     * 查询用户所拥有的权限
     *
     * @param uid
     * @return
     */
    List<String> findUserAuthorities(Long uid);

    /**
     * 查询用户所拥有的权限
     *
     * @param uid
     * @return
     */
    List<RoleInfo> findRoles(Long uid);


    /**
     * 查询用户名下所有账号
     *
     * @param uid
     * @return
     */
    List<UserLoginAccount> findLoginAccounts(Long uid);

    /**
     * 添加或者修改用户基本信息
     *
     * @param userInfo
     * @param loginAccounts
     * @return
     * @throws Exception
     */
    String insertOrUpdate(UserBaseInfo userInfo, List<UserLoginAccount> loginAccounts) throws Exception;

    /**
     * 设置用户的角色
     *
     * @param uid
     * @param roles
     * @throws Exception
     */
    void saveRoles(Long uid, Long[] roles) throws Exception;

    /**
     * 插入日志信息
     *
     * @param userOperateLog
     */
    void insertOperateLog(UserOperateLog userOperateLog);

    /**
     * 更新日志信息
     *
     * @param userOperateLog
     */
    void updateOperateLogById(UserOperateLog userOperateLog);

    /**
     * 插入用户登录日志
     *
     * @param userLoginLog
     */
    void insertLoginLog(UserLoginLog userLoginLog);

    /**
     * 查询用户登录日志
     *
     * @param bounds
     * @param uid
     * @return
     */
    PageResult<UserLoginLog> findLoginLogPage(PageBounds bounds, Long uid);

    /**
     * 更新用户密码
     *
     * @param uid
     * @param password
     * @param salt
     * @param passwordType
     */
    void updatePassword(Long uid, String password, String salt, PasswordType passwordType);

    /**
     * 更新用户基本信息
     *
     * @param uid
     * @param userBaseInfo
     */
    void updateBaseInfo(Long uid, UserBaseInfo userBaseInfo);

    /**
     * 更新用户登录账号
     *
     * @param uid
     * @param account
     */
    void updateLoginAccount(Long uid, String account, AccountType accountType);

    /**
     * 查询搜索账号
     *
     * @param searchKey
     * @return
     */
    List<Map<String, Object>> findSelectAccounts(String searchKey);
}
