添加通知日志状态获取
This commit is contained in:
+8
@@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import xtools.app.sys.model.dto.req.SysUserNoticePageReq;
|
import xtools.app.sys.model.dto.req.SysUserNoticePageReq;
|
||||||
import xtools.app.sys.model.dto.req.SysUserNoticeUpdateReq;
|
import xtools.app.sys.model.dto.req.SysUserNoticeUpdateReq;
|
||||||
import xtools.app.sys.model.dto.resp.SysUserNoticeResp;
|
import xtools.app.sys.model.dto.resp.SysUserNoticeResp;
|
||||||
|
import xtools.app.sys.model.dto.resp.SysUserNoticeStatusResp;
|
||||||
import xtools.app.sys.service.SysUserNoticeService;
|
import xtools.app.sys.service.SysUserNoticeService;
|
||||||
import xtools.boot.api.model.dto.Result;
|
import xtools.boot.api.model.dto.Result;
|
||||||
import xtools.boot.api.model.dto.page.PageReq;
|
import xtools.boot.api.model.dto.page.PageReq;
|
||||||
@@ -54,4 +56,10 @@ public class SysUserNoticeController {
|
|||||||
return sysUserNoticeService.delById(req);
|
return sysUserNoticeService.delById(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取状态信息")
|
||||||
|
@GetMapping("status")
|
||||||
|
public Result<SysUserNoticeStatusResp> getStatus() {
|
||||||
|
return sysUserNoticeService.getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -7,8 +7,11 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import xtools.app.sys.model.dto.req.SysUserNoticePageReq;
|
import xtools.app.sys.model.dto.req.SysUserNoticePageReq;
|
||||||
import xtools.app.sys.model.dto.resp.SysUserNoticeResp;
|
import xtools.app.sys.model.dto.resp.SysUserNoticeResp;
|
||||||
|
import xtools.app.sys.model.dto.resp.SysUserNoticeStatusResp;
|
||||||
import xtools.app.sys.model.entity.SysUserNotice;
|
import xtools.app.sys.model.entity.SysUserNotice;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Title : SysUserNoticeMapper</p>
|
* <p>Title : SysUserNoticeMapper</p>
|
||||||
* <p>Description : 系统用户通知公告表 Mapper 接口</p>
|
* <p>Description : 系统用户通知公告表 Mapper 接口</p>
|
||||||
@@ -33,4 +36,20 @@ public interface SysUserNoticeMapper extends BaseMapper<SysUserNotice> {
|
|||||||
@Param("query") SysUserNoticePageReq query
|
@Param("query") SysUserNoticePageReq query
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态信息
|
||||||
|
*
|
||||||
|
* @param todayStart 今日开始时间(当天 0 点)
|
||||||
|
* @param todayEnd 今日结束时间(次日 0 点)
|
||||||
|
* @param yesterdayStart 昨日开始时间(昨日 0 点)
|
||||||
|
* @param yesterdayEnd 昨日结束时间(今日 0 点)
|
||||||
|
* @return 状态信息
|
||||||
|
*/
|
||||||
|
SysUserNoticeStatusResp selectStatus(
|
||||||
|
@Param("todayStart") Instant todayStart,
|
||||||
|
@Param("todayEnd") Instant todayEnd,
|
||||||
|
@Param("yesterdayStart") Instant yesterdayStart,
|
||||||
|
@Param("yesterdayEnd") Instant yesterdayEnd
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+98
@@ -0,0 +1,98 @@
|
|||||||
|
package xtools.app.sys.model.dto.resp;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title : SysUserNoticeStatusResp</p>
|
||||||
|
* <p>Description : 系统用户通知公告表 状态响应对象</p>
|
||||||
|
* <p>Company : org.xujun</p>
|
||||||
|
*
|
||||||
|
* @author : xujun
|
||||||
|
* @version : 1.0.0
|
||||||
|
* @date : 2026-07-28 10:00:00
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SysUserNoticeStatusResp implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日公告数
|
||||||
|
*/
|
||||||
|
@Schema(description = "今日公告数")
|
||||||
|
private Long todayNoticeCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 昨日公告数
|
||||||
|
*/
|
||||||
|
@Schema(description = "昨日公告数")
|
||||||
|
private Long yesterdayNoticeCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总公告数
|
||||||
|
*/
|
||||||
|
@Schema(description = "总公告数")
|
||||||
|
private Long totalNoticeCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日未读数
|
||||||
|
*/
|
||||||
|
@Schema(description = "今日未读数")
|
||||||
|
private Long todayUnreadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 昨日未读数
|
||||||
|
*/
|
||||||
|
@Schema(description = "昨日未读数")
|
||||||
|
private Long yesterdayUnreadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总未读数
|
||||||
|
*/
|
||||||
|
@Schema(description = "总未读数")
|
||||||
|
private Long totalUnreadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日已读数
|
||||||
|
*/
|
||||||
|
@Schema(description = "今日已读数")
|
||||||
|
private Long todayReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 昨日已读数
|
||||||
|
*/
|
||||||
|
@Schema(description = "昨日已读数")
|
||||||
|
private Long yesterdayReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总已读数
|
||||||
|
*/
|
||||||
|
@Schema(description = "总已读数")
|
||||||
|
private Long totalReadCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日通知总数
|
||||||
|
*/
|
||||||
|
@Schema(description = "今日通知总数")
|
||||||
|
private Long todayTotalCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 昨日通知总数
|
||||||
|
*/
|
||||||
|
@Schema(description = "昨日通知总数")
|
||||||
|
private Long yesterdayTotalCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总通知数
|
||||||
|
*/
|
||||||
|
@Schema(description = "总通知数")
|
||||||
|
private Long totalCount;
|
||||||
|
|
||||||
|
}
|
||||||
+8
@@ -3,6 +3,7 @@ package xtools.app.sys.service;
|
|||||||
import xtools.app.sys.model.dto.req.SysUserNoticePageReq;
|
import xtools.app.sys.model.dto.req.SysUserNoticePageReq;
|
||||||
import xtools.app.sys.model.dto.req.SysUserNoticeUpdateReq;
|
import xtools.app.sys.model.dto.req.SysUserNoticeUpdateReq;
|
||||||
import xtools.app.sys.model.dto.resp.SysUserNoticeResp;
|
import xtools.app.sys.model.dto.resp.SysUserNoticeResp;
|
||||||
|
import xtools.app.sys.model.dto.resp.SysUserNoticeStatusResp;
|
||||||
import xtools.boot.api.model.dto.Result;
|
import xtools.boot.api.model.dto.Result;
|
||||||
import xtools.boot.api.model.dto.page.PageReq;
|
import xtools.boot.api.model.dto.page.PageReq;
|
||||||
import xtools.boot.api.model.dto.page.PageResp;
|
import xtools.boot.api.model.dto.page.PageResp;
|
||||||
@@ -62,4 +63,11 @@ public interface SysUserNoticeService {
|
|||||||
*/
|
*/
|
||||||
void saveByNoticeId(Long noticeId, final List<Long> uids, boolean isAll);
|
void saveByNoticeId(Long noticeId, final List<Long> uids, boolean isAll);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态信息
|
||||||
|
*
|
||||||
|
* @return 状态信息
|
||||||
|
*/
|
||||||
|
Result<SysUserNoticeStatusResp> getStatus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+22
@@ -12,6 +12,7 @@ import xtools.app.sys.mapper.SysUserNoticeMapper;
|
|||||||
import xtools.app.sys.model.dto.req.SysUserNoticePageReq;
|
import xtools.app.sys.model.dto.req.SysUserNoticePageReq;
|
||||||
import xtools.app.sys.model.dto.req.SysUserNoticeUpdateReq;
|
import xtools.app.sys.model.dto.req.SysUserNoticeUpdateReq;
|
||||||
import xtools.app.sys.model.dto.resp.SysUserNoticeResp;
|
import xtools.app.sys.model.dto.resp.SysUserNoticeResp;
|
||||||
|
import xtools.app.sys.model.dto.resp.SysUserNoticeStatusResp;
|
||||||
import xtools.app.sys.model.entity.SysUser;
|
import xtools.app.sys.model.entity.SysUser;
|
||||||
import xtools.app.sys.model.entity.SysUserNotice;
|
import xtools.app.sys.model.entity.SysUserNotice;
|
||||||
import xtools.app.sys.service.SysUserNoticeService;
|
import xtools.app.sys.service.SysUserNoticeService;
|
||||||
@@ -29,6 +30,9 @@ import xtools.boot.api.model.dto.req.IdListReq;
|
|||||||
import xtools.boot.db.mybatisplus.utils.QueryUtils;
|
import xtools.boot.db.mybatisplus.utils.QueryUtils;
|
||||||
import xtools.core.CollectionUtils;
|
import xtools.core.CollectionUtils;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -222,4 +226,22 @@ public class SysUserNoticeServiceImpl implements SysUserNoticeService, BaseParam
|
|||||||
return sysUserNoticeBaseService.getOne(query);
|
return sysUserNoticeBaseService.getOne(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态信息
|
||||||
|
*
|
||||||
|
* @return 状态信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<SysUserNoticeStatusResp> getStatus() {
|
||||||
|
// 计算今日/昨日的起止时间(系统时区)
|
||||||
|
ZoneId zone = ZoneId.systemDefault();
|
||||||
|
LocalDate today = LocalDate.now(ZoneId.systemDefault());
|
||||||
|
Instant todayStart = today.atStartOfDay(zone).toInstant();
|
||||||
|
Instant todayEnd = today.plusDays(CP_NUM1).atStartOfDay(zone).toInstant();
|
||||||
|
Instant yesterdayStart = today.minusDays(CP_NUM1).atStartOfDay(zone).toInstant();
|
||||||
|
Instant yesterdayEnd = todayStart;
|
||||||
|
SysUserNoticeStatusResp resp = sysUserNoticeMapper.selectStatus(todayStart, todayEnd, yesterdayStart, yesterdayEnd);
|
||||||
|
return Result.ok(resp);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,4 +42,49 @@
|
|||||||
ORDER BY
|
ORDER BY
|
||||||
sun.gmt_create
|
sun.gmt_create
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 获取状态信息 -->
|
||||||
|
<select id="selectStatus" resultType="xtools.app.sys.model.dto.resp.SysUserNoticeStatusResp">
|
||||||
|
SELECT
|
||||||
|
-- 公告数(按 notice_id 去重, 依据 gmt_create)
|
||||||
|
COUNT(DISTINCT CASE
|
||||||
|
WHEN sun.gmt_create >= #{todayStart} AND sun.gmt_create < #{todayEnd}
|
||||||
|
THEN sun.notice_id END) AS todayNoticeCount,
|
||||||
|
COUNT(DISTINCT CASE
|
||||||
|
WHEN sun.gmt_create >= #{yesterdayStart} AND sun.gmt_create < #{yesterdayEnd}
|
||||||
|
THEN sun.notice_id END) AS yesterdayNoticeCount,
|
||||||
|
COUNT(DISTINCT sun.notice_id) AS totalNoticeCount,
|
||||||
|
|
||||||
|
-- 未读数(notice_read 为空或非 1 视为未读, 依据 gmt_create)
|
||||||
|
COUNT(CASE
|
||||||
|
WHEN IFNULL(sun.notice_read, 0) = 0 AND sun.gmt_create >= #{todayStart} AND
|
||||||
|
sun.gmt_create < #{todayEnd}
|
||||||
|
THEN 1 END) AS todayUnreadCount,
|
||||||
|
COUNT(CASE
|
||||||
|
WHEN IFNULL(sun.notice_read, 0) = 0 AND sun.gmt_create >= #{yesterdayStart} AND
|
||||||
|
sun.gmt_create < #{yesterdayEnd}
|
||||||
|
THEN 1 END) AS yesterdayUnreadCount,
|
||||||
|
COUNT(CASE WHEN IFNULL(sun.notice_read, 0) = 0 THEN 1 END) AS totalUnreadCount,
|
||||||
|
|
||||||
|
-- 已读数(notice_read = 1, 依据 read_time)
|
||||||
|
COUNT(CASE
|
||||||
|
WHEN sun.notice_read = 1 AND sun.read_time >= #{todayStart} AND sun.read_time < #{todayEnd}
|
||||||
|
THEN 1 END) AS todayReadCount,
|
||||||
|
COUNT(CASE
|
||||||
|
WHEN sun.notice_read = 1 AND sun.read_time >= #{yesterdayStart} AND
|
||||||
|
sun.read_time < #{yesterdayEnd}
|
||||||
|
THEN 1 END) AS yesterdayReadCount,
|
||||||
|
COUNT(CASE WHEN sun.notice_read = 1 THEN 1 END) AS totalReadCount,
|
||||||
|
|
||||||
|
-- 通知总数(依据 gmt_create)
|
||||||
|
COUNT(CASE
|
||||||
|
WHEN sun.gmt_create >= #{todayStart} AND sun.gmt_create < #{todayEnd}
|
||||||
|
THEN 1 END) AS todayTotalCount,
|
||||||
|
COUNT(CASE
|
||||||
|
WHEN sun.gmt_create >= #{yesterdayStart} AND sun.gmt_create < #{yesterdayEnd}
|
||||||
|
THEN 1 END) AS yesterdayTotalCount,
|
||||||
|
COUNT(*) AS totalCount
|
||||||
|
FROM sys_user_notice sun
|
||||||
|
WHERE sun.is_deleted = 0
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user