Skip to content

Commit c5a336f

Browse files
committed
mod: remove patch tags and companies update feature
1 parent 33931eb commit c5a336f

File tree

24 files changed

+573
-1855
lines changed

24 files changed

+573
-1855
lines changed

app/api/company/route.ts

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@ import { z } from 'zod'
33
import { prisma } from '~/prisma'
44
import {
55
createCompanySchema,
6-
getCompanyByIdSchema,
7-
updateCompanySchema
6+
getCompanyByIdSchema
87
} from '~/validations/company'
9-
import {
10-
kunParseGetQuery,
11-
kunParsePostBody,
12-
kunParsePutBody
13-
} from '../utils/parseQuery'
8+
import { kunParseGetQuery, kunParsePostBody } from '../utils/parseQuery'
149
import { verifyHeaderCookie } from '~/middleware/_verifyHeaderCookie'
1510
import { getEnableOnlyCreatorCreateStatus } from '~/app/api/admin/setting/creator/getEnableOnlyCreatorCreateStatus'
1611

@@ -51,64 +46,6 @@ export const GET = async (req: NextRequest) => {
5146
return NextResponse.json(response)
5247
}
5348

54-
export const rewriteCompany = async (
55-
input: z.infer<typeof updateCompanySchema>
56-
) => {
57-
const {
58-
companyId,
59-
name,
60-
primary_language,
61-
introduction = '',
62-
logoLink = '',
63-
alias = [],
64-
official_website = [],
65-
parent_brand = []
66-
} = input
67-
68-
const existingCompany = await prisma.patch_company.findFirst({
69-
where: {
70-
OR: [{ name }, { alias: { has: name } }]
71-
}
72-
})
73-
if (existingCompany && existingCompany.id !== companyId) {
74-
return '这个会社已经存在了'
75-
}
76-
77-
const newCompany = await prisma.patch_company.update({
78-
where: { id: companyId },
79-
data: {
80-
name,
81-
introduction,
82-
logo: logoLink,
83-
alias,
84-
primary_language,
85-
official_website,
86-
parent_brand
87-
}
88-
})
89-
90-
return newCompany
91-
}
92-
93-
export const PUT = async (req: NextRequest) => {
94-
const input = await kunParsePutBody(req, updateCompanySchema)
95-
if (typeof input === 'string') {
96-
return NextResponse.json(input)
97-
}
98-
99-
const payload = await verifyHeaderCookie(req)
100-
if (!payload) {
101-
return NextResponse.json('用户未登录')
102-
}
103-
const { enableOnlyCreatorCreate } = await getEnableOnlyCreatorCreateStatus()
104-
if (enableOnlyCreatorCreate && payload.role < 2) {
105-
return NextResponse.json('网站正在遭受攻击, 目前仅允许创作者创建和更改项目')
106-
}
107-
108-
const response = await rewriteCompany(input)
109-
return NextResponse.json(response)
110-
}
111-
11249
export const createCompany = async (
11350
input: z.infer<typeof createCompanySchema>
11451
) => {

app/api/company/upload-logo/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export const uploadCompanyLogo = async (image: ArrayBuffer, id: number) => {
1717
await uploadImageToS3(`${bucketName}/logo.avif`, logoBuffer)
1818
}
1919

20-
export const POST = async (req: NextRequest) => {
20+
// @deprecated
21+
export const __POST = async (req: NextRequest) => {
2122
const input = await kunParseFormData(req, uploadLogoSchema)
2223
if (typeof input === 'string') {
2324
return NextResponse.json(input)

app/api/patch/introduction/company/route.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

app/api/patch/introduction/tag/route.ts

Lines changed: 0 additions & 88 deletions
This file was deleted.

app/api/tag/route.ts

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import { z } from 'zod'
22
import { NextRequest, NextResponse } from 'next/server'
3-
import {
4-
kunParseGetQuery,
5-
kunParsePostBody,
6-
kunParsePutBody
7-
} from '~/app/api/utils/parseQuery'
3+
import { kunParseGetQuery, kunParsePostBody } from '~/app/api/utils/parseQuery'
84
import { prisma } from '~/prisma/index'
95
import { verifyHeaderCookie } from '~/middleware/_verifyHeaderCookie'
10-
import {
11-
createTagSchema,
12-
getTagByIdSchema,
13-
updateTagSchema
14-
} from '~/validations/tag'
6+
import { createTagSchema, getTagByIdSchema } from '~/validations/tag'
157
import { getEnableOnlyCreatorCreateStatus } from '~/app/api/admin/setting/creator/getEnableOnlyCreatorCreateStatus'
168
import type { TagDetail } from '~/types/api/tag'
179

@@ -46,48 +38,6 @@ export const GET = async (req: NextRequest) => {
4638
return NextResponse.json(response)
4739
}
4840

49-
export const rewriteTag = async (input: z.infer<typeof updateTagSchema>) => {
50-
const { tagId, name, introduction = '', alias = [] } = input
51-
52-
const existingTag = await prisma.patch_tag.findFirst({
53-
where: {
54-
OR: [{ name }, { alias: { has: name } }]
55-
}
56-
})
57-
if (existingTag && existingTag.id !== tagId) {
58-
return '这个标签已经存在了'
59-
}
60-
61-
const newTag: TagDetail = await prisma.patch_tag.update({
62-
where: { id: tagId },
63-
data: {
64-
name,
65-
introduction,
66-
alias
67-
}
68-
})
69-
70-
return newTag
71-
}
72-
73-
export const PUT = async (req: NextRequest) => {
74-
const input = await kunParsePutBody(req, updateTagSchema)
75-
if (typeof input === 'string') {
76-
return NextResponse.json(input)
77-
}
78-
const payload = await verifyHeaderCookie(req)
79-
if (!payload) {
80-
return NextResponse.json('用户未登录')
81-
}
82-
const { enableOnlyCreatorCreate } = await getEnableOnlyCreatorCreateStatus()
83-
if (enableOnlyCreatorCreate && payload.role < 2) {
84-
return NextResponse.json('网站正在遭受攻击, 目前仅允许创作者创建和更改项目')
85-
}
86-
87-
const response = await rewriteTag(input)
88-
return NextResponse.json(response)
89-
}
90-
9141
export const createTag = async (input: z.infer<typeof createTagSchema>) => {
9242
const { name, introduction = '', alias = [] } = input
9343

components/company/CompanyHeader.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)