PHP项目

学生成绩管理系统

1、简介

  • 什么学校还教php,城大咯!

2、系统设计

在这里插入图片描述

3、数据库设计(sys_grade)

3.1、管理员表(sys_admin)

drop table sys_admin;

create table sys_admin
(
	`admin_id` int primary key auto_increment not null comment '主键自增',
	`admin_name` varchar(20) comment '管理员账号',
	`admin_nick` varchar(20) comment '管理员昵称',
	`admin_pwd` varchar(20) comment '管理员密码',
	`admin_phone` varchar(20) comment '管理员电话'
);

insert into sys_admin(`admin_name`,`admin_nick`,`admin_pwd`,`admin_phone`) values
('admin', '系统管理员', 'admin', '13377254691'),
('ruanjia', 'Ruanjia管理员', 'ruanjia', '13377254692'),
('test', '测试管理员', '123456', '13377254693')

select * from sys_admin;

3.2、教师表(sys_teacher)

drop table sys_teacher;

create table sys_teacher
(
	`teacher_id` int primary key auto_increment not null comment '主键(教师编号)',
    `teacher_pwd` varchar(32) not null comment '教师密码',
	`teacher_name` varchar(10) comment '教师名称',
	`teacher_phone` varchar(11) comment '教师电话'
);

insert into sys_teacher(`teacher_name`, `teacher_p`,`teacher_phone`) values
('刘日辉', '123456', '13766876555'),
('欧文辉', '123456', '13766876556'),
('秦  玉', '123456', '13766876557')

select * from sys_teacher;

3.3、学生表(sys_student)

drop table sys_student;

create table sys_student
(
	`student_id` int primary key auto_increment not null comment '主键',
	`student_number` varchar(10) not null comment '学号',
    `student_pwd` varchar(32) not null comment '密码',
	`student_name` varchar(10) not null comment '学生姓名',
	`professional_id` int not null comment '学生所属专业编号',
	`class` int not null comment '学生班级',
	`student_phone` varchar(11) not null comment '学生手机号码'
);

insert into sys_student(`student_number`, `student_name`, `professional_id`, `class`, `student_phone`)values
('2120180331', '蔡蔡一', 1, 1, '13377254691'),
('2120180332', '蔡蔡二', 1, 1, '13377254692'),
('2120180333', '蔡蔡三', 1, 1, '13377254693'),
('2120180334', '蔡蔡四', 1, 2, '13377254694'),
('2120180335', '蔡蔡五', 1, 3, '13377254695');

select * from sys_student;

3.4、院系表(sys_professional)

drop table sys_professional;

create table sys_professional
(
	`professional_id` int primary key auto_increment not null comment '主键',
	`professional_name` varchar(20) not null comment '院系\专业名称',
	`pid` varchar(3) not null comment '值为 0 标识为院系,其他代表院系专业',
	`professional_course` varchar(20) not null comment '院系\专业的课程'
); 

insert into sys_professional(`professional_name`, `pid`, `professional_course`) values
('计算机应用技术', '1', 'xxx'),
('信息工程学院', '0', ''),
('教育学院', '0', ''),
('软甲工程学院', '0', ''),
('商学院', '0', ''),
('汽车工程学院', '0', '')

select * from sys_professional;

3.5、课程表(sys_course)

drop table sys_course;

create table sys_course
(
	`course_id` int primary key auto_increment not null comment '主键',
	`course_name` varchar(20) not null comment '课程名称'
);

insert into sys_course(`course_name`) values
('PHP程序设计基础教程'),
('计算机网络原理'),
('计算机组成原理'),
('C++入门基础教程'),
('Spring 5 核心原理'),
('Spring Cloud Alibaba 微服务原理与实战')

select * from sys_course;

3.6、任课表(sys_ct)

drop table sys_ct;

create table sys_ct
(
	`ct_id` int primary key auto_increment not null comment '主键',
	`ct_time` char(10) not null comment '任课时间(例如:202201)',
	`course_id` int not null comment '课程编号',
	`professional_id` int not null comment '专业编号',
	`teacher_id` int not null comment '教师编号',
	`ct_student_time` varchar(4) not null comment '学生哪一届(例如:18届)'
)

insert into sys_ct(`ct_time`, `course_id`, `professional_id`, `teacher_id`, `ct_student_time`) values
('20220527', 1, 6, 1, '18届')

