package org.wfc.user.api;

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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.wfc.common.core.constant.SecurityConstants;
import org.wfc.common.core.constant.ServiceNameConstants;
import org.wfc.common.core.domain.LoginUser;
import org.wfc.common.core.domain.R;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.user.api.domain.UUser;
import org.wfc.user.api.domain.bo.UClientBo;
import org.wfc.user.api.domain.vo.UOrderVo;
import org.wfc.user.api.factory.RemoteUUserFallbackFactory;

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

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

    /**
     * 检查重复用户信息
     *
     * @param user 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/checkRepeat")
    public R<Boolean> checkRepeat(@RequestBody UUser user, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 记录用户登录IP地址和登录时间
     *
     * @param user 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PutMapping("/user/recordlogin")
    public R<Boolean> recordUserLogin(@RequestBody UUser user, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询用户列表
     * @param user 用户信息
     * @return 结果
     */
    @PostMapping("/user/page")
    public TableDataInfo page(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestBody UUser user);

    /**
     * 添加话单信息通过OmadaApi
     */
    @GetMapping("/cdr/addCdrInfo")
    public R<Boolean> addCdrInfoByOmadaApi();

    /**
     * 根据设备mac保存或更新设备信息
     */
    @PostMapping("/client/recordClientUser")
    public R<Boolean> recordClientUser(@RequestBody UClientBo clientBo);

    @PostMapping("/order/paySuccess/{id}")
    public R<Boolean> paySuccess(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/order/{id}")
    public R<UOrderVo> getOrderById(@PathVariable("id") Long id);
}
