package com.njzscloud.supervisory.sys.bulletin.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.sys.bulletin.pojo.BulletinEntity;
import com.njzscloud.supervisory.sys.bulletin.service.BulletinService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公告表
 */
@Slf4j
@RestController
@RequestMapping("/bulletin")
@RequiredArgsConstructor
public class BulletinController {

    private final BulletinService bulletinService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody BulletinEntity bulletinEntity) {
        bulletinService.add(bulletinEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody BulletinEntity bulletinEntity) {
        bulletinService.modify(bulletinEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        bulletinService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<BulletinEntity> detail(@RequestParam Long id) {
        return R.success(bulletinService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<BulletinEntity>> paging(PageParam pageParam, BulletinEntity bulletinEntity) {
        return R.success(bulletinService.paging(pageParam, bulletinEntity));
    }

}
