package com.zehong.web.controller.track;

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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TProductLogistics;
import com.zehong.system.service.ITProductLogisticsService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 出货物流Controller
 * 
 * @author zehong
 * @date 2024-08-30
 */
@RestController
@RequestMapping("/track/logistics")
public class TProductLogisticsController extends BaseController
{
    @Autowired
    private ITProductLogisticsService tProductLogisticsService;

    /**
     * 查询出货物流列表
     */
   // @PreAuthorize("@ss.hasPermi('system:logistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductLogistics tProductLogistics)
    {
        startPage();
        List<TProductLogistics> list = tProductLogisticsService.selectTProductLogisticsList(tProductLogistics);
        return getDataTable(list);
    }

    /**
     * 导出出货物流列表
     */
    //@PreAuthorize("@ss.hasPermi('system:logistics:export')")
    @Log(title = "出货物流", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductLogistics tProductLogistics)
    {
        List<TProductLogistics> list = tProductLogisticsService.selectTProductLogisticsList(tProductLogistics);
        ExcelUtil<TProductLogistics> util = new ExcelUtil<TProductLogistics>(TProductLogistics.class);
        return util.exportExcel(list, "出货物流数据");
    }

    /**
     * 获取出货物流详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:logistics:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductLogisticsService.selectTProductLogisticsById(id));
    }

    /**
     * 新增出货物流
     */
    //@PreAuthorize("@ss.hasPermi('system:logistics:add')")
    @Log(title = "出货物流", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductLogistics tProductLogistics)
    {
        return toAjax(tProductLogisticsService.insertTProductLogistics(tProductLogistics));
    }

    /**
     * 修改出货物流
     */
    //@PreAuthorize("@ss.hasPermi('system:logistics:edit')")
    @Log(title = "出货物流", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductLogistics tProductLogistics)
    {
        return toAjax(tProductLogisticsService.updateTProductLogistics(tProductLogistics));
    }

    /**
     * 删除出货物流
     */
    //@PreAuthorize("@ss.hasPermi('system:logistics:remove')")
    @Log(title = "出货物流", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductLogisticsService.deleteTProductLogisticsByIds(ids));
    }
}
