package com.xueyi.system.api.staff.feign;

import com.alibaba.fastjson2.JSONObject;
import com.xueyi.common.core.constant.basic.SecurityConstants;
import com.xueyi.common.core.constant.basic.ServiceConstants;
import com.xueyi.common.core.web.result.R;
import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto;
import com.xueyi.system.api.organize.feign.factory.RemoteUserFallbackFactory;
import com.xueyi.system.api.staff.domain.dto.DmStaffCommonDto;
import com.xueyi.system.api.staff.domain.vo.DmStaffFeature;
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.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 用户服务
 *
 * @author yrx
 */
@FeignClient(contextId = "remoteStaffService", value = ServiceConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteStaffService {

    @GetMapping("/staff/inner/{devId}/{timestamp}")
    R<List<DmStaffFeature>> listInner(@RequestParam(value = "devId") String devId, @RequestParam(value = "timestamp") String timestamp,
                                      @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/staff/inner-api/selectOne/{staffId}")
    JSONObject fetchStaff(@RequestParam(value = "staffId") String staffId, @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/staff/inner/tenantId/{enterpriseName}")
    public R<SysEnterpriseDto> tenantIdInner(@RequestParam(value = "enterpriseName") String enterpriseName) ;

    @PostMapping(value = "/staff/inner-api/new-staff")
    @ResponseBody
    public com.alibaba.fastjson2.JSONObject addStaff(@RequestBody DmStaffCommonDto commonDto,@RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}