package com.ltgk.boat.controller;

import com.ltgk.boat.domain.dto.BoatDisciplineExcelReq;
import com.ltgk.boat.domain.dto.GetBoatDisciplineListReq;
import com.ltgk.boat.domain.dto.SaveBoatDisciplineReq;
import com.ltgk.boat.domain.entity.DsBoatDiscipline;
import com.ltgk.boat.service.DsBoatDisciplineService;
import com.ltgk.common.annotation.Log;
import com.ltgk.common.annotation.RepeatSubmit;
import com.ltgk.common.core.controller.BaseController;
import com.ltgk.common.core.domain.AjaxResult;
import com.ltgk.common.core.page.TableDataInfo;
import com.ltgk.common.enums.BusinessType;
import com.ltgk.port.domain.dto.RemoveByIdReq;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * 船舶联合惩戒(ds_boat_discipline)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/fishingPort/boatDiscipline")
public class DsBoatDisciplineController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private DsBoatDisciplineService dsBoatDisciplineService;

    @Log(title = "联合惩戒新增修改", businessType = BusinessType.INSERT_OR_UPDATE)
    @ApiOperation(value = "联合惩戒新增修改")
    @PostMapping("/save")
    @RepeatSubmit(message = "请勿重复提交")
    public AjaxResult save(@Valid @RequestBody SaveBoatDisciplineReq saveBoatDisciplineReq) {
        return dsBoatDisciplineService.save(saveBoatDisciplineReq);
    }

    @Log(title = "联合惩戒删除", businessType = BusinessType.DELETE)
    @PostMapping("/delete")
    @ApiOperation(value = "联合惩戒删除")
    public AjaxResult delete(@Valid @RequestBody RemoveByIdReq removeByIdReq) {
        return AjaxResult.success(dsBoatDisciplineService.removeById(removeByIdReq.getId()));
    }

    /**
     * 联合惩戒列表
     *
     * @param getBoatDisciplineListReq
     * @return {@link List<DsBoatDiscipline>}
     */
    @Log(title = "联合惩戒列表", businessType = BusinessType.PAGE_QUERY)
    @PostMapping("/list")
    @ApiOperation(value = "联合惩戒列表")
    public TableDataInfo list(@Valid @RequestBody GetBoatDisciplineListReq getBoatDisciplineListReq) {
        return getDataTable(dsBoatDisciplineService.list(getBoatDisciplineListReq));
    }

    /**
     * 导出联合惩戒
     *
     * @param response
     * @param boatDisciplineExcelReq
     */
    @Log(title = "导出联合惩戒", businessType = BusinessType.EXPORT)
    @GetMapping("/exportExcel")
    @ApiOperation(value = "导出联合惩戒")
    public void exportExcel(HttpServletResponse response, @ModelAttribute BoatDisciplineExcelReq boatDisciplineExcelReq) {
        dsBoatDisciplineService.exportExcel(response, boatDisciplineExcelReq);
    }
}
