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.ContactInfo;
import com.dsk.system.domain.customer.dto.ContactInfoSearchDto;
import com.dsk.system.service.IContactInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 联系人(ContactInfo)表控制层
 *
 * @author makejava
 * @since 2023-07-25 17:18:00
 */
@RestController
@RequestMapping("/contact/info")
public class ContactInfoController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private IContactInfoService baseService;

    /**
     * 联系人列表
     */
//    @PreAuthorize("@ss.hasPermi('contact:info:list')")
    @GetMapping("/list")
    public TableDataInfo selectPageList(ContactInfoSearchDto dto){
        startPage();
        return getDataTable(baseService.selectList(dto));
    }

    /**
     * 联系人详情
     */
//    @PreAuthorize("@ss.hasPermi('contact:info')")
    @GetMapping("/{id}")
    public AjaxResult info(@PathVariable Long id){
        return AjaxResult.success(baseService.selectById(id));
    }

    /**
     * 添加用户联系人
     */
//    @PreAuthorize("@ss.hasPermi('contact:info:add')")
    @PostMapping()
    @RepeatSubmit()
    public AjaxResult add(@RequestBody ContactInfo baen){
        return AjaxResult.success(baseService.insert(baen));
    }

    /**
     * 编辑用户联系人
     */
//    @PreAuthorize("@ss.hasPermi('contact:info:edit')")
    @PutMapping()
    @RepeatSubmit()
    public AjaxResult edit(@RequestBody ContactInfo baen){
        return AjaxResult.success(baseService.update(baen));
    }

    /**
     * 删除用户联系人
     */
//    @PreAuthorize("@ss.hasPermi('contact:info:del')")
    @DeleteMapping("/{id}")
    @RepeatSubmit()
    public AjaxResult del(@PathVariable("id") Long id){
        return AjaxResult.success(baseService.deleteById(id));
    }

}
