package com.fjhx.mail.controller.enterprise;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.mail.entity.enterprise.dto.EnterpriseMailboxDto;
import com.fjhx.mail.entity.enterprise.dto.EnterpriseMailboxSelectDto;
import com.fjhx.mail.entity.enterprise.vo.EnterpriseMailboxVo;
import com.fjhx.mail.service.enterprise.EnterpriseMailboxService;
import com.ruoyi.common.annotation.NonInterception;
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-04-06
 */
@DS(SourceConstant.MAIL)
@RestController
@RequestMapping("/enterpriseMailbox")
public class EnterpriseMailboxController {

    @Autowired
    private EnterpriseMailboxService enterpriseMailboxService;

    /**
     * 企业邮箱分页
     */
    @PostMapping("/page")
    public Page<EnterpriseMailboxVo> page(@RequestBody EnterpriseMailboxSelectDto dto) {
        return enterpriseMailboxService.getPage(dto);
    }

    /**
     * 企业邮箱明细
     */
    @PostMapping("/detail")
    public EnterpriseMailboxVo detail(@RequestBody BaseSelectDto dto) {
        return enterpriseMailboxService.detail(dto.getId());
    }

    /**
     * 企业邮箱新增
     */
    @NonInterception
    @PostMapping("/add")
    public JSONObject add(@Validated @RequestBody EnterpriseMailboxDto enterpriseMailboxDto) {
        return enterpriseMailboxService.add(enterpriseMailboxDto);
    }

    /**
     * 企业邮箱编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody EnterpriseMailboxDto enterpriseMailboxDto) {
        enterpriseMailboxService.edit(enterpriseMailboxDto);
    }

    /**
     * 企业邮箱删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        enterpriseMailboxService.delete(dto.getId());
    }

}
