feat: 支持客户查询咨询详情
This commit is contained in:
1 parent
b299c313d1
commit
3186757d93
4 files changed
+46
-1
No files matched your search
@@ -497,6 +497,20 @@ export class CustomerInquirySubmissionController {
|
||||
return submissions.map((submission) => this.present(submission));
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
async get(@Req() request: FastifyRequest, @Param("id") id: string): Promise<unknown> {
|
||||
const identity = this.identity(request);
|
||||
const submission = await this.prisma.inquirySubmission.findFirst({
|
||||
where: { id, brandId: identity.brandId, customerSubject: identity.subject },
|
||||
include: {
|
||||
inquiryForm: { select: { name: true, purpose: true } },
|
||||
offering: { select: { id: true, name: true } },
|
||||
},
|
||||
});
|
||||
if (!submission) throw new NotFoundException("咨询记录不存在");
|
||||
return this.present(submission);
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Req() request: FastifyRequest,
|
||||
|
||||
@@ -534,6 +534,17 @@ test("admin can create and version an inquiry form", async () => {
|
||||
(item) => item.id === JSON.parse(submission.body).id,
|
||||
),
|
||||
);
|
||||
const customerSubmission = await request(
|
||||
`/customer/inquiry-submissions/${JSON.parse(submission.body).id}`,
|
||||
{ headers: { authorization: `Bearer ${customerToken}` } },
|
||||
);
|
||||
assert.equal(customerSubmission.statusCode, 200);
|
||||
assert.equal(JSON.parse(customerSubmission.body).customerSubject, undefined);
|
||||
const missingCustomerSubmission = await request(
|
||||
"/customer/inquiry-submissions/00000000-0000-0000-0000-000000000000",
|
||||
{ headers: { authorization: `Bearer ${customerToken}` } },
|
||||
);
|
||||
assert.equal(missingCustomerSubmission.statusCode, 404);
|
||||
const adminSubmissionsWithoutToken = await request("/admin/workspace/submissions");
|
||||
assert.equal(adminSubmissionsWithoutToken.statusCode, 401);
|
||||
const adminSubmissions = await request("/admin/workspace/submissions", {
|
||||
|
||||
Reference in new issue
Block a user