package com.fjhx.oa.controller.internal;

import com.fjhx.oa.entity.internal.po.InternalAddressBook;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;
import com.fjhx.oa.entity.internal.dto.InternalAddressBookDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.oa.service.internal.InternalAddressBookService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * <p>
 * 内部通讯录 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-04-04
 */
@RestController
@RequestMapping("/internalAddressBook")
public class InternalAddressBookController extends BaseController {

    @Autowired
    private InternalAddressBookService internalAddressBookService;

    /**
     * 内部通讯录分页
     */
    @GetMapping("/page")
    public TableDataInfo page(SysUser sysUser) {
        startPage();
        return getDataTable(internalAddressBookService.getPage(sysUser));
    }

    /**
     * 内部通讯录明细
     */
    @PostMapping("/detail")
    public List<InternalAddressBook> detail(@RequestBody InternalAddressBookDto dto) {
        return internalAddressBookService.detail(dto.getUserId());
    }

    /**
     * 内部通讯录新增
     */
    @PostMapping("/add")
    public void add(@RequestBody InternalAddressBookDto internalAddressBookDto) {
        internalAddressBookService.add(internalAddressBookDto);
    }

    /**
     * 内部通讯录编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody InternalAddressBookDto internalAddressBookDto) {
        internalAddressBookService.edit(internalAddressBookDto);
    }

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

}
