Skip to content

Commit

Permalink
Merge pull request #15 from 1321928757/liushijie-240514-elastic-client
Browse files Browse the repository at this point in the history
Liushijie 240514 elastic client
  • Loading branch information
1321928757 committed May 17, 2024
2 parents afc021b + 672dbd7 commit 0282cc8
Show file tree
Hide file tree
Showing 22 changed files with 169 additions and 166 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- ✅获奖API的完善,用户可查看获奖记录
- ✅完善保底策略【为每个用户维护保底计数器,保底后清空计数器】
- ✅Web添加奖品详细信息,概率等信息的展示
- ✅实现活动最近获奖记录展示榜【分库分表的聚合操作,整合ES】(前端还没写,找个时间补上)
- ✅实现活动最近获奖记录展示榜【分库分表的聚合操作,整合ES】

看这里!!!!!定时任务选用的xxl-job,但原版滥用xxl-job,存在多端口问题,每个服务的定时任务执行器都需要占用一个端口,当我们部署到类似与docker的容器中时,如果两个服务
执行器占用的端口一样就会产生端口冲突问题,我们需要主动为他们分配不同的端口,这非常不利于我们服务的水平扩容,所以我这里找了一个老哥修改的版本https://github.com/kdyzm/xxl-job
Expand Down Expand Up @@ -63,12 +63,14 @@ yarn run dev

