package com.shkj.wms.controller;

import java.util.List;

import com.shkj.wms.service.IJimuReportTypeConfigService;
import lombok.RequiredArgsConstructor;
import com.shkj.wms.config.ValidList;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.shkj.common.annotation.Log;
import com.shkj.common.enums.BusinessType;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.wms.vo.JimuReportTypeConfigVo;
import com.shkj.wms.bo.JimuReportTypeConfigQueryBo;
import com.shkj.wms.bo.JimuReportTypeConfigAddBo;
import com.shkj.wms.bo.JimuReportTypeConfigEditBo;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.utils.poi.ExcelUtil;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * 积木报表关联类型配置Controller
 *
 * @menu 积木报表关联类型配置管理
 * @author lch
 * @date 2022-08-23
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms/jimuReport/config")
public class JimuReportTypeConfigController extends BaseController {

    private final IJimuReportTypeConfigService iJimuReportTypeConfigService;

    /**
     * 查询积木报表关联类型配置列表
     */
    @PreAuthorize("@ss.hasPermi('wms:config:list')")
    @GetMapping("/list")
    public TableDataInfo<JimuReportTypeConfigVo> list(JimuReportTypeConfigQueryBo bo) {
        startPage();
        List<JimuReportTypeConfigVo> list = iJimuReportTypeConfigService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出积木报表关联类型配置列表
     */
    @PreAuthorize("@ss.hasPermi('wms:config:export')")
    @GetMapping("/export")
    public void export(HttpServletResponse response, JimuReportTypeConfigQueryBo bo) {
        List<JimuReportTypeConfigVo> list = iJimuReportTypeConfigService.queryList(bo);
        ExcelUtil<JimuReportTypeConfigVo> util = new ExcelUtil<JimuReportTypeConfigVo>(JimuReportTypeConfigVo.class);
        util.exportExcel(response, list, "积木报表关联类型配置数据");
    }

    /**
     * 获取积木报表关联类型配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:config:query')")
    @GetMapping("/{id}")
    public Result<JimuReportTypeConfigVo> getInfo(@PathVariable("id" ) Long id) {
        return iJimuReportTypeConfigService.queryById(id);
    }

    /**
     * 新增积木报表关联类型配置
     */
    @PreAuthorize("@ss.hasPermi('wms:config:add')")
    @Log(title = "积木报表关联类型配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<Boolean> add(@Valid @RequestBody JimuReportTypeConfigAddBo bo) {
        return iJimuReportTypeConfigService.insertByAddBo(bo);
    }

    /**
     * 修改积木报表关联类型配置
     */
    @PreAuthorize("@ss.hasPermi('wms:config:edit')")
    @Log(title = "积木报表关联类型配置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public Result<Boolean> edit(@Valid @RequestBody JimuReportTypeConfigEditBo bo) {
        return iJimuReportTypeConfigService.updateByEditBo(bo);
    }

    /**
     * 删除积木报表关联类型配置
     */
    @PreAuthorize("@ss.hasPermi('wms:config:remove')")
    @Log(title = "积木报表关联类型配置" , businessType = BusinessType.DELETE)
    @DeleteMapping("/remove")
    public Result<Boolean> remove(@Valid @RequestBody ValidList<Long> ids) {
        return iJimuReportTypeConfigService.deleteWithValidById(ids, true);
    }


}
