package com.ruoyi.web.controller.shipping.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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shipping.domain.TConditionAccessory;
import com.ruoyi.shipping.service.ITConditionAccessoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 凯和附件Controller
 * 
 * @author ruoyi
 * @date 2021-04-01
 */
@RestController
@RequestMapping("/shipping/accessory")
public class TConditionAccessoryController extends BaseController
{
    @Autowired
    private ITConditionAccessoryService tConditionAccessoryService;

    /**
     * 查询凯和附件列表
     */
    //@PreAuthorize("@ss.hasPermi('shipping:accessory:list')")
    @GetMapping("/list")
    public TableDataInfo list(TConditionAccessory tConditionAccessory)
    {
        startPage();
        List<TConditionAccessory> list = tConditionAccessoryService.selectTConditionAccessoryList(tConditionAccessory);
        return getDataTable(list);
    }

    /**
     * 导出凯和附件列表
     */
    @PreAuthorize("@ss.hasPermi('shipping:accessory:export')")
    @Log(title = "凯和附件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TConditionAccessory tConditionAccessory)
    {
        List<TConditionAccessory> list = tConditionAccessoryService.selectTConditionAccessoryList(tConditionAccessory);
        ExcelUtil<TConditionAccessory> util = new ExcelUtil<TConditionAccessory>(TConditionAccessory.class);
        return util.exportExcel(list, "accessory");
    }

    /**
     * 获取凯和附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('shipping:accessory:query')")
    @GetMapping(value = "/{fId}")
    public AjaxResult getInfo(@PathVariable("fId") Long fId)
    {
        return AjaxResult.success(tConditionAccessoryService.selectTConditionAccessoryById(fId));
    }

    /**
     * 新增凯和附件
     */
    @PreAuthorize("@ss.hasPermi('shipping:accessory:add')")
    @Log(title = "凯和附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TConditionAccessory tConditionAccessory)
    {
        return toAjax(tConditionAccessoryService.insertTConditionAccessory(tConditionAccessory));
    }

    /**
     * 修改凯和附件
     */
    @PreAuthorize("@ss.hasPermi('shipping:accessory:edit')")
    @Log(title = "凯和附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TConditionAccessory tConditionAccessory)
    {
        return toAjax(tConditionAccessoryService.updateTConditionAccessory(tConditionAccessory));
    }

    /**
     * 删除凯和附件
     */
    @PreAuthorize("@ss.hasPermi('shipping:accessory:remove')")
    @Log(title = "凯和附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fIds}")
    public AjaxResult remove(@PathVariable Long[] fIds)
    {
        return toAjax(tConditionAccessoryService.deleteTConditionAccessoryByIds(fIds));
    }
}
