|
@@ -0,0 +1,94 @@
|
|
|
|
|
+package com.chuanghai.ihotel.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.chuanghai.ihotel.anno.AdminLoginCheck;
|
|
|
|
|
+import com.chuanghai.ihotel.common.exception.BizCodeEnume;
|
|
|
|
|
+import com.chuanghai.ihotel.common.exception.RRException;
|
|
|
|
|
+import com.chuanghai.ihotel.common.utils.CommonResult;
|
|
|
|
|
+import com.chuanghai.ihotel.common.utils.PageParam;
|
|
|
|
|
+import com.chuanghai.ihotel.common.utils.PageUtils;
|
|
|
|
|
+import com.chuanghai.ihotel.entity.SystemNoticeEntity;
|
|
|
|
|
+import com.chuanghai.ihotel.service.SystemNoticeService;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 系统通知
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author codingliang
|
|
|
|
|
+ * @email codingliang@gmail.com
|
|
|
|
|
+ * @date 2022-08-11 17:15:07
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("ihotel/systemnotice")
|
|
|
|
|
+public class SystemNoticeController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SystemNoticeService systemNoticeService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 通知列表
|
|
|
|
|
+ * @param adminToken 管理员token
|
|
|
|
|
+ * @param readFlag 已读标识 0未读、1已读
|
|
|
|
|
+ * @param pageParam 分页参数
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @AdminLoginCheck
|
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
|
+ public CommonResult<PageUtils<SystemNoticeEntity>> list(@RequestHeader("admin_token")String adminToken,
|
|
|
|
|
+ String readFlag,
|
|
|
|
|
+ PageParam pageParam){
|
|
|
|
|
+ if (StringUtils.hasText(readFlag)) {
|
|
|
|
|
+ if (!("0".equals(readFlag) || "1".equals(readFlag))) {
|
|
|
|
|
+ throw new RRException(BizCodeEnume.PARAMETER_ERROR, "readFlag只能为0或1");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ PageUtils page = systemNoticeService.queryPage(readFlag, pageParam);
|
|
|
|
|
+
|
|
|
|
|
+ return CommonResult.ok().setResult(page);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 标记为已读
|
|
|
|
|
+ * @param adminToken 管理员token
|
|
|
|
|
+ * @param ids 消息id集合
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @AdminLoginCheck
|
|
|
|
|
+ @PutMapping("/read")
|
|
|
|
|
+ public CommonResult<String> read(@RequestHeader("admin_token")String adminToken,
|
|
|
|
|
+ @RequestBody Long[] ids) {
|
|
|
|
|
+ systemNoticeService.read(ids);
|
|
|
|
|
+
|
|
|
|
|
+ return CommonResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除通知
|
|
|
|
|
+ * @param adminToken 管理员token
|
|
|
|
|
+ * @param ids 消息id集合
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @AdminLoginCheck
|
|
|
|
|
+ @DeleteMapping("/delete")
|
|
|
|
|
+ public CommonResult<String> delete(@RequestHeader("admin_token")String adminToken,
|
|
|
|
|
+ @RequestBody Long[] ids){
|
|
|
|
|
+ boolean flag = systemNoticeService.removeByIds(Arrays.asList(ids));
|
|
|
|
|
+
|
|
|
|
|
+ if (flag) {
|
|
|
|
|
+ return CommonResult.ok();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return CommonResult.fail();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|