package com.djhk.common.api;

import com.djhk.common.api.model.LoginUser;
import com.djhk.common.constant.SecurityConstants;
import com.djhk.common.core.domain.R;
import com.djhk.common.core.domain.entity.SysUser;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户服务
 *
 * @author myk
 */
//@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 email 邮箱
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/email/{email}")
    public R<LoginUser> getUserInfoByEmail(@PathVariable("email") String email, @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);

    /**
     * 查询所有的用户列表
     *
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/getUserList")
    public R<List<SysUser>> getUserList( @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/check/userInfo")
    public R checkUserInfo(@RequestParam(name = "phone",defaultValue = "",required = false) String phone
            ,@RequestParam(name = "email",defaultValue = "",required = false) String email);



    @PostMapping("/user/reset/checkUser")
    public R resetCheckUser(@RequestParam(name = "phone",defaultValue = "",required = false) String phone
            ,@RequestParam(name = "email",defaultValue = "",required = false) String email);


    /* 通过userId查询用户信息
     *
     * @param userId
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/userId/{userId}")
    public R<SysUser> getUserInfoByUserId(@PathVariable("userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
