package com.shzg.project.worn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.shzg.project.worn.domain.dto.WornTechnicalAppraisalSimpleDTO;
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.shzg.framework.aspectj.lang.annotation.Log;
import com.shzg.framework.aspectj.lang.enums.BusinessType;
import com.shzg.project.worn.domain.WornTechnicalAppraisal;
import com.shzg.project.worn.service.IWornTechnicalAppraisalService;
import com.shzg.framework.web.controller.BaseController;
import com.shzg.framework.web.domain.AjaxResult;
import com.shzg.common.utils.poi.ExcelUtil;
import com.shzg.framework.web.page.TableDataInfo;

/**
 * 技术鉴定Controller
 * 
 * @author shzg
 * @date 2026-04-10
 */
@RestController
@RequestMapping("/worn/appraisal")
public class WornTechnicalAppraisalController extends BaseController
{
    @Autowired
    private IWornTechnicalAppraisalService wornTechnicalAppraisalService;

    /**
     * 查询技术鉴定列表
     */
    @PreAuthorize("@ss.hasPermi('worn:appraisal:list')")
    @GetMapping("/list")
    public TableDataInfo list(WornTechnicalAppraisal wornTechnicalAppraisal)
    {
        startPage();
        List<WornTechnicalAppraisal> list = wornTechnicalAppraisalService.selectWornTechnicalAppraisalList(wornTechnicalAppraisal);
        return getDataTable(list);
    }

    /**
     * 导出技术鉴定列表
     */
    @PreAuthorize("@ss.hasPermi('worn:appraisal:export')")
    @Log(title = "技术鉴定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WornTechnicalAppraisal wornTechnicalAppraisal)
    {
        List<WornTechnicalAppraisal> list = wornTechnicalAppraisalService.selectWornTechnicalAppraisalList(wornTechnicalAppraisal);
        ExcelUtil<WornTechnicalAppraisal> util = new ExcelUtil<WornTechnicalAppraisal>(WornTechnicalAppraisal.class);
        util.exportExcel(response, list, "技术鉴定数据");
    }

    /**
     * 获取技术鉴定详细信息
     */
    @PreAuthorize("@ss.hasPermi('worn:appraisal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wornTechnicalAppraisalService.selectWornTechnicalAppraisalById(id));
    }

    /**
     * 新增技术鉴定
     */
    @PreAuthorize("@ss.hasPermi('worn:appraisal:add')")
    @Log(title = "技术鉴定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WornTechnicalAppraisal wornTechnicalAppraisal)
    {
        return toAjax(wornTechnicalAppraisalService.insertWornTechnicalAppraisal(wornTechnicalAppraisal));
    }

    /**
     * 修改技术鉴定
     */
    @PreAuthorize("@ss.hasPermi('worn:appraisal:edit')")
    @Log(title = "技术鉴定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WornTechnicalAppraisal wornTechnicalAppraisal)
    {
        return toAjax(wornTechnicalAppraisalService.updateWornTechnicalAppraisal(wornTechnicalAppraisal));
    }

    /**
     * 删除技术鉴定表
     */
    @PreAuthorize("@ss.hasPermi('worn:appraisal:remove')")
    @Log(title = "技术鉴定表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") Long id)
    {
        return toAjax(wornTechnicalAppraisalService.deleteWornTechnicalAppraisalById(id));
    }
    @PostMapping("/addWithFiles")
    public AjaxResult addWithFiles(@RequestBody WornTechnicalAppraisal wornTechnicalAppraisal)
    {
        WornTechnicalAppraisalSimpleDTO dto =
                wornTechnicalAppraisalService.insertWornTechnicalAppraisalWithFiles(wornTechnicalAppraisal);

        return AjaxResult.success(dto);
    }
    @GetMapping("/myList")
    public TableDataInfo myList()
    {
        startPage();
        return wornTechnicalAppraisalService.selectMyTechnicalAppraisalSimplePageList();
    }
}
