package com.izouma.nineth.web.openapi;

import com.izouma.nineth.dto.CollectionDTO;
import com.izouma.nineth.dto.PageQuery;
import com.izouma.nineth.dto.openapi.TransferCollectionDTO;
import com.izouma.nineth.service.CollectionService;
import com.izouma.nineth.service.openapi.OpenApiService;
import com.izouma.nineth.web.BaseController;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * openApi 通用API 供系统调用 此api下都不需要登录的token
 * @author  ZouYuHong
 */
@RestController
@RequestMapping("/openApi")
@AllArgsConstructor
public class OpenApiController extends BaseController {
    private final OpenApiService openApiService;

    private CollectionService collectionService;


    @GetMapping("/transferCollections")
    public List<TransferCollectionDTO> transferCollections(@RequestParam("projectId") Long projectId){
        return openApiService.transferCollections(projectId);
    }


    /**
     * 所有二手藏品
     * @param pageQuery
     * @return
     */
    @PostMapping("/allSecondCollection")
    public Page<CollectionDTO> allSecondCollection(@RequestBody PageQuery pageQuery) {
        Page<CollectionDTO> page = collectionService.allSecondCollection(pageQuery);
        return page;
    }


}

