package com.dcsoft.system.api;

import com.dcsoft.common.core.web.domain.AjaxResult;
import com.dcsoft.system.api.domain.SmsDTO;
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.dcsoft.common.core.constant.SecurityConstants;
import com.dcsoft.common.core.constant.ServiceNameConstants;
import com.dcsoft.common.core.domain.R;
import com.dcsoft.system.api.domain.SysUser;
import com.dcsoft.system.api.factory.RemoteUserFallbackFactory;
import com.dcsoft.system.api.model.LoginUser;

/**
 * 用户服务
 *
 * @author dcsoft
 */
@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);

    /**
     * 通过用户名查询用户信息
     *
     * @param openid 绑定的openid
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/wxinfo/{openid}")
    public R<LoginUser> getWxUserInfo(@PathVariable("openid") String openid, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 更新openid
     *
     * @param sysUser 用户信息
     * @return 结果
     */
    @PostMapping("/user/updateOpenId")
    public R<Boolean> updateOpenId(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 发送短信
     *
     * @param smsDTO
     * @return 结果
     */
    @PostMapping("/user/sendMessage")
    public AjaxResult sendMessage(@RequestBody SmsDTO smsDTO, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户名查询用户信息(不返回异常信息)
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/infos/{username}")
    public R<LoginUser> getUserInfos(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询系统配置
     * @param configKey
     * @return
     */
    @GetMapping(value = "/config/configKey/{configKey}")
    AjaxResult selectConfigByKey(@PathVariable("configKey") String configKey);

    /**
     * 更新用户基本信息
     *
     * @param sysUser 用户信息
     * @return 结果
     */
    @PostMapping("/role/insertVisitor")
    public AjaxResult insertVisitor(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 更新用户基本信息
     *
     * @param sysUser 用户信息
     * @return 结果
     */
    @PostMapping("/user/updateByUserId")
    public R<?> updateByUserId(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
