当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript section.getByID方法代码示例

本文整理汇总了TypeScript中eta-lib.section.getByID方法的典型用法代码示例。如果您正苦于以下问题:TypeScript section.getByID方法的具体用法?TypeScript section.getByID怎么用?TypeScript section.getByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eta-lib.section的用法示例。


在下文中一共展示了section.getByID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的eta-lib.section.getByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。