

package com.jeelowcode.core.framework.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.Master;
import com.jeelowcode.core.framework.params.vo.role.DbFormRoleFieldVo;
import com.jeelowcode.framework.global.JeeLowCodeBaseConstant;
import com.jeelowcode.framework.tenant.annotation.JeeLowCodeTenantIgnore;
import com.jeelowcode.framework.utils.annotation.JeelowCodeCache;
import com.jeelowcode.framework.utils.model.JeeLowCodeUser;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;

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

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


    @JeelowCodeCache(cacheNames = "'AdapterMapper:getUserName:' + #userId", reflexClass = String.class,alwaysEffective = true)
    String getUserName(Long userId);

    @JeelowCodeCache(cacheNames = "'AdapterMapper:getNickname:' + #userId", reflexClass = String.class)
    String getNickname(Long userId);

    @JeelowCodeCache(cacheNames = "'AdapterMapper:getDeptName:' + #deptId", reflexClass = String.class)
    String getDeptName(Long deptId);


    @JeeLowCodeTenantIgnore
    @JeelowCodeCache(cacheNames = "'AdapterMapper:getUserIdByNikeName:' + #tenantId+'_' + #nikeName", reflexClass = Long.class,alwaysEffective = true)
    List<Long> getUserIdByNikeName(Long tenantId,String nikeName);
    @JeeLowCodeTenantIgnore
    @JeelowCodeCache(cacheNames = "'AdapterMapper:getDeptIdByDeptName:' + #tenantId+'_' +  #deptName", reflexClass = Long.class,alwaysEffective = true)
    List<Long> getDeptIdByDeptName(Long tenantId,String deptName);

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

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


    IPage<JeeLowCodeUser> getUserPageByUserIds(Long tenantId,IPage page, @Param("userIds") List<Long> userIds);

    /**
     * 根据表单id获取表单的字段对应的字典
     * @param dbFormId
     * @return
     */
    @JeelowCodeCache(cacheNames = "'AdapterMapper: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);
}
