package com.ruoyi.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.common.page.PageResult;
import com.ruoyi.controller.req.ActivityPageReq;
import com.ruoyi.controller.req.AppealMessagePageReq;
import com.ruoyi.controller.req.LikeReq;
import com.ruoyi.controller.req.SendMessageReq;
import com.ruoyi.controller.resp.*;
import com.ruoyi.frequency.activity.entity.Activity;
import com.ruoyi.frequency.activity.service.ActivityService;
import com.ruoyi.frequency.appeal.service.AppealService;
import com.ruoyi.frequency.appealdetail.service.AppealDetailService;
import com.ruoyi.frequency.like.service.LikeService;
import com.ruoyi.response.ResponseData;
import com.ruoyi.vo.BodyIdReq;
import com.ruoyi.vo.PageBasic;
import com.ruoyi.vo.RyController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 活动
 */
@CrossOrigin
@RestController
@RequestMapping("/api/activity")
@Api(tags = "活动")
public class ApiActivityController extends RyController {

    @Autowired
    private ActivityService activityService;


    @PostMapping("/activityPage")
    @ApiOperation(value = "活动列表", notes = "活动列表")
//    @UserLoginToken
    public ResponseData<PageResult<Page<Activity>>> activityPage(@RequestBody @Valid ActivityPageReq req) {
        return activityService.activityPage(req,getUserVo());
    }

    @PostMapping("/activityDetail")
    @ApiOperation(value = "活动详情", notes = "活动详情")
//    @UserLoginToken
    public ResponseData<Activity> activityDetail(@RequestBody @Valid BodyIdReq req) {
        return activityService.activityDetail(req.getId(),getUserVo());
    }

    @Autowired
    private LikeService likeService;

    @PostMapping("/activityLike")
    @UserLoginToken
    @ApiOperation(value = "活动点赞", notes = "活动点赞")
    public ResponseData activityLike(@RequestBody LikeReq req) {
        return likeService.like(req,getUserVo());
    }
}
