package com.zhiqiyun.open.core.service;


import com.baomidou.mybatisplus.extension.service.IService;
import com.zhiqiyun.open.core.enmus.AccountType;
import com.zhiqiyun.open.core.enmus.PasswordType;
import com.zhiqiyun.open.core.models.user.UserBaseInfo;
import com.zhiqiyun.open.core.models.user.UserLoginAccount;
import com.zhiqiyun.open.core.models.user.UserPassword;

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

/**
 * @author Administrator
 * @date 2017-6-5
 */
public interface UserBaseInfoService extends IService<UserBaseInfo> {

    /**
     * 查询用户单个的登录账号
     *
     * @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<UserLoginAccount> findLoginAccounts(Long uid);

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

    /**
     * 更新用户密码
     *
     * @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);

}
