package com.microservices.system.api;

import com.microservices.common.core.constant.SecurityConstants;
import com.microservices.common.core.constant.ServiceNameConstants;
import com.microservices.common.core.domain.R;
import com.microservices.system.api.factory.RemotePmsFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

@Component
@FeignClient(contextId = "remotePmsService", value = ServiceNameConstants.PMS_SERVICE, fallbackFactory = RemotePmsFallbackFactory.class)
public interface RemotePmsService {
    /**
     * 切换用户在Gitlink组织团队
     *
     * @param userId    用户id
     * @param deptId    组织id
     * @param oldRoleId 旧角色id
     * @param newRoleId 新角色id
     * @param source    来源
     * @return 结果
     */
    @PutMapping("/pmsEnterprise/changeUserGitlinkRole/user/{userId}/dept/{deptId}")
    public R<Boolean> changeUserGitlinkRole(
            @PathVariable("userId") Long userId
            , @PathVariable("deptId") Long deptId
            , @RequestParam("oldRoleId") Long oldRoleId
            , @RequestParam("newRoleId") Long newRoleId
            , @RequestHeader(SecurityConstants.FROM_SOURCE) String source
            , @RequestHeader(SecurityConstants.USER_KEY) String userKey);
}
