package com.dcsoft.system.face.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.system.api.domain.SysAuth;
import com.dcsoft.system.face.service.ISysAuthService;
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-29
 */
@RestController
@RequestMapping("/auth")
public class SysAuthController extends BaseController
{
    @Autowired
    private ISysAuthService sysAuthService;

    /**
     * 查询认证数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysAuth sysAuth)
    {
        startPage();
        List<SysAuth> list = sysAuthService.selectSysAuthList(sysAuth);
        return getDataTable(list);
    }

    /**
     * 导出认证数据列表
     */
    @Log(title = "认证数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAuth sysAuth)
    {
        List<SysAuth> list = sysAuthService.selectSysAuthList(sysAuth);
        ExcelUtil<SysAuth> util = new ExcelUtil<SysAuth>(SysAuth.class);
        util.exportExcel(response, list, "认证数据数据");
    }

    /**
     * 获取认证数据详细信息
     */
    @GetMapping(value = "/{appKey}")
    public AjaxResult getInfo(@PathVariable("appKey") String appKey)
    {
        return success(sysAuthService.selectSysAuthById(appKey));
    }

    /**
     * 新增认证数据
     */
    @Log(title = "认证数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAuth sysAuth)
    {
        return toAjax(sysAuthService.insertSysAuth(sysAuth));
    }

    /**
     * 修改认证数据
     */
    @Log(title = "认证数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAuth sysAuth)
    {
        return toAjax(sysAuthService.updateSysAuth(sysAuth));
    }

    /**
     * 删除认证数据
     */
    @Log(title = "认证数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysAuthService.deleteSysAuthByIds(ids));
    }
}