select * from sys_ct;

3.7、任课申请表(sys_audit_course)

drop table sys_audit_course;

create table sys_audit_course
(
	`audit_id` int primary key auto_increment not null comment '主键',
	`is_audit` varchar(1) not null comment '审核状态:0未审核,1审核通过,2审核未通过',
	`time` varchar(10) not null comment '任课时间',
	`course_id` int not null comment '课程编号',
	`professional_id` int not null comment '专业编号',
	`teacher_id` int not null comment '教师编号',
	`student_time` varchar(4) not null comment '那一届的学生',
	`audit_time` datetime not null comment '申请审核的时间'
);

insert into 

select * from sys_audit_course;

3.8、成绩表(sys_grade)

drop table sys_grade;

create table sys_grade
(
	`grade_id` int primary key auto_increment not null comment '主键',
	`ct_id` int not null comment '任课编号',
	`student_n` int not null comment '学生编号',
	`grade_value` int not null comment '成绩'
);

select * from sys_grade;

4、后台管理开发

4.1、需要使用的工具类

1、MySQL连接工具类
<!-- 数据库连接工具类 -->
<?php

/** MySQL连接工具类 */
class DBUtils
{
    private static $host = "mysql:dbname=sys_grade;host=127.0.0.1:3308";      /*主机地址*/
    private static $username = "root";  /*登录用户名*/
    private static $password = "";  /*密码*/

    /**
     * 查询操作
     *
     * @param $sql 执行SQL
     * @return array 数据列表
     */
    public static function selectAll($sql)
    {
        $result = self::db_connect() -> query($sql);
        $resAll = $result-> fetchAll();
        $result = null;//关闭连接
        return $resAll;
    }

    /**
     * 插入数据操作
     *
     * @param $sql 执行SQL
     * @return false|PDOStatement
     */
    public static function insert($sql)
    {
        $result = self::db_connect() -> exec($sql);
        $counts = $result;
        $result = null;//关闭连接
        return $counts;
    }

    /**
     * 删除操作
     *
     * @param $sql 执行SQL
     * @return false|PDOStatement
     */
    public static function delete($sql)
    {
        $result = self::db_connect() -> exec($sql);
        $counts = $result;
        $result = null;//关闭连接
        return $counts;
    }

    /**
     * 更新操作
     *
     * @param $sql 执行SQL
     * @return false|PDOStatement
     */
    public static function update($sql)
    {
        $result = self::db_connect() -> exec($sql);
        $counts = $result;
        $result = null;//关闭连接
        return $counts;
    }

    /**
     * 连接MySQL
     *
     * @return pdo
     */
    private static function db_connect()
    {
        return new pdo(self::$host,self::$username,self::$password);
    }

}
2、StringUtils工具类
<?php


class StringUtils
{
    private static $isEmpty = "";
    private static $isNull = null;

    /**
     * 校验字符串是否为空
     *
     * @param string $str 字符串
     * @return bool true/false
     */
    public static function isEmpty(string $str)
    {
        return self::isBlank($str) || self::$isEmpty == $str ? true : false;
    }

    /**
     * 校验对象是否为空
     *
     * @param string $str 字符串
     * @return bool true/false
     */
    public static function isBlank($obj)
    {
        return self::$isNull == $obj ? true : false;
    }

}

4.2、实体对象

1、管理员实体
<?php

/** 系统管理员 */
class sysAdmin
{

    /* 管理员编号 */
    private $adminId;
    /* 管理员账号 */
    private $adminName;
    /* 管理员昵称 */
    private $adminNick;
    /* 管理员密码 */
    private $adminPwd;
    /* 管理员手机号码 */
    private $adminPhone;

    /**
     * sysAdmin constructor.
     * @param $adminId
     * @param $adminName
     * @param $adminNick
     * @param $adminPwd
     * @param $adminPhone
     */
    public function __construct($adminId, $adminName, $adminNick, $adminPwd, $adminPhone)
    {
        $this->adminId = $adminId;
        $this->adminName = $adminName;
        $this->adminNick = $adminNick;
        $this->adminPwd = $adminPwd;
        $this->adminPhone = $adminPhone;
    }

    /**
     * @return mixed
     */
    public function getAdminId()
    {
        return $this->adminId;
    }

