33333333333
This commit is contained in:
3
doc/2025-05-17.sql
Normal file
3
doc/2025-05-17.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `cai_user_count`
|
||||
ADD COLUMN `new_fans_count` int NOT NULL DEFAULT 0 COMMENT '新增粉丝数' AFTER `give_gift_count`,
|
||||
ADD COLUMN `new_visitor_count` int NOT NULL DEFAULT 0 COMMENT '新增访客数' AFTER `give_gift_count`;
|
||||
@@ -5,18 +5,21 @@ import com.ruoyi.cai.dto.app.query.StarOrVisitorReq;
|
||||
import com.ruoyi.cai.dto.app.query.StarQuery;
|
||||
import com.ruoyi.cai.dto.app.query.star.BatchStarReq;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserStarOrVisitorList;
|
||||
import com.ruoyi.cai.mapper.UserCountMapper;
|
||||
import com.ruoyi.cai.service.UserFollowService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -26,6 +29,8 @@ public class UserStartAppController {
|
||||
|
||||
@Autowired
|
||||
private UserFollowService userFollowService;
|
||||
@Resource
|
||||
private UserCountMapper userCountMapper;
|
||||
|
||||
@PostMapping("/batchStar")
|
||||
@Operation(summary = "批量关注用户(为了防止接口滥用和性能问题,只会取前20个用户关注超过的舍弃)")
|
||||
@@ -55,6 +60,11 @@ public class UserStartAppController {
|
||||
@Operation(summary = "关注、粉丝列表查询")
|
||||
@Log(title = "粉丝列表查询", businessType = BusinessType.OTHER,isPrintResponseData = false, isSaveDb = false)
|
||||
public R<List<UserStarOrVisitorList>> page(StarQuery query, PageQuery pageQuery){
|
||||
// 查询粉丝列表,并且是第一页 就清空
|
||||
if(query.getType() != null && query.getType() == 2
|
||||
&& (pageQuery.getPageNum() == null || pageQuery.getPageNum() == 1)){
|
||||
userCountMapper.resetNewStarIncs(LoginHelper.getUserId());
|
||||
}
|
||||
Page<UserStarOrVisitorList> res = userFollowService.pageApp(pageQuery,query);
|
||||
return R.ok(res.getRecords());
|
||||
}
|
||||
|
||||
@@ -5,18 +5,21 @@ import com.ruoyi.cai.constant.CommonConstant;
|
||||
import com.ruoyi.cai.dto.app.query.StarOrVisitorReq;
|
||||
import com.ruoyi.cai.dto.app.query.VisitorQuery;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserStarOrVisitorList;
|
||||
import com.ruoyi.cai.mapper.UserCountMapper;
|
||||
import com.ruoyi.cai.service.UserVisitorService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -27,6 +30,8 @@ public class UserVisitorAppController {
|
||||
|
||||
@Autowired
|
||||
private UserVisitorService userVisitorService;
|
||||
@Resource
|
||||
private UserCountMapper userCountMapper;
|
||||
|
||||
// 除网络问题不返回异常。避免影响业务
|
||||
@PostMapping("/visitor")
|
||||
@@ -53,6 +58,11 @@ public class UserVisitorAppController {
|
||||
record.setCityId(CommonConstant.CITY_ID);
|
||||
}
|
||||
}
|
||||
// 查询粉丝列表,并且是第一页 就清空
|
||||
if(query.getType() != null && query.getType() == 2
|
||||
&& (pageQuery.getPageNum() == null || pageQuery.getPageNum() == 1)){
|
||||
userCountMapper.resetNewVisitorIncs(LoginHelper.getUserId());
|
||||
}
|
||||
return R.ok(records);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,14 @@ public class UserCount implements Serializable {
|
||||
*/
|
||||
@TableId(value = "user_id",type = IdType.INPUT)
|
||||
private Long userId;
|
||||
/**
|
||||
* 新增粉丝数
|
||||
*/
|
||||
private Long newFansCount;
|
||||
/**
|
||||
* 新增访客数
|
||||
*/
|
||||
private Long newVisitorCount;
|
||||
/**
|
||||
* 粉丝总数
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,15 @@ public interface UserCountMapper extends BaseMapper<UserCount> {
|
||||
|
||||
void starIncs(@Param("userId") Long userId, @Param("fansIncs") int fansIncs, @Param("followIncs") int followIncs);
|
||||
|
||||
void newStarIncs(@Param("userId") Long userId);
|
||||
|
||||
void resetNewStarIncs(@Param("userId") Long userId);
|
||||
|
||||
void visitorIncs(@Param("userId") Long userId, @Param("footIncs") int footIncs, @Param("visitorIncs") int visitorIncs);
|
||||
|
||||
void newVisitorIncs(Long userId);
|
||||
|
||||
void resetNewVisitorIncs(Long userId);
|
||||
|
||||
Page<UserCountAdminVo> pageAdmin(@Param("build") Page<Object> build, @Param("bo") UserCountAdminVo bo);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class UserCountServiceImpl extends ServiceImpl<UserCountMapper, UserCount
|
||||
public void star(Long fromUserId, Long toUserId) {
|
||||
baseMapper.starIncs(fromUserId,0,1);
|
||||
baseMapper.starIncs(toUserId,1,0);
|
||||
baseMapper.newStarIncs(toUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,6 +56,7 @@ public class UserCountServiceImpl extends ServiceImpl<UserCountMapper, UserCount
|
||||
public void visitor(Long fromUserId, Long toUserId) {
|
||||
baseMapper.visitorIncs(fromUserId,1,0);
|
||||
baseMapper.visitorIncs(toUserId,0,1);
|
||||
baseMapper.newVisitorIncs(toUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="giveGiftCount" column="give_gift_count"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
<update id="newStarIncs">
|
||||
update cai_user_count
|
||||
set new_fans_count = new_fans_count + 1
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
<update id="newVisitorIncs">
|
||||
update cai_user_count
|
||||
set new_visitor_count = new_visitor_count + 1
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
<update id="visitorIncs">
|
||||
update cai_user_count
|
||||
set
|
||||
@@ -22,6 +32,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
visitor_count = visitor_count + #{visitorIncs}
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
<update id="resetNewStarIncs">
|
||||
update cai_user_count
|
||||
set new_fans_count = 0
|
||||
where user_id = #{userId} and new_fans_count > 0
|
||||
</update>
|
||||
<update id="resetNewVisitorIncs">
|
||||
update cai_user_count
|
||||
set new_visitor_count = 0
|
||||
where user_id = #{userId} and new_visitor_count > 0
|
||||
</update>
|
||||
<select id="starIncs">
|
||||
update cai_user_count
|
||||
set
|
||||
|
||||
Reference in New Issue
Block a user