package com.njcn.user.api;

import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.user.api.fallback.UserFeignClientFallbackFactory;
import com.njcn.user.pojo.dto.UserDTO;
import com.njcn.user.pojo.po.User;
import com.njcn.user.pojo.vo.UserVO;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hongawen
 * @version 1.0.0
 * @date 2021年05月08日 15:11
 */
@FeignClient(value = ServerInfo.USER, path = "/user", fallbackFactory = UserFeignClientFallbackFactory.class, contextId = "user")
public interface UserFeignClient {

    /**
     * 根据登录名查询用户信息
     *
     * @param loginName 登录名
     * @return 用户基本信息
     */
    @GetMapping("/getUserByName/{loginName}")
    HttpResult<UserDTO> getUserByName(@PathVariable("loginName") String loginName);

    /**
     * 根据手机号查询用户信息
     *
     * @param phone 登录名
     * @return 用户基本信息
     */
    @GetMapping("/getUserByPhone/{phone}")
    HttpResult<UserDTO> getUserByPhone(@PathVariable("phone") String phone);

    /**
     * 认证后根据用户名判断用户状态
     *
     * @param loginName 登录名
     * @return 校验结果
     */
    @GetMapping("/judgeUserStatus/{loginName}")
    HttpResult<Boolean> judgeUserStatus(@PathVariable("loginName") String loginName);

    /**
     * 更新用户登录认证密码错误次数
     *
     * @param loginName 登录名
     * @return null
     */
    @PutMapping("/updateUserLoginErrorTimes/{loginName}")
    HttpResult<String> updateUserLoginErrorTimes(@PathVariable("loginName") String loginName);

    /**
     * 根据用户id集合查询用户信息
     *
     * @param ids
     * @return
     */
    @PostMapping("/userByIdList")
    HttpResult<List<User>> getUserByIdList(@RequestBody List<String> ids);

    @PostMapping("/appuserByIdList")
    @ApiImplicitParam(name = "ids", value = "用户id集合", required = true)
    HttpResult<List<User>> appuserByIdList(@RequestBody List<String> ids);

    /**
     * 根据部门ids查询接收短信通知的用户信息
     *
     * @param deptId
     * @return
     */
    @PostMapping("/getUserByDeptIds")
    HttpResult<List<User>> getUserByDeptIds(@RequestBody List<String> deptId);

    /**
     * 根据部门ids查询用户信息
     *
     * @param deptId
     * @return
     */
    @PostMapping("/getUserInfoByDeptIds")
    HttpResult<List<User>> getUserInfoByDeptIds(@RequestBody List<String> deptId);

    /**
     * 根据角色id查询用户id
     *
     * @param roleId 角色id集合
     */
    @PostMapping("/getUserIdByRoleId")
    HttpResult<List<String>> getUserIdByRoleId(@RequestBody List<String> roleId);

    /**
     * 根据角色Code集合查询用户信息
     *
     * @param roleCode
     * @return
     */
    @GetMapping("/getUserListByRoleCode")
    HttpResult<List<User>> getUserListByRoleCode(@RequestParam("roleCode") String roleCode);

    @GetMapping("/getUserById")
    HttpResult<UserVO> getUserById(@RequestParam("id") String id);

    @PostMapping("/getUserListByIds")
    HttpResult<List<User>> getUserListByIds(@RequestBody List<String> ids);

    @PostMapping("/getUserVOByIdList")
     HttpResult<List<UserVO>> getUserVOByIdList(@RequestBody List<String> ids);

    /**
     * 根据用户id获取该用户同部门下所有的所有用户id
     * @param id 用户id
     */
    @GetMapping("/getColleaguesIdByUserId")
    HttpResult<List<String>> getColleaguesIdByUserId(@RequestParam("id") String id);


    @GetMapping("/userRoleList")
    HttpResult<Boolean> userRoleList();
}
