Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 使部分接口返回用户数据 #15

Merged
merged 6 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/controller/DanmakuController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const emitDanmakuController = async (ctx: koaCtx, next: koaNext) => {
const emitDanmakuRequest: EmitDanmakuRequestDto = {
/** 非空 - KVID 视频 ID */
videoId: data.videoId,
/** 非空 - 用户 UUID */
uuid: data.uuid,
/** 非空 - 用户 UID */
uid: data.uid,
/** 非空 - 弹幕发送的时机,单位:秒(支持小数) */
time: data.time,
/** 非空 - 弾幕文本 */
Expand Down
4 changes: 4 additions & 0 deletions src/controller/DanmakuControllerDto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
type BasicDanmakuDto = {
/** 非空 - KVID 视频 ID */
videoId: number;
/** 非空 - 用户 UUID */
uuid: string;
/** 非空 - 用户 UID */
uid: number;
/** 非空 - 弹幕发送的时机,单位:秒(支持小数) */
time: number;
/** 非空 - 弾幕文本 */
Expand Down
2 changes: 2 additions & 0 deletions src/controller/VideoCommentControllerDto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ type VideoCommentIdDto = {
* 评论发送者的用户信息
*/
type CommentSenderUserInfo = {
/** 用户昵称 */
userNickname?: string;
/** 用户名 */
username?: string;
/** 用户头像的链接 */
Expand Down
2 changes: 1 addition & 1 deletion src/dbPool/schema/DanmakuSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DanmakuSchemaFactory {
/** KVID 视频 ID - 非空 */
videoId: { type: Number, required: true },
/** 弹幕发送者的的 UUID,关联用户安全集合的 UUID - 非空 */
UUID: { type: String, required: true },
uuid: { type: String, required: true },
/** 弹幕发送者的 UID - 非空 */
uid: { type: Number, required: true },
/** 弹幕发送的时机,单位:秒(支持小数) - 非空 */
Expand Down
8 changes: 5 additions & 3 deletions src/service/DanmakuService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const emitDanmakuService = async (emitDanmakuRequest: EmitDanmakuRequestD
try {
if (checkEmitDanmakuRequest(emitDanmakuRequest)) {
if ((await checkUserTokenService(uid, token)).success) {
const UUID = await getUserUuid(uid) // DELETE ME 这是一个临时解决方法,Cookie 中应当存储 UUID
if (!UUID) {
const uuid = await getUserUuid(uid) // DELETE ME 这是一个临时解决方法,Cookie 中应当存储 UUID
if (!uuid) {
console.error('ERROR', '发送弹幕失败,UUID 不存在', { uid })
return { success: false, message: '发送弹幕失败,UUID 不存在' }
}
Expand All @@ -31,7 +31,7 @@ export const emitDanmakuService = async (emitDanmakuRequest: EmitDanmakuRequestD
type Danmaku = InferSchemaType<typeof schemaInstance>
const nowDate = new Date().getTime()
const danmaku: Danmaku = {
UUID,
uuid,
uid,
...emitDanmakuRequest,
editDateTime: nowDate,
Expand Down Expand Up @@ -75,6 +75,8 @@ export const getDanmakuListByKvidService = async (getDanmakuByKvidRequest: GetDa

const select: SelectType<Danmaku> = {
videoId: 1,
uuid: 1,
uid: 1,
time: 1,
text: 1,
color: 1,
Expand Down
1 change: 1 addition & 0 deletions src/service/VideoCommentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const emitVideoCommentService = async (emitVideoCommentRequest: EmitVideo
_id: insertData2MongoDBResult.result?.[0]?._id?.toString(),
...videoComment,
userInfo: {
userNickname: videoCommentSenderUserInfoResult.userNickname,
username: videoCommentSenderUserInfoResult.username,
avatar: videoCommentSenderUserInfoResult.avatar,
userBannerImage: videoCommentSenderUserInfoResult.userBannerImage,
Expand Down
Loading