package com.securitycontrol.system.api;

import com.securitycontrol.system.api.domain.decision.SysMenu;
import com.securitycontrol.system.api.domain.decision.SysUserVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import com.securitycontrol.common.core.constant.SecurityConstants;
import com.securitycontrol.common.core.constant.ServiceNameConstants;
import com.securitycontrol.common.core.domain.Result;
import com.securitycontrol.system.api.factory.RemoteUserFallbackFactory;
import com.securitycontrol.system.api.model.LoginUser;

import java.util.List;

/**
 * 用户服务
 *
 * @author czc
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping("/userLogin/login/{username}")
    Result<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户id查询分配的按钮
     *
     * @param userId 用户名
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/sys/menu/getMenuPer")
    Result<List<String>> getMenulPer(@RequestBody String userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据用户id查询分配的菜单
     *
     * @param userId 用户id
     * @param source 来源
     * @return
     */
    @PostMapping("/userLogin/getAllMenuList")
    Result<List<SysMenu>> getAllMenuList(@RequestBody String userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     *    根据用户id查询分配的菜单
     * @param userId 用户id
     * @param source 来源
     * @return
     */
    @PostMapping("/userManage/getUserById/{userId}")
    Result<SysUserVo> getUserById(@PathVariable("userId") String userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改登录信息
     * @param userId
     * @param source
     */
    @PostMapping("/userLogin/updateUserLogin")
    void updateUserLogin(@RequestBody Long userId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
