package com.yida.data.system.feign;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.constant.FebsServerConstant;
import com.yida.data.common.core.entity.system.SystemUser;
import com.yida.data.common.core.entity.system.UserRole;
import com.yida.data.system.fallback.RemoteUserUserviceFallback;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = FebsServerConstant.FEBS_SERVER_SYSTEM, contextId = "userServiceClient", fallbackFactory =
    RemoteUserUserviceFallback.class)
public interface RemoteUserService {

    @GetMapping("/user/getInfoByUsername")
    ResultBean<SystemUser> getInfoByUsername(@RequestParam("username") String username);

    @GetMapping("/in/user/getInfoByUsername")
    ResultBean<SystemUser> getInfoByUsernameNoPermission(@RequestParam("username") String username);

    @GetMapping("/user/getInfoById")
    ResultBean<SystemUser> getInfoById(@RequestParam("id") Long id);

    @GetMapping("/user/listInfoById")
    ResultBean<List<SystemUser>> listInfoById(@RequestParam("ids") Long[] ids);

    @PostMapping("/in/user/add")
    ResultBean<SystemUser> addUser(@RequestBody SystemUser systemUser);

    @GetMapping("/in/user/subscribeYidaApp")
    ResultBean subscribeYidaApp(@RequestParam("userId") Long userId,
        @RequestParam("schoolId") Long schoolId,
        @RequestParam("type") Integer type);

    @PostMapping("/user/update")
    ResultBean updateUser(@RequestBody SystemUser systemUser);

    @PostMapping("/user/delUser")
    ResultBean delUser(@RequestBody String[] ids);

    @PostMapping("/user/addUserRole")
    ResultBean addUserRole(@RequestBody UserRole[] userRoles);

    @GetMapping("/in/user/bindRoleByMobile")
    ResultBean bindRoleByMobile(@RequestParam("mobile") String mobile,
        @RequestParam("roleName") String roleName);

    @GetMapping("/in/user/bindRoleByUser")
    ResultBean bindRoleByUser(@RequestParam("sysUserId") Long sysUserId,
        @RequestParam("roleName") String roleName);

    /**
     * 根据角色名修改用户角色
     */
    @PostMapping("/in/user/updateUserRoleByRoleName")
    ResultBean updateUserRoleByRoleName(@RequestParam("userId") Long userId, @RequestBody List<String> roleNames);
}
