/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.stocks.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.stocks.dto.DeviceDepreciateQuery;
import com.tofly.stocks.entity.DeviceDepreciate;
import com.tofly.stocks.service.DeviceDepreciateService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
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 admin
 * @date Mon Dec 12 00:00:00 CST 2022
 */
@RestController
@AllArgsConstructor
@RequestMapping("/devicedepreciate")
@Api(tags="设备折旧表接口")
public class DeviceDepreciateController {

    private final  DeviceDepreciateService deviceDepreciateService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param deviceDepreciateQuery 设备折旧表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getDeviceDepreciatePage(Page page, @ModelAttribute DeviceDepreciateQuery deviceDepreciateQuery) {
        return ResultRespone.success(deviceDepreciateService.getDataPage(page, deviceDepreciateQuery));
    }

    /**
     * 通过id查询设备折旧表
     * @param id id
     * @return ResultRespone
     */
    @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(deviceDepreciateService.getById(id));
    }

    /**
     * 新增设备折旧表
     * @param deviceDepreciate 设备折旧表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增设备折旧表" )
    @ApiOperation(value = "新增设备折旧表")
    @PostMapping
    public ResultRespone save(@RequestBody @Validated DeviceDepreciate deviceDepreciate) {
      return ResultRespone.success(deviceDepreciateService.saveDepreciate(deviceDepreciate));
    }

    /**
     * 修改设备折旧表
     * @param deviceDepreciate 设备折旧表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改设备折旧表" )
    @ApiOperation(value = "修改设备折旧表")
    @PutMapping
    public ResultRespone updateById(@RequestBody @Validated DeviceDepreciate deviceDepreciate) {
      return ResultRespone.success(deviceDepreciateService.editDepreciate(deviceDepreciate));
    }


    /**
     * 通过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(deviceDepreciateService.deleteByIds(ids));
    }


    /**
     * 选择设备折旧列表
     * @param page 分页对象
     * @param deviceDepreciateQuery 选择设备折旧列表
     * @return
     */
    @GetMapping("/getDeviceDepreciateList" )
    @ApiOperation(value = "分页查询，选择设备折旧列表")
    public ResultRespone getDepreciatePageData(Page page, @ModelAttribute DeviceDepreciateQuery deviceDepreciateQuery) {
        return ResultRespone.success(deviceDepreciateService.getDepreciateSelectDataPage(page, deviceDepreciateQuery));
    }

}
