package cn.reghao.tnb.content.app.chat.controller;

import cn.reghao.jutil.jdk.web.result.Result;
import cn.reghao.tnb.common.web.WebResult;
import cn.reghao.tnb.content.app.chat.model.dto.HongbaoDto;
import cn.reghao.tnb.content.app.chat.service.HongbaoService;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author reghao
 * @date 2024-12-03 14:28:53
 */
@RestController
@RequestMapping("/api/chat/hongbao")
public class HongbaoController {
    private final HongbaoService hongbaoService;

    public HongbaoController(HongbaoService hongbaoService) {
        this.hongbaoService = hongbaoService;
    }

    @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
    public String addHongbao(@RequestBody @Validated HongbaoDto hongbaoDto) {
        Result result = hongbaoService.addHongbao(hongbaoDto);
        return WebResult.result(result);
    }

    @PostMapping(value = "/get/{hongbaoId}", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getHongbao(@PathVariable("hongbaoId") Long hongbaoId) {
        Result result = hongbaoService.getHongbao(hongbaoId);
        return WebResult.result(result);
    }
}