    /**
     * @param mixed $adminId
     */
    public function setAdminId($adminId): void
    {
        $this->adminId = $adminId;
    }

    /**
     * @return mixed
     */
    public function getAdminName()
    {
        return $this->adminName;
    }

    /**
     * @param mixed $adminName
     */
    public function setAdminName($adminName): void
    {
        $this->adminName = $adminName;
    }

    /**
     * @return mixed
     */
    public function getAdminNick()
    {
        return $this->adminNick;
    }

    /**
     * @param mixed $adminNick
     */
    public function setAdminNick($adminNick): void
    {
        $this->adminNick = $adminNick;
    }

    /**
     * @return mixed
     */
    public function getAdminPwd()
    {
        return $this->adminPwd;
    }

    /**
     * @param mixed $adminPwd
     */
    public function setAdminPwd($adminPwd): void
    {
        $this->adminPwd = $adminPwd;
    }

    /**
     * @return mixed
     */
    public function getAdminPhone()
    {
        return $this->adminPhone;
    }

    /**
     * @param mixed $adminPhone
     */
    public function setAdminPhone($adminPhone): void
    {
        $this->adminPhone = $adminPhone;
    }

    /**
     * 自定义 toString()
     * @return array
     */
    public function toString()
    {
        return
        [
            "adminId" => $this->adminId,
            "adminName" => $this->adminName,
            "adminNick" => $this->adminNick,
            "adminPwd" => $this->adminPwd,
            "adminPhone" => $this->adminPhone,
        ];
    }

}
2、教师实体
<?php

/** 教师表 */
class SysTeacher
{

    /* 教师编号 */
    private $teacherId;
    /* 教师名称 */
    private $teacherName;
    /* 教师密码 */
    private $teacherPwd;
    /* 教师手机号码 */
    private $teacherPhone;

    /**
     * SysTeacher constructor.
     * @param $teacherId
     * @param $teacherName
     * @param $teacherPwd
     * @param $teacherPhone
     */
    public function __construct($teacherId, $teacherName, $teacherPwd, $teacherPhone)
    {
        $this->teacherId = $teacherId;
        $this->teacherName = $teacherName;
        $this->teacherPwd = $teacherPwd;
        $this->teacherPhone = $teacherPhone;
    }

    /**
     * @return mixed
     */
    public function getTeacherId()
    {
        return $this->teacherId;
    }

    /**
     * @param mixed $teacherId
     */
    public function setTeacherId($teacherId): void
    {
        $this->teacherId = $teacherId;
    }

    /**
     * @return mixed
     */
    public function getTeacherName()
    {
        return $this->teacherName;
    }

    /**
     * @param mixed $teacherName
     */
    public function setTeacherName($teacherName): void
    {
        $this->teacherName = $teacherName;
    }

    /**
     * @return mixed
     */
    public function getTeacherPwd()
    {
        return $this->teacherPwd;
    }

    /**
     * @param mixed $teacherPwd
     */
    public function setTeacherPwd($teacherPwd): void
    {
        $this->teacherPwd = $teacherPwd;
    }

    /**
     * @return mixed
     */
    public function getTeacherPhone()
    {
        return $this->teacherPhone;
    }

    /**
     * @param mixed $teacherPhone
     */
    public function setTeacherPhone($teacherPhone): void
    {
        $this->teacherPhone = $teacherPhone;
    }

    /**
     * 自定义 toString()
     * @return array
     */
    public function toString()
    {
        return
        [
          "teacherId" => $this->teacherId,
          "teacherName" => $this->teacherName,
          "teacherPwd" => $this->teacherPwd,
          "teacherPhone" => $this->teacherPhone,
        ];
    }

}
3、学生实体
<?php

/** 学生实体 */
class SysStudent
{
    /** 主键 */
    private $studentId;
    /** 学号 */
    private $studentNumber;
    /** 密码 */
    private $studentPwd;
    /** 姓名 */
    private $studentName;
    /** 专业编号 */
    private $professionalId;
    /** 班级 */
    private $class;
    /** 手机号码 */
    private $studentPhone;

