package com.datamate.common.auth.infrastructure.persistence.mapper;

import com.datamate.common.auth.domain.model.AuthPermissionInfo;
import com.datamate.common.auth.domain.model.AuthRoleInfo;
import com.datamate.common.auth.domain.model.AuthUserAccount;
import com.datamate.common.auth.domain.model.AuthUserSummary;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 认证授权数据访问
 */
@Mapper
public interface AuthMapper {
    AuthUserAccount findUserByUsername(@Param("username") String username);

    AuthUserAccount findUserById(@Param("userId") Long userId);

    int updateLastLoginAt(@Param("userId") Long userId);

    List<AuthRoleInfo> findRolesByUserId(@Param("userId") Long userId);

    List<String> findPermissionCodesByUserId(@Param("userId") Long userId);

    List<AuthUserSummary> listUsers();

    List<AuthRoleInfo> listRoles();

    List<AuthPermissionInfo> listPermissions();

    int countRolesByIds(@Param("roleIds") List<String> roleIds);

    int deleteUserRoles(@Param("userId") Long userId);

    int insertUserRoles(@Param("userId") Long userId, @Param("roleIds") List<String> roleIds);
}

