package com.goldenwater.web.controller.gx;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Anonymous;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.common.enums.BusinessType;
import com.goldenwater.common.utils.poi.ExcelUtil;
import com.goldenwater.gx.domain.GxExchangeQuality;
import com.goldenwater.gx.service.IGxExchangeQualityService;

/**
 * 数据质量评估Controller
 */
@RestController
@RequestMapping("/gx/quality")
public class GxExchangeQualityController extends BaseController
{
    @Autowired
    private IGxExchangeQualityService gxExchangeQualityService;

    @PreAuthorize("@ss.hasPermi('gx:quality:list')")
    @GetMapping("/list")
    public TableDataInfo list(GxExchangeQuality quality)
    {
        startPage();
        List<GxExchangeQuality> list = gxExchangeQualityService.selectGxExchangeQualityList(quality);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('gx:quality:export')")
    @Log(title = "数据质量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GxExchangeQuality quality)
    {
        List<GxExchangeQuality> list = gxExchangeQualityService.selectGxExchangeQualityList(quality);
        ExcelUtil<GxExchangeQuality> util = new ExcelUtil<GxExchangeQuality>(GxExchangeQuality.class);
        util.exportExcel(response, list, "数据质量评估");
    }

    @PreAuthorize("@ss.hasPermi('gx:quality:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return success(gxExchangeQualityService.selectGxExchangeQualityById(id));
    }

    @PreAuthorize("@ss.hasPermi('gx:quality:remove')")
    @Log(title = "数据质量", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gxExchangeQualityService.deleteGxExchangeQualityByIds(ids));
    }

    @Anonymous
    @GetMapping("/front/list")
    public AjaxResult frontList(@RequestParam(value = "stcd", required = false) String stcd)
    {
        GxExchangeQuality quality = new GxExchangeQuality();
        quality.setStcd(stcd);
        return success(gxExchangeQualityService.selectGxExchangeQualityList(quality));
    }
}
