package com.dsk.biz.controller;

import com.dsk.biz.domain.ContactInfo;
import com.dsk.biz.domain.bo.ContactInfoSearchDto;
import com.dsk.biz.domain.vo.ContactInfoListVo;
import com.dsk.biz.service.IContactInfoService;
import com.dsk.common.annotation.RepeatSubmit;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.page.TableDataInfo;
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<ContactInfoListVo> selectPageList(ContactInfoSearchDto dto, PageQuery pageQuery){
        return baseService.selectList(dto,pageQuery);
    }

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

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

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

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

}
