/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.xrtygis.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtygis.entity.TfNrwAnalyse;
import com.tofly.xrtygis.service.TfNrwAnalyseService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Arrays;
/**
 * 产销差分析记录表
 *
 * @author JF
 * @date Fri May 27 00:00:00 CST 2022
 */
@RestController
@AllArgsConstructor
@RequestMapping("/tfnrwanalyse")
@Api(tags="产销差分析记录表接口")
public class TfNrwAnalyseController {

    private final  TfNrwAnalyseService tfNrwAnalyseService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param tfNrwAnalyse 产销差分析记录表
    * @return
    */
    @ToFlyAppLog(title="分页查询" )
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getTfNrwAnalysePage(Page page, @ModelAttribute TfNrwAnalyse tfNrwAnalyse) {
      return ResultRespone.success(tfNrwAnalyseService.page(page, Wrappers.query(tfNrwAnalyse)));
    }


    /**
     * 通过id查询产销差分析记录表
     * @param id id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过ID查询" )
    @GetMapping("/{id}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    public ResultRespone getById(@PathVariable("id" ) Long id) {
      return ResultRespone.success(tfNrwAnalyseService.getById(id));
    }

    /**
     * 新增产销差分析记录表
     * @param tfNrwAnalyse 产销差分析记录表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增产销差分析记录表" )
    @ApiOperation(value = "新增产销差分析记录表")
    @PostMapping
    public ResultRespone save(@RequestBody TfNrwAnalyse tfNrwAnalyse) {
      return ResultRespone.success(tfNrwAnalyseService.save(tfNrwAnalyse));
    }

    /**
     * 修改产销差分析记录表
     * @param tfNrwAnalyse 产销差分析记录表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改产销差分析记录表" )
    @ApiOperation(value = "修改产销差分析记录表")
    @PutMapping
    public ResultRespone updateById(@RequestBody TfNrwAnalyse tfNrwAnalyse) {
      return ResultRespone.success(tfNrwAnalyseService.updateById(tfNrwAnalyse));
    }

    /**
     * 通过id删除产销差分析记录表
     * @param id id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id删除产销差分析记录表" )
    @ApiOperation(value = "通过ID删除产销差分析记录表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable Long id) {
      return ResultRespone.success(tfNrwAnalyseService.removeById(id));
    }

    /**
     * 通过id批量删除产销差分析记录表
     * @param ids id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id批量删除产销差分析记录表" )
    @ApiOperation(value = "通过ID批量删除产销差分析记录表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeById(String ids) {
        return ResultRespone.success(tfNrwAnalyseService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
