package net.northking.cctp.platform.api.comlibrary;

import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.platform.api.comlibrary.service.CpComponentLibraryApiService;
import net.northking.cctp.platform.api.comlibrary.service.CpComponentListApiService;
import net.northking.cctp.platform.dto.comlibrary.CpComLibListEngineDto;
import net.northking.cctp.platform.dto.comlibrary.CpComponentLibraryDetailDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RequestMapping("/pub")
@RestController
public class CpComLibPubCtrl {
    @Autowired
    private CpComponentLibraryApiService apiService;
    @Autowired
    private CpComponentListApiService listService;

    @ApiOperation(value = "feign:组件库清单获取-引擎")
    @PostMapping(value = "/library/getLibListByEngine",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<List<CpComponentLibraryDetailDto>> getLibListByEngine(
            @RequestBody @Validated CpComLibListEngineDto query)
    {
        ResultWrapper<List<CpComponentLibraryDetailDto>> wrapper = new ResultWrapper<>();
        List<CpComponentLibraryDetailDto> list = apiService.getLibListByEngine(query);

        return wrapper.success(list);
    }

}
