package com.goldenwater.slaj.sins.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.sins.domain.ObjExpert;
import com.goldenwater.slaj.sins.service.IObjExpertService;

@RestController
@RequestMapping("/sins/objexpert")
public class ObjExpertController extends BaseController {
    @Autowired
    private IObjExpertService objExpertService;

    @GetMapping("/list")
    public TableDataInfo list(ObjExpert objExpert) { startPage(); List<ObjExpert> list = objExpertService.selectObjExpertList(objExpert); return getDataTable(list); }

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

    @PostMapping
    public AjaxResult add(@RequestBody ObjExpert objExpert) { return toAjax(objExpertService.insertObjExpert(objExpert)); }

    @PutMapping
    public AjaxResult edit(@RequestBody ObjExpert objExpert) { return toAjax(objExpertService.updateObjExpert(objExpert)); }

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

    @Log(title = "专家信息管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('sins:objexpert:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ObjExpert objExpert) { List<ObjExpert> list = objExpertService.selectObjExpertList(objExpert); ExcelUtil<ObjExpert> util = new ExcelUtil<ObjExpert>(ObjExpert.class); util.exportExcel(response, list, "专家信息管理数据"); }
}
