package com.zd.laboratory.controller;

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

import com.zd.common.core.domain.per.PerFun;
import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.web.domain.ResultData;
import com.zd.common.security.service.TokenService;
import com.zd.laboratory.domain.vo.LabNegativelistVO;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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 com.zd.common.log.annotation.Log;
import com.zd.common.log.enums.BusinessType;
import com.zd.common.security.annotation.PreAuthorize;
import com.zd.laboratory.domain.LabNegativelistHistory;
import com.zd.laboratory.service.ILabNegativelistHistoryService;
import com.zd.common.core.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.zd.common.core.web.page.TableDataInfo;

/**
 * 负面清单历史记录/违规历史记录Controller
 *
 * @author zd
 * @date 2021-12-17
 */
@RestController
@Api(tags = "【负面清单历史记录/违规历史记录】")
//作者手动加入 ，在接口上加作者@ApiOperationSupport(author = "XXX")
@RequestMapping("/negativeListHistory")
public class LabNegativelistHistoryController extends BaseController
{
    @Autowired
    private ILabNegativelistHistoryService labNegativelistHistoryService;

    @Autowired
    private TokenService tokenService;

    /**
     * 查询负面清单历史记录列表
     */
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_NEGATIVELISTHISTORY + PerFun.LIST)
    @GetMapping("/list")
    @ApiOperation(value = "查询负面清单历史记录列表")
    public TableDataInfo<LabNegativelistHistory> list(LabNegativelistVO labNegativelistHistory)
    {
        startPage();
        List<LabNegativelistHistory> list = labNegativelistHistoryService.selectLabNegativelistHistoryList(labNegativelistHistory);
        return getDataTable(list);
    }

    /**
     * 查询个人负面清单历史记录列表
     */
    @GetMapping("/getIdlist")
    @ApiOperation(value = "查询负面清单历史记录列表")
    public TableDataInfo<LabNegativelistHistory> getIdlist(LabNegativelistVO vo)
    {
        startPage();
        vo.setDataType(1);
        vo.setJoinUserId(tokenService.getLoginUser().getUserid());
        List<LabNegativelistHistory> list = labNegativelistHistoryService.selectLabNegativelistHistoryList(vo);
        return getDataTable(list);
    }



    /**
     * 导出负面清单历史记录列表
     *//*
    @ApiOperation(value = "导出负面清单历史记录列表")
    @PreAuthorize(hasPermi = "laboratory:negativeListHistory:export")
    @Log(title = "负面清单历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LabNegativelistHistory labNegativelistHistory) throws IOException
    {
        List<LabNegativelistHistory> list = labNegativelistHistoryService.selectLabNegativelistHistoryList(labNegativelistHistory);
        ExcelUtil<LabNegativelistHistory> util = new ExcelUtil<LabNegativelistHistory>(LabNegativelistHistory.class);
        util.exportExcel(response, list, "负面清单历史记录数据");
    }*/

    /**
     * 获取负面清单历史记录详细信息
     */
    @ApiOperation(value = "获取负面清单历史记录详细信息")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_NEGATIVELISTHISTORY + PerFun.QUERY)
    @GetMapping(value = "/{id}")
    public ResultData<LabNegativelistHistory> getInfo(@PathVariable("id") Long id)
    {
        return ResultData.success(labNegativelistHistoryService.selectLabNegativelistHistoryById(id));
    }

    /**
     * 新增负面清单历史记录
     */
    @ApiOperation(value = "新增负面清单历史记录")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_NEGATIVELISTHISTORY + PerFun.ADD)
    @Log(title = "负面清单历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public ResultData add(@RequestBody LabNegativelistHistory labNegativelistHistory)
    {
        return ResultData.result(labNegativelistHistoryService.insertLabNegativelistHistory(labNegativelistHistory));
    }

    /**
     * 修改负面清单历史记录
     */
    @ApiOperation(value = "修改负面清单历史记录")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_NEGATIVELISTHISTORY + PerFun.EDIT)
    @Log(title = "负面清单历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultData edit(@RequestBody LabNegativelistHistory labNegativelistHistory)
    {
        return  ResultData.result(labNegativelistHistoryService.updateLabNegativelistHistory(labNegativelistHistory));
    }

    /**
     * 删除负面清单历史记录
     */
    @ApiOperation(value = "删除负面清单历史记录")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_NEGATIVELISTHISTORY + PerFun.REMOVE)
    @Log(title = "负面清单历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResultData remove(@PathVariable Long[] ids)
    {
        return ResultData.result(labNegativelistHistoryService.deleteLabNegativelistHistoryByIds(ids));
    }
}
