本文整理匯總了TypeScript中eta-lib.person類的典型用法代碼示例。如果您正苦於以下問題:TypeScript person類的具體用法?TypeScript person怎麽用?TypeScript person使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了person類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: fetchResults
private fetchResults(req: express.Request, res: express.Response, callback: (env: { [key: string]: any }) => void): void {
eta.person.getByID(req.body.student, (person: eta.Person) => {
if (!person) {
callback({ errcode: eta.http.InternalError });
return;
}
let sectionSql: string = "AND Section.id = ?";
let params: string[] = [req.body.student, eta.term.getCurrent().id];
if (req.body.section) {
params.push(req.body.section);
}
let sql: string = `
SELECT
GROUP_CONCAT(DISTINCT CONCAT(Course.subject, ' ', Course.number) ORDER BY Course.subject, Course.number SEPARATOR ', ') AS "0",
DATE_FORMAT(Visit.timeIn, '%c/%e/%Y') AS "1",
LOWER(TIME_FORMAT(Visit.timeIn, '%l:%i %p')) AS "2",
IFNULL(
LOWER(TIME_FORMAT(Visit.timeOut, '%l:%i %p')),
'N/A'
) AS "3",
IFNULL(
ROUND(TIME_TO_SEC(TIMEDIFF(Visit.timeOut, Visit.timeIn)) / 3600, 2),
'0.00'
) AS "4"
FROM
Visit
RIGHT JOIN Section ON
Visit.section REGEXP Section.id
RIGHT JOIN Course ON
Section.course = Course.id
WHERE
Visit.student = ? AND
Visit.term = ?
${req.body.section ? sectionSql : ""}
GROUP BY Visit.timeIn`;
eta.db.query(sql, params, (err: eta.DBError, rows: any[]) => {
if (err) {
eta.logger.dbError(err);
callback({ errcode: eta.http.InternalError });
return;
}
callback({
"raw": JSON.stringify({
"firstName": person.firstName,
"lastName": person.lastName,
"visits": rows
})
});
});
});
}
示例2: callback
eta.section.getByProfessor(req.session["userid"], (rawSections: eta.Section[]) => {
if (!rawSections) {
callback({ errcode: eta.http.InternalError });
return;
}
let sections: eta.Section[] = eta.section.removePrevious(rawSections, eta.term.getCurrent().id);
if (sections.length === 0) { // no sections at all or no current sections
res.redirect("/track/index");
return;
}
sections.sort(eta.section.sort);
eta.person.getByID(req.session["userid"], (person: eta.Person) => {
if (!person) {
callback({ errcode: eta.http.InternalError });
return;
}
callback({
"name": person.firstName + " " + person.lastName,
"sections": sections
});
});
});
示例3: callback
eta.db.query(sql, [eta.term.getCurrent().id, req.session["userid"]], (err: eta.DBError, rows: any[]) => {
if (err) {
eta.logger.dbError(err);
callback({ errcode: eta.http.InternalError });
return;
}
let totalHours: number = 0;
for (let i: number = 0; i < rows.length; i++) {
totalHours += rows[i].totalHours;
}
eta.person.getByID(req.session["userid"], (person: eta.Person) => {
if (!person) {
callback({ errcode: eta.http.InternalError });
return;
}
callback({
"visits": rows,
"name": person.firstName + " " + person.lastName,
"totalHours": totalHours.toFixed(2)
});
});
});
示例4: callback
eta.db.query(sql, [], (err: eta.DBError, rows: any[]) => {
if (err) {
eta.logger.dbError(err);
callback({ errcode: eta.http.InternalError });
return;
}
eta.person.getByID(req.session["userid"], (person: eta.Person) => {
if (!person) {
// this person doesn't exist
eta.logger.warn("Person " + req.session["userid"] + " does not exist.");
callback({ errcode: eta.http.InternalError });
return;
}
callback({
"isAvailable": rows.length != 0,
"firstName": person.firstName,
"lastName": person.lastName,
"error": req.query.error,
"success": req.query.success,
"positions": rows
});
});
});