package com.zehong.web.controller.supervision;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TWorkSupervision;
import com.zehong.system.service.ITWorkSupervisionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工作督导Controller
 * 
 * @author zehong
 * @date 2025-08-15
 */
@RestController
@RequestMapping("/system/supervision")
public class TWorkSupervisionController extends BaseController
{
    @Autowired
    private ITWorkSupervisionService tWorkSupervisionService;

    /**
     * 查询工作督导列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TWorkSupervision tWorkSupervision)
    {
        startPage();
        List<TWorkSupervision> list = tWorkSupervisionService.selectTWorkSupervisionList(tWorkSupervision);
        return getDataTable(list);
    }

    /**
     * 导出工作督导列表
     */
    @Log(title = "工作督导", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TWorkSupervision tWorkSupervision)
    {
        List<TWorkSupervision> list = tWorkSupervisionService.selectTWorkSupervisionList(tWorkSupervision);
        ExcelUtil<TWorkSupervision> util = new ExcelUtil<TWorkSupervision>(TWorkSupervision.class);
        return util.exportExcel(list, "工作督导数据");
    }

    /**
     * 获取工作督导详细信息
     */
    @GetMapping(value = "/{supervisionId}")
    public AjaxResult getInfo(@PathVariable("supervisionId") Long supervisionId)
    {
        return AjaxResult.success(tWorkSupervisionService.selectTWorkSupervisionById(supervisionId));
    }

    /**
     * 新增工作督导
     */
    @Log(title = "工作督导", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWorkSupervision tWorkSupervision)
    {
        return toAjax(tWorkSupervisionService.insertTWorkSupervision(tWorkSupervision));
    }

    /**
     * 修改工作督导
     */
    @Log(title = "工作督导", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWorkSupervision tWorkSupervision)
    {
        return toAjax(tWorkSupervisionService.updateTWorkSupervision(tWorkSupervision));
    }

    /**
     * 删除工作督导
     */
    @Log(title = "工作督导", businessType = BusinessType.DELETE)
	@DeleteMapping("/{supervisionIds}")
    public AjaxResult remove(@PathVariable Long[] supervisionIds)
    {
        return toAjax(tWorkSupervisionService.deleteTWorkSupervisionByIds(supervisionIds));
    }
}
