mirror of
https://github.com/ZeroCatDev/ClassworksKV.git
synced 2025-12-07 13:03:09 +00:00
feat: 更新设备列表接口,添加 namespace 字段;修改 token 设置名称的条件,支持家长类型
This commit is contained in:
parent
78843418de
commit
a1deb5e6e3
@ -584,6 +584,7 @@ router.get("/devices", jwtAuth, async (req, res, next) => {
|
||||
id: true,
|
||||
uuid: true,
|
||||
name: true,
|
||||
namespace: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
|
||||
@ -287,8 +287,8 @@ router.post(
|
||||
}
|
||||
|
||||
// 验证 token 类型是否为 student
|
||||
if (appInstall.deviceType !== 'student') {
|
||||
return next(errors.createError(403, "只有学生类型的 token 可以设置名称"));
|
||||
if (!['student','parent'].includes(appInstall.deviceType)) {
|
||||
return next(errors.createError(403, "只有学生和家长类型的 token 可以设置名称"));
|
||||
}
|
||||
|
||||
// 读取设备的 classworks-list-main 键值
|
||||
@ -326,7 +326,7 @@ router.post(
|
||||
// 更新 AppInstall 的 note 字段
|
||||
const updatedInstall = await prisma.appInstall.update({
|
||||
where: { id: appInstall.id },
|
||||
data: { note: name },
|
||||
data: { note: appInstall.deviceType === 'parent' ? `${name} 家长` : name },
|
||||
});
|
||||
|
||||
return res.json({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user