|
@@ -3,16 +3,26 @@ package org.springblade.factory.controller;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
-import org.springblade.factory.dto.AddNoticeDTO;
|
|
|
+import org.springblade.factory.dto.BladeNoticeDTO;
|
|
|
import org.springblade.factory.entity.PcBladeNotice;
|
|
|
+import org.springblade.factory.entity.PcBladeOrder;
|
|
|
import org.springblade.factory.service.PcBladeNoticeService;
|
|
|
+import org.springblade.factory.vo.PcBladeNoticeVO;
|
|
|
+import org.springblade.factory.wrapper.PcBladeNoticeWrapper;
|
|
|
+import org.springblade.factory.wrapper.PcBladeOrderWrapper;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 系统公告主表 前端控制器
|
|
@@ -20,6 +30,7 @@ import java.util.List;
|
|
|
* @author horizon
|
|
|
* @since 2025-08-05
|
|
|
*/
|
|
|
+@AllArgsConstructor
|
|
|
@RestController
|
|
|
@RequestMapping("/api/factory/notice")
|
|
|
public class PcBladeNoticeController {
|
|
@@ -31,49 +42,47 @@ public class PcBladeNoticeController {
|
|
|
* 分页查询
|
|
|
*/
|
|
|
@GetMapping("/page")
|
|
|
- public IPage<PcBladeNotice> page(
|
|
|
- @RequestParam(defaultValue = "1") long current,
|
|
|
- @RequestParam(defaultValue = "10") long size,
|
|
|
- @RequestParam(required = false) Long orgId,
|
|
|
- @RequestParam(required = false) Integer status) {
|
|
|
- QueryWrapper<PcBladeNotice> qw = new QueryWrapper<>();
|
|
|
- qw.eq(orgId != null, "ORG_ID", orgId)
|
|
|
- .eq(status != null, "status", status)
|
|
|
- .orderByDesc("create_time");
|
|
|
- return noticeService.page(new Page<>(current, size), qw);
|
|
|
+ public R<IPage<PcBladeNoticeVO>> page(
|
|
|
+ @ApiIgnore @RequestParam Map<String, Object> noticeParams,
|
|
|
+ Query query,
|
|
|
+ BladeUser bladeUser) {
|
|
|
+ // 1. 构建基础查询条件
|
|
|
+ QueryWrapper<PcBladeNotice> queryWrapper = Condition.getQueryWrapper(noticeParams, PcBladeNotice.class);
|
|
|
+ // 2. 执行分页查询
|
|
|
+ IPage<PcBladeNotice> pages = noticeService.page(Condition.getPage(query), queryWrapper);
|
|
|
+ // 3. 转换VO并返回
|
|
|
+ return R.data(PcBladeNoticeWrapper.build().pageVO(pages));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 单条查询
|
|
|
*/
|
|
|
- @GetMapping("/detail/{id}")
|
|
|
- public R<PcBladeNotice> get(@PathVariable Serializable id) {
|
|
|
- return R.data(noticeService.getById(id));
|
|
|
+ @GetMapping("/detail")
|
|
|
+ public R<PcBladeNoticeVO> get(@RequestParam("id") Long id) {
|
|
|
+ return R.data(PcBladeNoticeWrapper.build().entityVO(noticeService.selectPcBladeNoticeById(id)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增
|
|
|
*/
|
|
|
@PostMapping("/add")
|
|
|
- public R save(@RequestBody AddNoticeDTO dto) {
|
|
|
- PcBladeNotice notice = new PcBladeNotice();
|
|
|
- BeanUtils.copyProperties(dto, notice);
|
|
|
- return R.status(noticeService.save(notice));
|
|
|
+ public R save(@RequestBody BladeNoticeDTO dto) {
|
|
|
+ return R.status(noticeService.insertNotice(dto));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改
|
|
|
*/
|
|
|
- @PutMapping
|
|
|
- public boolean update(@RequestBody PcBladeNotice entity) {
|
|
|
- return noticeService.updateById(entity);
|
|
|
+ @PostMapping("/update")
|
|
|
+ public R update(@RequestBody BladeNoticeDTO dto) {
|
|
|
+ return R.status(noticeService.updateNotice(dto));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量删除(逻辑删除)
|
|
|
*/
|
|
|
- @DeleteMapping
|
|
|
- public boolean delete(@RequestParam("ids") List<Long> ids) {
|
|
|
- return noticeService.removeByIds(ids);
|
|
|
- }
|
|
|
+// @DeleteMapping
|
|
|
+// public boolean delete(@RequestParam("ids") List<Long> ids) {
|
|
|
+// return noticeService.removeByIds(ids);
|
|
|
+// }
|
|
|
}
|