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.common.utils.PageUtils;
import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 客户相关
 *
 * @author lcl
 * @create 2023/5/16
 */
@RestController
@RequestMapping("/customer")
public class CustomerController extends BaseController {

    @Autowired
    private ICustomerService baseService;

    /**
     * 查询客户列表
     */
    @PreAuthorize("@ss.hasPermi('customer:list')")
    @GetMapping("/list")
    public TableDataInfo selectPageList(CustomerSearchDto dto){
        startPage();
        return getDataTable(baseService.selectList(dto));
    }

    /**
     * 添加客户
     */
    @PreAuthorize("@ss.hasPermi('customer:add')")
    @PostMapping()
    @RepeatSubmit
    public AjaxResult add(Customer customer){
        return AjaxResult.success(baseService.add(customer));
    }

    /**
     * 编辑客户
     */
    @PreAuthorize("@ss.hasPermi('customer:edit')")
    @PostMapping()
    @RepeatSubmit
    public AjaxResult edit(Customer customer){
        return AjaxResult.success(baseService.edit(customer));
    }

}
