package com.cpxt.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.cpxt.common.annotation.Log;
import com.cpxt.common.core.controller.BaseController;
import com.cpxt.common.core.domain.AjaxResult;
import com.cpxt.common.enums.BusinessType;
import com.cpxt.biz.domain.BizCustomerRoute;
import com.cpxt.biz.service.IBizCustomerRouteService;
import com.cpxt.common.utils.poi.ExcelUtil;
import com.cpxt.common.core.page.TableDataInfo;

/**
 * 路线Controller
 * 
 * @author YIN
 * @date 2024-12-16
 */
@RestController
@RequestMapping("/biz/route")
public class BizCustomerRouteController extends BaseController
{
    @Autowired
    private IBizCustomerRouteService bizCustomerRouteService;

    /**
     * 查询路线列表
     */
    @PreAuthorize("@ss.hasPermi('biz:route:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizCustomerRoute bizCustomerRoute)
    {
        startPage();
        List<BizCustomerRoute> list = bizCustomerRouteService.selectBizCustomerRouteList(bizCustomerRoute);
        return getDataTable(list);
    }

    @GetMapping("/list2")
    public AjaxResult list2(BizCustomerRoute bizCustomerRoute)
    {
        return AjaxResult.success( bizCustomerRouteService.selectBizCustomerRouteList(bizCustomerRoute));
    }

    /**
     * 导出路线列表
     */
    @PreAuthorize("@ss.hasPermi('biz:route:export')")
    @Log(title = "路线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizCustomerRoute bizCustomerRoute)
    {
        List<BizCustomerRoute> list = bizCustomerRouteService.selectBizCustomerRouteList(bizCustomerRoute);
        ExcelUtil<BizCustomerRoute> util = new ExcelUtil<BizCustomerRoute>(BizCustomerRoute.class);
        util.exportExcel(response, list, "路线数据");
    }

    /**
     * 获取路线详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:route:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizCustomerRouteService.selectBizCustomerRouteById(id));
    }

    /**
     * 新增路线
     */
    @PreAuthorize("@ss.hasPermi('biz:route:add')")
    @Log(title = "路线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizCustomerRoute bizCustomerRoute)
    {
        return toAjax(bizCustomerRouteService.insertBizCustomerRoute(bizCustomerRoute));
    }

    /**
     * 修改路线
     */
    @PreAuthorize("@ss.hasPermi('biz:route:edit')")
    @Log(title = "路线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizCustomerRoute bizCustomerRoute)
    {
        return toAjax(bizCustomerRouteService.updateBizCustomerRoute(bizCustomerRoute));
    }

    /**
     * 删除路线
     */
    @PreAuthorize("@ss.hasPermi('biz:route:remove')")
    @Log(title = "路线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizCustomerRouteService.deleteBizCustomerRouteByIds(ids));
    }
}
