package com.ruoyi.web.controller.system;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ruoyi.system.domain.vo.UrYearValidDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.ResponseData;
import java.util.List;
import javax.validation.Valid;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.UrYearValidData;
import com.ruoyi.system.service.IUrYearValidDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专利有效按年统计结果Controller
 * 
 * @author dm
 * @date 2023-02-12
 */
@Api(value = "专利有效按年统计结果",tags = "专利有效按年统计结果")
@ApiSupport(author = "dm",order = 10)
@RestController
@RequestMapping("/system/urYearValidData")
public class UrYearValidDataController extends BaseController
{
    @Autowired
    private IUrYearValidDataService urYearValidDataService;

    /**
     * 查询专利有效按年统计结果列表
     */
    @ApiOperation(value = "查询专利有效按年统计结果列表",notes = "查询专利有效按年统计结果列表")
    @ApiOperationSupport(order = 10)
    @PreAuthorize("@ss.hasPermi('system:urYearValidData:list')")
    @GetMapping("/list")
    public TableDataInfo<UrYearValidData> list(UrYearValidDataVo urYearValidData)
    {
        startPage();
        List<UrYearValidData> list = urYearValidDataService.selectUrYearValidDataList(urYearValidData);
        return getDataTable(list);
    }

    /**
     * 导出专利有效按年统计结果列表
     */
    @ApiOperation(value = "导出专利有效按年统计结果列表",notes = "导出专利有效按年统计结果列表")
    @ApiOperationSupport(order = 20)
    @PreAuthorize("@ss.hasPermi('system:urYearValidData:export')")
    @Log(title = "专利有效按年统计结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UrYearValidDataVo urYearValidData)
    {
        List<UrYearValidData> list = urYearValidDataService.selectUrYearValidDataList(urYearValidData);
        ExcelUtil<UrYearValidData> util = new ExcelUtil<UrYearValidData>(UrYearValidData.class);
        util.exportExcel(response, list, "专利有效按年统计结果数据");
    }

    /**
     * 获取专利有效按年统计结果详细信息
     */
    @ApiOperation(value = "获取专利有效按年统计结果详细信息",notes = "获取专利有效按年统计结果详细信息")
    @ApiOperationSupport(order = 30)
    @PreAuthorize("@ss.hasPermi('system:urYearValidData:query')")
    @GetMapping(value = "/{id}")
    public ResponseData<UrYearValidData> getInfo(@PathVariable("id") Long id)
    {
        return ResponseData.success(urYearValidDataService.selectUrYearValidDataById(id));
    }

    /**
     * 新增专利有效按年统计结果
     */
    @ApiOperation(value = "新增专利有效按年统计结果",notes = "新增专利有效按年统计结果")
    @ApiOperationSupport(order = 40,ignoreParameters = {"urYearValidData.id"})
    @PreAuthorize("@ss.hasPermi('system:urYearValidData:add')")
    @Log(title = "专利有效按年统计结果", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public ResponseData add(@RequestBody @Valid @ApiParam(required=true) UrYearValidData urYearValidData)
    {
        int i = urYearValidDataService.insertUrYearValidData(urYearValidData);
        if(i>0){
            //返回主键
            return ResponseData.success(urYearValidData.getId());
        }else{
            return ResponseData.error();
        }
    }

    /**
     * 修改专利有效按年统计结果
     */
    @ApiOperation(value = "修改专利有效按年统计结果",notes = "修改专利有效按年统计结果")
    @ApiOperationSupport(order = 50)
    @PreAuthorize("@ss.hasPermi('system:urYearValidData:edit')")
    @Log(title = "专利有效按年统计结果", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @RepeatSubmit
    public ResponseData edit(@RequestBody @Valid @ApiParam(required=true) UrYearValidData urYearValidData)
    {
        int i = urYearValidDataService.updateUrYearValidData(urYearValidData);
        if(i>0){
            //返回主键
            return ResponseData.success(urYearValidData.getId());
        }else{
            return ResponseData.error();
        }
    }

    /**
     * 删除专利有效按年统计结果
     */
    @ApiOperation(value = "删除专利有效按年统计结果",notes = "删除专利有效按年统计结果")
    @ApiOperationSupport(order = 60)
    @PreAuthorize("@ss.hasPermi('system:urYearValidData:remove')")
    @Log(title = "专利有效按年统计结果", businessType = BusinessType.DELETE)
    @PostMapping("/delete/{ids}")
    public ResponseData remove(@PathVariable Long[] ids)
    {
        //return toResult(urYearValidDataService.deleteUrYearValidDataByIds(ids));
        //逻辑删除
        return toResult(urYearValidDataService.setDeleteByIds(ids));
    }

    /**
     * 查询专利有效按年统计结果列表---不进行分页
     */
    @ApiOperation(value = "查询专利有效按年统计结果列表---不进行分页",notes = "查询专利有效按年统计结果列表---不进行分页")
    @ApiOperationSupport(order = 70)
//    @PreAuthorize("@ss.hasPermi('system:urYearValidData:list')")
    @GetMapping("/getDataList")
    public ResponseData<List<UrYearValidData>> getDataList(UrYearValidDataVo urYearValidData)
    {
        List<UrYearValidData> list = urYearValidDataService.selectUrYearValidDataList(urYearValidData);
        return ResponseData.success(list);
    }
}
