package com.ruoyi.web.controller.dxp.system.customer;

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

import com.ruoyi.dxp.dto.AuditDto;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dxp.domain.Application;
import com.ruoyi.dxp.service.IApplicationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应用Controller
 * 
 * @author jy
 * @date 2022-12-06
 */
@RestController
@RequestMapping("/system/audit/application")
public class ApplicationController extends BaseController
{
    @Autowired
    private IApplicationService applicationService;

    /**
     * 查询应用列表
     */
    @PreAuthorize("@ss.hasPermi('system/audit:application:list')")
    @GetMapping("/list")
    public TableDataInfo list(Application application)
    {
        startPage();
        List<Application> list = applicationService.selectApplicationList(application);
        return getDataTable(list);
    }

    /**
     * 获取应用详细信息
     */
    @PreAuthorize("@ss.hasPermi('system/audit:application:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(applicationService.selectApplicationById(id));
    }

    /**
     * 删除应用
     */
    @PreAuthorize("@ss.hasPermi('system/audit:application:remove')")
    @Log(title = "应用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long ids)
    {
        return applicationService.deleteApplicationById(ids);
    }

    /**
     * 审核应用
     */
    @PreAuthorize("@ss.hasPermi('system/audit:application:audit')")
    @Log(title = "应用", businessType = BusinessType.AUDIT)
    @PostMapping("/audit")
    public AjaxResult audit(@RequestBody AuditDto auditDto) {
        return applicationService.audit(auditDto);
    }
}