    /**
     * SysStudent constructor.
     * @param $studentId
     * @param $studentNumber
     * @param $studentPwd
     * @param $studentName
     * @param $professionalId
     * @param $class
     * @param $studentPhone
     */
    public function __construct($studentId, $studentNumber, $studentPwd, $studentName, $professionalId, $class, $studentPhone)
    {
        $this->studentId = $studentId;
        $this->studentNumber = $studentNumber;
        $this->studentPwd = $studentPwd;
        $this->studentName = $studentName;
        $this->professionalId = $professionalId;
        $this->class = $class;
        $this->studentPhone = $studentPhone;
    }

    /**
     * student对象属性映射sql
     *
     * @param array $data
     * @return array
     */
    public static function foreachStudent(array $data)
    {
        $user = [];
        foreach ($data as $time => $chi)
        {
            $sysStudent = new SysStudent
            (
                $chi['student_id'],
                $chi['student_number'],
                $chi['student_pwd'],
                $chi['student_name'],
                $chi['professional_id'],
                $chi['class'],
                $chi['student_phone']
            );
            $sysStudent = $sysStudent -> toString();
            array_push($user, $sysStudent);
        }
        return $user;
    }

    /**
     * @return mixed
     */
    public function getStudentId()
    {
        return $this->studentId;
    }

    /**
     * @param mixed $studentId
     */
    public function setStudentId($studentId): void
    {
        $this->studentId = $studentId;
    }

    /**
     * @return mixed
     */
    public function getStudentNumber()
    {
        return $this->studentNumber;
    }

    /**
     * @param mixed $studentNumber
     */
    public function setStudentNumber($studentNumber): void
    {
        $this->studentNumber = $studentNumber;
    }

    /**
     * @return mixed
     */
    public function getStudentPwd()
    {
        return $this->studentPwd;
    }

    /**
     * @param mixed $studentPwd
     */
    public function setStudentPwd($studentPwd): void
    {
        $this->studentPwd = $studentPwd;
    }

    /**
     * @return mixed
     */
    public function getStudentName()
    {
        return $this->studentName;
    }

    /**
     * @param mixed $studentName
     */
    public function setStudentName($studentName): void
    {
        $this->studentName = $studentName;
    }

    /**
     * @return mixed
     */
    public function getProfessionalId()
    {
        return $this->professionalId;
    }

    /**
     * @param mixed $professionalId
     */
    public function setProfessionalId($professionalId): void
    {
        $this->professionalId = $professionalId;
    }

    /**
     * @return mixed
     */
    public function getClass()
    {
        return $this->class;
    }

    /**
     * @param mixed $class
     */
    public function setClass($class): void
    {
        $this->class = $class;
    }

    /**
     * @return mixed
     */
    public function getStudentPhone()
    {
        return $this->studentPhone;
    }

    /**
     * @param mixed $studentPhone
     */
    public function setStudentPhone($studentPhone): void
    {
        $this->studentPhone = $studentPhone;
    }

    /**
     * 自定义 toString()
     * @return array
     */
    public function toString()
    {
        return
        [
            "studentId" => $this->studentId,
            "studentNumber" => $this->studentNumber,
            "studentPwd" => $this->studentPwd,
            "studentName" => $this->studentName,
            "professionalId" => $this->professionalId,
            "class" => $this->class,
            "studentPhone" => $this->studentPhone,
        ];
    }
}
4、院系实体
<?php

/** 院系表 */
class SysProfessional
{

    /* 院系编号 */
    private $professionalId;
    /* 院系名称 */
    private $professionalName;
    /* 0:代表是院系,其他代表是院系专业 */
    private $pid;
    /* 专业课程 */
    private $professionalCourse;

    /**
     * SysProfessional constructor.
     * @param $professionalId
     * @param $professionalName
     * @param $pid
     * @param $professionalCourse
     */
    public function __construct($professionalId, $professionalName, $pid, $professionalCourse)
    {
        $this->professionalId = $professionalId;
        $this->professionalName = $professionalName;
        $this->pid = $pid;
        $this->professionalCourse = $professionalCourse;
    }

    /**
     * @return mixed
     */
    public function getProfessionalId()
    {
        return $this->professionalId;
    }

    /**
     * @param mixed $professionalId
     */
    public function setProfessionalId($professionalId): void
    {
        $this->professionalId = $professionalId;
    }

    /**
     * @return mixed
     */
    public function getProfessionalName()
    {
        return $this->professionalName;
    }

