package com.inspect.metadata.bdconfig.controller;

import com.inspect.metadata.bdconfig.domain.BasedataBdConfigAlgConvert;
import com.inspect.metadata.bdconfig.service.IBasedataBdConfigAlgConvertService;
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/algconvert"})
public class BasedataBdConfigAlgConvertController extends BaseController {
    private final IBasedataBdConfigAlgConvertService basedataBdConfigAlgConvertService;

    public BasedataBdConfigAlgConvertController(IBasedataBdConfigAlgConvertService basedataBdConfigAlgConvertService) {
        this.basedataBdConfigAlgConvertService = basedataBdConfigAlgConvertService;
    }

    @RequiresPermissions({"basedata/bdconfig:algconvert:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataBdConfigAlgConvert basedataBdconfigAlgConvert) {
        this.startPage();
        List<BasedataBdConfigAlgConvert> list = this.basedataBdConfigAlgConvertService.selectBasedataBdConfigAlgConvertList(basedataBdconfigAlgConvert);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/bdconfig:algconvert:export"})
    @Log(
            title = "基础数据-设备对应",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataBdConfigAlgConvert basedataBdconfigAlgConvert) {
        List<BasedataBdConfigAlgConvert> list = this.basedataBdConfigAlgConvertService.selectBasedataBdConfigAlgConvertList(basedataBdconfigAlgConvert);
        ExcelUtil<BasedataBdConfigAlgConvert> util = new ExcelUtil<>(BasedataBdConfigAlgConvert.class);
        util.exportExcel(response, list, "基础数据-设备对应数据");
    }

    @RequiresPermissions({"basedata/bdconfig:algconvert:query"})
    @GetMapping({"/{algConvertId}"})
    public AjaxResult getInfo(@PathVariable("algConvertId") Long algConvertId) {
        return AjaxResult.success(this.basedataBdConfigAlgConvertService.selectBasedataBdConfigAlgConvertByAlgConvertId(algConvertId));
    }

    @RequiresPermissions({"basedata/bdconfig:algconvert:add"})
    @Log(
            title = "基础数据-设备对应",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataBdConfigAlgConvert basedataBdconfigAlgConvert) {
        return this.toAjax(this.basedataBdConfigAlgConvertService.insertBasedataBdConfigAlgConvert(basedataBdconfigAlgConvert));
    }

    @RequiresPermissions({"basedata/bdconfig:algconvert:edit"})
    @Log(
            title = "基础数据-设备对应",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataBdConfigAlgConvert basedataBdconfigAlgConvert) {
        return this.toAjax(this.basedataBdConfigAlgConvertService.updateBasedataBdConfigAlgConvert(basedataBdconfigAlgConvert));
    }

    @RequiresPermissions({"basedata/bdconfig:algconvert:remove"})
    @Log(
            title = "基础数据-设备对应",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{algConvertIds}"})
    public AjaxResult remove(@PathVariable Long[] algConvertIds) {
        return this.toAjax(this.basedataBdConfigAlgConvertService.deleteBasedataBdConfigAlgConvertByAlgConvertIds(algConvertIds));
    }
}
