package com.fjhx.mail.controller.personal;

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.personal.dto.PersonalMailboxDto;
import com.fjhx.mail.entity.personal.dto.PersonalMailboxSelectDto;
import com.fjhx.mail.entity.personal.vo.PersonalMailboxVo;
import com.fjhx.mail.service.personal.PersonalMailboxService;
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("/personalMailbox")
public class PersonalMailboxController {

    @Autowired
    private PersonalMailboxService personalMailboxService;

    /**
     * 个人邮箱分页
     */
    @PostMapping("/page")
    public Page<PersonalMailboxVo> page(@RequestBody PersonalMailboxSelectDto dto) {
        return personalMailboxService.getPage(dto);
    }

    /**
     * 个人邮箱明细
     */
    @PostMapping("/detail")
    public PersonalMailboxVo detail(@RequestBody BaseSelectDto dto) {
        return personalMailboxService.detail(dto.getId());
    }

    /**
     * 个人邮箱新增
     */
    @NonInterception
    @PostMapping("/add")
    public JSONObject add(@Validated @RequestBody PersonalMailboxDto personalMailboxDto) {
        return personalMailboxService.add(personalMailboxDto);
    }

    /**
     * 个人邮箱编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody PersonalMailboxDto personalMailboxDto) {
        personalMailboxService.edit(personalMailboxDto);
    }

    /**
     * 个人邮箱删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        personalMailboxService.delete(dto.getId());
    }

}
