package com.czg.controller.user;

import com.czg.account.dto.AcUserMsgDTO;
import com.czg.account.service.AcUserMsgService;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户端/用户消息
 *
 * @author yjjie
 * @date 2025/12/9 19:17
 */
@RestController
@RequestMapping("/user/msg")
public class UserMsgController {

    @Resource
    private AcUserMsgService acUserMsgService;

    /**
     * 获取未读消息数量
     */
    @GetMapping("/unReadCount")
    public CzgResult<Long> getUnReadCount() {
        return CzgResult.success(acUserMsgService.getUnReadCount());
    }

    /**
     * 获取用户消息列表
     */
    @GetMapping("/page")
    public CzgResult<Page<AcUserMsgDTO>> getUserMsgPage() {
        return CzgResult.success(acUserMsgService.getUserMsgPage());
    }

    /**
     * 根据订单 Id 获取消息列表
     */
    @GetMapping("/order/{orderId}")
    public CzgResult<List<AcUserMsgDTO>> getMsgListByOrderId(@PathVariable Long orderId) {
        return CzgResult.success(acUserMsgService.getMsgListByOrderId(orderId));
    }
}
