[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"article-public-dDLZGpA4":3,"public-project-articles-dDLZGpA4":16},{"id":4,"uuid":5,"project_id":4,"title":6,"content":7,"type":8,"status":9,"public_enabled":9,"views":10,"sort":11,"created_at":12,"updated_at":13,"project_title":14,"project_slug":15},26,"dDLZGpA4","09. 开发学生登录功能","\n# SQL\n\nstudent\n\n```sql\nCREATE TABLE `student` (\n  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',\n  `username` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '学号',\n  `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密码',\n  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名称',\n  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号',\n  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '邮箱',\n  `sex` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '性别',\n  `birth` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '生日',\n  `avatar` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '头像',\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;\n```\n\n# 开发后台\n\n设计一个父类 Account\n\n```java\npackage com.example.entity;\n\npublic class Account {\n    private String username;\n    private String password;\n    private String name;\n\n    public String getUsername() {\n        return username;\n    }\n\n    public void setUsername(String username) {\n        this.username = username;\n    }\n\n    public String getPassword() {\n        return password;\n    }\n\n    public void setPassword(String password) {\n        this.password = password;\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n}\n\n```\n\n让 Admin 和 Student 都继承这个父类\n\n注意在 admin 表和 student 表加一个新的字段：role\nstudent 表加新的字段\n![image.png](https:\u002F\u002Fcdn.nlark.com\u002Fyuque\u002F0\u002F2023\u002Fpng\u002F751015\u002F1700404388870-742e2e90-c9d8-4f51-a2db-a54ec4a79dec.png#averageHue=%23f9f8f7&clientId=ue4eb1b6b-af87-4&from=paste&height=159&id=ue8d5dad6&originHeight=199&originWidth=957&originalType=binary&ratio=1.25&rotation=0&showTitle=false&size=12671&status=done&style=none&taskId=u26e91587-3bcb-4856-a3bf-867851cafaa&title=&width=765.6)\nadmin 表加一个新的字段\n![image.png](https:\u002F\u002Fcdn.nlark.com\u002Fyuque\u002F0\u002F2023\u002Fpng\u002F751015\u002F1700404338614-26bad3ac-a8ad-4074-a328-48fb79859664.png#averageHue=%23f8f6f5&clientId=ue4eb1b6b-af87-4&from=paste&height=114&id=uaa854817&originHeight=142&originWidth=739&originalType=binary&ratio=1.25&rotation=0&showTitle=false&size=10318&status=done&style=none&taskId=uac970e8a-627a-4cb9-8814-7812d004fee&title=&width=591.2)\n\n完整的登录接口\n\n```java\n\u002F**\n * 登录接口\n *\u002F\n@PostMapping(\"\u002Flogin\")\npublic Result login(@RequestBody Account account) {\n    Account dbAccount;\n    if (RoleEnum.ADMIN.name().equals(account.getRole())) {  \u002F\u002F 管理员登录\n        dbAccount = adminService.login(account);\n    } else if (RoleEnum.STUDENT.name().equals(account.getRole())) {  \u002F\u002F 学生登录\n        dbAccount = studentService.login(account);\n    } else {\n        return Result.error(\"角色错误\");\n    }\n    return Result.success(dbAccount);\n}\n```\n\nStudentService 登录逻辑\n\n```java\n\u002F**\n * 登录\n *\u002F\npublic Account login(Account account) {\n    Account dbStudent = studentMapper.selectByUsername(account.getUsername());\n    if (dbStudent == null) {\n        \u002F\u002F 没有用户\n        throw new CustomException(\"账号或密码错误\");\n    }\n    \u002F\u002F 比较密码\n    if (!account.getPassword().equals(dbStudent.getPassword())) {\n        throw new CustomException(\"账号或密码错误\");\n    }\n    \u002F\u002F 登录成功\n    return dbStudent;\n}\n```\n\n测试\n![image.png](https:\u002F\u002Fcdn.nlark.com\u002Fyuque\u002F0\u002F2023\u002Fpng\u002F751015\u002F1700404691003-a67dc723-6e23-478d-ae5d-df1bd229f295.png#averageHue=%23fcf9f8&clientId=ue4eb1b6b-af87-4&from=paste&height=620&id=u1ebbb17f&originHeight=775&originWidth=1266&originalType=binary&ratio=1.25&rotation=0&showTitle=false&size=67041&status=done&style=none&taskId=u4863ec8f-9b8e-4f85-a384-55c28ae0c96&title=&width=1012.8)\n\n# Vue\n\n```vue\n\u003Cel-form :model=\"data.form\" ref=\"formRef\" :rules=\"rules\">\n  \u003Cel-form-item prop=\"username\">\n    \u003Cel-input prefix-icon=\"User\" v-model=\"data.form.username\" placeholder=\"请输入账号\" \u002F>\n  \u003C\u002Fel-form-item>\n  \u003Cel-form-item prop=\"password\">\n    \u003Cel-input show-password prefix-icon=\"Lock\" v-model=\"data.form.password\"  placeholder=\"请输入密码\" \u002F>\n  \u003C\u002Fel-form-item>\n  \u003Cel-form-item prop=\"role\">\n    \u003Cel-select style=\"width: 100%\" v-model=\"data.form.role\">\n      \u003Cel-option value=\"ADMIN\" label=\"管理员\">\u003C\u002Fel-option>\n      \u003Cel-option value=\"STUDENT\" label=\"学生\">\u003C\u002Fel-option>\n    \u003C\u002Fel-select>\n  \u003C\u002Fel-form-item>\n  \u003Cel-form-item>\n    \u003Cel-button type=\"primary\" style=\"width: 100%\" @click=\"login\">登 录\u003C\u002Fel-button>\n  \u003C\u002Fel-form-item>\n\u003C\u002Fel-form>\n```\n\n![image.png](https:\u002F\u002Fcdn.nlark.com\u002Fyuque\u002F0\u002F2023\u002Fpng\u002F751015\u002F1700405177253-0c681b04-acd4-46f2-a9c0-741865935d75.png#averageHue=%232d2b2b&clientId=ue4eb1b6b-af87-4&from=paste&height=99&id=udcdb58e6&originHeight=124&originWidth=674&originalType=binary&ratio=1.25&rotation=0&showTitle=false&size=9547&status=done&style=none&taskId=u5c2499c0-1336-4bcd-ad32-75dcdf7cb6e&title=&width=539.2)\n","coding",1,1019,27,"2024-04-16 02:36:20","2026-05-03 22:49:02","SpringBoot+Vue3的学生成绩管理系统","student-performance",{"project":17,"items":18},{"id":4,"title":14,"slug":15},[19,26,32,38,44,50,56,62,67,68,74,80,86,92,98,104],{"id":20,"uuid":21,"project_id":4,"title":22,"type":8,"status":9,"public_enabled":9,"views":23,"sort":24,"created_at":25,"updated_at":13,"project_title":14,"project_slug":15},18,"7r0zrxqF","01. 学生成绩管理系统介绍",3753,19,"2025-01-09 10:22:30",{"id":24,"uuid":27,"project_id":4,"title":28,"type":8,"status":9,"public_enabled":9,"views":29,"sort":30,"created_at":31,"updated_at":13,"project_title":14,"project_slug":15},"h5U5WN1A","02. 脚手架介绍",3957,20,"2025-01-09 10:22:49",{"id":30,"uuid":33,"project_id":4,"title":34,"type":8,"status":9,"public_enabled":9,"views":35,"sort":36,"created_at":37,"updated_at":13,"project_title":14,"project_slug":15},"aKzqZqzY","03. 实现登录功能",3607,21,"2024-04-16 02:36:48",{"id":36,"uuid":39,"project_id":4,"title":40,"type":8,"status":9,"public_enabled":9,"views":41,"sort":42,"created_at":43,"updated_at":13,"project_title":14,"project_slug":15},"xve1cq5m","04. 开发课程管理页面",1907,22,"2024-04-16 02:36:40",{"id":42,"uuid":45,"project_id":4,"title":46,"type":8,"status":9,"public_enabled":9,"views":47,"sort":48,"created_at":49,"updated_at":13,"project_title":14,"project_slug":15},"KUfmmtjB","05. 开发课程分页查询接口",1303,23,"2024-04-16 02:36:36",{"id":48,"uuid":51,"project_id":4,"title":52,"type":8,"status":9,"public_enabled":9,"views":53,"sort":54,"created_at":55,"updated_at":13,"project_title":14,"project_slug":15},"5aLIaQCP","06. 开发课程前后台数据对接",1040,24,"2024-04-16 02:36:32",{"id":54,"uuid":57,"project_id":4,"title":58,"type":8,"status":9,"public_enabled":9,"views":59,"sort":60,"created_at":61,"updated_at":13,"project_title":14,"project_slug":15},"dTwkIyqR","07. 开发课程新增和编辑功能",990,25,"2024-04-16 02:36:27",{"id":60,"uuid":63,"project_id":4,"title":64,"type":8,"status":9,"public_enabled":9,"views":65,"sort":4,"created_at":66,"updated_at":13,"project_title":14,"project_slug":15},"NlyNo5n8","08. 开发课程管理删除功能",666,"2024-04-16 02:36:23",{"id":4,"uuid":5,"project_id":4,"title":6,"type":8,"status":9,"public_enabled":9,"views":10,"sort":11,"created_at":12,"updated_at":13,"project_title":14,"project_slug":15},{"id":11,"uuid":69,"project_id":4,"title":70,"type":8,"status":9,"public_enabled":9,"views":71,"sort":72,"created_at":73,"updated_at":13,"project_title":14,"project_slug":15},"5qCBv54l","10. 开发学生注册功能",811,28,"2024-04-16 02:36:15",{"id":72,"uuid":75,"project_id":4,"title":76,"type":8,"status":9,"public_enabled":9,"views":77,"sort":78,"created_at":79,"updated_at":13,"project_title":14,"project_slug":15},"smeYDA8N","11. 开发学生管理功能",1060,29,"2024-04-16 02:36:10",{"id":78,"uuid":81,"project_id":4,"title":82,"type":8,"status":9,"public_enabled":9,"views":83,"sort":84,"created_at":85,"updated_at":13,"project_title":14,"project_slug":15},"eji2Bt8v","12. 开发文件上传下载功能",914,30,"2024-04-16 02:36:07",{"id":84,"uuid":87,"project_id":4,"title":88,"type":8,"status":9,"public_enabled":9,"views":89,"sort":90,"created_at":91,"updated_at":13,"project_title":14,"project_slug":15},"BkumMnOk","13. 开发个人资料功能",980,31,"2024-04-16 02:36:03",{"id":90,"uuid":93,"project_id":4,"title":94,"type":8,"status":9,"public_enabled":9,"views":95,"sort":96,"created_at":97,"updated_at":13,"project_title":14,"project_slug":15},"C7ux2BRH","14. 开发学生选课功能",1221,32,"2024-04-16 02:35:58",{"id":96,"uuid":99,"project_id":4,"title":100,"type":8,"status":9,"public_enabled":9,"views":101,"sort":102,"created_at":103,"updated_at":13,"project_title":14,"project_slug":15},"fLHT6xiE","15. 开发成绩管理功能",1253,33,"2024-04-16 02:35:54",{"id":105,"uuid":106,"project_id":4,"title":107,"type":8,"status":9,"public_enabled":9,"views":108,"sort":109,"created_at":110,"updated_at":111,"project_title":14,"project_slug":15},56,"k3gvEqlV","基于SpringBoot+Vue3的学生成绩管理系统资料汇总",355,100,"2024-12-26 16:23:07","2026-05-07 15:36:12.649662+00"]