28 lines
567 B
JavaScript
28 lines
567 B
JavaScript
|
"use strict";
|
||
|
const resToList = (res) => {
|
||
|
if (res == null || res == void 0) {
|
||
|
return null;
|
||
|
}
|
||
|
console.log("淑娟转换", res);
|
||
|
let list = res.map((e) => {
|
||
|
if (e.extField1 == null) {
|
||
|
e.extField1 = 0;
|
||
|
}
|
||
|
return {
|
||
|
username: e.username || "",
|
||
|
profilePicture: e.profilePicture || "",
|
||
|
score: e.extField1
|
||
|
};
|
||
|
});
|
||
|
list.sort((a, b) => b.score - a.score);
|
||
|
while (list.length < 3) {
|
||
|
list.push({
|
||
|
username: "",
|
||
|
profilePicture: "",
|
||
|
score: 0
|
||
|
});
|
||
|
}
|
||
|
return list;
|
||
|
};
|
||
|
exports.resToList = resToList;
|