This commit is contained in:
PQZ 2025-03-31 13:53:08 +08:00
commit fb0b5b894c
14 changed files with 259 additions and 19 deletions

View File

@ -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 分页参数
@ -140,7 +140,6 @@ public class BusiNoticeController extends BaseController
* noticeId 通告主键
* publishTakeDown 1发布0下架
*/
@PreAuthorize("@ss.hasPermi('busi:notice:edit')")
@PostMapping("/publishTakeDown")
public AjaxResult publishTakeDown(@RequestParam("noticeId") String noticeId,@RequestParam("publishTakeDown") String publishTakeDown)
{
@ -195,4 +194,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<BusiNotice> page = new Page<>(pageNum, pageSize);
IPage<BusiNoticeVo> list = busiNoticeService.appFootprintList(query,page);
return success(list);
}
}

View File

@ -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<String> 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();
}
}

View File

@ -28,7 +28,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
/**
* 用户关注Controller
*
*
* @author 朱春云
* @date 2025-03-29
*/
@ -109,4 +109,15 @@ public class BusiUserLoveController extends BaseController
List<String> list = new ArrayList<>(Arrays.asList(ids));
return toAjax(busiUserLoveService.removeByIds(list));
}
/**
* 用户关注或取消关注接口
* @param userId 通告主id isLove 0取消关注 1 关注
*/
@PostMapping("/userLoveIs")
public AjaxResult userLoveIs(Long userId,String isLove)
{
busiUserLoveService.userLoveIs(userId,isLove);
return success();
}
}

View File

@ -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 */

View File

@ -41,6 +41,15 @@ public interface BusiNoticeMapper extends BaseMapper<BusiNotice> {
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.ruoyi.busi.domain.BusiNotice>
**/
IPage<BusiNoticeVo> queryAppListPage(@Param("entity") AppNoticeQuery query, Page<BusiNotice> page);
/**
* 小程序端查询浏览通告列表
* @author zcy
* @date 15:39 2025/3/29
* @param query 查询条件
* @return com.ruoyi.common.core.domain.AjaxResult
**/
IPage<BusiNoticeVo> appFootprintList(@Param("entity") AppNoticeQuery query, Page<BusiNotice> page);
/**
* 小程序端查询通告详细信息
* @author 朱春云

View File

@ -29,5 +29,7 @@ public class AppNoticeQuery {
private Double feeUp;
/** 稿费要求-下限 */
private Double feeDown;
//用户id
private Long userId;
}

View File

@ -63,6 +63,15 @@ public interface IBusiNoticeService extends IService<BusiNotice>
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.ruoyi.busi.domain.BusiNotice>
**/
IPage<BusiNoticeVo> queryAppListPage(AppNoticeQuery query, Page<BusiNotice> page);
/**
* 小程序端查询浏览通告列表
* @author zcy
* @date 15:39 2025/3/29
* @param query 查询条件
* @return com.ruoyi.common.core.domain.AjaxResult
**/
IPage<BusiNoticeVo> appFootprintList(AppNoticeQuery query, Page<BusiNotice> page);
/**
* 小程序端查询通告详细信息

View File

@ -8,11 +8,18 @@ import com.ruoyi.busi.domain.BusiNoticeView;
/**
* 通告浏览量Service接口
*
*
* @author 朱春云
* @date 2025-03-17
*/
public interface IBusiNoticeViewService extends IService<BusiNoticeView>
{
IPage<BusiNoticeView> queryListPage(BusiNoticeView pageReqVO, Page<BusiNoticeView> page);
/**
* 浏览增加
* @param noticeId 通告id
* @param userId 用户id
*/
void addView(String noticeId,Long userId);
}

View File

@ -8,11 +8,16 @@ import com.ruoyi.busi.domain.BusiUserLove;
/**
* 用户关注Service接口
*
*
* @author 朱春云
* @date 2025-03-29
*/
public interface IBusiUserLoveService extends IService<BusiUserLove>
{
IPage<BusiUserLove> queryListPage(BusiUserLove pageReqVO, Page<BusiUserLove> page);
/**
* 用户关注或取消关注接口
* @param userId 通告主id isLove 0取消关注 1 关注
*/
void userLoveIs(Long userId,String isLove);
}

View File

@ -226,6 +226,46 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
}
/**
* 小程序端查询浏览通告列表
* @author zcy
* @date 15:39 2025/3/29
* @param query 查询条件
* @return com.ruoyi.common.core.domain.AjaxResult
**/
@Override
public IPage<BusiNoticeVo> appFootprintList(AppNoticeQuery query, Page<BusiNotice> page) {
query.setUserId(SecurityUtils.getUserId());
IPage<BusiNoticeVo> pageList = busiNoticeMapper.appFootprintList(query,page);
List<String> idList = pageList.getRecords().stream().map(BusiNotice::getId).collect(Collectors.toList());
if(!idList.isEmpty()){
//查报名数量
List<Map<String,Object>> mapList = busiNoticeSignMapper.selectReportNumByIdList(idList);
//转map
Map<String,Object> objectMap = mapList.stream().collect(Collectors.toMap(each-> Objects.toString(each.get("id"),""),each->each.get("reportNum")));
//查博主类型字典
List<BaseCategory> categoryList = baseCategoryService.listByParentCode(DictConstants.BLOGGER_TYPES_KEY,null);
//转map
Map<String,String> 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 朱春云

View File

@ -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<BusiNoticeViewMapper,
{
@Autowired
private BusiNoticeViewMapper busiNoticeViewMapper;
@Autowired
private IMemberFootprintService memberFootprintService;
@Override
public IPage<BusiNoticeView> queryListPage(BusiNoticeView pageReqVO, Page<BusiNoticeView> 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);
}
}
}

