package com.fs.hisStore.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.domain.R;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.hisStore.domain.FsShippingTemplatesScrm;
import com.fs.hisStore.param.FsShippingTemplatesAddEditParam;
import com.fs.hisStore.service.IFsShippingTemplatesScrmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 运费模板Controller
 *
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/store/shippingTemplates")
public class FsShippingTemplatesScrmController extends BaseController
{
    @Autowired
    private IFsShippingTemplatesScrmService fsShippingTemplatesService;

    /**
     * 查询运费模板列表
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplates:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsShippingTemplatesScrm fsShippingTemplates)
    {
        startPage();
        fsShippingTemplates.setIsDel(0);
        List<FsShippingTemplatesScrm> list = fsShippingTemplatesService.selectFsShippingTemplatesList(fsShippingTemplates);
        return getDataTable(list);
    }

    /**
     * 导出运费模板列表
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplates:export')")
    @Log(title = "运费模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsShippingTemplatesScrm fsShippingTemplates)
    {
        List<FsShippingTemplatesScrm> list = fsShippingTemplatesService.selectFsShippingTemplatesList(fsShippingTemplates);
        ExcelUtil<FsShippingTemplatesScrm> util = new ExcelUtil<FsShippingTemplatesScrm>(FsShippingTemplatesScrm.class);
        return util.exportExcel(list, "shippingTemplates");
    }

    /**
     * 获取运费模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplates:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsShippingTemplatesService.selectFsShippingTemplatesById(id));
    }

    /**
     * 新增运费模板
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplates:add')")
    @Log(title = "运费模板", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody FsShippingTemplatesAddEditParam param)
    {
        return fsShippingTemplatesService.addOrEdit(param);
    }
    /**
     * 修改运费模板
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplates:edit')")
    @Log(title = "运费模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody FsShippingTemplatesAddEditParam param)
    {
        return fsShippingTemplatesService.addOrEdit(param);
    }
    /**
     * 删除运费模板
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplates:remove')")
    @Log(title = "运费模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsShippingTemplatesService.deleteFsShippingTemplatesByIds(ids));
    }

    @GetMapping("/getAllList")
    public R getAllList(FsShippingTemplatesScrm fsShippingTemplates)
    {
        fsShippingTemplates.setIsDel(0);
        List<FsShippingTemplatesScrm> list = fsShippingTemplatesService.selectFsShippingTemplatesList(fsShippingTemplates);
        return R.ok().put("data",list);
    }
}
