package com.mcwl.web.controller.resource;

import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.resource.domain.ToActivity;
import com.mcwl.resource.service.ToActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**活动
 * @Author：ChenYan
 * @Project：McWl
 * @Package：com.mcwl.web.controller.resource
 * @Filename：ToActivityController
 * @Description TODO
 * @Date：2025/1/9 17:59
 */
@Api(tags = "活动")
@RestController
@RequestMapping("/ToActivity")
public class ToActivityController extends BaseController {
    @Autowired
    private ToActivityService toActivityService;

    /**
     * 查询活动列表
     */
    @ApiOperation(value = "活动列表")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody ToActivity toActivity)
    {

        List<ToActivity> list = toActivityService.selectToActivityList(toActivity);
        return getDataTable(list);
    }



    @ApiOperation(value = "活动详情")
    @PostMapping("finById")
    public R<ToActivity> finById(@RequestBody ToActivity toActivity)
    {
        return R.ok(toActivityService.getById(toActivity.getId()));
    }


    @ApiOperation(value = "活动添加")
    @PostMapping("add")
    public R<Object> add(@RequestBody ToActivity toActivity)
    {
        toActivityService.save(toActivity);
        return R.ok();
    }


    @ApiOperation(value = "活动修改")
    @PostMapping("update")
    public R<Object> update(@RequestBody ToActivity toActivity)
    {
        toActivityService.updateById(toActivity);
        return R.ok();
    }


    @ApiOperation(value = "活动删除")
    @PostMapping("delete")
    public R<Object> delete(@RequestBody ToActivity toActivity)
    {
        toActivityService.removeById(toActivity);
        return R.ok();
    }


    @ApiOperation(value = "活动批量删除")
    @PostMapping("deleteByIds")
    public R<Object> deleteByIds(@RequestBody List<ToActivity> toActivity)
    {
        toActivityService.removeByIds(toActivity);
        return R.ok();
    }



}
