package com.xdap.self_development.service;


import com.xdap.self_development.controller.request.ModelRolesRequest;
import com.xdap.self_development.controller.request.PreAndRolePageRequest;
import com.xdap.self_development.controller.request.RolePerJoinRequest;
import com.xdap.self_development.controller.request.UserRoleBindingRequest;
import com.xdap.self_development.domain.dto.PageResultDTO;
import com.xdap.self_development.domain.pojo.EngineParamDetailPojo;
import com.xdap.self_development.domain.pojo.ModelRolesPojo;
import com.xdap.self_development.domain.pojo.ParameterPojo;
import com.xdap.self_development.domain.view.MenuParamView;
import com.xdap.self_development.domain.view.RoleInfoView;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface ModelRoleService {

    void addRoles(ModelRolesRequest request);

    List<ModelRolesPojo> selectRoles();

    void updatePerForRole(List<RolePerJoinRequest> request);

    void updateRole(ModelRolesPojo modelRolesPojo, String userID);

    List<MenuParamView> selectPersByUser(String userOrDepID);

    List<MenuParamView> selectPersByRole(String roleID);

    void removeRoles(String roleID, String userID);

    void userRoleBinding(UserRoleBindingRequest userRoleBindingRequest);

    HashMap<String, List<String>> selectUserOrDeptByRole(@NotBlank String roleID);

    boolean matchesAnyPermission(
            EngineParamDetailPojo pojo,
            Map<String, Map<String, Set<String>>> permissionIndex,
            String cat
    );

    boolean matchesAnyPermission(
            EngineParamDetailPojo pojo,
            Map<String, Map<String, Set<String>>> permissionIndex,
            List<String> cats
    );

    boolean matchesAnyPermission(
            ParameterPojo pojo,
            Map<String, Map<String, Set<String>>> permissionIndex,
            List<String> cats
    );

    Map<String, Map<String, Set<String>>> buildPermissionIndex(
            Set<String> permissions
    );

    PageResultDTO<RoleInfoView> getPreAndRoleByCondition(PreAndRolePageRequest request);

    void updateUserRole(UserRoleBindingRequest request, int isDept);

    void writePreAndRole(HttpServletResponse response);

    List<RoleInfoView> getPerAndRole(PreAndRolePageRequest request);
}
