package com.bonus.material.archives.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.archives.domain.ArchivesDetails;
import com.bonus.material.archives.domain.ArchivesInfo;
import com.bonus.material.archives.domain.ArchivesVo;
import com.bonus.material.archives.domain.ElcSignatureInfo;
import com.bonus.material.archives.service.ArchivesService;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 电子档案管理接口
 * @Author ma_sh
 * @create 2024/12/26 9:25
 */
@Api(tags = "电子档案管理接口")
@RestController
@RequestMapping("/archives")
public class ArchivesController extends BaseController {

    @Resource
    private ArchivesService archivesService;

    /**
     * 获取电子档案分类树
     * @param archiveInfo
     * @return
     */
    @ApiOperation(value = "获取电子档案分类树")
    //@RequiresPermissions("archives:type:list")
    @GetMapping("/getTypeList")
    public AjaxResult getTypeList(ArchivesInfo archiveInfo)
    {
        return archivesService.getTypeList(archiveInfo);
    }

    /**
     * 获取电子档案详情信息
     * @param archivesDetails
     * @return
     */
    @ApiOperation(value = "获取电子档案详情信息")
    //@RequiresPermissions("archives:type:list")
    @GetMapping("/getDetailsList")
    public AjaxResult getDetailsList(ArchivesDetails archivesDetails)
    {
        startPage();
        List<ArchivesDetails> list = archivesService.getDetailsList(archivesDetails);
        return AjaxResult.success(getDataTable(list));
    }

    /**
     * 新增电子档案分类树
     * @param archiveInfo
     * @return
     */
    @ApiOperation(value = "新增电子档案分类树")
    @PreventRepeatSubmit
    //@RequiresPermissions("archives:type:add")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ArchivesInfo archiveInfo)
    {
        return archivesService.add(archiveInfo);
    }

    /**
     * 新增电子档案右侧类型
     * @param archivesVo
     * @return
     */
    @ApiOperation(value = "新增电子档案右侧类型")
    @PreventRepeatSubmit
    //@RequiresPermissions("archives:type:add")
    @PostMapping("/addDetails")
    public AjaxResult addDetails(@RequestBody ArchivesVo archivesVo)
    {
        return archivesService.addDetails(archivesVo);
    }

    /**
     * 修改电子档案分类树
     * @param archiveInfo
     * @return
     */
    @ApiOperation(value = "修改电子档案分类树")
    @PreventRepeatSubmit
    //@RequiresPermissions("archives:type:update")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody ArchivesInfo archiveInfo)
    {
        return archivesService.edit(archiveInfo);
    }

    /**
     * 电子签名 查询用户表信息
     * @param info
     * @return
     */
    @ApiOperation(value = "电子签名 查询用户表信息")
    @GetMapping("/getSign")
    public AjaxResult getSign(ElcSignatureInfo info)
    {
        return archivesService.getSign(info);
    }

    /**
     * 修改电子签名 修改用户表信息
     * @param info
     * @return
     */
    @ApiOperation(value = "电子签名 修改用户表信息")
    //@PreventRepeatSubmit
    @PostMapping("/updateSign")
    public AjaxResult updateSign(@RequestBody ElcSignatureInfo info)
    {
        return archivesService.updateSign(info);
    }

    /**
     * 修改电子档案右侧详情
     * @param archivesDetails
     * @return
     */
    @ApiOperation(value = "修改电子档案右侧详情")
    @PreventRepeatSubmit
    //@RequiresPermissions("archives:type:update")
    @PostMapping("/updateDetails")
    public AjaxResult updateDetails(@RequestBody ArchivesDetails archivesDetails)
    {
        return archivesService.updateDetails(archivesDetails);
    }

    /**
     * 删除电子档案分类树
     * @param archiveInfo
     * @return
     */
    @ApiOperation(value = "删除电子档案分类树")
    @PreventRepeatSubmit
    //@RequiresPermissions("archives:type:delete")
    @PostMapping("/deleteById")
    public AjaxResult deleteById(@RequestBody ArchivesInfo archiveInfo)
    {
        return archivesService.deleteById(archiveInfo);
    }

    /**
     * 删除电子档案右侧详情
     * @param archivesVo
     * @return
     */
    @ApiOperation(value = "删除电子档案右侧详情")
    @PreventRepeatSubmit
    //@RequiresPermissions("archives:type:delete")
    @PostMapping("/deleteByDetails")
    public AjaxResult deleteByDetails(@RequestBody ArchivesVo archivesVo)
    {
        return archivesService.deleteByDetails(archivesVo);
    }

    /**
     * 下载电子档案右侧详情
     * @param archivesVo
     * @return
     */
    @ApiOperation(value = "下载电子档案右侧详情")
    //@RequiresPermissions("archives:type:download")
    @GetMapping("/download")
    public AjaxResult download(ArchivesVo archivesVo, HttpServletRequest request, HttpServletResponse response)
    {
        return archivesService.download(archivesVo, request, response);
    }


}
