package com.bc.exam.modules.gonggao.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bc.exam.core.api.ApiRest;
import com.bc.exam.core.api.controller.BaseController;
import com.bc.exam.core.api.dto.BaseIdsReqDTO;
import com.bc.exam.core.api.dto.PagingReqDTO;
import com.bc.exam.modules.gonggao.entity.TGonggao;
import com.bc.exam.modules.gonggao.service.TGonggaoService;
import io.swagger.annotations.ApiOperation;
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 javax.annotation.Resource;

/**
 * @Description 描述:公告表 前端控制器
 * @Author A贾宇婷034244310
 * @Date 20260615
 */
@RestController
@RequestMapping("/gonggao/gggl")
public class TGonggaoController extends BaseController {


    @Resource
    TGonggaoService tGonggaoService;


    /**
     * 公告分页查找
     * @param reqDTO
     * @return
     */
    @ApiOperation(value = "分页查找")
    @PostMapping("/paging")
    public ApiRest<IPage<TGonggao>> paging(@RequestBody PagingReqDTO<TGonggao> reqDTO) {
        //分页查询并转换
        IPage<TGonggao> page = tGonggaoService.paging(reqDTO);
        return super.success(page);
    }



    /**
     * 公告表添加或修改
     * @param reqDTO
     * @return
     */
    @ApiOperation(value = "公告表添加或修改")
    @PostMapping("/save")
    public ApiRest save(@RequestBody TGonggao reqDTO) {
        reqDTO.setName("系统管理员");
        tGonggaoService.saveOrUpdate(reqDTO);
        return super.success();
    }

    /**
     * 批量删除
     * @param reqDTO
     * @return
     */
    @ApiOperation(value = "批量删除")
    @PostMapping("delete")
    public ApiRest edit(@RequestBody BaseIdsReqDTO reqDTO) {
        //根据ID删除
        tGonggaoService.removeByIds(reqDTO.getIds());
        return super.success();
    }
}

