package cn.estsh.i3plus.core.api.iservice.busi;

import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.platform.bean.*;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authc.AuthenticationException;

import java.util.List;

/**
 * @Description : 账号账号服务
 * @Reference :
 * @Author : wei.peng
 * @Date : 2018-10-25 16:21
 * @Modify :
 **/
public interface ISysUserService {

    /**
     * 账号登录
     * @param loginName     登录名
     * @param password      登录密码
     * @param languageCode  界面语言
     * @return
     */
    @ApiOperation(value = "账号登录",notes = "普通账号登录功能")
    SessionUser queryUserLogin(String loginName, String password, String languageCode) throws AuthenticationException;

    /**
     * 修改状态
     * @param id        修改账号状态
     * @param status    状态
     * @param user      当前会话账号
     * @return
     */
    @ApiOperation(value = "修改状态",notes = "修改指定账号状态")
    void updateSysUserStatus(Long id, int status, SessionUser user);

    /**
     * 批量修改账号状态
     * @param ids
     * @param status
     * @param user
     */
    @ApiOperation(value = "修改状态",notes = "批量修改指定账号状态")
    void updateBatchSysUserStatus(Long[] ids, int status, SessionUser user);

    /**
     * 修改账号信息
     * @param sysUser
     */
    @ApiOperation(value = "修改账号信息",notes = "修改账号信息")
    void updateSysUser(SysUser sysUser) throws Exception;

    /**
     * 修改账号密码
     * @param userId     需要修改的账号ID
     * @param password      旧密码
     * @param newPwd        新密码
     */
    @ApiOperation(value = "修改号密码",notes = "修改账号的密码信息")
    void updateSysUserPassword(Long userId,String password,String newPwd)  throws Exception;

    /**
     * 刷新账号登录信息
     * @param userId
     */
    @ApiOperation(value = "刷新账号",notes = "刷新账号登录信息")
    void refreshUserLoginInformation(Long userId);

    /**
     * 新增账号信息
     * @param sysUser 新增账号
     * @return
     */
    @ApiOperation(value = "新增账号",notes = "新增账号信息")
    SysUser insertSysUser(SysUser sysUser)throws Exception;

    /**
     * 添加 账号登录信息
     * @param sysLogUserLogin
     * @return
     */
    @ApiOperation(value = "新增登录日志",notes = "新增登录日志信息")
    SysLogUserLogin insertSysLogUserLogin(SysLogUserLogin sysLogUserLogin);

    /**
     * 刷新账号角色关系
     * @param sysUser
     * @param roleIds
     * @param userName
     */
    @ApiOperation(value = "刷新账号",notes = "刷新账号角色关系")
    void refreshSysRefUserRole(SysUser sysUser, Long[] roleIds , String userName);

    /**
     * 根据Key 删除数据
     * @param id
     * @return
     */
    @ApiOperation(value = "删除账号",notes = "根据ID 删除张哈信息")
    void deleteSysUserById(Long id);

    /**
     * 批量删除账号 逻辑删除
     * @param ids   需要删除的账号ID
     * @param user  当前会话账号
     */
    @ApiOperation(value = "删除账号",notes = "根据ID 批量删除张哈信息")
    void deleteBatchSysUserById(Long[] ids, SessionUser user);

    /**
     * 查询所有数据
     * @return
     */
    @ApiOperation(value = "查询所有",notes = "查询所有账号信息")
    List<SysUser> list();

    @ApiOperation(value = "查询用户ID 集合",notes = "根据角色Id 查询用户ID集合")
    List<Long> findSysUserIdListByRoleId(Long roleId);

    @ApiOperation(value = "查询用户ID 集合",notes = "根据部门Id 查询用户ID集合")
    List<Long> findSysUserIdListByDepartmentId(List<Long> idList);

    /**
     * 复杂查询
     * @param user
     * @param pager
     * @return
     */
    @ApiOperation(value = "账号查询",notes = "查询账号信息-复杂查询")
    ListPager<SysUser> querySysUserByPager(SysUser user, Pager pager);

    /**
     * 根据id 数据
     * @param id
     * @return
     */
    @ApiOperation(value = "账号查询",notes = "查询账号信息-根据ID查询")
    SysUser getSysUserById(Long id);

    /**
     * 获取账号详细信息
     * @param id
     * @return
     */
    @ApiOperation(value = "获取用户信息",notes = "查询用户信息-根据ID查询")
    SysUserInfo getSysUserInfoById(Long id);

    /**
     * 根据登录名称 获取账号信息
     * @param loginName
     * @return
     */
    @ApiOperation(value = "获取账号信息",notes = "查询用户信息-根据登录名称查询")
    SysUser getSysUserByLoginName(String loginName);

    /**
     * 根据手机号查询账号
     * @param email
     * @return
     */
    @ApiOperation(value = "获取账号信息",notes = "查询用户信息-根据邮箱查询")
    SysUser getSysUserByEmail(String email);

    /**
     *  根据手机号查询账号
     * @param phone
     * @return
     */
    @ApiOperation(value = "获取账号信息",notes = "查询用户信息-根据手机查询")
    SysUser getSysUserByPhone(String phone);

    /**
     * 查出账号角色关系
     * @param userId
     * @return
     */
    @ApiOperation(value = "获取用户角色信息",notes = "获取指定账号的所有角色信息")
    List<SysRefUserRole> findSysRefUserRoleByUserId(Long userId);

    /**
     * 判断账号名是否存在
     * @param userLoginName
     * @param id
     * @return
     */
    @ApiOperation(value = "账号检查",notes = "检查账号的登录名是否重复")
    boolean checkSysUserLoginName(String userLoginName, long id);

    /**
     * 判断邮箱是否存在
     * @param email
     * @param id
     * @return
     */
    @ApiOperation(value = "账号检查",notes = "检查账号的邮箱是否重复")
    boolean checkSysUserEmail(String email,long id);

    /**
     * 判断手机是否存在
     * @param phone
     * @param id
     * @return
     */
    @ApiOperation(value = "账号检查",notes = "检查账号的手机号是否重复")
    boolean checkSysUserPhone(String phone,long id);

    /**
     * 账号唯一教研
     * @param user
     */
    @ApiOperation(value = "账号检查",notes = "检查账号信息唯一(登录名、邮箱、手机号)")
    void checkSysUserOnly(SysUser user);

    @ApiOperation(value = "查询账户数量")
    long getSysUserCount();

    /**
     * 登录封装账号信息
     * @param sessionUser
     * @param user
     * @param userType
     * @param languageCode
     * @return
     */
    @ApiOperation(value = "封装用户信息",notes = "封装登录完成后的用户信息(角色、权限、部门、组织、岗位)")
    SessionUser packSessionUser(SessionUser sessionUser, SysUser user, Integer userType, String languageCode);
}
