ソースを参照

add getApplications

Starink 6 年 前
コミット
301bfd8ebb

+ 87 - 5
pages/admin/checkApplications.vue

@@ -1,16 +1,98 @@
 <template>
-  <div>
-
+  <div class="main-card__body" v-loading="pageLoading">
+    <h1 class="main-card__title">
+      认证审核
+    </h1>
+    <el-table
+      :data="applications"
+      stripe
+      height="400"
+    >
+      <el-table-column
+        fixed
+        type="index"
+        width="50">
+      </el-table-column>
+      <el-table-column
+        prop="realName"
+        label="姓名"
+        width="120">
+      </el-table-column>
+      <el-table-column
+        prop="organization"
+        label="所属单位"
+        width="120">
+      </el-table-column>
+      <el-table-column
+        prop="jobNumber"
+        label="工号"
+        width="120">
+      </el-table-column>
+      <el-table-column
+        prop="phone"
+        label="手机"
+        width="120">
+      </el-table-column>
+      <el-table-column
+        prop="email"
+        label="邮箱"
+        width="200">
+      </el-table-column>
+      <el-table-column
+        fixed="right"
+        label="操作"
+        width="100">
+        <template slot-scope="scope">
+          <el-button @click="pass(scope.row)" type="text" size="small">通过</el-button>
+          <el-button @click="reject(scope.row)" type="text" size="small">否决</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
   </div>
 </template>
 
 <script>
   export default {
     name: "checkApplications",
-    layout: 'admin'
+    layout: 'admin',
+    data(){
+      return{
+        applications: [],
+        pageLoading: true
+      }
+    },
+    mounted(){
+      this.getApplications();
+      this.pageLoading = false;
+    },
+    methods: {
+      getApplications(){
+        this.$api.$get('/admin/getApplications').then((res) =>
+          {
+            if(res.code === 0){
+              this.applications = res.data;
+            }else{
+              this.$message({
+                showClose: true,
+                message: res.message,
+                type: 'error'
+              });
+            }
+          }
+        ).catch((e)=>{
+          console.log(e);
+        });
+      },
+      pass(row){
+
+      },
+      reject(row){
+
+      }
+    }
   };
 </script>
 
-<style scoped>
-
+<style lang="scss" scoped>
+  @import '~/assets/css/person.scss';
 </style>

+ 25 - 0
server/controller/admin.js

@@ -0,0 +1,25 @@
+const teacherModel = require('../model/teacher');
+const Response = require('../util/response');
+const getTokenUser = require('../util/tokenProcessor');
+
+
+class AdminController {
+
+  static async getApplications(ctx){
+    let theUser = await getTokenUser(ctx);
+    if(theUser.role !== "ADMIN"){
+      ctx.status = 401;
+    }else{
+      let result = await teacherModel.getApplications();
+      if(result){
+        ctx.body = Response.success(result);
+      }else{
+        ctx.body = Response.failed("获取失败");
+      }
+    }
+
+  }
+}
+
+
+module.exports = AdminController;

+ 15 - 0
server/controller/teacher.js

@@ -35,6 +35,21 @@ class TeacherController {
       ctx.body = Response.failed("参数错误");
     }
   }
+
+  static async getApplications(ctx){
+    let theUser = await getTokenUser(ctx);
+    if(theUser.role !== "ADMIN"){
+      ctx.status = 401;
+    }else{
+      let result = await teacherModel.getApplications();
+      if(result){
+        ctx.body = Response.success(result);
+      }else{
+        ctx.body = Response.failed("获取失败");
+      }
+    }
+
+  }
 }
 
 

+ 6 - 0
server/model/teacher.js

@@ -39,6 +39,12 @@ class TeacherModel {
     return true;
   }
 
+  static async getApplications(){
+    return Teacher.findAll({
+      where: {state: 'identifying'}
+    });
+  }
+
 
 }
 

+ 3 - 0
server/routes/index.js

@@ -4,6 +4,7 @@ const CourseController = require('../controller/course');
 const OIDCController = require('../controller/oidc');
 const AuthController = require('../controller/auth');
 const TeacherController = require('../controller/teacher');
+const AdminController = require('../controller/admin');
 const router = new Router({prefix: '/api'});
 
 module.exports = () => {
@@ -19,6 +20,8 @@ module.exports = () => {
   router.post('/teacher/apply', TeacherController.apply);
   router.post('/teacher/reapply', TeacherController.reapply);
 
+  router.get('/admin/getApplications', AdminController.getApplications);
+
     router.get('/course/getMyCourses',  CourseController.getMyCourses);
     router.get('/course/getHotCourses',  CourseController.getHotCourses);