活动主界面
电脑端网页效果
![](https://img-blog.csdnimg.cn/direct/7de9e313b6714ff295a3b84f5f587e09.png)
![](https://github.com/1321928757/static-resources/blob/main/PC1.png?raw=true)
![](https://github.com/1321928757/static-resources/blob/main/PC2.png?raw=true)

移动端网页效果
![](https://img-blog.csdnimg.cn/direct/385be76b39504e6a8411452edbd96baf.png)
![](https://img-blog.csdnimg.cn/direct/4cff95ebde68493699ad38a0a8aedf96.png)
![](https://img-blog.csdnimg.cn/direct/f0ae21b949b348b789c4ce72013bb89c.png)
![](https://github.com/1321928757/static-resources/blob/main/PE1.jpg?raw=true)
前端获奖记录展示没有找到合适的组件(有一个上下滚动展示的,但是太吃性能了,就换成这个横向滚动库了),效果貌似也还行?
![](https://github.com/1321928757/static-resources/blob/main/PE2.jpg?raw=true)
![](https://github.com/1321928757/static-resources/blob/main/PE3.jpg?raw=true)


## 🫧项目架构
Expand Down
2 changes: 1 addition & 1 deletion big-market-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ spring:
config:
name: big-market-app
profiles:
active: local
active: cloud
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void saveUserAwardRecord(UserAwardRecordEntity userAwardRecordEntity) {
syncRecordMessage.setAwardTitle(userAwardRecordEntity.getAwardTitle());
syncRecordMessage.setAwardTime(userAwardRecordEntity.getAwardTime());
syncRecordMessage.setOrderId(userAwardRecordEntity.getOrderId());
syncRecordMessage.setOrderId(userAwardRecordEntity.getOrderId());
syncRecordMessage.setActivityId(userAwardRecordEntity.getActivityId());
BaseEvent.EventMessage<SyncAwardRecordEvent.SyncRecordMessage> syncRecordMessageEventMessage = syncAwardRecordEvent.buildEventMessage(syncRecordMessage);

// 3.构建发货消息任务对象
Expand Down
1 change: 0 additions & 1 deletion big-market-infrastructure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.25</version>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import cn.bugstack.infrastructure.persistent.doc.UserAwardRecordDoc;
import cn.bugstack.infrastructure.persistent.po.Task;
import cn.bugstack.infrastructure.persistent.po.UserAwardRecord;
import cn.bugstack.infrastructure.persistent.redis.IRedisService;
import cn.bugstack.middleware.db.router.strategy.IDBRouterStrategy;
import cn.bugstack.types.enums.ResponseCode;
import cn.bugstack.types.exception.AppException;
import cn.bugstack.types.model.PageData;
import cn.hutool.core.util.DesensitizedUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DuplicateKeyException;
Expand Down Expand Up @@ -160,7 +160,15 @@ public List<UserAwardRecordEntity> queryLastestAwardingRecord(Long activityId, i
// 1.查询数据
List<UserAwardRecordDoc> userAwardRecordDocs = userAwardRecordIndex.queryLastestDocByActivityId(activityId, count);

// 2.数据转换,使用hutool工具对用户id脱敏,页可以引入缓存+定时任务来优化性能,但是及时性没有直接查询好
// 2.使用hutool工具对用户id脱敏,可以引入缓存+定时任务来优化性能,但是及时性没有直接查询好
for (UserAwardRecordDoc userAwardRecordDoc : userAwardRecordDocs) {
// 从第七位开始截取 TODO 这里暂时硬编码了,微信的openid很长,前六位相等,所以截取七位以后的,可以根据系统用户id情况改写这个
String userid = StrUtil.subSuf(userAwardRecordDoc.getUserId(), 7);
// 数据脱敏
userAwardRecordDoc.setUserId(DesensitizedUtil.idCardNum(userid, 5, 5));
}

// 3.数据转换
return userAwardRecordDocs.stream().map(userAwardRecordDoc -> UserAwardRecordEntity.builder()
.userId(userAwardRecordDoc.getUserId())
.awardTitle(userAwardRecordDoc.getAwardTitle())
Expand Down
21 changes: 0 additions & 21 deletions docs/dev-ops/app/docker-compose-1.0.yml

This file was deleted.

20 changes: 0 additions & 20 deletions docs/dev-ops/app/start.sh

This file was deleted.

1 change: 0 additions & 1 deletion docs/dev-ops/app/stop.sh

This file was deleted.

99 changes: 0 additions & 99 deletions docs/dev-ops/environment/docker-compose.yml

This file was deleted.

2 changes: 0 additions & 2 deletions docs/dev-ops/environment/redis/redis.conf

This file was deleted.

3 changes: 1 addition & 2 deletions docs/web/big-market-vue3/.env.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
VITE_MODE_NAME=development
VITE_API_HOST= "http://localhost:80"
# VITE_API_HOST='http://154.201.80.213:11111'
VITE_API_HOST= "http://localhost:11111"
2 changes: 1 addition & 1 deletion docs/web/big-market-vue3/.env.product
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_MODE_NAME=production
VITE_API_HOST='http://154.201.80.213:11111'
VITE_API_HOST='http://服务ip:服务端口'
4 changes: 3 additions & 1 deletion docs/web/big-market-vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"pinia-plugin-persistedstate": "^3.2.1",
"sass": "^1.75.0",
"vue": "^3.2.47",
"vue-router": "^4.2.2"
"vue-router": "^4.2.2",
"vue3-marquee": "^4.2.0",
"vue3-seamless-scroll": "^2.0.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.1.0",
Expand Down
5 changes: 5 additions & 0 deletions docs/web/big-market-vue3/src/api/raffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ export const userSignUp = () => {
// 分页查询用户的获奖记录
export const queryPageAwardRecord = (pageRequest) => {
return axiosClient.post(`/api/v1/raffle/award/query_page_award_record`, pageRequest)
}

// 查询活动下最新的获奖记录,展示用
export const queryLatestAwardRecord = (request) => {
return axiosClient.post(`/api/v1/raffle/award/query_activity_award_record`, request)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script setup>
import { ref } from "vue";
import { Vue3Marquee } from 'vue3-marquee'
import {formatDate} from '@/utils/time.js'
const isScroll = ref(false)
const prop = defineProps({
latestAwardRecords: Array,
});
setTimeout(() => {
isScroll.value = true
}, 2000)
</script>

<template>
<div>
<Vue3Marquee :list="list" class="scroll" :duration="70">
<div class="item" :isWatch="true" v-for="(awardRecord, index) in prop.latestAwardRecords" :key="index">
<span>用户{{ awardRecord.userId }}在{{ formatDate(awardRecord.awardTime) }}抽取到了奖品【{{awardRecord.awardTitle}}】</span>
</div>
</Vue3Marquee>
</div>
</template>

<style scoped>
.scroll {
width: 100%;
overflow: hidden;
color: gray;
}
.scroll .item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 3px 0;
margin-right: 20px;
}
</style>
Loading

0 comments on commit 0282cc8

Please sign in to comment.