package com.fjhx.mail.controller.my;

import com.alibaba.fastjson.JSONObject;
import com.fjhx.mail.entity.my.dto.MyFolderDto;
import com.fjhx.mail.entity.my.dto.MyFolderSelectDto;
import com.fjhx.mail.entity.my.vo.MyFolderVo;
import com.fjhx.mail.service.my.MyFolderService;
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;

import java.util.List;


/**
 * <p>
 * 我的文件夹 前端控制器
 * </p>
 *
 * @author
 * @since 2023-05-29
 */
@RestController
@RequestMapping("/myFolder")
public class MyFolderController {

    @Autowired
    private MyFolderService myFolderService;

    /**
     * 我的文件树形
     */
    @PostMapping("/tree")
    public List<JSONObject> tree(@Validated @RequestBody MyFolderSelectDto dto) {
        return myFolderService.tree(dto);
    }

    /**
     * 我的文件夹明细
     */
    @PostMapping("/detail")
    public MyFolderVo detail(@RequestBody BaseSelectDto dto) {
        return myFolderService.detail(dto.getId());
    }

    /**
     * 我的文件夹新增
     */
    @PostMapping("/add")
    public void add(@Validated @RequestBody MyFolderDto myFolderDto) {
        myFolderService.add(myFolderDto);
    }

    /**
     * 我的文件夹编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody MyFolderDto myFolderDto) {
        myFolderService.edit(myFolderDto);
    }

    /**
     * 我的文件夹删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        myFolderService.delete(dto.getId());
    }

}
