const Router = require('@koa/router')({ prefix: '/api' }) const Token = require('../token') const Scale = require('../controllers/scale') const Member = require('../controllers/member') const Message = require('../controllers/message') const Test = require('../controllers/test') const Department = require('../controllers/department') const School = require('../controllers/school') const SchoolYuyue = require('../controllers/schoolyuyue') const Upload = require('../controllers/upload') // const UIC = require('../controllers/uic') // const HITSZ = require('../controllers/hitsz') const routers = Router // 首页 .get('/', ctx => ctx.body = '

Hello API

' + new Date() + '

') // 登录/注册/客户端IP .post('/login', Member.Login) .post('/regist', Member.Regist) // 会员 .get('/member/:id(\\d+)', Member.GetInfo) .get('/member/:id/totestlist', Token.Verify, Member.ScaleListByDistr) .get('/member/:id/tested', Token.Verify, Test.List) .get('/member/mobile/exist', Member.MobileExist) .post('/member/:id(\\d+)', Member.ModifyInfo) .put('/member/:id/birthday', Member.Birthday) // 会员类型 .get('/department/allchildren', Department.AllChildren) // 学校 .get('/school', School.SchoolList) .all('/school/zixun', Token.Verify, SchoolYuyue.Zixun) .get('/school/yuyue-by-date', SchoolYuyue.YuyueByDate) .get('/school/yuyue-week-count', Token.Verify, SchoolYuyue.YuyueWeekCount) .all('/school/tuanfu', Token.Verify, SchoolYuyue.Tuanfu) .get('/school/last-zixun-feedback-exist', Token.Verify, SchoolYuyue.LastZixunFeedbackExist) .all('/school/yuyue-apply', Token.Verify, SchoolYuyue.YuyueApply) .post('/school/yuyue', Token.Verify, SchoolYuyue.AddYuyue) .get('/school/:id(\\d+)/consultant', SchoolYuyue.Consultant) .get('/school/yuyue-by-consultant', SchoolYuyue.YuyueByConsultant) .get('/school/:id/setting', School.Setting) .get('/school/:id/scalelist', School.ScaleList) .get('/school/:id/adminmenu', School.AdminMenu) .get('/school/:id/summary-count', School.SummaryCount) .get('/school/:id/number/exist', School.NumberExist) .get('/school/pub/test', School.Public.Test) .get('/school/pub/zx', School.Public.Zixun) .get('/school/pub/consultant', School.Public.Consultant) // 站内消息/手机短信 .get('/message/new', Message.New) .post('/message/mobilecode', Message.SendMobileCode) .put('/message/readed', Message.Readed) .post('/message/sms', Message.SMS) // 量表 .get('/lb/:id', Scale.Info) .get('/lb/:id/question', Scale.Question) // 测评 .post('/test/start', Token.Verify, Test.Start) // 北京师范大学-香港浸会大学联合国际学院 // .post('/uic/user-transfer', UIC.UserTransfer) // .get('/uic/user-notify', UIC.UserNotify) // .get('/uic/user-transfer-link', UIC.UserTransferLink) // .post('/uic/import', Token.Verify, UIC.Import) // 哈尔滨工业大学(深圳) // .get('/hitsz/total', HITSZ.Total) // .get('/hitsz/import', HITSZ.Import) // .get('/hitsz/number', HITSZ.GetNumber) // 文件上传 .post('/upload', Upload) .all('/(.*)', ctx => ctx.body = { code: -5, message: '[' + ctx.method.toLowerCase() + '][' + ctx.request.path + '] Not Found' }) module.exports = routers