mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-21 01:46:28 +08:00
core: use NumericArray to parse uids
This commit is contained in:
1 parent
38bee6415d
commit
4b48c0c164
3 files changed
+10
-2
No files matched your search
@@ -136,7 +136,7 @@ class DomainUserHandler extends ManageHandler {
|
||||
this.back();
|
||||
}
|
||||
|
||||
@param('uid', Types.Array)
|
||||
@param('uid', Types.NumericArray)
|
||||
@param('role', Types.String)
|
||||
async postSetUsers(domainId: string, uid: number[], role: string) {
|
||||
await domain.setUserRole(domainId, uid, role);
|
||||
|
||||
@@ -68,6 +68,7 @@ export interface Types {
|
||||
Time: Type,
|
||||
Range: (range: Array<string | number> | Dictionary<any>) => Type,
|
||||
Array: Type,
|
||||
NumericArray: Type,
|
||||
Set: Type,
|
||||
}
|
||||
|
||||
@@ -140,6 +141,13 @@ export const Types: Types = {
|
||||
if (v instanceof Array) return v;
|
||||
return v ? [v] : [];
|
||||
}, null],
|
||||
NumericArray: [(v) => {
|
||||
if (v instanceof Array) return v.map(Number);
|
||||
return v ? [Number(v)] : [];
|
||||
}, (v) => {
|
||||
if (v instanceof Array) return !v.map(Number).includes(NaN);
|
||||
return !Number.isNaN(+v);
|
||||
}],
|
||||
Set: [(v) => {
|
||||
if (v instanceof Array) return new Set(v);
|
||||
return v ? new Set([v]) : new Set();
|
||||
|
||||
Reference in new issue
Block a user