    /**
     * @param mixed $professionalName
     */
    public function setProfessionalName($professionalName): void
    {
        $this->professionalName = $professionalName;
    }

    /**
     * @return mixed
     */
    public function getPid()
    {
        return $this->pid;
    }

    /**
     * @param mixed $pid
     */
    public function setPid($pid): void
    {
        $this->pid = $pid;
    }

    /**
     * @return mixed
     */
    public function getProfessionalCourse()
    {
        return $this->professionalCourse;
    }

    /**
     * @param mixed $professionalCourse
     */
    public function setProfessionalCourse($professionalCourse): void
    {
        $this->professionalCourse = $professionalCourse;
    }

    /**
     * 自定义 toString()
     * @return array
     */
    public function toString()
    {
        return
        [
            "professionalId" => $this->professionalId,
            "professionalName" => $this->professionalName,
            "pid" => $this->pid,
            "professionalCourse" => $this->professionalCourse,
        ];
    }

}
5、课程实体
<?php

/** 课程表 */
class SysCourse
{

    /* 课程编号 */
    private $courseId;
    /* 课程名称 */
    private $courseName;

    /**
     * SysCourse constructor.
     * @param $courseId
     * @param $courseName
     */
    public function __construct($courseId, $courseName)
    {
        $this->courseId = $courseId;
        $this->courseName = $courseName;
    }

    /**
     * @return mixed
     */
    public function getCourseId()
    {
        return $this->courseId;
    }

    /**
     * @param mixed $courseId
     */
    public function setCourseId($courseId): void
    {
        $this->courseId = $courseId;
    }

    /**
     * @return mixed
     */
    public function getCourseName()
    {
        return $this->courseName;
    }

    /**
     * @param mixed $courseName
     */
    public function setCourseName($courseName): void
    {
        $this->courseName = $courseName;
    }

    /**
     * 自定义 toString()
     * @return array
     */
    public function toString()
    {
        return
        [
            "courseId" => $this->courseId,
            "courseName" => $this->courseName
        ];
    }


}
6、任课实体
<?php

/** 任课表 */
class SysCt
{

    /* 任课编号 */
    private $ctId;
    /* 任课时间 */
    private $ctTime;
    /* 课程编号 */
    private $courseId;
    /* 专业编号 */
    private $professionalId;
    /* 教师编号 */
    private $teacherId;
    /* 学生哪一届(例如:18届) */
    private $ctStudentTime;

    /**
     * SysCt constructor.
     * @param $ctId
     * @param $ctTime
     * @param $courseId
     * @param $professionalId
     * @param $teacherId
     * @param $ctStudentTime
     */
    public function __construct($ctId, $ctTime, $courseId, $professionalId, $teacherId, $ctStudentTime)
    {
        $this->ctId = $ctId;
        $this->ctTime = $ctTime;
        $this->courseId = $courseId;
        $this->professionalId = $professionalId;
        $this->teacherId = $teacherId;
        $this->ctStudentTime = $ctStudentTime;
    }

    /**
     * @return mixed
     */
    public function getCtId()
    {
        return $this->ctId;
    }

    /**
     * @param mixed $ctId
     */
    public function setCtId($ctId): void
    {
        $this->ctId = $ctId;
    }

    /**
     * @return mixed
     */
    public function getCtTime()
    {
        return $this->ctTime;
    }

    /**
     * @param mixed $ctTime
     */
    public function setCtTime($ctTime): void
    {
        $this->ctTime = $ctTime;
    }

    /**
     * @return mixed
     */
    public function getCourseId()
    {
        return $this->courseId;
    }

    /**
     * @param mixed $courseId
     */
    public function setCourseId($courseId): void
    {
        $this->courseId = $courseId;
    }

    /**
     * @return mixed
     */
    public function getProfessionalId()
    {
        return $this->professionalId;
    }

    /**
     * @param mixed $professionalId
     */
    public function setProfessionalId($professionalId): void
    {
        $this->professionalId = $professionalId;
    }

    /**
     * @return mixed
     */
    public function getTeacherId()
    {
        return $this->teacherId;
    }

    /**
     * @param mixed $teacherId
     */
    public function setTeacherId($teacherId): void
    {
        $this->teacherId = $teacherId;
    }

