package com.hz.pm.api.projectlib.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
import com.hz.pm.api.projectlib.manage.ProjectCollectionManage;
import com.hz.pm.api.projectlib.model.dto.ProjectCollectionSaveDTO;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.vo.ProjectCollectionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Classname ProjectCollectionController
 * @Description
 * @Date 2023/6/25 9:11
 * @Author PoffyZhang
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "项目归集控制器")
@RequestMapping("/api/v1/project-collection")
public class ProjectCollectionController {

    private final ProjectCollectionManage collectionManage;

    @GetMapping("/list")
    @ApiOperation("项目归集列表")
    public PageVo<ProjectCollectionVO> list(ProjectListReq req) {
        return collectionManage.list(req);
    }

    @GetMapping("/detail/{id}")
    @ApiOperation("项目归集详情")
    public ProjectCollectionVO detail(@PathVariable Long id) {
        return collectionManage.detail(id);
    }

    @PostMapping("/save")
    @ApiOperation("项目归集保存")
    @WebLog("项目归集保存")
    public String save(@Valid @RequestBody ProjectCollectionSaveDTO dto) {
        return collectionManage.save(dto);
    }

    @PostMapping("/delete/{id}")
    @ApiOperation("项目归集删除")
    @WebLog("项目归集删除")
    public String delete(@PathVariable Long id) {
        return collectionManage.delete(id);
    }
}
