package com.kxs.system.biz.controller.kxsapp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.common.security.annotation.Inner;
import com.kxs.system.api.model.KxsActivityMarket;
import com.kxs.system.api.vo.kxsapp.activityMarket.ActivityMarketVO;
import com.kxs.system.api.vo.kxsapp.activityMarket.ActivityMarketListVO;
import com.kxs.system.biz.service.KxsActivityMarketService;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页(ActivityMarket)控制层
 *
 * @author 系统
 * @since 2023-12-15 12:16:33
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("activityMarket")
public class ActivityMarketController {

    /**
     * 服务对象
     */
    private final KxsActivityMarketService kxsActivityMarketService;



    /**
     * 市场活动-市场活动列表
     *
     * @param page 分页对象
     * @param menuId 类目ID
     * @return 市场活动-市场活动列表
     */
    @GetMapping("/list")
    @Inner(value = false)
    public R list(@ParameterObject Page<ActivityMarketListVO> page, @RequestParam("menuId") Integer menuId) {

        return R.ok(kxsActivityMarketService.getByPage(page, menuId));
    }


    /**
     * 市场活动-市场活动详情
     *
     * @param id 主键ID
     * @return 市场活动-市场活动详情
     */
    @GetMapping("/getById")
    @Inner(value = false)
    public R getById(@RequestParam("id") Integer id) {

        KxsActivityMarket byId = kxsActivityMarketService.getById(id);
        ActivityMarketVO activityMarketGetByIdVO = new ActivityMarketVO();
        BeanUtils.copyProperties(byId, activityMarketGetByIdVO);
        return R.ok(activityMarketGetByIdVO);
    }

}

