package com.bonus.zlpt.system.api;

import com.bonus.zlpt.common.core.web.domain.AjaxResult;
import com.bonus.zlpt.common.core.web.page.TableDataInfo;
import com.bonus.zlpt.system.api.domain.SysUser;
import com.bonus.zlpt.system.api.factory.RemoteUserFallbackFactory;
import com.bonus.zlpt.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.bonus.zlpt.common.core.constant.SecurityConstants;
import com.bonus.zlpt.common.core.constant.ServiceNameConstants;
import com.bonus.zlpt.common.core.domain.R;

import java.util.List;

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

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


    /**
     * 获取用户列表
     */
    @PostMapping("/user/list")
    TableDataInfo list(@RequestBody SysUser user);


    /**
     * 根据用户id获取用户信息
     * @param userId
     * @return
     */
    @GetMapping("/user/list/{userId}")
    R<SysUser> selectUserById(@PathVariable("userId") Long userId);


    /**
     * 新增用户
     * @param user
     * @return
     */
    @PostMapping("/user")
    AjaxResult add(@Validated @RequestBody SysUser user);


    /**
     * 修改用户
     * @param user
     * @return
     */
    @PutMapping("/user")
    AjaxResult edit(@Validated @RequestBody SysUser user);


    /**
     * 删除用户
     * @param userIds
     * @return
     */
    @DeleteMapping("/user/{userIds}")
    AjaxResult remove(@PathVariable("userIds") Long[] userIds);


}
