feat: initial commit with Nuxt 3 student management system
- Add Nuxt 3 + Prisma + SQLite full-stack setup - Add student CRUD API with batch import/export - Add stats dashboard with gender/class distribution - Add target community settings feature - Add Docker deployment support (Dockerfile + docker-compose) - Add README with development and deployment instructions
This commit is contained in:
10
server/api/settings/index.get.ts
Normal file
10
server/api/settings/index.get.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { prisma } from '~/server/utils/prisma'
|
||||
|
||||
export default defineEventHandler(async () => {
|
||||
const settings = await prisma.settings.findMany()
|
||||
const result: Record<string, string> = {}
|
||||
settings.forEach(s => {
|
||||
result[s.key] = s.value
|
||||
})
|
||||
return result
|
||||
})
|
||||
21
server/api/settings/save.post.ts
Normal file
21
server/api/settings/save.post.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { prisma } from '~/server/utils/prisma'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event)
|
||||
|
||||
if (body.key === 'targetCommunities' && Array.isArray(body.value)) {
|
||||
await prisma.settings.upsert({
|
||||
where: { key: body.key },
|
||||
create: { key: body.key, value: JSON.stringify(body.value) },
|
||||
update: { value: JSON.stringify(body.value) }
|
||||
})
|
||||
} else {
|
||||
await prisma.settings.upsert({
|
||||
where: { key: body.key },
|
||||
create: { key: body.key, value: body.value },
|
||||
update: { value: body.value }
|
||||
})
|
||||
}
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
Reference in New Issue
Block a user