package com.zhongzheng.controller.order;

import java.util.List;
import java.util.Arrays;

import com.zhongzheng.modules.order.bo.OrderInputTemplateAddBo;
import com.zhongzheng.modules.order.bo.OrderInputTemplateEditBo;
import com.zhongzheng.modules.order.bo.OrderInputTemplateQueryBo;
import com.zhongzheng.modules.order.service.IOrderInputTemplateService;
import com.zhongzheng.modules.order.vo.OrderInputTemplateVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
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.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 订单采集信息模板Controller
 *
 * @author hjl
 * @date 2021-11-05
 */
@Api(value = "订单采集信息模板控制器", tags = {"订单采集信息模板管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/order/input/template")
public class OrderInputTemplateController extends BaseController {

    private final IOrderInputTemplateService iOrderInputTemplateService;

    /**
     * 查询订单采集信息模板列表
     */
    @ApiOperation("查询订单采集信息模板列表")
    @PreAuthorize("@ss.hasPermi('system:template:list')")
    @GetMapping("/list")
    public TableDataInfo<OrderInputTemplateVo> list(OrderInputTemplateQueryBo bo) {
        startPage();
        List<OrderInputTemplateVo> list = iOrderInputTemplateService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出订单采集信息模板列表
     */
    /*@ApiOperation("导出订单采集信息模板列表")
    @PreAuthorize("@ss.hasPermi('system:template:export')")
    @Log(title = "订单采集信息模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<OrderInputTemplateVo> export(OrderInputTemplateQueryBo bo) {
        List<OrderInputTemplateVo> list = iOrderInputTemplateService.queryList(bo);
        ExcelUtil<OrderInputTemplateVo> util = new ExcelUtil<OrderInputTemplateVo>(OrderInputTemplateVo.class);
        return util.exportExcel(list, "订单采集信息模板");
    }*/

    /**
     * 获取订单采集信息模板详细信息
     */
    @ApiOperation("获取订单采集信息模板详细信息")
    @PreAuthorize("@ss.hasPermi('system:template:query')")
    @GetMapping("/{id}")
    public AjaxResult<OrderInputTemplateVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iOrderInputTemplateService.queryById(id));
    }

    /**
     * 新增订单采集信息模板
     */
    @ApiOperation("新增订单采集信息模板")
    @PreAuthorize("@ss.hasPermi('system:template:add')")
    @Log(title = "订单采集信息模板", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody OrderInputTemplateAddBo bo) {
        return toAjax(iOrderInputTemplateService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改订单采集信息模板
     */
    @ApiOperation("修改订单采集信息模板")
    @PreAuthorize("@ss.hasPermi('system:template:edit')")
    @Log(title = "订单采集信息模板", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody OrderInputTemplateEditBo bo) {
        return toAjax(iOrderInputTemplateService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除订单采集信息模板
     */
    /*@ApiOperation("删除订单采集信息模板")
    @PreAuthorize("@ss.hasPermi('system:template:remove')")
    @Log(title = "订单采集信息模板" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iOrderInputTemplateService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }*/
}
