Commit 739a6e3f by 林永健

feat(follow): 新增当前员工关注数查询功能

- 在StoreFollowController中新增countStaffFollows接口,实现当前员工关注数API
- 在MerchantBiFollowMapper接口中添加根据员工UUID和业务类型统计关注数的方法
- 在Mapper XML中新增对应SQL查询语句,支持业务类型条件筛选
- 在MerchantBiFollowRemote及其实现类中新增countStaffFollows远程调用接口
- 在MerchantBiFollowService中实现countStaffFollows具体业务逻辑,包含参数校验和日志记录
- 优化部分日志提示内容,增强代码健壮性和易读性
1 parent dad6aa08
...@@ -52,4 +52,11 @@ public interface MerchantBiFollowRemote { ...@@ -52,4 +52,11 @@ public interface MerchantBiFollowRemote {
* @return 门店 ID -> 关注数 * @return 门店 ID -> 关注数
*/ */
RpcResponse<Map<Integer, Integer>> findFollowCounts(MerchantBiFollowReq request); RpcResponse<Map<Integer, Integer>> findFollowCounts(MerchantBiFollowReq request);
/**
* 查询当前员工关注数
* @param request 请求参数 (含 staffUuid, businessType)
* @return 关注数量
*/
RpcResponse<Integer> countStaffFollows(SceneBaseReq request);
} }
...@@ -56,4 +56,12 @@ public interface MerchantBiFollowMapper extends OreMapper<MerchantBiFollow> { ...@@ -56,4 +56,12 @@ public interface MerchantBiFollowMapper extends OreMapper<MerchantBiFollow> {
* 查询关注数大于等于指定值的记录 * 查询关注数大于等于指定值的记录
*/ */
List<MerchantBiFollow> findByMinFollowCount(@Param("minCount") Integer minCount); List<MerchantBiFollow> findByMinFollowCount(@Param("minCount") Integer minCount);
/**
* 根据员工 UUID 查询关注数量
* @param staffUuid 员工 UUID
* @param businessType 业务类型(可选)
* @return 关注数量
*/
Integer countFollowsByStaffUuid(@Param("staffUuid") String staffUuid, @Param("businessType") Byte businessType);
} }
...@@ -77,4 +77,14 @@ public class MerchantBiFollowRemoteImpl implements MerchantBiFollowRemote { ...@@ -77,4 +77,14 @@ public class MerchantBiFollowRemoteImpl implements MerchantBiFollowRemote {
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage()); return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
} }
} }
@Override
public RpcResponse<Integer> countStaffFollows(@RequestBody SceneBaseReq request) {
try {
return RpcResponse.success(followService.countStaffFollows(request));
} catch (Exception e) {
log.error("查询当前员工关注数异常", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
} }
...@@ -724,7 +724,7 @@ public class MerchantBiFollowService { ...@@ -724,7 +724,7 @@ public class MerchantBiFollowService {
*/ */
public Map<Integer, Integer> findFollowCounts(MerchantBiFollowReq request) { public Map<Integer, Integer> findFollowCounts(MerchantBiFollowReq request) {
if (CollectionUtils.isEmpty(request.getMerchantIds())) { if (CollectionUtils.isEmpty(request.getMerchantIds())) {
log.warn("批量查询关注数:门店ID为空"); log.warn("批量查询关注数:门店 ID 为空");
return Collections.emptyMap(); return Collections.emptyMap();
} }
...@@ -734,4 +734,21 @@ public class MerchantBiFollowService { ...@@ -734,4 +734,21 @@ public class MerchantBiFollowService {
request.getBusinessType(), request.getMerchantIds().size(), followCountMap.size()); request.getBusinessType(), request.getMerchantIds().size(), followCountMap.size());
return followCountMap; return followCountMap;
} }
/**
* 查询当前员工关注数
*/
public Integer countStaffFollows(SceneBaseReq req) {
if (StringUtils.isBlank(req.getLoginUserUuid())) {
log.warn("查询当前员工关注数:loginUserUuid 为空");
return 0;
}
long startMs = System.currentTimeMillis();
Byte businessType = req.getBizs() == null ? null : req.getBizs().byteValue();
Integer count = followMapper.countFollowsByStaffUuid(req.getLoginUserUuid(), businessType);
log.info("查询当前员工关注数完成:loginUserUuid={}, biz={}, count={}, 耗时={}ms",
req.getLoginUserUuid(), req.getBizs(), count, System.currentTimeMillis() - startMs);
return count == null ? 0 : count;
}
} }
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<select id="findFollowersByFollowIds" resultMap="BaseResultMap"> <select id="findFollowersByFollowIds" resultMap="BaseResultMap">
SELECT SELECT
follow_id, staff_name *
FROM dj_merchant_bi_follow_detail FROM dj_merchant_bi_follow_detail
WHERE follow_id IN WHERE follow_id IN
<foreach collection="followIds" item="id" open="(" separator="," close=")"> <foreach collection="followIds" item="id" open="(" separator="," close=")">
......
...@@ -132,4 +132,16 @@ ...@@ -132,4 +132,16 @@
WHERE follow_count >= #{minCount} WHERE follow_count >= #{minCount}
AND deleted_flag = 'N' AND deleted_flag = 'N'
</select> </select>
<select id="countFollowsByStaffUuid" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT f.merchant_id, f.business_type)
FROM dj_merchant_bi_follow f
INNER JOIN dj_merchant_bi_follow_detail d ON d.follow_id = f.id
WHERE d.staff_uuid = #{staffUuid}
AND f.deleted_flag = 'N'
AND d.deleted_flag = 'N'
<if test="businessType != null">
AND f.business_type = #{businessType}
</if>
</select>
</mapper> </mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!