

package com.lideeyunji.core.framework.mapper;

import com.baomidou.dynamic.datasource.annotation.Master;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lideeyunji.tool.framework.yunji.annotation.lideeYunjiCache;
import com.lideeyunji.tool.framework.yunji.constant.lideeRedisConstants;
import com.lideeyunji.tool.framework.yunji.model.lideeYunJiUser;
import com.lideeyunji.tool.framework.tenant.core.aop.TenantIgnore;
import org.apache.ibatis.annotations.Param;

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

/**
 *  适配器相关
 */
@Master
public interface AdapterMapper {


    @lideeYunjiCache(cacheNames = "'"+ lideeRedisConstants.REDIS_ADAPTER+":getUserName:' + #userId", reflexClass = String.class)
    String getUserName(Long userId);

    @lideeYunjiCache(cacheNames = "'"+ lideeRedisConstants.REDIS_ADAPTER+":getNickname:' + #userId", reflexClass = String.class)
    String getNickname(Long userId);

    //获取所有用户名称
    List<Map<String,Object>> getAllNickNameList();


    @lideeYunjiCache(cacheNames = "'"+ lideeRedisConstants.REDIS_ADAPTER+":getDeptName:' + #deptId", reflexClass = String.class)
    String getDeptName(Long deptId);

    //获取所有部门名称
    List<Map<String,Object>> getAllDeptNameList();

    @TenantIgnore
    @lideeYunjiCache(cacheNames = "'"+ lideeRedisConstants.REDIS_ADAPTER+":getUserIdByNikeName:' + #tenantId+'_' + #nikeName", reflexClass = Long.class)
    List<Long> getUserIdByNikeName(Long tenantId,String nikeName);

    @TenantIgnore
    @lideeYunjiCache(cacheNames = "'"+ lideeRedisConstants.REDIS_ADAPTER+":getDeptIdByDeptName:' + #tenantId+'_' +  #deptName", reflexClass = Long.class)
    List<Long> getDeptIdByDeptName(Long tenantId,String deptName);

    @TenantIgnore
    List<String> getRoleCodeByUser(Long userId,Long deptId,Long roleId);

    @TenantIgnore
    List<Long> getRoleIdByUser(Long userId,Long deptId,Long roleId);

    /**
     * 根据部门获取用户列表
     * @param page
     * @param deptIdList
     * @param params
     * @return
     */
    IPage<lideeYunJiUser> getUserPageByDeptId(Long tenantId, IPage page, List<Long> deptIdList, @Param("params") Map<String, Object> params);

    /**
     * 根据角色获取用户列表
     * @param page
     * @param roleId
     * @param deptIdList
     * @param params
     * @return
     */
    IPage<lideeYunJiUser> getUserPageByRoleId(Long tenantId, IPage page, Long roleId, List<Long> deptIdList, @Param("params") Map<String, Object> params);

    /**
     * 根据表单id获取表单的字段对应的字典
     * @param dbFormId
     * @return
     */
    @lideeYunjiCache(cacheNames = "'"+ lideeRedisConstants.REDIS_ADAPTER+":getDictMap:' + #dictCode", reflexClass = Map.class,nullIsSave = true)
    List<Map<String, Object>> getSysDictMap(String dictCode);

    //菜单格式化
    List<Map<String,Object>> getMenuI18nMapList();

    //更新国际化
    void updateMenuI18n(Long id,String i18n);

    List<Map<String,Object>> getUserIdAndDeptName(Long tenantId,List<Long> deptIdList);
    List<Map<String,Object>> getUserIdAndPostName(Long tenantId);
}
