feat: 新增个人消息接口,调整个人信息接口地址

This commit is contained in:
2025-04-05 22:42:40 +08:00
parent 1de7b20fb0
commit e8aa739860
6 changed files with 135 additions and 5 deletions

View File

@@ -16,8 +16,12 @@
package top.continew.admin.system.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import top.continew.admin.system.model.entity.NoticeDO;
import top.continew.admin.system.model.query.NoticeQuery;
import top.continew.admin.system.model.resp.NoticeDetailResp;
import top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp;
import top.continew.starter.data.mp.base.BaseMapper;
@@ -38,4 +42,13 @@ public interface NoticeMapper extends BaseMapper<NoticeDO> {
* @return 仪表盘公告列表
*/
List<DashboardNoticeResp> selectDashboardList(@Param("userId") Long userId);
/**
* 分页查询公告列表
*
* @param page 分页条件
* @param query 查询条件
* @return 公告列表
*/
IPage<NoticeDetailResp> selectNoticePage(@Param("page") Page<NoticeDO> page, @Param("query") NoticeQuery query);
}

View File

@@ -16,6 +16,7 @@
package top.continew.admin.system.model.query;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.starter.data.core.annotation.Query;
@@ -49,4 +50,10 @@ public class NoticeQuery implements Serializable {
*/
@Schema(description = "类型", example = "1")
private String type;
/**
* 用户 ID
*/
@JsonIgnore
private Long userId;
}

View File

@@ -16,6 +16,8 @@
package top.continew.admin.system.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.continew.admin.common.context.UserContextHolder;
@@ -27,6 +29,8 @@ import top.continew.admin.system.model.resp.NoticeDetailResp;
import top.continew.admin.system.model.resp.NoticeResp;
import top.continew.admin.system.model.resp.dashboard.DashboardNoticeResp;
import top.continew.admin.system.service.NoticeService;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.resp.PageResp;
import top.continew.starter.extension.crud.service.BaseServiceImpl;
import java.util.List;
@@ -41,9 +45,18 @@ import java.util.List;
@RequiredArgsConstructor
public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, NoticeDO, NoticeResp, NoticeDetailResp, NoticeQuery, NoticeReq> implements NoticeService {
@Override
public PageResp<NoticeResp> page(NoticeQuery query, PageQuery pageQuery) {
IPage<NoticeDetailResp> page = baseMapper.selectNoticePage(new Page<>(pageQuery.getPage(), pageQuery
.getSize()), query);
PageResp<NoticeResp> pageResp = PageResp.build(page, super.getListClass());
pageResp.getList().forEach(this::fill);
return pageResp;
}
@Override
public List<DashboardNoticeResp> listDashboard() {
Long userId = UserContextHolder.isAdmin() ? null : UserContextHolder.getUserId();
Long userId = UserContextHolder.getUserId();
return baseMapper.selectDashboardList(userId);
}
}

View File

@@ -15,4 +15,28 @@
ORDER BY sort ASC, effective_time DESC
LIMIT 5
</select>
<select id="selectNoticePage" resultType="top.continew.admin.system.model.resp.NoticeDetailResp">
SELECT *
FROM sys_notice AS t1
<where>
<if test="query.userId != null">
t1.notice_scope = 1 OR (t1.notice_scope = 2 AND JSON_EXTRACT(t1.notice_users, "$[0]") = CAST(#{query.userId} AS CHAR))
AND (t1.effective_time IS NULL OR NOW() > t1.effective_time)
AND (t1.terminate_time IS NULL OR t1.terminate_time > NOW())
</if>
<if test="query.title != null and query.title != ''">
AND t1.title LIKE CONCAT('%', #{query.title}, '%')
</if>
<if test="query.type != null and query.type != ''">
AND t1.type = #{query.type}
</if>
</where>
<if test="query.userId != null">
ORDER BY t1.sort ASC, t1.effective_time DESC
</if>
<if test="query.userId == null">
ORDER BY t1.create_time DESC
</if>
</select>
</mapper>