获取置顶文章

获取置顶文章
This commit is contained in:
amypeng 2026-06-08 16:05:02 +08:00
parent f3a718d75a
commit 83566e947a
6 changed files with 67 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import com.microservices.common.security.annotation.RequiresPermissions;
import com.microservices.common.security.utils.SecurityUtils;
import com.microservices.zone.detail.domain.vo.ZoneFrontRoleVo;
import com.microservices.zone.detail.service.IZoneDetailService;
import com.microservices.zone.member.domain.vo.ZonePointsTopDocVo;
import com.microservices.zone.project.domain.vo.*;
import com.microservices.zone.project.service.IZoneProjectService;
import com.microservices.zone.member.service.IZonePointsAccountService;
@ -176,6 +177,15 @@ public class FrontController extends BaseController {
return toAjax(zoneProjectService.deleteMyZoneProjectByIds(ids));
}
/**
* 查询专区置顶文章列表
*/
@GetMapping("/getTopDoc/{zoneId}")
@ApiOperation(value = "查询专区置顶文章列表")
public GenericsAjaxResult<List<ZonePointsTopDocVo>> getTopDoc(@PathVariable("zoneId") Long zoneId) {
return genericsSuccess(zonePointsAccountService.selectTopDocList(zoneId));
}
/**
* 检查当前登录用户在当前专区下角色
*/

View File

@ -28,6 +28,9 @@ public class ZonePointsTopDocVo {
@ApiModelProperty("文章名称")
private String docName;
@ApiModelProperty("文章概要")
private String summary;
@ApiModelProperty("是否积分置顶")
private Boolean isPointsTop;

View File

@ -1,9 +1,12 @@
package com.microservices.zone.member.mapper;
import com.microservices.zone.member.domain.points.ZonePointsDoc;
import com.microservices.zone.member.domain.vo.ZonePointsTopDocVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 专区积分文档Mapper接口
*
@ -80,4 +83,12 @@ public interface ZonePointsDocMapper {
* @return 置顶文章记录
*/
ZonePointsDoc selectPointsTopByZoneIdAndUserId(@Param("zoneId") Long zoneId, @Param("userId") Long userId);
/**
* 查询专区下置顶文章列表左联 cms_doc过期时间晚于当前时间用于前台展示
*
* @param zoneId 专区ID
* @return 置顶文章列表含文章名称和概要
*/
List<ZonePointsTopDocVo> selectTopDocList(@Param("zoneId") Long zoneId);
}

View File

@ -85,6 +85,14 @@ public interface IZonePointsAccountService {
*/
ZonePointsTopDocVo getCurrentUserPointsTopDoc(Long zoneId);
/**
* 查询专区下置顶文章列表过期时间晚于当前时间用于前台展示
*
* @param zoneId 专区ID
* @return 置顶文章列表
*/
List<ZonePointsTopDocVo> selectTopDocList(Long zoneId);
/**
* 获取当前登录用户的置顶项目信息
*

View File

@ -291,14 +291,26 @@ public class ZonePointsAccountServiceImpl implements IZonePointsAccountService {
remoteCmsService.selectCmsDocJSONObjectById(pointsDoc.getDocId(), SecurityConstants.INNER));
if (cmsDocJson != null) {
vo.setDocName(cmsDocJson.getString("name"));
vo.setSummary(cmsDocJson.getString("summary"));
}
} catch (Exception e) {
logger.warn("获取置顶文章名称失败 docId={} error={}", pointsDoc.getDocId(), e.getMessage());
logger.warn("获取置顶文章信息失败 docId={} error={}", pointsDoc.getDocId(), e.getMessage());
}
return vo;
}
/**
* 查询专区下置顶文章列表过期时间晚于当前时间用于前台展示
*
* @param zoneId 专区ID
* @return 置顶文章列表含文章名称和概要通过 SQL 左联 cms_doc 获取
*/
@Override
public List<ZonePointsTopDocVo> selectTopDocList(Long zoneId) {
return zonePointsDocMapper.selectTopDocList(zoneId);
}
/**
* 获取当前登录用户的置顶项目信息
*

View File

@ -101,4 +101,26 @@
limit 1
</select>
<!-- 查询专区下置顶文章列表(左联 cms_doc 获取文章名称和概要,过期时间晚于当前时间) -->
<resultMap type="com.microservices.zone.member.domain.vo.ZonePointsTopDocVo" id="ZonePointsTopDocVoResult">
<result property="id" column="zpd_id"/>
<result property="zoneId" column="zone_id"/>
<result property="docId" column="doc_id"/>
<result property="docName" column="doc_name"/>
<result property="summary" column="summary"/>
<result property="isPointsTop" column="is_points_top"/>
<result property="expiryTime" column="expiry_time"/>
</resultMap>
<select id="selectTopDocList" resultMap="ZonePointsTopDocVoResult">
select zpd.id as zpd_id, zpd.zone_id, zpd.doc_id, zpd.is_points_top, zpd.expiry_time,
cd.name as doc_name, cd.summary
from zone_points_doc zpd
left join cms_doc cd on zpd.doc_id = cd.id
where zpd.zone_id = #{zoneId}
and zpd.is_points_top = 1
and zpd.expiry_time > NOW()
order by zpd.create_time desc
</select>
</mapper>