|
@@ -24,6 +24,14 @@ export class PromotionLinkController {
|
|
|
|
|
|
|
|
async create(request: FastifyRequest<{ Body: CreatePromotionLinkBody }>, reply: FastifyReply) {
|
|
async create(request: FastifyRequest<{ Body: CreatePromotionLinkBody }>, reply: FastifyReply) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ const user = request.user
|
|
|
|
|
+ if (!user) {
|
|
|
|
|
+ return reply.code(403).send({ message: '用户未登录' })
|
|
|
|
|
+ }
|
|
|
|
|
+ if (user.role === UserRole.TEAM) {
|
|
|
|
|
+ const team = await this.teamService.findByUserId(user.id)
|
|
|
|
|
+ request.body.teamId = team.id
|
|
|
|
|
+ }
|
|
|
const promotionLink = await this.promotionLinkService.create(request.body)
|
|
const promotionLink = await this.promotionLinkService.create(request.body)
|
|
|
return reply.code(201).send(promotionLink)
|
|
return reply.code(201).send(promotionLink)
|
|
|
} catch (error) {
|
|
} catch (error) {
|