package cn.qinys.platform.admin.controller;

import cn.qinys.platform.admin.req.WishingTreeCreateReq;
import cn.qinys.platform.admin.req.WishingTreePageReq;
import cn.qinys.platform.admin.resp.WishingTreePageResp;
import cn.qinys.platform.admin.service.WishTreeService;
import cn.qinys.platform.base.response.Result;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * @author lie tan
 * @description
 * @date 2026-05-23 12:05
 **/

@RestController
@RequestMapping("/admin/tree")
public class WishTreeController {

    @Resource
    private WishTreeService wishTreeService;


    @GetMapping("/page")
    public Result<Page<WishingTreePageResp>> getWishTreePage(WishingTreePageReq req) {
        Page<WishingTreePageResp> wishTreePage = wishTreeService.getWishTreePage(req);
        return new Result<>(wishTreePage);
    }

    @PostMapping("/create")
    public Result<Integer> createWishTree(@RequestBody @Valid WishingTreeCreateReq req) {
        Integer id = wishTreeService.createWishTree(req);
        return new Result<>("created", id);
    }

}