View File

@ -1,9 +1,12 @@
package com.ruoyi.busi.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.utils.DateUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -13,7 +16,7 @@ import com.ruoyi.busi.service.IBusiUserLoveService;
/**
* 用户关注Service业务层处理
*
*
* @author 朱春云
* @date 2025-03-29
*/
@ -27,4 +30,29 @@ public class BusiUserLoveServiceImpl extends ServiceImpl<BusiUserLoveMapper,Busi
public IPage<BusiUserLove> queryListPage(BusiUserLove pageReqVO, Page<BusiUserLove> page) {
return busiUserLoveMapper.queryListPage(pageReqVO, page);
}
/**
* 用户关注或取消关注接口
* @param userId 通告主id isLove 0取消关注 1 关注
*/
@Override
public void userLoveIs(Long userId, String isLove) {
Long nowUserId = SecurityUtils.getUserId();
if ("0".equals(isLove)){
//取消关注
busiUserLoveMapper.delete(new LambdaQueryWrapper<BusiUserLove>().eq(BusiUserLove::getUserId,nowUserId).eq(BusiUserLove::getLoveUserId,userId));
}else {
if (busiUserLoveMapper.selectOne(new LambdaQueryWrapper<BusiUserLove>().eq(BusiUserLove::getUserId,nowUserId).eq(BusiUserLove::getLoveUserId,userId))!=null){
//已关注
return;
}
//关注
BusiUserLove busiUserLove = new BusiUserLove();
busiUserLove.setUserId(nowUserId);
busiUserLove.setLoveUserId(userId);
busiUserLove.setCreateTime(DateUtils.getNowDate());
busiUserLove.setCreator(String.valueOf(nowUserId));
busiUserLoveMapper.insert(busiUserLove);
}
}
}

View File

@ -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;
}

View File

@ -136,5 +136,66 @@ order by dbns.create_time desc
WHERE
main.id = #{noticeId}
</select>
<select id="appFootprintList" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
SELECT
dbn.*,
dbnv.view_num AS viewNum,
su.avatar,
su.nick_name AS userNickName
FROM
dl_busi_notice dbn
LEFT JOIN dl_busi_notice_view dbnv ON dbn.id = dbnv.id
inner join dl_member_footprint footprint on footprint.notice_id = dbn.id and footprint.user_id = #{entity.userId}
LEFT JOIN sys_user su ON dbn.user_id = su.user_id
WHERE
dbn.del_flag = 0
AND (dbn.approval_status = '1')
<if test="entity.gift!=null and entity.gift!=''">
AND ( dbn.gift_detail IS NOT NULL AND dbn.gift_detail != '' )
</if>
<if test="entity.platformCode!=null and entity.platformCode!=''">
AND ( dbn.platform_code =#{entity.platformCode} )
</if>
<if test="entity.bloggerType!=null and entity.bloggerType!=''">
AND ( dbn.blogger_types LIKE CONCAT('%',#{entity.bloggerType},'%') )
</if>
<if test="entity.searchValue!=null and entity.searchValue!=''">
AND ( dbn.title LIKE CONCAT('%',#{entity.searchValue},'%') OR
dbn.detail LIKE CONCAT('%',#{entity.searchValue},'%') )
</if>
<if test="entity.rewardType=='money'">
AND ( dbn.fee_down IS NOT NULL OR dbn.fee_up IS NOT NULL )
</if>
<if test="entity.rewardType=='gift'">
AND ( dbn.gift_detail IS NOT NULL AND dbn.gift_detail!='' )
</if>
<if test="entity.fansUp!=null">
AND ( dbn.fans_up &lt;=#{entity.fansUp} )
</if>
<if test="entity.fansDown!=null">
AND ( dbn.fans_up &gt;=#{entity.fansDown} )
</if>
<if test="entity.feeUp!=null">
AND ( dbn.fee_up &lt;=#{entity.feeUp} )
</if>
<if test="entity.feeDown!=null">
AND ( dbn.fee_down &gt;=#{entity.feeDown} )
</if>
ORDER BY
<choose>
<when test="entity.sortBy=='new'">
-- 查最新的 --
dbn.create_time DESC
</when>
<when test="entity.sortBy=='money'">
-- 查高奖励 --
dbn.fee_up DESC
</when>
<otherwise>
-- 默认正序排列 --
dbn.create_time ASC
</otherwise>
</choose>
</select>
</mapper>