/*
* Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.
*
*/
package net.northking.cctp.platform.api.comlibrary;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.db.Pagination;
import net.northking.cctp.common.http.QueryByPage;
import net.northking.cctp.common.http.ResultWrapper;

import net.northking.cctp.platform.dto.comlibrary.CpComponentListDetailDto;
import net.northking.cctp.platform.dto.comlibrary.CpComponentListQueryDto;
import net.northking.cctp.platform.api.comlibrary.service.CpComponentListApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;

@Api(tags = "组件清单")
@RequestMapping("/v1")
@RestController
public class CpComponentListQueryCtrl
{
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(CpComponentListQueryCtrl.class);

  @Autowired
  private CpComponentListApiService apiService;

  /**
   * 分页查询 组件清单 列表
   *
   * @param queryByPage  查询条件
   * @return 数据列表
   */
  @ApiOperation(value = "分页查询组件清单:用于函数或插件的单独组件清单查询")
  @PostMapping(value = "/paging/query/CpComponentLists",
      produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
      consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
  public ResultWrapper<Pagination<CpComponentListDetailDto>> pagingQuery(
      @RequestBody @Validated QueryByPage<CpComponentListQueryDto> queryByPage)
  {
    ResultWrapper<Pagination<CpComponentListDetailDto>> wrapper = new ResultWrapper<>();
    Pagination<CpComponentListDetailDto> page = apiService.pagingQueryNew(queryByPage);

    return wrapper.success(page);
  }
}


