package com.xtd.project.assets.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
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.xtd.framework.aspectj.lang.annotation.Log;
import com.xtd.framework.aspectj.lang.enums.BusinessType;
import com.xtd.project.assets.domain.DbAuditForm;
import com.xtd.project.assets.service.IDbAuditFormService;
import com.xtd.framework.web.controller.BaseController;
import com.xtd.framework.web.domain.AjaxResult;
import com.xtd.common.utils.poi.ExcelUtil;
import com.xtd.framework.web.page.TableDataInfo;

/**
 * 审核Controller
 * 
 * @author xtd
 * @date 2020-04-09
 */
@RestController
@RequestMapping("/assets/audit")
public class DbAuditFormController extends BaseController
{
    @Autowired
    private IDbAuditFormService dbAuditFormService;

    /**
     * 查询审核列表
     */
    @PreAuthorize("@ss.hasPermi('assets:audit:list')")
    @GetMapping("/list")
    public TableDataInfo list(DbAuditForm dbAuditForm)
    {
        startPage();
        List<DbAuditForm> list = dbAuditFormService.selectDbAuditFormList(dbAuditForm);
        return getDataTable(list);
    }

    /**
     * 导出审核列表
     */
    @PreAuthorize("@ss.hasPermi('assets:audit:export')")
    @Log(title = "审核", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DbAuditForm dbAuditForm)
    {
        List<DbAuditForm> list = dbAuditFormService.selectDbAuditFormList(dbAuditForm);
        ExcelUtil<DbAuditForm> util = new ExcelUtil<DbAuditForm>(DbAuditForm.class);
        return util.exportExcel(list, "audit");
    }

    /**
     * 获取审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('assets:audit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dbAuditFormService.selectDbAuditFormById(id));
    }

    /**
     * 新增审核
     */
    @PreAuthorize("@ss.hasPermi('assets:audit:add')")
    @Log(title = "审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DbAuditForm dbAuditForm)
    {
        return toAjax(dbAuditFormService.insertDbAuditForm(dbAuditForm));
    }

    /**
     * 修改审核
     */
    @PreAuthorize("@ss.hasPermi('assets:audit:edit')")
    @Log(title = "审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DbAuditForm dbAuditForm)
    {
        return toAjax(dbAuditFormService.updateDbAuditForm(dbAuditForm));
    }

    /**
     * 删除审核
     */
    @PreAuthorize("@ss.hasPermi('assets:audit:remove')")
    @Log(title = "审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dbAuditFormService.deleteDbAuditFormByIds(ids));
    }
}
