package com.goldenwater.slaj.ttsa.controller;

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.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.slaj.ttsa.domain.BisTtsaDesigndetail;
import com.goldenwater.slaj.ttsa.service.IBisTtsaDesigndetailService;

@RestController
@RequestMapping("/ttsa/ttsadesigndetail")
public class BisTtsaDesigndetailController extends BaseController {
    @Autowired
    private IBisTtsaDesigndetailService bisTtsaDesigndetailService;

    @GetMapping("/list")
    public TableDataInfo list(BisTtsaDesigndetail bisTtsaDesigndetail) {
        startPage();
        List<BisTtsaDesigndetail> list = bisTtsaDesigndetailService.selectBisTtsaDesigndetailList(bisTtsaDesigndetail);
        return getDataTable(list);
    }

    @GetMapping("/{guid}")
    public AjaxResult getInfo(@PathVariable String guid) {
        return AjaxResult.success(bisTtsaDesigndetailService.selectBisTtsaDesigndetailByGuid(guid));
    }

    @PostMapping
    public AjaxResult add(@RequestBody BisTtsaDesigndetail bisTtsaDesigndetail) {
        return toAjax(bisTtsaDesigndetailService.insertBisTtsaDesigndetail(bisTtsaDesigndetail));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BisTtsaDesigndetail bisTtsaDesigndetail) {
        return toAjax(bisTtsaDesigndetailService.updateBisTtsaDesigndetail(bisTtsaDesigndetail));
    }

    @DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids) {
        return toAjax(bisTtsaDesigndetailService.deleteBisTtsaDesigndetailByGuids(guids));
    }

    @Log(title = "指定明细管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ttsa:ttsadesigndetail:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisTtsaDesigndetail bisTtsaDesigndetail) {
        List<BisTtsaDesigndetail> list = bisTtsaDesigndetailService.selectBisTtsaDesigndetailList(bisTtsaDesigndetail);
        ExcelUtil<BisTtsaDesigndetail> util = new ExcelUtil<BisTtsaDesigndetail>(BisTtsaDesigndetail.class);
        util.exportExcel(response, list, "指定明细管理数据");
    }
}
