package com.dcsoft.system.visitor.controller;

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

import com.dcsoft.system.visitor.domain.VisVisitorExamine;
import com.dcsoft.system.visitor.service.IVisVisitorExamineService;
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.dcsoft.common.log.annotation.Log;
import com.dcsoft.common.log.enums.BusinessType;
import com.dcsoft.common.security.annotation.RequiresPermissions;
import com.dcsoft.common.core.web.controller.BaseController;
import com.dcsoft.common.core.web.domain.AjaxResult;
import com.dcsoft.common.core.utils.poi.ExcelUtil;
import com.dcsoft.common.core.web.page.TableDataInfo;

/**
 * 访客审核Controller
 *
 * @author nichun
 * @date 2023-03-11
 */
@RestController
@RequestMapping("/visitorExamine")
public class VisVisitorExamineController extends BaseController
{
    @Autowired
    private IVisVisitorExamineService visVisitorExamineService;

    /**
     * 查询访客审核列表
     */
    @RequiresPermissions("visitor:visitorExamine:list")
    @GetMapping("/list")
    public TableDataInfo list(VisVisitorExamine visVisitorExamine)
    {
        startPage();
        List<VisVisitorExamine> list = visVisitorExamineService.selectVisVisitorExamineList(visVisitorExamine);
        return getDataTable(list);
    }

    /**
     * 导出访客审核列表
     */
    @Log(title = "访客审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VisVisitorExamine visVisitorExamine)
    {
        List<VisVisitorExamine> list = visVisitorExamineService.selectVisVisitorExamineList(visVisitorExamine);
        ExcelUtil<VisVisitorExamine> util = new ExcelUtil<VisVisitorExamine>(VisVisitorExamine.class);
        util.exportExcel(response, list, "访客审核数据");
    }

    /**
     * 获取访客审核详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(visVisitorExamineService.selectVisVisitorExamineById(id));
    }

    /**
     * 新增访客审核
     */
    @Log(title = "访客审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VisVisitorExamine visVisitorExamine)
    {
        return toAjax(visVisitorExamineService.insertVisVisitorExamine(visVisitorExamine));
    }

    /**
     * 修改访客审核
     */
    @Log(title = "访客审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VisVisitorExamine visVisitorExamine)
    {
        return toAjax(visVisitorExamineService.updateVisVisitorExamine(visVisitorExamine));
    }

    /**
     * 删除访客审核
     */
    @Log(title = "访客审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(visVisitorExamineService.deleteVisVisitorExamineByIds(ids));
    }
}
