package com.dsk.web.controller.system;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.system.domain.SysPush;
import com.dsk.system.service.ISysPushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统推送(SysPush)表控制层
 *
 * @author lcl
 * @since 2023-12-14 10:09:24
 */
@RestController
@RequestMapping("sysPush")
public class SysPushController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private ISysPushService baseService;

    /**
     * 推送分页列表
     */
    @GetMapping("/pageList")
    public TableDataInfo<SysPush> pageList(SysPush bean, PageQuery query) {
        return baseService.pageList(bean, query);
    }

    /**
     * 添加推送人
     */
    @PostMapping
    public R<Void> add(@RequestBody SysPush bean) {
        return toAjax(baseService.save(bean));
    }

    /**
     * 修改推送状态
     */
    @PutMapping("/updateStatus")
    public R<Void> updateStatus(@RequestBody SysPush bean) {
        return toAjax(baseService.update(Wrappers.<SysPush>lambdaUpdate()
                .set(SysPush::getStatus, bean.getStatus()).eq(SysPush::getId, bean.getId())));
    }

    /**
     * 删除推送人
     */
    @DeleteMapping("/{id}")
    public R<Void> del(@PathVariable Long id) {
        return toAjax(baseService.removeById(id));
    }

}

