package com.yh.saas.plugin.news.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.winsea.svc.base.base.entity.CommonVessel;
import com.winsea.svc.base.base.view.DeptInfoView;
import com.yh.saas.plugin.news.command.*;
import com.yh.saas.plugin.news.service.INewsCircularManagementInfoService;
import com.yh.saas.plugin.news.service.INewsCircularManagementReceiveService;
import com.yh.saas.plugin.news.vo.CircularManagementInfoVo;
import com.yh.saas.plugin.news.vo.CircularManagementReceiveVo;
import com.yh.saas.common.support.plugin.PluginFeature;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(value = "通知通函管理", description = "通知通函发布")
@RestController
@RequestMapping("/txCircularManagementInfo")
@PluginFeature(id = "CircularManagement", name = "通知通函")
public class NewsCircularManagementInfoController {

    @Autowired
    private INewsCircularManagementInfoService circularManagementInfoService;

    @Autowired
    private INewsCircularManagementReceiveService circularManagementReceiveService;


    @ApiOperation(value = "查询通知通函列表", notes = "查询通知通函列表")
    @PluginFeature(id = "Circular", name = "通知通函查询")
    @GetMapping("/query/queryCircularManagementInfoList")
    public Page<CircularManagementInfoVo> queryCircularManagementInfoList(
            CircularManagementInfoSearchCommand example) {
        return circularManagementInfoService.queryCircularManagementInfoList(example);
    }
    /**
     * 导出通知通函
     *
     * @param example
     */
    @GetMapping("/query/exportCircularManagementInfoList")
    public void exportCircularManagementInfoList (
            CircularManagementInfoSearchCommand example, HttpServletResponse response) {
         this.circularManagementInfoService.exportCircularManagementInfoList(example,response);
    }


    @ApiOperation(value = "查询通知通函详情", notes = "查询通知通函详情")
    @GetMapping("/query/getInfoById")
    public CircularManagementInfoVo getInfoById(String id) {
        return circularManagementInfoService.getInfoById(id);
    }


    @ApiOperation(value = "查询通知通函历史详情", notes = "查询通知通函历史详情")
    @GetMapping("/query/getInfoHisById")
    public List<CircularManagementReceiveVo> getInfoHisById(String id) {
        return circularManagementReceiveService.getInfoHisById(id);
    }


    @ApiOperation(value = "新增通知通函", notes = "新增通知通函")
    @PostMapping("/api/saveCircularManagementInfo")
    public String saveCircularManagementInfo(@RequestBody CircularManagementInfoSaveCommand example) {
        return circularManagementInfoService.saveCircularManagementInfo(example);
    }

    @ApiOperation(value = "修改通知通函", notes = "修改通知通函")
    @PostMapping("/api/updateCircularManagementInfo")
    public String updateCircularManagementInfo(@RequestBody CircularManagementInfoSaveCommand example) {
        return circularManagementInfoService.updateCircularManagementInfo(example);
    }


    @ApiOperation(value = "删除通知通函", notes = "删除通知通函")
    @PostMapping("/api/moveCircularManagementInfo")
    public void moveCircularManagementInfo(@RequestParam String id) {
        circularManagementInfoService.moveCircularManagementInfo(id);
    }


    @ApiOperation(value = "发送通知通函", notes = "发送通知通函")
    @PostMapping("/api/sendCircularManagementInfo")
    public void sendCircularManagementInfo(@RequestBody CircularManagementInfoSendCommand example) {
        circularManagementInfoService.sendCircularManagementInfo(example);
    }


    @ApiOperation(value = "退回通知通函", notes = "退回通知通函")
    @PostMapping("/api/backCircularManagementInfo")
    public void backCircularManagementInfo(@RequestBody CircularManagementReceiveCommand example) {
        circularManagementInfoService.backCircularManagementInfo(example);
    }


    @ApiOperation(value = "查询接收通知通函信息列表", notes = "查询接收通知通函信息列表")
    @GetMapping("/query/queryCircularManagementReceiveListById")
    public List<CircularManagementReceiveVo> queryCircularManagementReceiveListById(CircularManagementReceiveSearchCommand example) {
        return circularManagementInfoService.queryCircularManagementReceiveListById(example);
    }


    @ApiOperation(value = "查询船舶信息列表", notes = "查询船舶信息列表")
    @GetMapping("/query/getVesselList")
    public List<CommonVessel> getVesselList(CircularManagementInfoSearchCommand example) {
        return circularManagementInfoService.getVesselList(example);
    }

    @ApiOperation(value = "查询部门信息列表", notes = "查询部门信息列表")
    @GetMapping("/query/getDeptList")
    public List<DeptInfoView> getDeptList(CircularManagementInfoSearchCommand example) {
        return circularManagementInfoService.getDeptList(example);
    }



}
