From 529a743a02a595ebbe2677bd71a2de0ddb963152 Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Wed, 25 Sep 2024 09:49:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bweb/controller/CmsController.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bweb/src/main/java/com/bweb/controller/CmsController.java b/bweb/src/main/java/com/bweb/controller/CmsController.java index 7e0f20e..832f708 100644 --- a/bweb/src/main/java/com/bweb/controller/CmsController.java +++ b/bweb/src/main/java/com/bweb/controller/CmsController.java @@ -135,6 +135,32 @@ public class CmsController { } } + @RequestMapping(value="/delete",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "删除") + public ResponseData delete(@RequestBody CmsContent body) { + try { + if (body == null || body.getId() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + // 查询内容 + CmsContent cmsContent = cmsContentService.getDetail(body.getId()); + if (cmsContent == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到数据"); + } + if (!CmsStatusEnum.status1.getStatus().equals(cmsContent.getStatus())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法删除,状态错误"); + } + cmsContent.setStatus(CmsStatusEnum.status0.getStatus()); + cmsContentService.editData(cmsContent); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/getDetail",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询详情")