package com.inspect.metadata.bdconfig.controller;

import com.inspect.metadata.bdconfig.domain.BasedataBdConfigDeviceConvert;
import com.inspect.metadata.bdconfig.service.IBasedataBdConfigDeviceConvertService;
import com.inspect.base.core.utils.poi.ExcelUtil;
import com.inspect.base.core.web.controller.BaseController;
import com.inspect.base.core.web.domain.AjaxResult;
import com.inspect.base.core.web.page.TableDataInfo;
import com.inspect.common.log.annotation.Log;
import com.inspect.common.log.enums.BizType;
import com.inspect.common.security.annotation.RequiresPermissions;

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

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/bdconfig/deviceconvert"})
public class BasedataBdConfigDeviceConvertController extends BaseController {
    private final IBasedataBdConfigDeviceConvertService basedataBdConfigDeviceConvertService;

    public BasedataBdConfigDeviceConvertController(IBasedataBdConfigDeviceConvertService basedataBdConfigDeviceConvertService) {
        this.basedataBdConfigDeviceConvertService = basedataBdConfigDeviceConvertService;
    }

    @RequiresPermissions({"basedata/bdconfig:deviceconvert:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataBdConfigDeviceConvert basedataBdconfigDeviceConvert) {
        this.startPage();
        List<BasedataBdConfigDeviceConvert> list = this.basedataBdConfigDeviceConvertService.selectBasedataBdConfigDeviceConvertList(basedataBdconfigDeviceConvert);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/bdconfig:deviceconvert:export"})
    @Log(
            title = "基础数据-算法对应",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataBdConfigDeviceConvert basedataBdconfigDeviceConvert) {
        List<BasedataBdConfigDeviceConvert> list = this.basedataBdConfigDeviceConvertService.selectBasedataBdConfigDeviceConvertList(basedataBdconfigDeviceConvert);
        ExcelUtil<BasedataBdConfigDeviceConvert> util = new ExcelUtil<>(BasedataBdConfigDeviceConvert.class);
        util.exportExcel(response, list, "基础数据-算法对应数据");
    }

    @RequiresPermissions({"basedata/bdconfig:deviceconvert:query"})
    @GetMapping({"/{deviceConvertId}"})
    public AjaxResult getInfo(@PathVariable("deviceConvertId") Long deviceConvertId) {
        return AjaxResult.success(this.basedataBdConfigDeviceConvertService.selectBasedataBdConfigDeviceConvertByDeviceConvertId(deviceConvertId));
    }

    @RequiresPermissions({"basedata/bdconfig:deviceconvert:add"})
    @Log(
            title = "基础数据-算法对应",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataBdConfigDeviceConvert basedataBdconfigDeviceConvert) {
        return this.toAjax(this.basedataBdConfigDeviceConvertService.insertBasedataBdConfigDeviceConvert(basedataBdconfigDeviceConvert));
    }

    @RequiresPermissions({"basedata/bdconfig:deviceconvert:edit"})
    @Log(
            title = "基础数据-算法对应",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataBdConfigDeviceConvert basedataBdconfigDeviceConvert) {
        return this.toAjax(this.basedataBdConfigDeviceConvertService.updateBasedataBdConfigDeviceConvert(basedataBdconfigDeviceConvert));
    }

    @RequiresPermissions({"basedata/bdconfig:deviceconvert:remove"})
    @Log(
            title = "基础数据-算法对应",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{deviceConvertIds}"})
    public AjaxResult remove(@PathVariable Long[] deviceConvertIds) {
        return this.toAjax(this.basedataBdConfigDeviceConvertService.deleteBasedataBdConfigDeviceConvertByDeviceConvertIds(deviceConvertIds));
    }
}
