package com.zd.laboratory.controller;

import com.zd.common.core.domain.per.PerFun;
import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.exception.ServiceException;
import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.poi.ExcelUtil;
import com.zd.common.core.web.controller.BaseController;
import com.zd.common.core.web.domain.AjaxResult;
import com.zd.common.core.web.domain.ResultData;
import com.zd.common.core.web.page.TableDataInfo;
import com.zd.common.log.annotation.Log;
import com.zd.common.log.enums.BusinessType;
import com.zd.common.security.annotation.PreAuthorize;
import com.zd.common.security.service.TokenService;
import com.zd.laboratory.domain.*;
import com.zd.laboratory.domain.vo.LabCheckRecordDetailsVO;
import com.zd.laboratory.domain.vo.LabCheckRecordVO;
import com.zd.laboratory.service.*;
import com.zd.system.api.domain.SysUser;
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.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 隐患检查审核日志Controller
 *
 * @author zd
 * @date 2022-03-31
 */
@RestController
@Api(tags = "【隐患检查审核日志】")
//作者手动加入 ，在接口上加作者@ApiOperationSupport(author = "XXX")
//@ApiSupport(author = Knife4jConfiguration.Author.)
@RequestMapping("/detailslog")
public class LabCheckRecordDetailslogController extends BaseController
{
    @Autowired
    private ILabCheckRecordDetailslogService labCheckRecordDetailslogService;

    /**
     * 查询隐患检查审核日志列表
     */
    @PreAuthorize(hasPermi = "laboratory:detailslog:list")
    @GetMapping("/list")
    @ApiOperation(value = "查询隐患检查审核日志列表")
    public TableDataInfo<LabCheckRecordDetailslog> list(LabCheckRecordDetailslog labCheckRecordDetailslog)
    {
        startPage();
        List<LabCheckRecordDetailslog> list = labCheckRecordDetailslogService.selectLabCheckRecordDetailslogList(labCheckRecordDetailslog);
        return getDataTable(list);
    }

    /**
     * 导出隐患检查审核日志列表
     */
    @ApiOperation(value = "导出隐患检查审核日志列表")
    @PreAuthorize(hasPermi = "laboratory:detailslog:export")
    @Log(title = "隐患检查审核日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LabCheckRecordDetailslog labCheckRecordDetailslog) throws IOException
    {
        List<LabCheckRecordDetailslog> list = labCheckRecordDetailslogService.selectLabCheckRecordDetailslogList(labCheckRecordDetailslog);
        ExcelUtil<LabCheckRecordDetailslog> util = new ExcelUtil<LabCheckRecordDetailslog>(LabCheckRecordDetailslog.class);
        util.exportExcel(response, list, "隐患检查审核日志数据");
    }

    /**
     * 获取隐患检查审核日志详细信息
     */
    @ApiOperation(value = "获取隐患检查审核日志详细信息")
    @PreAuthorize(hasPermi = "laboratory:detailslog:query")
    @GetMapping(value = "/{id}")
    public ResultData<LabCheckRecordDetailslog> getInfo(@PathVariable("id") Long id)
    {
        return ResultData.success(labCheckRecordDetailslogService.selectLabCheckRecordDetailslogById(id));
    }

    /**
     * 新增隐患检查审核日志
     */
    @ApiOperation(value = "新增隐患检查审核日志")
    @PreAuthorize(hasPermi = "laboratory:detailslog:add")
    @Log(title = "隐患检查审核日志", businessType = BusinessType.INSERT)
    @PostMapping
    public ResultData add(@RequestBody LabCheckRecordDetailslog labCheckRecordDetailslog)
    {
        return ResultData.result(labCheckRecordDetailslogService.insertLabCheckRecordDetailslog(labCheckRecordDetailslog));
    }

    /**
     * 修改隐患检查审核日志
     */
    @ApiOperation(value = "修改隐患检查审核日志")
    @PreAuthorize(hasPermi = "laboratory:detailslog:edit")
    @Log(title = "隐患检查审核日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultData edit(@RequestBody LabCheckRecordDetailslog labCheckRecordDetailslog)
    {
        return  ResultData.result(labCheckRecordDetailslogService.updateLabCheckRecordDetailslog(labCheckRecordDetailslog));
    }

    /**
     * 删除隐患检查审核日志
     */
    @ApiOperation(value = "删除隐患检查审核日志")
    @PreAuthorize(hasPermi = "laboratory:detailslog:remove")
    @Log(title = "隐患检查审核日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public ResultData remove(@PathVariable Long[] ids)
    {
        return ResultData.result(labCheckRecordDetailslogService.deleteLabCheckRecordDetailslogByIds(ids));
    }
}
