package com.dsk.web.controller.customer;

import com.dsk.common.annotation.RepeatSubmit;
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.customer.CustomerDecisionChain;
import com.dsk.system.domain.customer.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()
    @RepeatSubmit()
    public AjaxResult add(@RequestBody CustomerDecisionChain customerDecisionChain){
        return AjaxResult.success(baseService.insert(customerDecisionChain));
    }

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

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

}
