package com.fjhx.mail.controller.my;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mail.entity.my.dto.MyContactPersonDto;
import com.fjhx.mail.entity.my.dto.MyContactPersonSelectDto;
import com.fjhx.mail.entity.my.vo.MyContactPersonVo;
import com.fjhx.mail.service.my.MyContactPersonService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 联系人 前端控制器
 * </p>
 *
 * @author
 * @since 2023-06-09
 */
@RestController
@RequestMapping("/myContactPerson")
public class MyContactPersonController {

    @Autowired
    private MyContactPersonService myContactPersonService;

    /**
     * 联系人分页
     */
    @PostMapping("/page")
    public Page<MyContactPersonVo> page(@RequestBody MyContactPersonSelectDto dto) {
        return myContactPersonService.getPage(dto);
    }

    /**
     * 联系人明细
     */
    @PostMapping("/detail")
    public MyContactPersonVo detail(@RequestBody BaseSelectDto dto) {
        return myContactPersonService.detail(dto.getId());
    }

    /**
     * 联系人新增
     */
    @PostMapping("/add")
    public void add(@Validated @RequestBody MyContactPersonDto myContactPersonDto) {
        myContactPersonService.add(myContactPersonDto);
    }

    /**
     * 联系人编辑
     */
    @PostMapping("/edit")
    public void edit(@Validated @RequestBody MyContactPersonDto myContactPersonDto) {
        myContactPersonService.edit(myContactPersonDto);
    }

    /**
     * 联系人删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        myContactPersonService.delete(dto.getId());
    }

}