    /**
     * @return mixed
     */
    public function getCtStudentTime()
    {
        return $this->ctStudentTime;
    }

    /**
     * @param mixed $ctStudentTime
     */
    public function setCtStudentTime($ctStudentTime): void
    {
        $this->ctStudentTime = $ctStudentTime;
    }

    /**
     * 自定义 toString()
     * @return array
     */
    public function toString()
    {
        return
        [
            "ctId" => $this->ctId,
            "ctTime" => $this->ctTime,
            "courseId" => $this->courseId,
            "professionalId" => $this->professionalId,
            "teacherId" => $this->teacherId,
            "ctStudentTime" => $this->ctStudentTime
        ];
    }

}
7、任课申请实体
<?php

/** 任课申请表 */
class SysAuditCourse
{

    /* 申请编号 */
    private $auditId;
    /* 审核状态:0未审核,1审核通过,2审核未通过 */
    private $isAudit;
    /* 任课时间 */
    private $time;
    /* 课程编号 */
    private $courseId;
    /* 专业编号 */
    private $professionalId;
    /* 教师编号 */
    private $teacherId;
    /* 那一届的学生 */
    private $studentTime;
    /* 申请时间 */
    private $auditTime;

    /**
     * SysAuditCourse constructor.
     * @param $auditId
     * @param $isAudit
     * @param $time
     * @param $courseId
     * @param $professionalId
     * @param $teacherId
     * @param $studentTime
     * @param $auditTime
     */
    public function __construct($auditId, $isAudit, $time, $courseId, $professionalId, $teacherId, $studentTime, $auditTime)
    {
        $this->auditId = $auditId;
        $this->isAudit = $isAudit;
        $this->time = $time;
        $this->courseId = $courseId;
        $this->professionalId = $professionalId;
        $this->teacherId = $teacherId;
        $this->studentTime = $studentTime;
        $this->auditTime = $auditTime;
    }

    /**
     * @return mixed
     */
    public function getAuditId()
    {
        return $this->auditId;
    }

    /**
     * @param mixed $auditId
     */
    public function setAuditId($auditId): void
    {
        $this->auditId = $auditId;
    }

    /**
     * @return mixed
     */
    public function getIsAudit()
    {
        return $this->isAudit;
    }

    /**
     * @param mixed $isAudit
     */
    public function setIsAudit($isAudit): void
    {
        $this->isAudit = $isAudit;
    }

    /**
     * @return mixed
     */
    public function getTime()
    {
        return $this->time;
    }

    /**
     * @param mixed $time
     */
    public function setTime($time): void
    {
        $this->time = $time;
    }

    /**
     * @return mixed
     */
    public function getCourseId()
    {
        return $this->courseId;
    }

    /**
     * @param mixed $courseId
     */
    public function setCourseId($courseId): void
    {
        $this->courseId = $courseId;
    }

    /**
     * @return mixed
     */
    public function getProfessionalId()
    {
        return $this->professionalId;
    }

    /**
     * @param mixed $professionalId
     */
    public function setProfessionalId($professionalId): void
    {
        $this->professionalId = $professionalId;
    }

    /**
     * @return mixed
     */
    public function getTeacherId()
    {
        return $this->teacherId;
    }

    /**
     * @param mixed $teacherId
     */
    public function setTeacherId($teacherId): void
    {
        $this->teacherId = $teacherId;
    }

    /**
     * @return mixed
     */
    public function getStudentTime()
    {
        return $this->studentTime;
    }

    /**
     * @param mixed $studentTime
     */
    public function setStudentTime($studentTime): void
    {
        $this->studentTime = $studentTime;
    }

    /**
     * @return mixed
     */
    public function getAuditTime()
    {
        return $this->auditTime;
    }

    /**
     * @param mixed $auditTime
     */
    public function setAuditTime($auditTime): void
    {
        $this->auditTime = $auditTime;
    }

    /**
     * 自定义 toString()
     *
     * @return array
     */
    public function toString()
    {
        return
        [
            "auditId" => $this->auditId,
            "isAudit" => $this->isAudit,
            "time" => $this->time,
            "courseId" => $this->courseId,
            "professionalId" => $this->professionalId,
            "teacherId" => $this->teacherId,
            "studentTime" => $this->studentTime,
            "auditTime" => $this->auditTime
        ];
    }

}
8、成绩实体
<?php

