package com.fjhx.oa.controller.external;

import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.oa.entity.external.vo.ExternalAddressBookVo;
import com.fjhx.oa.entity.external.dto.ExternalAddressBookSelectDto;
import com.fjhx.oa.entity.external.dto.ExternalAddressBookDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.oa.service.external.ExternalAddressBookService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * <p>
 * 外部通讯录 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-04-06
 */
@RestController
@RequestMapping("/externalAddressBook")
public class ExternalAddressBookController {

    @Autowired
    private ExternalAddressBookService externalAddressBookService;

    /**
     * 外部通讯录分页
     */
    @PostMapping("/page")
    public Page<ExternalAddressBookVo> page(@RequestBody ExternalAddressBookSelectDto dto) {
        return externalAddressBookService.getPage(dto);
    }

    /**
     * 外部通讯录明细
     */
    @PostMapping("/detail")
    public List<ExternalAddressBookVo> detail(@RequestBody BaseSelectDto dto) {
        return externalAddressBookService.detail(dto.getId());
    }

    /**
     * 外部通讯录新增
     */
    @PostMapping("/add")
    public void add(@RequestBody ExternalAddressBookDto externalAddressBookDto) {
        externalAddressBookService.add(externalAddressBookDto);
    }

    /**
     * 外部通讯录编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ExternalAddressBookDto externalAddressBookDto) {
        externalAddressBookService.edit(externalAddressBookDto);
    }

    /**
     * 外部通讯录删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        externalAddressBookService.delete(dto.getId());
    }

}
