package com.zjsgfa.project.zjsgfa.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.zjsgfa.framework.aspectj.lang.annotation.Log;
import com.zjsgfa.framework.aspectj.lang.enums.BusinessType;
import com.zjsgfa.project.zjsgfa.domain.SjNdxm;
import com.zjsgfa.project.zjsgfa.service.ISjNdxmService;
import com.zjsgfa.framework.web.controller.BaseController;
import com.zjsgfa.framework.web.domain.AjaxResult;
import com.zjsgfa.common.utils.poi.ExcelUtil;
import com.zjsgfa.framework.web.page.TableDataInfo;

/**
 * 难度项目Controller
 * 
 * @author ruoyi
 * @date 2026-02-02
 */
@RestController
@RequestMapping("/system/ndxm")
public class SjNdxmController extends BaseController
{
    @Autowired
    private ISjNdxmService sjNdxmService;

    /**
     * 查询难度项目列表
     */
    //@PreAuthorize("@ss.hasPermi('system:ndxm:list')")
    @GetMapping("/list")
    public TableDataInfo list(SjNdxm sjNdxm)
    {
        startPage();
        List<SjNdxm> list = sjNdxmService.selectSjNdxmList(sjNdxm);
        return getDataTable(list);
    }

    /**
     * 导出难度项目列表
     */
    //@PreAuthorize("@ss.hasPermi('system:ndxm:export')")
    @Log(title = "难度项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SjNdxm sjNdxm)
    {
        List<SjNdxm> list = sjNdxmService.selectSjNdxmList(sjNdxm);
        ExcelUtil<SjNdxm> util = new ExcelUtil<SjNdxm>(SjNdxm.class);
        util.exportExcel(response, list, "难度项目数据");
    }

    /**
     * 获取难度项目详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:ndxm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        SjNdxm sjNdxm = sjNdxmService.selectSjNdxmById(id);
        if(sjNdxm==null){
            sjNdxm=new SjNdxm();
        }
        return AjaxResult.success(sjNdxm);
    }

    /**
     * 新增难度项目
     */
    //@PreAuthorize("@ss.hasPermi('system:ndxm:add')")
    @Log(title = "难度项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SjNdxm sjNdxm)
    {
        return toAjax(sjNdxmService.insertSjNdxm(sjNdxm));
    }

    /**
     * 修改难度项目
     */
    //@PreAuthorize("@ss.hasPermi('system:ndxm:edit')")
    @Log(title = "难度项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SjNdxm sjNdxm)
    {
        return toAjax(sjNdxmService.updateSjNdxm(sjNdxm));
    }

    /**
     * 删除难度项目
     */
    //@PreAuthorize("@ss.hasPermi('system:ndxm:remove')")
    @Log(title = "难度项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sjNdxmService.deleteSjNdxmByIds(ids));
    }
}
