package com.srs.web.controller.comprehensive;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.comprehensive.domain.CphGoodCancelLog;
import com.srs.comprehensive.service.ICphGoodCancelLogService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;

/**
 * 取消申请记录Controller
 *
 * @author srs
 * @date 2023-11-07
 */
@RestController
@RequestMapping("/comprehensive/log")
@Api(value = "取消申请记录管理", tags = "取消申请记录管理")
public class CphGoodCancelLogController extends BaseController {
    @Autowired
    private ICphGoodCancelLogService cphGoodCancelLogService;

    /**
     * 查询取消申请记录列表
     */
    @GetMapping("/list")
    @ApiOperation("查询取消申请记录列表")
    public TableDataInfo list(CphGoodCancelLog cphGoodCancelLog) {
        startPage();
        List<CphGoodCancelLog> list = cphGoodCancelLogService.selectCphGoodCancelLogList(cphGoodCancelLog);
        return getDataTable(list);
    }

    /**
     * 导出取消申请记录列表
     */
    @Log(title = "取消申请记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出取消申请记录列表")
    public void export(HttpServletResponse response, CphGoodCancelLog cphGoodCancelLog) {
        List<CphGoodCancelLog> list = cphGoodCancelLogService.selectCphGoodCancelLogList(cphGoodCancelLog);
        ExcelUtil<CphGoodCancelLog> util = new ExcelUtil<CphGoodCancelLog>(CphGoodCancelLog.class);
        util.exportExcel(response, list, "取消申请记录数据");
    }

    /**
     * 获取取消申请记录详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取取消申请记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(cphGoodCancelLogService.selectCphGoodCancelLogById(id));
    }

    /**
     * 新增取消申请记录
     */
    @Log(title = "取消申请记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增取消申请记录")
    public AjaxResult add(@RequestBody CphGoodCancelLog cphGoodCancelLog) {
        return toAjax(cphGoodCancelLogService.insertCphGoodCancelLog(cphGoodCancelLog));
    }

    /**
     * 修改取消申请记录
     */
    @Log(title = "取消申请记录", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改取消申请记录")
    public AjaxResult edit(@RequestBody CphGoodCancelLog cphGoodCancelLog) {
        return toAjax(cphGoodCancelLogService.updateCphGoodCancelLog(cphGoodCancelLog));
    }

    /**
     * 删除取消申请记录
     */
    @Log(title = "取消申请记录", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除取消申请记录")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(cphGoodCancelLogService.deleteCphGoodCancelLogByIds(ids));
    }
}
