/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.stocks.controller;
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.DeviceTransInfoDto;
import com.tofly.stocks.dto.DeviceTransInfoQuery;
import com.tofly.stocks.service.DeviceTransInfoService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;

import java.util.Arrays;
import java.util.List;
/**
 * 设备转移信息表
 *
 * @author admin
 * @date Fri Nov 25 00:00:00 CST 2022
 */
@RestController
@AllArgsConstructor
@RequestMapping("/devicetransinfo")
@Api(tags="设备转移信息表接口")
public class DeviceTransInfoController {

    private final  DeviceTransInfoService deviceTransInfoService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param deviceTransInfoQuery 设备转移信息表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getDeviceTransInfoPage(Page page, @Validated DeviceTransInfoQuery deviceTransInfoQuery) {
    	return ResultRespone.success(deviceTransInfoService.getDataPage(page,deviceTransInfoQuery));
    }


    /**
     * 通过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(deviceTransInfoService.getById(id));
    }

    /**
     * 新增设备转移信息表
     * @param deviceTransInfoDto 设备转移信息表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增设备转移信息表" )
    @ApiOperation(value = "新增设备转移信息表")
    @PostMapping
    public ResultRespone save(@Validated DeviceTransInfoDto deviceTransInfoDto,
    		@RequestPart(required = false) @ApiParam("附件列表") List<MultipartFile> files) {
        return ResultRespone.success(deviceTransInfoService.saveDeviceTransInfo(deviceTransInfoDto, files));
    }

    /**
     * 修改设备转移信息表
     * @param deviceTransInfoDto 设备转移信息表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改设备转移信息表" )
    @ApiOperation(value = "修改设备转移信息表")
    @PutMapping
    public ResultRespone updateDeviceTransInfo(@Validated DeviceTransInfoDto deviceTransInfoDto,
    		@RequestPart(required = false) @ApiParam("附件列表") List<MultipartFile> files) {
      return ResultRespone.success(deviceTransInfoService.editDeviceTransInfo(deviceTransInfoDto, files));
    }



    /**
     * 通过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(deviceTransInfoService.deleteByIds(ids));
    }
    
    
    /**
     * 通过设备处置信息id查询明细
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/transDetail/{id}" )
    @ApiOperation(value = "通过设备处置信息id查询明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    public ResultRespone getDeviceHandleDetailByInfoId(@PathVariable("id" ) Long id) {
    	return ResultRespone.success(deviceTransInfoService.getDeviceTransDetailByInfoId(id));
    }
    
    
}
