mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	fix(system): 修复查询未读公告和消息数据错误
This commit is contained in:
		| @@ -17,8 +17,11 @@ | ||||
| package top.continew.admin.system.controller; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.enums.ParameterIn; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import top.continew.admin.common.controller.BaseController; | ||||
| import top.continew.admin.system.enums.NoticeMethodEnum; | ||||
| import top.continew.admin.system.enums.NoticeScopeEnum; | ||||
| @@ -31,6 +34,7 @@ import top.continew.starter.core.validation.ValidationUtils; | ||||
| import top.continew.starter.extension.crud.annotation.CrudApi; | ||||
| import top.continew.starter.extension.crud.annotation.CrudRequestMapping; | ||||
| import top.continew.starter.extension.crud.enums.Api; | ||||
| import top.continew.starter.extension.crud.validation.CrudValidationGroup; | ||||
|  | ||||
| import java.lang.reflect.Method; | ||||
| import java.util.Arrays; | ||||
| @@ -69,4 +73,13 @@ public class NoticeController extends BaseController<NoticeService, NoticeResp, | ||||
|                 .contains(method), "通知方式 [{}] 不正确", method)); | ||||
|         } | ||||
|     } | ||||
|     @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH) | ||||
|     @ResponseBody | ||||
|     @PutMapping({"/{id}"}) | ||||
|     public void update(@Validated({CrudValidationGroup.Update.class}) @RequestBody NoticeReq req, | ||||
|                        @PathVariable("id") Long id) { | ||||
|         //更新公告并删除阅读记录 | ||||
|         this.baseService.update(req, id); | ||||
|         this.baseService.deleteReadLog(List.of(id)); | ||||
|     } | ||||
| } | ||||
| @@ -66,4 +66,9 @@ public interface NoticeService extends BaseService<NoticeResp, NoticeDetailResp, | ||||
|      * @return 仪表盘公告列表 | ||||
|      */ | ||||
|     List<DashboardNoticeResp> listDashboard(); | ||||
|     /** | ||||
|      * 删除阅读记录 | ||||
|      * | ||||
|      */ | ||||
|     void deleteReadLog(List<Long> ids); | ||||
| } | ||||
| @@ -182,4 +182,8 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, NoticeDO, N | ||||
|         Long userId = UserContextHolder.getUserId(); | ||||
|         return baseMapper.selectDashboardList(userId); | ||||
|     } | ||||
|     @Override | ||||
|     public void deleteReadLog(List<Long> ids) { | ||||
|         noticeLogService.deleteByNoticeIds(ids); | ||||
|     } | ||||
| } | ||||
| @@ -53,7 +53,7 @@ | ||||
|         SELECT | ||||
|             t1.* | ||||
|         FROM sys_message AS t1 | ||||
|             LEFT JOIN sys_message_log AS t2 ON t2.message_id = t1.id | ||||
|             LEFT JOIN sys_message_log AS t2 ON t2.message_id = t1.id AND t2.user_id = #{userId} | ||||
|         WHERE (t1.scope = 1 OR (t1.scope = 2 AND JSON_CONTAINS(t1.users, CONCAT('"', #{userId}, '"')))) | ||||
|         AND t2.read_time IS NULL | ||||
|     </select> | ||||
| @@ -62,7 +62,7 @@ | ||||
|         SELECT | ||||
|             COUNT(1) | ||||
|         FROM sys_message AS t1 | ||||
|             LEFT JOIN sys_message_log AS t2 ON t2.message_id = t1.id | ||||
|             LEFT JOIN sys_message_log AS t2 ON t2.message_id = t1.id AND t2.user_id = #{userId} | ||||
|         WHERE (t1.scope = 1 OR (t1.scope = 2 AND JSON_CONTAINS(t1.users, CONCAT('"', #{userId}, '"')))) | ||||
|         AND t2.read_time IS NULL | ||||
|           <if test="type != null"> | ||||
|   | ||||
| @@ -43,9 +43,9 @@ | ||||
|  | ||||
|     <select id="selectUnreadIdsByUserId" resultType="java.lang.Long"> | ||||
|         SELECT | ||||
|             t1.id | ||||
|         t1.id | ||||
|         FROM sys_notice AS t1 | ||||
|         LEFT JOIN sys_notice_log AS t2 ON t2.notice_id = t1.id | ||||
|         LEFT JOIN sys_notice_log AS t2 ON t2.notice_id = t1.id AND t2.user_id = #{userId} | ||||
|         WHERE (t1.notice_scope = 1 OR (t1.notice_scope = 2 AND JSON_CONTAINS(t1.notice_users, CONCAT('"', #{userId}, '"')))) | ||||
|         <if test="noticeMethod != null"> | ||||
|             AND JSON_CONTAINS(t1.notice_methods, CAST(#{noticeMethod} AS CHAR)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 摔倒的红烧肉
					摔倒的红烧肉