package com.dsk.web.controller.customer;

import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.system.domain.CustomerDecisionChain;
import com.dsk.system.domain.dto.CustomerDecisionChainSearchDto;
import com.dsk.system.service.ICustomerDecisionChainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 客户决策链条
 * @author lcl
 * @create 2023/5/16
 */
@RestController
@RequestMapping("/customer/decision/chain")
public class CustomerDecisionChainController extends BaseController {

    @Autowired
    private ICustomerDecisionChainService baseService;

    /**
     * 获取客户决策链条列表
     */
    @PreAuthorize("@ss.hasPermi('customer:decision:chain:list')")
    @GetMapping("/list")
    public TableDataInfo selectPageList(CustomerDecisionChainSearchDto dto){
        startPage();
        return getDataTable(baseService.selectList(dto));
    }

    /**
     * 添加客户决策链条
     */
    @PreAuthorize("@ss.hasPermi('customer:decision:chain:add')")
    @PostMapping()
    public AjaxResult add(CustomerDecisionChain customerDecisionChain){
        return AjaxResult.success(baseService.insert(customerDecisionChain));
    }

    /**
     * 编辑客户决策链条
     */
    @PreAuthorize("@ss.hasPermi('customer:decision:chain:edit')")
    @PutMapping()
    public AjaxResult edit(CustomerDecisionChain customerDecisionChain){
        return AjaxResult.success(baseService.update(customerDecisionChain));
    }

    /**
     * 删除客户决策链条
     */
    @PreAuthorize("@ss.hasPermi('customer:decision:chain:del')")
    @DeleteMapping("/{id}")
    public AjaxResult del(@PathVariable("id") Long id){
        return AjaxResult.success(baseService.deleteById(id));
    }

}