/** 成绩表 */
class SysGrade
{

    private $gradeId;
    private $ctId;
    private $studentId;
    private $gradeValue;

    /**
     * SysGrade constructor.
     * @param $gradeId
     * @param $ctId
     * @param $studentId
     * @param $gradeValue
     */
    public function __construct($gradeId, $ctId, $studentId, $gradeValue)
    {
        $this->gradeId = $gradeId;
        $this->ctId = $ctId;
        $this->studentId = $studentId;
        $this->gradeValue = $gradeValue;
    }

    /**
     * @return mixed
     */
    public function getGradeId()
    {
        return $this->gradeId;
    }

    /**
     * @param mixed $gradeId
     */
    public function setGradeId($gradeId): void
    {
        $this->gradeId = $gradeId;
    }

    /**
     * @return mixed
     */
    public function getCtId()
    {
        return $this->ctId;
    }

    /**
     * @param mixed $ctId
     */
    public function setCtId($ctId): void
    {
        $this->ctId = $ctId;
    }

    /**
     * @return mixed
     */
    public function getStudentId()
    {
        return $this->studentId;
    }

    /**
     * @param mixed $studentId
     */
    public function setStudentId($studentId): void
    {
        $this->studentId = $studentId;
    }

    /**
     * @return mixed
     */
    public function getGradeValue()
    {
        return $this->gradeValue;
    }

    /**
     * @param mixed $gradeValue
     */
    public function setGradeValue($gradeValue): void
    {
        $this->gradeValue = $gradeValue;
    }

    /**
     * 自定义 toString()
     *
     * @return array
     */
    public function toString()
    {
        return
        [
          "gradeId" => $this->gradeId,
          "ctId" => $this->ctId,
          "studentId" => $this->studentId,
          "gradeValue" => $this->gradeValue
        ];
    }

}
9、系统菜单实体

4.3、功能开发

1、登录接口开发
<?php
require('../result/ResultInfo.php');
require('../utils/DBUtils.php');
require('../utils/StringUtils.php');
require('../entity/SysStudent.php');
require('../entity/SysMenu.php');
require('../entity/SysTeacher.php');

/** 获取登录登录参数 */
$username = $_POST['username'];
$password = $_POST['password'];
$code = $_POST['code'];/* 0: 学生,1:老师 */

/** 系统登录功能(登录成功:返回用户菜单(老师或者学生)) */
function login($username, $password, $code)
{
    // 学生登录 0
    if (!StringUtils::isEmpty($username) && $code == "0")
    {
        $data = DBUtils::selectAll("select * from sys_student where student_number=$username limit 1");
        if (!StringUtils::isBlank($data))
        {
            $user = sysstudent::foreachStudent($data);
            $menus = sysmenu::getStudentMenuList();
            if (!StringUtils::isEmpty($password) && $user[0]['studentPwd'] == $password)
            {
                echo ResultInfo::ok([
                    "userInfo" => $user,
                    "menus" => $menus
                ]);
            } else
            {
                echo ResultInfo::error("密码错误!");
            }
        } else
        {
            echo ResultInfo::error("该学生【 $username 】不存在,请联系老师!");
        }
    }
    // 老师登陆 1
    else if (!StringUtils::isEmpty($username) && $code == "1")
    {
        $data = DBUtils::selectAll("select * from sys_teacher where teacher_id=$username");
        if (!StringUtils::isBlank($data))
        {
            $user = systeacher::foreachTeacher($data);
            $menus = sysmenu::getTeacherMenuList();
            if (!StringUtils::isEmpty($password) && $user[0]['teacherPwd'] == $password)
            {
                echo ResultInfo::ok([
                    "userInfo" => $user,
                    "menus" => $menus
                ]);
            } else
            {
                echo ResultInfo::error("密码错误!");
            }
        } else
        {
            echo ResultInfo::error("该教师【 $username 】不存在,请联系学校领导!");
        }
    }
    // 未知(抛异常)
    else
    {
        echo ResultInfo::error("系统异常,请联系管理员!");
    }
}

/* 调用登录函数 */
login($username,$password,$code);

5、前台管理开发

5.1、JS-JSON

// 对象转JSON
JSON.stringify()

// 字符串转JSON
JSON.parse()
  • 2
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值