package com.crm.manager.service;

import com.crm.rely.backend.core.constant.PrefixEnum;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
import com.crm.rely.backend.core.dto.sales.SalesBalanceDto;
import com.crm.rely.backend.core.dto.user.info.*;
import com.crm.rely.backend.core.entity.custom.info.InfoEntity;
import com.crm.rely.backend.core.entity.user.info.*;
import com.crm.rely.backend.core.pojo.table.UserInfoTable;
import com.crm.rely.backend.exception.ServiceException;

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

/**
 * @program: crm-backend
 * @description:
 * @author: houn
 * @create: 2019-07-25 16:12
 */
public interface UserInfoService {
    Integer loginValid(UserLoginValidEntity entity) throws ServiceException;

    /**
     * 用户登录
     *
     * @param entity
     * @return
     * @throws ServiceException
     */
    InfoEntity login(UserLoginEntity entity) throws ServiceException;
    /**
     * 关联用户登录
     *
     * @param entity
     * @return
     * @throws ServiceException
     */
    InfoEntity loginByAttachId(UserAttachLoginEntity entity) throws ServiceException;

    /**
     * 添加用户信息
     *
     * @param entity
     * @throws ServiceException
     */
    UserInfoTable add(UserInfoAddEntity entity) throws Exception;

    /**
     * 删除用户
     *
     * @param entity
     * @throws ServiceException
     */
    void delete(UserInfoDeleteEntity entity) throws ServiceException;

    /**
     * 修改用户信息
     *
     * @param entity
     * @throws ServiceException
     */
    UserInfoTable update(UserInfoUpdateEntity entity) throws ServiceException;

    /**
     * 根据条件搜索列表
     *
     * @param entity
     * @return
     * @throws ServiceException
     */
    BaseResultWithPagerDto searchPage(UserInfoSearchEntity entity) throws ServiceException;

    /**
     * 根据id查询
     *
     * @param id
     * @return
     * @throws ServiceException
     */
    UserInfoSearchDto searchSingle(Long id) throws ServiceException;

    void updateLang(UserInfoUpdateLangEntity entity) throws ServiceException;

    void updatePasswordSendEmail(UserUpdatePasswordSendEmailEntity entity) throws ServiceException;

    void updatePassword(UserUpdateEmailPasswordEntity entity) throws ServiceException;

    void updatePassword(UserUpdateLoginPasswordEntity entity) throws ServiceException;

    UserInfoIbNoDto searchIbSingle(UserInfoIbSearchEntity entity) throws ServiceException;

    UserStaticDto getStaticData() throws Exception;

    BaseResultDto<List<SalesInfoDropdownDto>> getSalesInfoDropdown() throws Exception;

    BaseResultDto<List<SalesInfoDropdownDto>> getSalesInfoDropdown(Long pId) throws Exception;
    BaseResultDto<List<SalesInfoDropdownDto>> getSalesLeaderInfoDropdown() throws ServiceException;
    String getStampByPId(Long pid);

    PrefixEnum getPrefixEnum(Long roleId) throws ServiceException;

    boolean existsByAreaId(Long areaId) throws Exception;

    UserInfoTable getDataById(Long id) throws ServiceException;

    List<UserInfoTable> getAllByStamp(String stamp) throws ServiceException;

    String getIdStamp(Long id, Long pid);

    void initIdStamp() throws Exception;

    Map<String, Long> mapIdByIbNo(List<String> ibNos) throws ServiceException;

    void loginSendCode(UserLoginSendEmailCodeEntity entity) throws ServiceException;

    void loginValidateCode(String email, String emailCode) throws ServiceException;

    void loginValidateGoogleAuthenticatorCode(UserInfoTable user, Integer code) throws ServiceException;

    UserInfoGoogleSecretKeyDto getGoogleSecretKey(Long id) throws ServiceException;

    /**
     * 绑定谷歌验证码
     *
     * @param entity
     * @throws ServiceException
     */
    void bind(UserInfoBindEntity entity) throws ServiceException;

    /**
     * 清理密钥-不可使用谷歌验证码登录
     *
     * @param id
     * @throws ServiceException
     */
    void closeSecretKey(Long id) throws ServiceException;

    /**
     * 重置密钥 后续重新绑定
     *
     * @param id
     * @throws ServiceException
     */
    void reSecretKey(Long id) throws ServiceException;

    /**
     * Add user balance
     *
     * @param id
     * @param amount
     * @throws ServiceException
     */
    void addBalance(Long id, Float amount) throws ServiceException;

    /**
     * 根据ID获取销售的薪资信息
     *
     * @param id
     * @return
     * @throws ServiceException
     */
    SalesBalanceDto getSalesBalanceById(Long id) throws ServiceException;

    /**
     * 获取用户数型结构
     * @return
     * @throws ServiceException
     */
    List<UserInfoTreeDto> getUserInfoTree() throws ServiceException;

    BaseResultWithPagerDto getEntryUserList(UserInfoEntrySearchEntity entity) throws ServiceException;

    List<UserEntryInfoSearchDto> getUserList(UserInfoListEntity entity) throws ServiceException;

    String resetPassword(UserResetPasswordEntity entity) throws Exception;

    UserInfoSalesDto getSalesInfo(UserInfoSalesSearchEntity entity);

    void updateExcludeShowLoginType(UserInfoUpdateExcludeShowLoginTypeEntity entity) throws Exception;

    List<UserAttachInfoDto> getUserAttachInfo(InfoEntity infoEntity) throws ServiceException;
}
