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.UrPatentValidStaticVo;
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.UrValidShowData;
import com.ruoyi.system.service.IUrValidShowDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 有效概览成品Controller
 * 
 * @author dm
 * @date 2023-02-14
 */
@Api(value = "有效概览成品",tags = "有效概览成品")
@ApiSupport(author = "dm",order = 10)
@RestController
@RequestMapping("/system/urValidShowData")
public class UrValidShowDataController extends BaseController
{
    @Autowired
    private IUrValidShowDataService urValidShowDataService;

    /**
     * 获取有效概览成品详细信息
     */
    @ApiOperation(value = "获取有效概览成品详细信息",notes = "获取有效概览成品详细信息")
    @ApiOperationSupport(order = 30)
    @PreAuthorize("@ss.hasPermi('system:urValidShowData:query')")
    @GetMapping(value = "/{id}")
    public ResponseData<UrValidShowData> getInfo(@PathVariable("id") Long id)
    {
        return ResponseData.success(urValidShowDataService.selectUrValidShowDataById(id));
    }

    /**
     * 新增有效概览成品
     */
    @ApiOperation(value = "新增有效概览成品",notes = "新增有效概览成品")
    @ApiOperationSupport(order = 40,ignoreParameters = {"urValidShowData.id"})
    @PreAuthorize("@ss.hasPermi('system:urValidShowData:add')")
    @Log(title = "有效概览成品", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public ResponseData add(@RequestBody @Valid @ApiParam(required=true) UrValidShowData urValidShowData)
    {
        int i = urValidShowDataService.insertUrValidShowData(urValidShowData);
        if(i>0){
            //返回主键
            return ResponseData.success(urValidShowData.getId());
        }else{
            return ResponseData.error();
        }
    }

    /**
     * 修改有效概览成品
     */
    @ApiOperation(value = "修改有效概览成品",notes = "修改有效概览成品")
    @ApiOperationSupport(order = 50)
    @PreAuthorize("@ss.hasPermi('system:urValidShowData:edit')")
    @Log(title = "有效概览成品", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @RepeatSubmit
    public ResponseData edit(@RequestBody @Valid @ApiParam(required=true) UrValidShowData urValidShowData)
    {
        int i = urValidShowDataService.updateUrValidShowData(urValidShowData);
        if(i>0){
            //返回主键
            return ResponseData.success(urValidShowData.getId());
        }else{
            return ResponseData.error();
        }
    }

    /**
     * 删除有效概览成品
     */
    @ApiOperation(value = "删除有效概览成品",notes = "删除有效概览成品")
    @ApiOperationSupport(order = 60)
    @PreAuthorize("@ss.hasPermi('system:urValidShowData:remove')")
    @Log(title = "有效概览成品", businessType = BusinessType.DELETE)
    @PostMapping("/delete/{ids}")
    public ResponseData remove(@PathVariable Long[] ids)
    {
        //return toResult(urValidShowDataService.deleteUrValidShowDataByIds(ids));
        //逻辑删除
        return toResult(urValidShowDataService.setDeleteByIds(ids));
    }

    /**
     * 查询有效概览成品列表---不进行分页
     */
    @ApiOperation(value = "查询有效概览成品列表---不进行分页",notes = "查询有效概览成品列表---不进行分页")
    @ApiOperationSupport(order = 70)
    @PreAuthorize("@ss.hasPermi('system:urValidShowData:list')")
    @GetMapping("/getDataList")
    public ResponseData<List<UrPatentValidStaticVo>> getDataList(UrValidShowData urValidShowData)
    {
        List<UrPatentValidStaticVo> list = urValidShowDataService.selectUrValidShowDataList(urValidShowData);
        return ResponseData.success(list);
    }

    /**
     * 导出excel
     */
    @ApiOperation(value = "导出excel",notes = "导出excel")
    @ApiOperationSupport(order = 20)
    @PreAuthorize("@ss.hasPermi('system:urYearValidData:export')")
    @Log(title = "导出excel", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UrValidShowData vo)
    {
        urValidShowDataService.export(vo, response);
    }
}
