Browse Source

feat: [消息通知] 加入已读功能

master
memorylkf 2 months ago
parent
commit
f55eab68f5
1 changed files with 34 additions and 3 deletions
  1. +34
    -3
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/HomeController.java

+ 34
- 3
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/HomeController.java View File

@ -1,7 +1,9 @@
package com.hxhq.business.controller; package com.hxhq.business.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxhq.business.domain.Notice; import com.hxhq.business.domain.Notice;
import com.hxhq.business.dto.study.StudyListDto; import com.hxhq.business.dto.study.StudyListDto;
import com.hxhq.business.enums.NormalEnum;
import com.hxhq.business.enums.study.StudyTypeEnum; import com.hxhq.business.enums.study.StudyTypeEnum;
import com.hxhq.business.form.study.StudySearchForm; import com.hxhq.business.form.study.StudySearchForm;
import com.hxhq.business.service.INoticeService; import com.hxhq.business.service.INoticeService;
@ -10,10 +12,13 @@ import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult; import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo; import com.hxhq.common.core.web.page.TableDataInfo;
import com.hxhq.common.security.annotation.RequiresPermissions; import com.hxhq.common.security.annotation.RequiresPermissions;
import com.hxhq.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
@ -35,17 +40,15 @@ public class HomeController extends BaseController
* 查询首页数量 * 查询首页数量
*/ */
@GetMapping("/count") @GetMapping("/count")
@RequiresPermissions("business:user:work")
public AjaxResult list() public AjaxResult list()
{ {
return AjaxResult.success(studyService.queryHomeCount()); return AjaxResult.success(studyService.queryHomeCount());
} }
/** /**
* 查询试验列表
* 查询通知列表
*/ */
@GetMapping("/noticeList") @GetMapping("/noticeList")
@RequiresPermissions("business:user:work")
public TableDataInfo noticeService() public TableDataInfo noticeService()
{ {
startPage(); startPage();
@ -53,4 +56,32 @@ public class HomeController extends BaseController
TableDataInfo table = getDataTable(list); TableDataInfo table = getDataTable(list);
return table; return table;
} }
/**
* 通知已读
*/
@PostMapping("/noticeRead")
public AjaxResult noticeRead(@RequestBody Notice notice)
{
Notice info = noticeService.getById(notice.getId());
if(info!=null && info.getStatus().equals(NormalEnum.no.getValue())){
info.setStatus(NormalEnum.yes.getValue());
noticeService.updateById(info);
}
return AjaxResult.success();
}
/**
* 查询未读通知数量
*/
@GetMapping("/noticeCount")
public AjaxResult noticeCount()
{
QueryWrapper<Notice> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", SecurityUtils.getUserId());
queryWrapper.eq("status", NormalEnum.no.getValue());
Map<String,Object> count = new HashMap<>(1);
count.put("noticeCount",noticeService.count(queryWrapper));
return AjaxResult.success(count);
}
} }

Loading…
Cancel
Save