2024年大数据最全用户积分和积分排行榜功能微服务实现_积分排行榜软件架构,2024年最新高级大数据开发都应该知道

   日期:2024-12-26    作者:vuuyk 移动:http://oml01z.riyuangf.com/mobile/quote/52776.html

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化

2024年大数据最全用户积分和积分排行榜功能微服务实现_积分排行榜软件架构,2024年最新高级大数据开发都应该知道

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化资料的朋友,可以戳这里获取

 
 

server:
port: 7006 # 端口

spring:
application:
name: ms-points # 应用名

datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/seckill?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useUnicode=true&useSSL=false

redis:
port: 6379
host: localhost
timeout: 3000
password: 123456
database: 2

swagger:
base-package: com.zjq.points
title: 积分功能微服务API接口文档

eureka:
instance:
prefer-ip-address: true
instance-id: {server.port}
client:
service-url:
defaultZone: http://localhost:7000/eureka/

service:
name:
ms-oauth-server: http://ms-oauth2-server/
ms-users-server: http://ms-users/

mybatis:
configuration:
map-underscore-to-camel-case: true # 开启驼峰映射

logging:
pattern:
console: ‘%d{HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n’

 

package com.zjq.points.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.util.Collections;


@Configuration
public class RestTemplateConfiguration {

 

}

 

package com.zjq.points.config;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;


@Configuration
public class RedisTemplateConfiguration {

 

* redisTemplate 序列化使用的jdkSerializeable, 存储二进制字节码, 所以自定义序列化类
*
* @param redisConnectionFactory
* @return
*/
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);

 

}

 


@Getter
@Setter
public class UserPoints extends BaseModel {

 

}

 
 

* 添加积分
*
* @param userId 用户ID
* @param points 积分
* @param types 类型 0=签到,1=关注好友,2=添加Feed,3=添加商户评论
* @return
*/
@PostMapping
public ResultInfo addPoints(@RequestParam(required = false) Integer userId,
@RequestParam(required = false) Integer points,
@RequestParam(required = false) Integer types) {
userPointsService.addPoints(userId, points, types);
return ResultInfoUtil.buildSuccess(request.getServletPath(), points);
}

 
 

* 添加积分
*
* @param userId 用户ID
* @param points 积分
* @param types 类型 0=签到,1=关注好友,2=添加Feed,3=添加商户评论
*/
@Transactional(rollbackFor = Exception.class)
public void addPoints(Integer userId, Integer points, Integer types) {
// 基本参数校验
AssertUtil.isTrue(userId == null || userId < 1, “用户不能为空”);
AssertUtil.isTrue(points == null || points < 1, “积分不能为空”);
AssertUtil.isTrue(types == null, “请选择对应的积分类型”);

 
 
 

* 添加积分
* @param userPoints 用户积分实体
*/
@Insert(“insert into t_user_points (fk_user_id, points, types, is_valid, create_date, update_date) " +
" values (#{fkUserId}, #{points}, #{types}, 1, now(), now())”)
void save(UserPoints userPoints);

 

spring:
application:
name: ms-gateway
cloud:
gateway:
discovery:
locator:
enabled: true # 开启配置注册中心进行路由功能
lower-case-service-id: true # 将服务名称转小写
routes:
# 积分服务路由
- id: ms-points
uri: lb://ms-points
predicates:
- Path=/points
@Getter
public enum PointTypesConstant {

 

}

 
 

* 添加用户积分
*
* @param count 连续签到次数
* @param signInUserId 登录用户id
* @return 获取的积分
*/
private int addPoints(int count, Integer signInUserId) {
// 签到1天送10积分,连续签到2天送20积分,3天送30积分,4天以上均送50积分
int points = 10;
if (count == 2) {
points = 20;
} else if (count == 3) {
points = 30;
} else if (count >= 4) {
points = 50;
}
// 调用积分接口添加积分
// 构建请求头
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
// 构建请求体(请求参数
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
body.add(“userId”, signInUserId);
body.add(“points”, points);
body.add(“types”, PointTypesConstant.sign.getType());
HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(body, headers);
// 发送请求
ResponseEntity result = restTemplate.postForEntity(pointsServerName,
entity, ResultInfo.class);
AssertUtil.isTrue(result.getStatusCode() != HttpStatus.OK, “登录失败!”);
ResultInfo resultInfo = result.getBody();
if (resultInfo.getCode() != ApiConstant.SUCCESS_CODE) {
// 失败了, 事物要进行回滚
throw new ParameterException(resultInfo.getCode(), resultInfo.getMessage());
}
return points;
}

 
 
 

SELECT
t1.fk_user_id AS id,
sum( t1.points ) AS total,
rank() over (ORDER BY sum( t1.points ) DESC) AS ranks,
t2.nickname,
t2.avatar_url
FROM
t_user_points t1
LEFT JOIN t_users t2 ON t1.fk_user_id = t2.id
WHERE
t1.is_valid = 1
AND t2.is_valid = 1
GROUP BY
t1.fk_user_id
ORDER BY
total DESC
LIMIT 20

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化资料的朋友,可以戳这里获取

T JOIN t_users t2 ON t1.fk_user_id = t2.id
WHERE
t1.is_valid = 1
AND t2.is_valid = 1
GROUP BY
t1.fk_user_id
ORDER BY
total DESC
LIMIT 20

[外链图片转存中…(img-WUi1O4d4-1715605814653)]
[外链图片转存中…(img-PX828xD2-1715605814653)]
[外链图片转存中…(img-SerqqnQw-1715605814654)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新


特别提示:本信息由相关用户自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


举报收藏 0评论 0
0相关评论
相关最新动态
推荐最新动态
点击排行
{
网站首页  |  关于我们  |  联系方式  |  使用协议  |  隐私政策  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  鄂ICP备2020018471号