package com.kym.admin.controller;

import com.kym.common.R;
import com.kym.common.annotation.SysLog;
import com.kym.entity.queryParams.ActivityQueryParam;
import com.kym.entity.vo.ActivityVo;
import com.kym.service.ActivityService;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author skyline
 * @since 2023-10-18
 */
@RestController
@RequestMapping("/activity")
public class ActivityController {

    private final ActivityService activityService;

    public ActivityController(ActivityService activityService) {
        this.activityService = activityService;
    }


    @SysLog(value = "新增活动", ignoreParams = true)
    @PostMapping("/add")
    R<?> createActivity(@RequestBody ActivityVo activityVo) {
        activityService.createActivity(activityVo);
        return R.success();
    }

    @SysLog("活动列表")
    @GetMapping
    R<?> listActivity(@ModelAttribute ActivityQueryParam params) {
        return R.success(activityService.listActivity(params));
    }

    @SysLog("活动详情")
    @GetMapping("/{activityId}")
    R<?> activityDetail(@PathVariable("activityId") String activityId) {
        return R.success(activityService.activityDetail(activityId));
    }

    @SysLog("终止活动")
    @GetMapping("/terminateActivity/{activityId}")
    R<?> terminateActivity(@PathVariable("activityId") String activityId) {
        activityService.terminateActivity(activityId);
        return R.success();
    }

}
