package com.ylx.discover.moment.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ylx.common.core.domain.R;
import com.ylx.discover.moment.domain.dto.MomentPageDTO;
import com.ylx.discover.moment.domain.vo.MomentPageVO;
import com.ylx.moment.domain.vo.MomentDetailVO;
import com.ylx.moment.service.ITechnicianMomentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/discover/moment")
@Api(tags = {"用户端发现商户动态"})
@Slf4j
public class CustomerMomentController {

    @Resource
    private ITechnicianMomentService momentService;

    @PostMapping("/page")
    @ApiOperation("获取发现页动态列表")
    public R<Page<MomentPageVO>> getMomentPage(@Validated @RequestBody MomentPageDTO dto) {
        Page<MomentPageVO> result = this.momentService.getMomentPage(dto);
        return R.ok(result);
    }

    @ApiOperation("根据动态ID查询动态详情")
    @GetMapping("/detail/{id}")
    public R<MomentDetailVO> getMomentDetailById(@PathVariable("id") Long id) {
        MomentDetailVO momentDetail = this.momentService.getMomentDetail(id, null, null);
        return R.ok(momentDetail);
    }

}
