package com.ningdatech.pmapi.filemanage.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.filemanage.manage.DocumentationManage;
import com.ningdatech.pmapi.filemanage.model.dto.DocumentationGroupSaveDTO;
import com.ningdatech.pmapi.filemanage.model.dto.DocumentationSaveDTO;
import com.ningdatech.pmapi.filemanage.model.param.DocumentationListParam;
import com.ningdatech.pmapi.filemanage.model.vo.DocumentationGroupVO;
import com.ningdatech.pmapi.filemanage.model.vo.DocumentationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @Classname DocumentationController
 * @Description
 * @Date 2023/6/6 15:48
 * @Author PoffyZhang
 */
@RestController
@AllArgsConstructor
@Api(tags = "档案管理-资料文档控制器")
@RequestMapping("/api/v1/file-manage/documentation")
@Validated
public class DocumentationController {

    private final DocumentationManage documentationManage;

    @GetMapping("/group/list")
    @ApiOperation(value = "分组列表", notes = "分组列表")
    public List<DocumentationGroupVO> groupList(){
        return documentationManage.groupList();
    }

    @PostMapping("/group/add")
    @ApiOperation(value = "分组添加", notes = "分组添加")
    @WebLog("档案管理-资料文档-分组添加")
    public String addGroup(@Validated @RequestBody DocumentationGroupSaveDTO dto){
        return documentationManage.addGroup(dto);
    }

    @PostMapping("/group/delete/{id}")
    @ApiOperation(value = "分组删除", notes = "分组删除")
    @WebLog("档案管理-资料文档-分组删除")
    public String deleteGroup(@PathVariable Long id){
        return documentationManage.deleteGroup(id);
    }

    @GetMapping("/list")
    @ApiOperation(value = "文档列表", notes = "文档列表")
    public PageVo<DocumentationVO> list(@ModelAttribute DocumentationListParam param){
        return documentationManage.list(param);
    }

    @GetMapping("/detail/{id}")
    @ApiOperation(value = "文档详情", notes = "文档详情")
    public DocumentationVO detail(@PathVariable Long id){
        return documentationManage.detail(id);
    }

    @PostMapping("/add")
    @ApiOperation(value = "文档添加", notes = "文档添加")
    @WebLog("档案管理-资料文档-文档添加")
    public String addDoc(@Validated @RequestBody DocumentationSaveDTO dto){
        return documentationManage.addDoc(dto);
    }

    @PostMapping("/delete/{id}")
    @ApiOperation(value = "文档删除", notes = "文档删除")
    @WebLog("档案管理-资料文档-文档删除")
    public String deleteDoc(@PathVariable Long id){
        return documentationManage.deleteDoc(id);
    }
}
