package com.zd.laboratory.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.zd.common.core.domain.per.PerFun;
import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.web.domain.ResultData;
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.zd.common.log.annotation.Log;
import com.zd.common.log.enums.BusinessType;
import com.zd.common.security.annotation.PreAuthorize;
import com.zd.laboratory.domain.ApkMachineconfig;
import com.zd.laboratory.service.IApkMachineconfigService;
import com.zd.common.core.web.controller.BaseController;
import com.zd.common.core.web.domain.AjaxResult;
import com.zd.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.zd.common.swagger.config.Knife4jConfiguration;

import com.zd.common.core.web.page.TableDataInfo;

/**
 * 【一体机获取配置文件】Controller
 *
 * @author zd
 * @date 2021-12-09
 */
@RestController
@Api(tags = "【【一体机获取配置文件】】")
//作者手动加入 ，在接口上加作者@ApiOperationSupport(author = "XXX")
@ApiSupport(author = Knife4jConfiguration.Author.CYL)
@RequestMapping("/machineconfig")
public class ApkMachineconfigController extends BaseController
{
    @Autowired
    private IApkMachineconfigService apkMachineconfigService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_MACHINECONFIG + PerFun.LIST)
    @GetMapping("/list")
    @ApiOperation(value = "查询【请填写功能名称】列表")
    public TableDataInfo<ApkMachineconfig> list(ApkMachineconfig apkMachineconfig)
    {
        startPage();
        List<ApkMachineconfig> list = apkMachineconfigService.selectApkMachineconfigList(apkMachineconfig);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @ApiOperation(value = "导出【请填写功能名称】列表")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_MACHINECONFIG + PerFun.EXPORT)
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApkMachineconfig apkMachineconfig) throws IOException
    {
        List<ApkMachineconfig> list = apkMachineconfigService.selectApkMachineconfigList(apkMachineconfig);
        ExcelUtil<ApkMachineconfig> util = new ExcelUtil<ApkMachineconfig>(ApkMachineconfig.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation(value = "获取【请填写功能名称】详细信息")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_MACHINECONFIG + PerFun.QUERY)
    @GetMapping(value = "/{id}")
    public ResultData<ApkMachineconfig> getInfo(@PathVariable("id") Long id)
    {
        return ResultData.success(apkMachineconfigService.selectApkMachineconfigById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @ApiOperation(value = "新增【请填写功能名称】")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_MACHINECONFIG + PerFun.ADD)
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public ResultData add(@RequestBody ApkMachineconfig apkMachineconfig)
    {
        return ResultData.result(apkMachineconfigService.insertApkMachineconfig(apkMachineconfig));
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation(value = "修改【请填写功能名称】")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_MACHINECONFIG + PerFun.EDIT)
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultData edit(@RequestBody ApkMachineconfig apkMachineconfig)
    {
        return  ResultData.result(apkMachineconfigService.updateApkMachineconfig(apkMachineconfig));
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation(value = "删除【请填写功能名称】")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_MACHINECONFIG + PerFun.REMOVE)
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResultData remove(@PathVariable Long[] ids)
    {
        return ResultData.result(apkMachineconfigService.deleteApkMachineconfigByIds(ids));
    }



    /**
     * 获取一体机详细信息
     */
    @ApiOperation(value = "获取一体机详细信息")
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_MACHINECONFIG + PerFun.QUERY)
    @GetMapping(value = "/getMachineConfig/{hardwareNum}")
    public AjaxResult getMachineConfig(@PathVariable("hardwareNum") String hardwareNum)
    {
        ApkMachineconfig apkMachineconfig = apkMachineconfigService.selectApkMachineconfigByHardwareNum(hardwareNum);
        if(apkMachineconfig!=null){
            return AjaxResult.success(apkMachineconfig);
        }
        return AjaxResult.error("没有配置相关信息");
    }
}
