package com.inspect.metadata.eqpbook.controller;

import com.inspect.metadata.eqpbook.domain.BasedataEqpBookModel;
import com.inspect.metadata.eqpbook.service.IBasedataEqpBookModelService;
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.beans.factory.annotation.Autowired;
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({"/eqpbookmodel"})
public class BasedataEqpBookModelController extends BaseController {
    private final IBasedataEqpBookModelService basedataEqpBookModelService;

    public BasedataEqpBookModelController(IBasedataEqpBookModelService basedataEqpBookModelService) {
        this.basedataEqpBookModelService = basedataEqpBookModelService;
    }

    @RequiresPermissions({"basedata/eqpbook:eqpbookmodel:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataEqpBookModel basedataEqpbookModel) {
        this.startPage();
        List<BasedataEqpBookModel> list = this.basedataEqpBookModelService.selectBasedataEqpBookModelList(basedataEqpbookModel);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/eqpbook:eqpbookmodel:export"})
    @Log(
            title = "台账位置信息表",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataEqpBookModel basedataEqpbookModel) {
        List<BasedataEqpBookModel> list = this.basedataEqpBookModelService.selectBasedataEqpBookModelList(basedataEqpbookModel);
        ExcelUtil<BasedataEqpBookModel> util = new ExcelUtil<>(BasedataEqpBookModel.class);
        util.exportExcel(response, list, "台账位置信息表数据");
    }

    @RequiresPermissions({"basedata/eqpbook:eqpbookmodel:query"})
    @GetMapping({"/{eqpbookModelId}"})
    public AjaxResult getInfo(@PathVariable("eqpbookModelId") String eqpBookModelId) {
        return AjaxResult.success(this.basedataEqpBookModelService.selectBasedataEqpBookModelByEqpBookModelId(eqpBookModelId));
    }

    @RequiresPermissions({"basedata/eqpbook:eqpbookmodel:add"})
    @Log(
            title = "台账位置信息表",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataEqpBookModel basedataEqpbookModel) {
        return this.toAjax(this.basedataEqpBookModelService.insertBasedataEqpBookModel(basedataEqpbookModel));
    }

    @RequiresPermissions({"basedata/eqpbook:eqpbookmodel:edit"})
    @Log(
            title = "台账位置信息表",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataEqpBookModel basedataEqpbookModel) {
        return this.toAjax(this.basedataEqpBookModelService.updateBasedataEqpBookModel(basedataEqpbookModel));
    }

    @RequiresPermissions({"basedata/eqpbook:eqpbookmodel:remove"})
    @Log(
            title = "台账位置信息表",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{eqpbookModelIds}"})
    public AjaxResult remove(@PathVariable("eqpbookModelIds") String[] eqpBookModelIds) {
        return this.toAjax(this.basedataEqpBookModelService.deleteBasedataEqpBookModelByEqpBookModelIds(eqpBookModelIds));
    }
}
