package com.muyu.common.system.remote;

import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;

import com.muyu.common.system.domain.*;
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;


import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
import com.muyu.common.system.domain.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;


/**
 * 用户服务
 *
 * @author muyu
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {


    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     *
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source  请求来源
     *
     * @return 结果
     */
    @PostMapping("/user/register")
    public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/user/companyList")
    public Result<List<SysUser>> companyList ();

    @PostMapping("/ent/list")
    public Result<List<SysEnt>> list (@RequestBody SysEnt sysEnt);


    /**
     * 通过用户名查询用户信息
     *
     * @param firmCode
     * @param userName 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping("/user/info")
    public Result<LoginUser> getUserInfo (@RequestParam("firmCode") String firmCode, @RequestParam("userName") String userName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取角色数据权限
     *
     * @param user 用户
     *
     * @return 角色权限信息
     */
    @PostMapping("/permission/getRole")
    public Set<String> getRolePermission (@RequestBody SysUser user);

    /**
     * 获取菜单数据权限
     *
     * @param user 用户
     *
     * @return 菜单权限信息
     */
    @PostMapping("/permission/getMenu")
    public Set<String> getMenuPermission (@RequestBody SysUser user);



    /**
     * 根据部门编号获取详细信息
     */
    @GetMapping(value = "/dept/{deptId}")
    public Result<SysDept> selectDeptById (@PathVariable("deptId") Long deptId);


    /**
     * 新增用户角色信息
     *
     * @param user 用户对象
     */
    @PostMapping("/user/insertUserRole")
    public void insertUserRole (@RequestBody SysUser user);

    /**
     * 新增用户岗位信息
     *
     * @param user 用户对象
     */
    @PostMapping("/user/insertUserPost")
    public void insertUserPost (@RequestBody SysUser user);

    /**
     * 注册用户
     */
    @PostMapping("/user")
    public Result addUser (@RequestBody SysUser user);


}
