-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
226 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* 调用接口,获取指定学生的数据 | ||
* @param id 学生ID | ||
* @returns | ||
*/ | ||
function getStudentByID(id: string): Promise<any> { | ||
// !模拟接口响应的数据 | ||
const student = { | ||
sid: id, | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
gender: 'male', | ||
age: '20', | ||
cid: 'c_12345', | ||
cName: 'Computer Science' | ||
} | ||
|
||
return Promise.resolve(student) | ||
} | ||
|
||
/** | ||
* 调用接口,获取全部学生的数据 | ||
* @returns | ||
*/ | ||
function getAll(): Promise<any> { | ||
// !模拟接口响应的数据 | ||
const student = { | ||
sid: 's_12345', | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
gender: 'male', | ||
age: '20', | ||
cid: 'c_12345', | ||
cName: 'Computer Science' | ||
} | ||
return Promise.resolve([student]) | ||
} | ||
|
||
export { getStudentByID, getAll } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* @module student.bll | ||
* @description 学生业务逻辑层 | ||
*/ | ||
import StudentDal from 'dal/student.dal' | ||
|
||
const { getAll, getDataById } = new StudentDal() | ||
|
||
export { getAll, getDataById } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @module student.dal | ||
* @description 学生数据访问层 | ||
*/ | ||
import Student from 'entities/student.entity' | ||
import { getAll, getStudentByID } from 'api/student.api' | ||
|
||
export default class StudentDal { | ||
constructor() {} | ||
|
||
// 根据ID获取学生信息 | ||
async getDataById(id: string): Promise<Student> { | ||
const student = await getStudentByID(id) | ||
const { sid, firstName, lastName, gender, age, cid, cName } = student | ||
return new Student(sid, firstName, lastName, gender, age, cid, cName) | ||
} | ||
|
||
// 根据获取全部学生信息 | ||
async getAll(): Promise<Student[]> { | ||
const students = await getAll() | ||
return students.map((student: any) => { | ||
const { sid, firstName, lastName, gender, age, cid, cName } = student | ||
return new Student(sid, firstName, lastName, gender, age, cid, cName) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export default class Student { | ||
sid: string | ||
fullName: string | ||
firstName: string | ||
lastName: string | ||
gender: string | ||
age: number | ||
cid: string | ||
cName: string | ||
|
||
constructor( | ||
sid: string, | ||
firstName: string, | ||
lastName: string, | ||
gender: string, | ||
age: number, | ||
cid: string, | ||
cName: string | ||
) { | ||
this.sid = sid | ||
this.firstName = firstName | ||
this.lastName = lastName | ||
this.fullName = firstName + ' ' + lastName | ||
this.gender = gender | ||
this.age = age | ||
this.cid = cid | ||
this.cName = cName | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<script setup lang="ts"> | ||
import { getAll } from 'bll/student.bll' | ||
import { ref, onMounted } from 'vue' | ||
let tableData = ref() | ||
onMounted(async () => { | ||
tableData.value = await getAll() | ||
}) | ||
</script> | ||
|
||
<template> | ||
<main> | ||
<table | ||
class="border-collapse w-full border border-slate-400 dark:border-slate-500 bg-white dark:bg-slate-800 text-sm shadow-sm" | ||
> | ||
<thead class="bg-slate-50 dark:bg-slate-700"> | ||
<tr> | ||
<th | ||
class="w-1/5 border border-slate-300 dark:border-slate-600 font-semibold p-4 text-slate-900 dark:text-slate-200 text-left" | ||
> | ||
Id | ||
</th> | ||
<th | ||
class="w-1/5 border border-slate-300 dark:border-slate-600 font-semibold p-4 text-slate-900 dark:text-slate-200 text-left" | ||
> | ||
姓名 | ||
</th> | ||
<th | ||
class="w-1/5 border border-slate-300 dark:border-slate-600 font-semibold p-4 text-slate-900 dark:text-slate-200 text-left" | ||
> | ||
年龄 | ||
</th> | ||
<th | ||
class="w-1/5 border border-slate-300 dark:border-slate-600 font-semibold p-4 text-slate-900 dark:text-slate-200 text-left" | ||
> | ||
性别 | ||
</th> | ||
<th | ||
class="w-1/5 border border-slate-300 dark:border-slate-600 font-semibold p-4 text-slate-900 dark:text-slate-200 text-left" | ||
> | ||
班级 | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="item in tableData" :key="item.id"> | ||
<td class="border border-slate-300 dark:border-slate-700 p-4 text-slate-500 dark:text-slate-400"> | ||
{{ item.sid }} | ||
</td> | ||
<td class="border border-slate-300 dark:border-slate-700 p-4 text-slate-500 dark:text-slate-400"> | ||
{{ item.fullName }} | ||
</td> | ||
<td class="border border-slate-300 dark:border-slate-700 p-4 text-slate-500 dark:text-slate-400"> | ||
{{ item.age }} | ||
</td> | ||
<td class="border border-slate-300 dark:border-slate-700 p-4 text-slate-500 dark:text-slate-400"> | ||
{{ item.gender }} | ||
</td> | ||
<td class="border border-slate-300 dark:border-slate-700 p-4 text-slate-500 dark:text-slate-400"> | ||
{{ item.cName }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</main> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
{ | ||
"extends": "@vue/tsconfig/tsconfig.dom.json", | ||
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"], | ||
"include": ["env.d.ts", "bll/", "dal/", "entities/", "api/", "src/**/*", "src/**/*.vue"], // 注意:通配规则,必须放在具体规则后面 | ||
"exclude": ["src/**/tests/*"], | ||
"compilerOptions": { | ||
"composite": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
"@/*": ["./src/*"], | ||
"dal/*": ["./dal/*"], | ||
"bll/*": ["./bll/*"], | ||
"entities/*": ["./entities/*"], | ||
"api/*": ["./api/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters