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.BizCustomerRouteShop;
import com.cpxt.biz.service.IBizCustomerRouteShopService;
import com.cpxt.common.utils.poi.ExcelUtil;
import com.cpxt.common.core.page.TableDataInfo;

/**
 * 路线店铺关联Controller
 *
 * @author YIN
 * @date 2024-12-16
 */
@RestController
@RequestMapping("/biz/routeShop")
public class BizCustomerRouteShopController extends BaseController
{
    @Autowired
    private IBizCustomerRouteShopService bizCustomerRouteShopService;

    /**
     * 查询路线店铺关联列表
     */
    @PreAuthorize("@ss.hasPermi('biz:routeShop:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizCustomerRouteShop bizCustomerRouteShop)
    {
        startPage();
        List<BizCustomerRouteShop> list = bizCustomerRouteShopService.selectBizCustomerRouteShopList(bizCustomerRouteShop);
        return getDataTable(list);
    }

    /**
     * 导出路线店铺关联列表
     */
    @PreAuthorize("@ss.hasPermi('biz:routeShop:export')")
    @Log(title = "路线店铺关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizCustomerRouteShop bizCustomerRouteShop)
    {
        List<BizCustomerRouteShop> list = bizCustomerRouteShopService.selectBizCustomerRouteShopList(bizCustomerRouteShop);
        ExcelUtil<BizCustomerRouteShop> util = new ExcelUtil<BizCustomerRouteShop>(BizCustomerRouteShop.class);
        util.exportExcel(response, list, "路线店铺关联数据");
    }

    /**
     * 获取路线店铺关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:routeShop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizCustomerRouteShopService.selectBizCustomerRouteShopById(id));
    }

    /**
     * 新增路线店铺关联
     */
    @PreAuthorize("@ss.hasPermi('biz:routeShop:add')")
    @Log(title = "路线店铺关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizCustomerRouteShop bizCustomerRouteShop)
    {
        return toAjax(bizCustomerRouteShopService.insertBizCustomerRouteShop(bizCustomerRouteShop));
    }

    /**
     * 修改路线店铺关联
     */
    @PreAuthorize("@ss.hasPermi('biz:routeShop:edit')")
    @Log(title = "路线店铺关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizCustomerRouteShop bizCustomerRouteShop)
    {
        return toAjax(bizCustomerRouteShopService.updateBizCustomerRouteShop(bizCustomerRouteShop));
    }

    /**
     * 删除路线店铺关联
     */
    @PreAuthorize("@ss.hasPermi('biz:routeShop:remove')")
    @Log(title = "路线店铺关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizCustomerRouteShopService.deleteBizCustomerRouteShopByIds(ids));
    }
}
