package com.fs.store.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.store.domain.FsShippingTemplatesRegion;
import com.fs.store.service.IFsShippingTemplatesRegionService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 邮费区域Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/shippingTemplatesRegion")
public class FsShippingTemplatesRegionController extends BaseController
{
    @Autowired
    private IFsShippingTemplatesRegionService fsShippingTemplatesRegionService;

    /**
     * 查询邮费区域列表
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplatesRegion:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsShippingTemplatesRegion fsShippingTemplatesRegion)
    {
        startPage();
        List<FsShippingTemplatesRegion> list = fsShippingTemplatesRegionService.selectFsShippingTemplatesRegionList(fsShippingTemplatesRegion);
        return getDataTable(list);
    }

    /**
     * 导出邮费区域列表
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplatesRegion:export')")
    @Log(title = "邮费区域", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsShippingTemplatesRegion fsShippingTemplatesRegion)
    {
        List<FsShippingTemplatesRegion> list = fsShippingTemplatesRegionService.selectFsShippingTemplatesRegionList(fsShippingTemplatesRegion);
        ExcelUtil<FsShippingTemplatesRegion> util = new ExcelUtil<FsShippingTemplatesRegion>(FsShippingTemplatesRegion.class);
        return util.exportExcel(list, "shippingTemplatesRegion");
    }

    /**
     * 获取邮费区域详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplatesRegion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsShippingTemplatesRegionService.selectFsShippingTemplatesRegionById(id));
    }

    /**
     * 新增邮费区域
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplatesRegion:add')")
    @Log(title = "邮费区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsShippingTemplatesRegion fsShippingTemplatesRegion)
    {
        return toAjax(fsShippingTemplatesRegionService.insertFsShippingTemplatesRegion(fsShippingTemplatesRegion));
    }

    /**
     * 修改邮费区域
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplatesRegion:edit')")
    @Log(title = "邮费区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsShippingTemplatesRegion fsShippingTemplatesRegion)
    {
        return toAjax(fsShippingTemplatesRegionService.updateFsShippingTemplatesRegion(fsShippingTemplatesRegion));
    }

    /**
     * 删除邮费区域
     */
    @PreAuthorize("@ss.hasPermi('store:shippingTemplatesRegion:remove')")
    @Log(title = "邮费区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsShippingTemplatesRegionService.deleteFsShippingTemplatesRegionByIds(ids));
    }
}
