package com.ruoyi.frequency.highendauth.controller;

import java.util.List;

import com.ruoyi.frequency.auth.entity.Auth;
import com.ruoyi.frequency.auth.model.result.AuthCount;
import com.ruoyi.frequency.highendauth.model.result.HighendAuthCount;
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.frequency.highendauth.entity.HighendAuth;
import com.ruoyi.frequency.highendauth.service.HighendAuthService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 高端认证Controller
 *
 * @author liwenlong
 * @date 2023-10-20
 */
@RestController
@RequestMapping("/frequency/highendauth")
public class HighendAuthController extends BaseController
{
    @Autowired
    private HighendAuthService highendAuthService;

    /**
     * 查询高端认证列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:highendauth:list')")
    @PostMapping("/list")
    public TableDataInfo<HighendAuth> list(@RequestBody HighendAuth highendAuth)
    {
        startPage();
        List<HighendAuth> list = highendAuthService.selectHighendAuthList(highendAuth);
        return getDataTable(list);
    }

    /**
     * 统计
     */
    @PostMapping("/statistics")
    public AjaxResult statistics(@RequestBody HighendAuth highendAuth)
    {
        HighendAuthCount count = highendAuthService.statistics(highendAuth);
        return AjaxResult.success(count);
    }

    /**
     * 导出高端认证列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:highendauth:export')")
    @Log(title = "高端认证", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HighendAuth highendAuth)
    {
        List<HighendAuth> list = highendAuthService.selectHighendAuthList(highendAuth);
        ExcelUtil<HighendAuth> util = new ExcelUtil<HighendAuth>(HighendAuth.class);
        return util.exportExcel(list, "高端认证数据");
    }

    /**
     * 获取高端认证详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:highendauth:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<HighendAuth> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(highendAuthService.selectHighendAuthById(id));
    }

    /**
     * 新增高端认证
     */
    @PreAuthorize("@ss.hasPermi('frequency:highendauth:add')")
    @Log(title = "高端认证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HighendAuth highendAuth)
    {
        return toAjax(highendAuthService.insertHighendAuth(highendAuth));
    }

    /**
     * 完善
     */
    @PreAuthorize("@ss.hasPermi('frequency:highendauth:edit')")
    @Log(title = "高端认证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HighendAuth highendAuth)
    {
        return toAjax(highendAuthService.updateHighendAuth(highendAuth));
    }


    /**
     * 删除高端认证
     */
    @PreAuthorize("@ss.hasPermi('frequency:highendauth:remove')")
    @Log(title = "高端认证", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(highendAuthService.deleteHighendAuthByIds(ids));
    }


    /**
     *上传企业微信二维码
     */
    @PreAuthorize("@ss.hasPermi('frequency:highendauth:uploadCode')")
    @Log(title = "高端认证", businessType = BusinessType.UPDATE)
    @PostMapping("/uploadCode")
    public AjaxResult uploadCode(@RequestBody HighendAuth highendAuth)
    {
        return toAjax(highendAuthService.uploadCode(highendAuth));
    }
}
