package com.xueyi.system.api.digitalmans.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.digitalmans.domain.dto.DmManDeviceDto;
import com.xueyi.system.api.digitalmans.domain.dto.DmSyncDigitalmanDto;
import com.xueyi.system.api.digitalmans.domain.po.DmDigitalmanExtPo;
import com.xueyi.system.api.organize.feign.factory.RemoteUserFallbackFactory;
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 java.util.List;

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

    /**
     * 同步数字人信息 | 内部调用
     */
    @GetMapping("/man/inner/{manCode}/{timestamp}")
    public R<DmSyncDigitalmanDto> listInner(@RequestParam(value = "manCode") String manCode, @RequestParam(value = "timestamp") String timestamp,
                                            @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/man/inner/select-digitalman-ext")
    public R<DmDigitalmanExtPo> selectExtByDeviceId(@RequestParam(value = "devId") String devId,
                                                    @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
    @GetMapping("/man/inner/init/{snCode}")
    public R<Integer> initInner(@RequestParam(value = "snCode") String snCode,
                                            @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/man/inner/update_device_online")
    public R<Boolean> updateDeviceOnline(@RequestParam(value = "deviceId")String deviceId, @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
    @PostMapping("/man/inner/sync_ext_isonline")
    public R<Integer> syncExtIsonline(@RequestBody List<DmManDeviceDto> devices, @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/man/inner-api/devInfo/{devId}")
    public R<DmDigitalmanExtPo> devInfo(@RequestParam(value = "devId") String devId, @RequestHeader(SecurityConstants.ENTERPRISE_ID) Long enterpriseId, @RequestHeader(SecurityConstants.SOURCE_NAME) String sourceName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/man/api/mansInfo")
    public R<JSONObject> mansInfo();

    @GetMapping("/man/delRecognizedRecords")
    public R<JSONObject> delRecognizedRecords(@RequestParam(value = "day") Integer days);

}