package com.fjhx.mail.controller.my;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mail.entity.my.dto.MyTagDto;
import com.fjhx.mail.entity.my.dto.MyTagSelectDto;
import com.fjhx.mail.entity.my.po.MyTag;
import com.fjhx.mail.entity.my.vo.MyTagVo;
import com.fjhx.mail.service.my.MyTagService;
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("/myTag")
public class MyTagController {

    @Autowired
    private MyTagService myTagService;

    /**
     * 我的标签分页
     */
    @PostMapping("/page")
    public Page<MyTagVo> page(@RequestBody MyTagSelectDto dto) {
        return myTagService.getPage(dto);
    }

    /**
     * 我的标签明细
     */
    @PostMapping("/detail")
    public MyTagVo detail(@RequestBody BaseSelectDto dto) {
        return myTagService.detail(dto.getId());
    }

    /**
     * 我的标签新增
     */
    @PostMapping("/add")
    public void add(@Validated @RequestBody MyTagDto myTagDto) {
        myTagService.add(myTagDto);
    }

    /**
     * 我的标签编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody MyTagDto myTagDto) {
        myTagService.edit(myTagDto);
    }

    /**
     * 我的标签删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        myTagService.delete(dto.getId());
    }

    /**
     * 获取邮件标签
     */
    @PostMapping("/getListByMessageId")
    public List<MyTag> getListByMessageId(@RequestBody BaseSelectDto dto) {
        return myTagService.getListByMessageId(dto.getId());
    }

}
