package com.ygtx.gxt.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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ygtx.common.annotation.Log;
import com.ygtx.common.core.controller.BaseController;
import com.ygtx.common.core.domain.AjaxResult;
import com.ygtx.common.enums.BusinessType;
import com.ygtx.gxt.domain.GxtUserRuntimeScore;
import com.ygtx.gxt.service.IGxtUserRuntimeScoreService;
import com.ygtx.common.utils.poi.ExcelUtil;
import com.ygtx.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;

/**
 * 维保运行天数得分Controller
 * 
 * @author ruoyi
 * @date 2025-11-05
 */
@RestController
@RequestMapping("/gxt/userruntimescore")
@Api(tags = "维保运行天数得分")
public class GxtUserRuntimeScoreController extends BaseController
{
    @Autowired
    private IGxtUserRuntimeScoreService gxtUserRuntimeScoreService;

    /**
     * 查询维保运行天数得分列表
     */
    @ApiOperation("查询维保运行天数得分列表")
    @GetMapping("/list")
    public TableDataInfo list(GxtUserRuntimeScore gxtUserRuntimeScore)
    {
        startPage();
        List<GxtUserRuntimeScore> list = gxtUserRuntimeScoreService.selectGxtUserRuntimeScoreList(gxtUserRuntimeScore);
        return getDataTable(list);
    }

    /**
     * 导出维保运行天数得分列表
     */
    @Log(title = "维保运行天数得分", businessType = BusinessType.EXPORT)
    @ApiOperation("导出维保运行天数得分列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, GxtUserRuntimeScore gxtUserRuntimeScore)
    {
        List<GxtUserRuntimeScore> list = gxtUserRuntimeScoreService.selectGxtUserRuntimeScoreList(gxtUserRuntimeScore);
        ExcelUtil<GxtUserRuntimeScore> util = new ExcelUtil<GxtUserRuntimeScore>(GxtUserRuntimeScore.class);
        util.exportExcel(response, list, "维保运行天数得分数据");
    }

    /**
     * 获取维保运行天数得分详细信息
     */
    @ApiOperation("获取维保运行天数得分详细信息")
    @ApiImplicitParam(name = "id", value = "主键ID", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gxtUserRuntimeScoreService.selectGxtUserRuntimeScoreById(id));
    }

    /**
     * 新增维保运行天数得分
     */
    @Log(title = "维保运行天数得分", businessType = BusinessType.INSERT)
    @ApiOperation("新增维保运行天数得分")
    @PostMapping
    public AjaxResult add(@RequestBody GxtUserRuntimeScore gxtUserRuntimeScore)
    {
        return toAjax(gxtUserRuntimeScoreService.insertGxtUserRuntimeScore(gxtUserRuntimeScore));
    }

    /**
     * 修改维保运行天数得分
     */
    @Log(title = "维保运行天数得分", businessType = BusinessType.UPDATE)
    @ApiOperation("修改维保运行天数得分")
    @PutMapping
    public AjaxResult edit(@RequestBody GxtUserRuntimeScore gxtUserRuntimeScore)
    {
        return toAjax(gxtUserRuntimeScoreService.updateGxtUserRuntimeScore(gxtUserRuntimeScore));
    }

    /**
     * 批量修改维保运行天数得分
     */
    @Log(title = "维保运行天数得分", businessType = BusinessType.UPDATE)
    @ApiOperation("批量修改维保运行天数得分")
    @PutMapping("/batch")
    public AjaxResult batchEdit(@RequestBody List<GxtUserRuntimeScore> gxtUserRuntimeScores)
    {
        return toAjax(gxtUserRuntimeScoreService.updateGxtUserRuntimeScores(gxtUserRuntimeScores));
    }

    /**
     * 删除维保运行天数得分
     */
    @Log(title = "维保运行天数得分", businessType = BusinessType.DELETE)
    @ApiOperation("删除维保运行天数得分")
    @ApiImplicitParam(name = "ids", value = "主键ID数组", required = true, dataType = "Long[]", paramType = "path", dataTypeClass = Long[].class)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gxtUserRuntimeScoreService.deleteGxtUserRuntimeScoreByIds(ids));
    }
}