package com.ms.biz;

import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.dto.ItemDTO;
import com.ms.biz.tool.CloudRequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

@ExtensionService("httpDemo")
@Slf4j
public class HttpDemoService implements ExtensionServiceHandler<ItemDTO, Integer> {

    @Autowired
    private CloudRequestTemplate cloudRequestTemplate;

    @Override
    public BaseResponse<Integer> handle(BaseRequest<ItemDTO> req) {
        log.info("HttpDemoService");
        try {
            String resp = cloudRequestTemplate.executePost("http://cp.nbmsm.top/apps/app/getList", null);
            log.info(resp);
        } catch (Exception e) {
            log.error(e.getMessage());
        }

        return BaseResponse.<Integer>builder()
                .success(true)
                .message("success")
                .data(123)
                .code("10000")
                .build();
    }
}
