From a7db103de3b1865ab266b03fb966065024f95e82 Mon Sep 17 00:00:00 2001 From: 13405411873 <1994398261@qq.com> Date: Sat, 29 Mar 2025 16:09:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E5=91=8A=E8=AF=A6=E6=83=85=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busi/controller/BusiNoticeController.java | 20 +++++- .../controller/BusiNoticeViewController.java | 16 ++++- .../com/ruoyi/busi/domain/BusiNoticeView.java | 8 +-- .../ruoyi/busi/mapper/BusiNoticeMapper.java | 9 +++ .../com/ruoyi/busi/query/AppNoticeQuery.java | 2 + .../busi/service/IBusiNoticeService.java | 9 +++ .../busi/service/IBusiNoticeViewService.java | 9 ++- .../service/impl/BusiNoticeServiceImpl.java | 40 ++++++++++++ .../impl/BusiNoticeViewServiceImpl.java | 35 ++++++++++- .../ruoyi/member/domain/MemberFootprint.java | 18 +++--- .../mapper/busi/BusiNoticeMapper.xml | 61 +++++++++++++++++++ 11 files changed, 212 insertions(+), 15 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeController.java index 6d576f7..c45a83d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeController.java @@ -61,7 +61,7 @@ public class BusiNoticeController extends BaseController /** * 查询博主报名的通告 * @author PQZ - * @date 11:13 2025/3/29 + * @date 11:13 2025/3/29 * @param userId 用户id * @param pageNum 分页参数 * @param pageSize 分页参数 @@ -195,4 +195,22 @@ public class BusiNoticeController extends BaseController return success(detail); } + /** + * 小程序端查询浏览通告列表 + * @author zcy + * @date 15:39 2025/3/29 + * @param query 查询条件 + * @param pageNum 1 + * @param pageSize 10 + * @return com.ruoyi.common.core.domain.AjaxResult + **/ + @GetMapping("/appFootprintList") + public AjaxResult appFootprintList(AppNoticeQuery query, + @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) + { + Page page = new Page<>(pageNum, pageSize); + IPage list = busiNoticeService.appFootprintList(query,page); + return success(list); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeViewController.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeViewController.java index 3ff0acb..7843338 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeViewController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeViewController.java @@ -6,6 +6,7 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.annotation.Anonymous; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -28,7 +29,7 @@ import com.ruoyi.common.core.page.TableDataInfo; /** * 通告浏览量Controller - * + * * @author 朱春云 * @date 2025-03-17 */ @@ -109,4 +110,17 @@ public class BusiNoticeViewController extends BaseController List list = new ArrayList<>(Arrays.asList(ids)); return toAjax(busiNoticeViewService.removeByIds(list)); } + + /** + * 增加浏览记录 + * @param noticeId 通告记录,userId用户id + * @return + */ + @PostMapping("/addView") + @Anonymous + public AjaxResult addView(String noticeId,Long userId) + { + busiNoticeViewService.addView(noticeId,userId); + return success(); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/domain/BusiNoticeView.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/domain/BusiNoticeView.java index 9aa7797..707872f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/domain/BusiNoticeView.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/domain/BusiNoticeView.java @@ -7,21 +7,21 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import com.ruoyi.common.core.domain.DlBaseEntity; +import java.io.Serializable; + /** * 通告浏览量对象 dl_busi_notice_view - * + * * @author 朱春云 * @date 2025-03-17 */ @TableName("dl_busi_notice_view") @Data -@EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @Builder @NoArgsConstructor @AllArgsConstructor -public class BusiNoticeView extends DlBaseEntity -{ +public class BusiNoticeView implements Serializable { private static final long serialVersionUID = 1L; /** 通告id */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiNoticeMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiNoticeMapper.java index b7de661..525718f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiNoticeMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiNoticeMapper.java @@ -41,6 +41,15 @@ public interface BusiNoticeMapper extends BaseMapper { * @return com.baomidou.mybatisplus.core.metadata.IPage **/ IPage queryAppListPage(@Param("entity") AppNoticeQuery query, Page page); + /** + * 小程序端查询浏览通告列表 + * @author zcy + * @date 15:39 2025/3/29 + * @param query 查询条件 + * @return com.ruoyi.common.core.domain.AjaxResult + **/ + IPage appFootprintList(@Param("entity") AppNoticeQuery query, Page page); + /** * 小程序端查询通告详细信息 * @author 朱春云 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/query/AppNoticeQuery.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/query/AppNoticeQuery.java index 406a0de..b8de8f7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/query/AppNoticeQuery.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/query/AppNoticeQuery.java @@ -29,5 +29,7 @@ public class AppNoticeQuery { private Double feeUp; /** 稿费要求-下限 */ private Double feeDown; + //用户id + private Long userId; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeService.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeService.java index 55ae411..c7ea263 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeService.java @@ -63,6 +63,15 @@ public interface IBusiNoticeService extends IService * @return com.baomidou.mybatisplus.core.metadata.IPage **/ IPage queryAppListPage(AppNoticeQuery query, Page page); + /** + * 小程序端查询浏览通告列表 + * @author zcy + * @date 15:39 2025/3/29 + * @param query 查询条件 + * @return com.ruoyi.common.core.domain.AjaxResult + **/ + IPage appFootprintList(AppNoticeQuery query, Page page); + /** * 小程序端查询通告详细信息 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeViewService.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeViewService.java index 1ff6c47..10eb291 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeViewService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeViewService.java @@ -8,11 +8,18 @@ import com.ruoyi.busi.domain.BusiNoticeView; /** * 通告浏览量Service接口 - * + * * @author 朱春云 * @date 2025-03-17 */ public interface IBusiNoticeViewService extends IService { IPage queryListPage(BusiNoticeView pageReqVO, Page page); + + /** + * 浏览增加 + * @param noticeId 通告id + * @param userId 用户id + */ + void addView(String noticeId,Long userId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeServiceImpl.java index b5afc59..8a983bc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeServiceImpl.java @@ -226,6 +226,46 @@ public class BusiNoticeServiceImpl extends ServiceImpl appFootprintList(AppNoticeQuery query, Page page) { + query.setUserId(SecurityUtils.getUserId()); + IPage pageList = busiNoticeMapper.appFootprintList(query,page); + List idList = pageList.getRecords().stream().map(BusiNotice::getId).collect(Collectors.toList()); + if(!idList.isEmpty()){ + //查报名数量 + List> mapList = busiNoticeSignMapper.selectReportNumByIdList(idList); + //转map + Map objectMap = mapList.stream().collect(Collectors.toMap(each-> Objects.toString(each.get("id"),""),each->each.get("reportNum"))); + //查博主类型字典 + List categoryList = baseCategoryService.listByParentCode(DictConstants.BLOGGER_TYPES_KEY,null); + //转map + Map categoryMap = categoryList.stream().collect(Collectors.toMap(BaseCategory::getCode,BaseCategory::getTitle)); + pageList.getRecords().forEach(item->{ + //报名数量、浏览量、相关字典转换 + if(null==item.getViewNum()){ + item.setViewNum(0); + } + if(!objectMap.containsKey(item.getId()) || null==objectMap.get(item.getId())){ + item.setReportNum(0); + }else{ + item.setReportNum((Integer) objectMap.get(item.getId())); + } + item.setBloggerTypesText(noticeUtils.translateBloggerTypes(item.getBloggerTypes(),categoryMap)); + if(StringUtils.isNotEmpty(item.getImages())){ + item.setMainImage(item.getImages().split(StrUtil.COMMA)[0]); + } + }); + } + return pageList; + } + /** * 小程序端查询通告详细信息 * @author 朱春云 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeViewServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeViewServiceImpl.java index dbf55ae..16ac366 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeViewServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeViewServiceImpl.java @@ -1,8 +1,11 @@ package com.ruoyi.busi.service.impl; +import java.util.Date; import java.util.List; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.member.domain.MemberFootprint; +import com.ruoyi.member.service.IMemberFootprintService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -12,7 +15,7 @@ import com.ruoyi.busi.service.IBusiNoticeViewService; /** * 通告浏览量Service业务层处理 - * + * * @author 朱春云 * @date 2025-03-17 */ @@ -21,9 +24,39 @@ public class BusiNoticeViewServiceImpl extends ServiceImpl queryListPage(BusiNoticeView pageReqVO, Page page) { return busiNoticeViewMapper.queryListPage(pageReqVO, page); } + /** + * 浏览增加 + * @param noticeId 通告id + * @param userId 用户id + */ + @Override + public void addView(String noticeId, Long userId) { + //通告浏览量增加 + BusiNoticeView busiNoticeView = busiNoticeViewMapper.selectById(noticeId); + if (busiNoticeView == null){ + busiNoticeView = new BusiNoticeView(); + busiNoticeView.setId(noticeId); + busiNoticeView.setViewNum(1L); + busiNoticeViewMapper.insert(busiNoticeView); + } + busiNoticeView.setViewNum(busiNoticeView.getViewNum()+1); + busiNoticeViewMapper.updateById(busiNoticeView); + if (userId != null){ + //通告浏览记录增加 + MemberFootprint memberFootprint = new MemberFootprint(); + memberFootprint.setNoticeId(noticeId); + memberFootprint.setUserId(userId); + memberFootprint.setCreateTime(new Date()); + memberFootprintService.save(memberFootprint); + } + + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/member/domain/MemberFootprint.java b/ruoyi-admin/src/main/java/com/ruoyi/member/domain/MemberFootprint.java index 477ad91..fe8cba6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/member/domain/MemberFootprint.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/member/domain/MemberFootprint.java @@ -1,27 +1,27 @@ package com.ruoyi.member.domain; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import com.ruoyi.common.core.domain.DlBaseEntity; +import java.io.Serializable; +import java.util.Date; + /** * 浏览足迹对象 dl_member_footprint - * + * * @author vinjor-m * @date 2025-03-17 */ @TableName("dl_member_footprint") @Data -@EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @Builder @NoArgsConstructor @AllArgsConstructor -public class MemberFootprint extends DlBaseEntity -{ +public class MemberFootprint implements Serializable { private static final long serialVersionUID = 1L; /** 唯一主键 */ @@ -35,5 +35,9 @@ public class MemberFootprint extends DlBaseEntity /** 通告id */ @Excel(name = "通告id") private String noticeId; + /** 创建时间 */ + @TableField(fill = FieldFill.INSERT) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; } diff --git a/ruoyi-admin/src/main/resources/mapper/busi/BusiNoticeMapper.xml b/ruoyi-admin/src/main/resources/mapper/busi/BusiNoticeMapper.xml index 326610f..567ac34 100644 --- a/ruoyi-admin/src/main/resources/mapper/busi/BusiNoticeMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/busi/BusiNoticeMapper.xml @@ -136,5 +136,66 @@ order by dbns.create_time desc WHERE main.id = #{noticeId} +