當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript eta-lib.params類代碼示例

本文整理匯總了TypeScript中eta-lib.params的典型用法代碼示例。如果您正苦於以下問題:TypeScript params類的具體用法?TypeScript params怎麽用?TypeScript params使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了params類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: render

 public render(req: express.Request, res: express.Response, callback: (env: { [key: string]: any }) => void): void {
     if (!eta.params.test(req.body, ["student"])) {
         callback({ errcode: eta.http.InvalidParameters });
         return;
     }
     if (req.body.section) { // acting as professor
         eta.section.getByID(req.body.section, (section: eta.Section) => {
             if (!section) {
                 callback({ errcode: eta.http.InternalError });
                 return;
             }
             // the prof isn't the one logged in
             if (section.professor != req.session["userid"]) {
                 callback({ errcode: eta.http.Forbidden });
                 return;
             }
             this.fetchResults(req, res, callback);
         });
     } else { // acting as athlete director
         eta.athlete.isDirector(req.session["userid"], (isAthleteDirector: boolean) => {
             if (isAthleteDirector === null) {
                 callback({ errcode: eta.http.InternalError });
                 return;
             }
             if (!isAthleteDirector) {
                 res.redirect("/track/index");
                 return;
             }
             this.fetchResults(req, res, callback);
         });
     }
 }
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:32,代碼來源:get-single.ts

示例2: render

 public render(req: express.Request, res: express.Response, callback: (env: { [key: string]: any }) => void): void {
     if (!eta.params.test(req.query, ["id"])) {
         callback({ errcode: eta.http.InvalidParameters });
         return;
     }
     eta.section.getByID(req.query.id, (section: eta.Section) => {
         if (!section) {
             callback({ errcode: eta.http.NotFound });
             return;
         }
         // the prof isn't the one logged in
         if (section.professor != req.session["userid"]) {
             callback({ errcode: eta.http.Forbidden });
             return;
         }
         let isPastWeek: boolean = !!req.query.isPastWeek;
         let pastWeekSql: string = `AND DATE(Visit.timeIn) >= (CURDATE() - INTERVAL 7 DAY)`;
         let sql: string = `
             SELECT
                 Person.id,
                 Person.firstName,
                 Person.lastName,
                 VisitCount.count AS visitCount,
                 VisitCount.duration AS visitDuration
             FROM
                 StudentSection
                     LEFT JOIN Person ON
                         StudentSection.student = Person.id
                     LEFT JOIN (
                         SELECT
                             Visit.student AS student,
                             COUNT(DISTINCT Visit.student, Visit.timeIn) AS count,
                             ROUND(SUM(TIME_TO_SEC(TIMEDIFF(Visit.timeOut, Visit.timeIn))) / 3600, 2) AS duration
                         FROM
                             Visit
                         WHERE
                             Visit.section REGEXP ?
                             ${isPastWeek ? pastWeekSql : ""}
                         GROUP BY Visit.student
                     ) VisitCount ON
                         StudentSection.student = VisitCount.student
             WHERE
                 StudentSection.section = ? AND
                 StudentSection.status = 'E'`;
         eta.db.query(sql, [req.query.id, req.query.id], (err: eta.DBError, rows: any[]) => {
             if (err) {
                 eta.logger.dbError(err);
                 callback({ errcode: eta.http.InternalError });
                 return;
             }
             callback({
                 "section": section,
                 "students": rows,
                 "isPastWeek": isPastWeek
             });
         });
     });
 }
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:58,代碼來源:section.ts

示例3: render

 public render(req: express.Request, res: express.Response, callback: (env: { [key: string]: any }) => void): void {
     if ((!eta.params.test(req.body, ["page", "name", "type"])) || ((!req.body.value && req.body.value !== "") && req.body.type != "boolean")) {
         callback({ errcode: eta.http.InvalidParameters });
         return;
     }
     if (req.body.type == "boolean") {
         req.body.value = !!req.body.value;
     }
     eta.logger.json(req.body);
     eta.setting.set(req.body.page, req.body.name, req.body.value, req.body.type, (success: boolean) => {
         eta.logger.trace("Setting set: " + success);
         eta.setting.init();
         if (req.body.shouldRedirect) {
             res.redirect("../edit/settings?lastPage=" + querystring.escape(req.body.page));
         } else {
             res.send(success.toString());
         }
     });
 }
開發者ID:crossroads-education,項目名稱:eta-sys,代碼行數:19,代碼來源:settings.ts

示例4: render

 public render(req: express.Request, res: express.Response, callback: (env: { [key: string]: any }) => void): void {
     if (!eta.params.test(req.body, ["name", "email", "phone", "subject", "message"])) {
         callback({ errcode: eta.http.InvalidParameters });
         return;
     }
     eta.mail.sendMail({
         "from": req.body.email,
         "to": "mathmac@iupui.edu",
         "subject": `[Website Comments] ${req.body.name}: ${req.body.subject}`,
         "text": `From: ${req.body.name}
                 Email: ${req.body.email}
                 Phone: ${req.body.phone}
                 Subject: ${req.body.subject}
                 Message:
                 ${req.body.message}`.replace(/    /g, "")
     }, (err: Error, info: nodemailer.SentMessageInfo) => {
         if (err) {
             eta.logger.warn("Could not send mail from " + req.body.email + ": " + err.message);
             res.redirect("/contact?error=" + querystring.escape("failed-to-send-email"));
             return;
         }
         res.redirect("/contact?success=true");
     });
 }
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:24,代碼來源:contact.ts

示例5: render

 public render(req: express.Request, res: express.Response, callback: (env: { [key: string]: any }) => void): void {
     if (!eta.params.test(req.body, ["start", "end"])) {
         callback({ errcode: eta.http.InvalidParameters });
         return;
     }
     let sql: string = `
         SELECT
             1 AS isExamJam,
             DATE(start) AS day
         FROM
             DateExamJam
         WHERE
             DATE(start) > DATE(?) AND
             DATE(start) < DATE(?)`;
     eta.db.query(sql, [req.body.start, req.body.end], (err: eta.DBError, examJamDays: any[]) => {
         if (err) {
             eta.logger.dbError(err);
             return callback({ errcode: eta.http.InternalError });
         }
         sql = `
             SELECT
                 1 AS isClosed,
                 date AS day
             FROM
                 DateClosed
             WHERE
                 date > DATE(?) AND
                 date < DATE(?)`;
         eta.db.query(sql, [req.body.start, req.body.end], (err: eta.DBError, rawDays: any[]) => {
             if (err) {
                 eta.logger.dbError(err);
                 callback({ errcode: eta.http.InternalError });
                 return;
             }
             let days: {
                 [date: string]: {
                     isExamJam: boolean;
                     isClosed: boolean;
                 }
             } = {};
             for (let i: number = 0; i < examJamDays.length; i++) {
                 rawDays.push(examJamDays[i]);
             }
             for (let i: number = 0; i < rawDays.length; i++) {
                 let day: string = eta.time.getStandardDate(rawDays[i].day);
                 if (!days[day]) {
                     days[day] = {
                         "isExamJam": false,
                         "isClosed": false
                     };
                 }
                 if (rawDays[i].isExamJam) {
                     days[day].isExamJam = true;
                 }
                 if (rawDays[i].isClosed) {
                     days[day].isClosed = true;
                 }
             }
             callback({
                 "raw": JSON.stringify(days)
             });
         });
     });
 }
開發者ID:crossroads-education,項目名稱:eta-front,代碼行數:64,代碼來源:get-calendar.ts


注:本文中的eta-lib.params類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。