From 5e7a0bac1f6267ef1ce3352c821fe94f3197ce37 Mon Sep 17 00:00:00 2001 From: Tomanage <2630024077@qq.com> Date: Thu, 10 Oct 2024 15:43:41 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=9Ccode=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 前端/.eslintrc.js | 31 ++ 前端/.gitignore | 14 + 前端/app.js | 19 ++ 前端/app.json | 22 ++ 前端/app.wxss | 1 + 前端/pages/add_stu/add_stu.js | 157 +++++++++++ 前端/pages/add_stu/add_stu.json | 3 + 前端/pages/add_stu/add_stu.wxml | 12 + 前端/pages/add_stu/add_stu.wxss | 111 ++++++++ 前端/pages/call_roll/call_roll.js | 179 ++++++++++++ 前端/pages/call_roll/call_roll.json | 3 + 前端/pages/call_roll/call_roll.wxml | 17 ++ 前端/pages/call_roll/call_roll.wxss | 113 ++++++++ 前端/pages/classSelector/classSelector.js | 37 +++ 前端/pages/classSelector/classSelector.json | 4 + 前端/pages/classSelector/classSelector.wxml | 13 + 前端/pages/classSelector/classSelector.wxss | 33 +++ 前端/pages/class_manage/class_manage.js | 266 ++++++++++++++++++ 前端/pages/class_manage/class_manage.json | 3 + 前端/pages/class_manage/class_manage.wxml | 31 ++ 前端/pages/class_manage/class_manage.wxss | 139 +++++++++ 前端/pages/class_message/class_message.js | 66 +++++ 前端/pages/class_message/class_message.json | 3 + 前端/pages/class_message/class_message.wxml | 10 + 前端/pages/class_message/class_message.wxss | 38 +++ 前端/pages/function/function.js | 119 ++++++++ 前端/pages/function/function.json | 4 + 前端/pages/function/function.wxml | 18 ++ 前端/pages/function/function.wxss | 70 +++++ 前端/pages/images/add_stu.png | Bin 0 -> 253839 bytes 前端/pages/images/arrow_icon.png | Bin 0 -> 2285 bytes 前端/pages/images/call_roll.png | Bin 0 -> 357521 bytes 前端/pages/images/class_manage.png | Bin 0 -> 223698 bytes 前端/pages/images/class_message.png | Bin 0 -> 298224 bytes 前端/pages/images/eggs.png | Bin 0 -> 3908 bytes 前端/pages/images/function.png | Bin 0 -> 30385 bytes 前端/pages/images/record.png | Bin 0 -> 321717 bytes 前端/pages/images/welcome.png | Bin 0 -> 108189 bytes 前端/pages/index/index.js | 49 ++++ 前端/pages/index/index.json | 4 + 前端/pages/index/index.wxml | 27 ++ 前端/pages/index/index.wxss | 62 ++++ 前端/pages/logs/logs.js | 18 ++ 前端/pages/logs/logs.json | 4 + 前端/pages/logs/logs.wxml | 6 + 前端/pages/logs/logs.wxss | 16 ++ 前端/pages/record/record.js | 66 +++++ 前端/pages/record/record.json | 3 + 前端/pages/record/record.wxml | 13 + 前端/pages/record/record.wxss | 49 ++++ 前端/pages/welcome/welcome.js | 9 + 前端/pages/welcome/welcome.json | 3 + 前端/pages/welcome/welcome.wxml | 5 + 前端/pages/welcome/welcome.wxss | 21 ++ 前端/project.config.json | 28 ++ 前端/project.private.config.json | 8 + 前端/sitemap.json | 7 + 前端/utils/util.js | 19 ++ 后端/pom.xml | 121 ++++++++ .../main/java/com/demo/DemoApplication.java | 16 ++ .../com/demo/controller/ClazzController.java | 40 +++ .../com/demo/controller/ExcelController.java | 28 ++ .../demo/controller/StudentController.java | 40 +++ .../src/main/java/com/demo/entity/Clazz.java | 9 + .../main/java/com/demo/entity/Student.java | 16 ++ .../java/com/demo/mapper/ClazzMapper.java | 25 ++ .../java/com/demo/mapper/StudentMapper.java | 38 +++ 后端/src/main/resources/application.yml | 8 + .../java/com/demo/DemoApplicationTests.java | 13 + 69 files changed, 2307 insertions(+) create mode 100644 前端/.eslintrc.js create mode 100644 前端/.gitignore create mode 100644 前端/app.js create mode 100644 前端/app.json create mode 100644 前端/app.wxss create mode 100644 前端/pages/add_stu/add_stu.js create mode 100644 前端/pages/add_stu/add_stu.json create mode 100644 前端/pages/add_stu/add_stu.wxml create mode 100644 前端/pages/add_stu/add_stu.wxss create mode 100644 前端/pages/call_roll/call_roll.js create mode 100644 前端/pages/call_roll/call_roll.json create mode 100644 前端/pages/call_roll/call_roll.wxml create mode 100644 前端/pages/call_roll/call_roll.wxss create mode 100644 前端/pages/classSelector/classSelector.js create mode 100644 前端/pages/classSelector/classSelector.json create mode 100644 前端/pages/classSelector/classSelector.wxml create mode 100644 前端/pages/classSelector/classSelector.wxss create mode 100644 前端/pages/class_manage/class_manage.js create mode 100644 前端/pages/class_manage/class_manage.json create mode 100644 前端/pages/class_manage/class_manage.wxml create mode 100644 前端/pages/class_manage/class_manage.wxss create mode 100644 前端/pages/class_message/class_message.js create mode 100644 前端/pages/class_message/class_message.json create mode 100644 前端/pages/class_message/class_message.wxml create mode 100644 前端/pages/class_message/class_message.wxss create mode 100644 前端/pages/function/function.js create mode 100644 前端/pages/function/function.json create mode 100644 前端/pages/function/function.wxml create mode 100644 前端/pages/function/function.wxss create mode 100644 前端/pages/images/add_stu.png create mode 100644 前端/pages/images/arrow_icon.png create mode 100644 前端/pages/images/call_roll.png create mode 100644 前端/pages/images/class_manage.png create mode 100644 前端/pages/images/class_message.png create mode 100644 前端/pages/images/eggs.png create mode 100644 前端/pages/images/function.png create mode 100644 前端/pages/images/record.png create mode 100644 前端/pages/images/welcome.png create mode 100644 前端/pages/index/index.js create mode 100644 前端/pages/index/index.json create mode 100644 前端/pages/index/index.wxml create mode 100644 前端/pages/index/index.wxss create mode 100644 前端/pages/logs/logs.js create mode 100644 前端/pages/logs/logs.json create mode 100644 前端/pages/logs/logs.wxml create mode 100644 前端/pages/logs/logs.wxss create mode 100644 前端/pages/record/record.js create mode 100644 前端/pages/record/record.json create mode 100644 前端/pages/record/record.wxml create mode 100644 前端/pages/record/record.wxss create mode 100644 前端/pages/welcome/welcome.js create mode 100644 前端/pages/welcome/welcome.json create mode 100644 前端/pages/welcome/welcome.wxml create mode 100644 前端/pages/welcome/welcome.wxss create mode 100644 前端/project.config.json create mode 100644 前端/project.private.config.json create mode 100644 前端/sitemap.json create mode 100644 前端/utils/util.js create mode 100644 后端/pom.xml create mode 100644 后端/src/main/java/com/demo/DemoApplication.java create mode 100644 后端/src/main/java/com/demo/controller/ClazzController.java create mode 100644 后端/src/main/java/com/demo/controller/ExcelController.java create mode 100644 后端/src/main/java/com/demo/controller/StudentController.java create mode 100644 后端/src/main/java/com/demo/entity/Clazz.java create mode 100644 后端/src/main/java/com/demo/entity/Student.java create mode 100644 后端/src/main/java/com/demo/mapper/ClazzMapper.java create mode 100644 后端/src/main/java/com/demo/mapper/StudentMapper.java create mode 100644 后端/src/main/resources/application.yml create mode 100644 后端/src/test/java/com/demo/DemoApplicationTests.java diff --git a/前端/.eslintrc.js b/前端/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/前端/.eslintrc.js @@ -0,0 +1,31 @@ +/* + * Eslint config file + * Documentation: https://eslint.org/docs/user-guide/configuring/ + * Install the Eslint extension before using this feature. + */ +module.exports = { + env: { + es6: true, + browser: true, + node: true, + }, + ecmaFeatures: { + modules: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + globals: { + wx: true, + App: true, + Page: true, + getCurrentPages: true, + getApp: true, + Component: true, + requirePlugin: true, + requireMiniProgram: true, + }, + // extends: 'eslint:recommended', + rules: {}, +} diff --git a/前端/.gitignore b/前端/.gitignore new file mode 100644 index 0000000..14ea590 --- /dev/null +++ b/前端/.gitignore @@ -0,0 +1,14 @@ +# Windows +[Dd]esktop.ini +Thumbs.db +$RECYCLE.BIN/ + +# macOS +.DS_Store +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes + +# Node.js +node_modules/ diff --git a/前端/app.js b/前端/app.js new file mode 100644 index 0000000..1ed57c4 --- /dev/null +++ b/前端/app.js @@ -0,0 +1,19 @@ +// app.js +App({ + onLaunch() { + // 展示本地存储能力 + const logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + + // 登录 + wx.login({ + success: res => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + } + }) + }, + globalData: { + userInfo: null + } +}) diff --git a/前端/app.json b/前端/app.json new file mode 100644 index 0000000..e1d58d9 --- /dev/null +++ b/前端/app.json @@ -0,0 +1,22 @@ +{ + "pages": [ + "pages/welcome/welcome", + "pages/call_roll/call_roll", + "pages/function/function", + "pages/class_manage/class_manage", + "pages/add_stu/add_stu", + "pages/class_message/class_message", + "pages/record/record", + "pages/index/index", + "pages/logs/logs" + ], + "window": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "Weixin", + "navigationBarBackgroundColor": "#ffffff" + }, + "style": "v2", + "componentFramework": "glass-easel", + "sitemapLocation": "sitemap.json", + "lazyCodeLoading": "requiredComponents" +} \ No newline at end of file diff --git a/前端/app.wxss b/前端/app.wxss new file mode 100644 index 0000000..75f4fde --- /dev/null +++ b/前端/app.wxss @@ -0,0 +1 @@ +/**app.wxss**/ diff --git a/前端/pages/add_stu/add_stu.js b/前端/pages/add_stu/add_stu.js new file mode 100644 index 0000000..69b5b81 --- /dev/null +++ b/前端/pages/add_stu/add_stu.js @@ -0,0 +1,157 @@ +// pages/addStudent/addStudent.js +Page({ + data: { + className:"K班", + input: "", + students:[ + + ] + }, + + onLoad: function(options) { + console.log(options); + // options 参数包含了从上一个页面传递过来的数据 + const receivedClassName = options.className; // 获取传递过来的 className,默认为空字符串 + + // 更新页面的数据 + this.setData({ + className: receivedClassName // 将接收到的 className 赋值给页面的 data 属性 + }); + console.log(this.data.className); + }, + + //获取输入框内容 + onInput: function(e) { + console.log(e.detail.value) + this.setData({ + input: e.detail.value//保存输入 + }); + }, + + // Excel文件导入 + importExcel: function() { + const that = this; + wx.chooseMessageFile({ + count: 1, // 默认为1,设置选择文件的数量 + type: 'file', + extension: ['xlsx'], // 指定文件的后缀名 + success(res) { + const tempFiles = res.tempFiles; // 临时文件路径 + const filePath = tempFiles[0].path; // 获取文件的路径 + console.log(tempFiles); + that.readExcel(filePath); // 读取文件内容 + }, + fail(err) { + console.error('选择文件失败:', err); + } + }); + }, + + // 读取Excel文件内容 + readExcel(filePath) { + // 可以使用微信小程序的API或将文件上传到服务器解析 + const that = this; + wx.uploadFile({ + url: 'http://192.168.152.1:8090/excel/import', // 你的服务器上传地址 + filePath: filePath, + name: 'file', + success: uploadRes => { + // 假设服务器返回解析后的 JSON 数据 + const data = JSON.parse(uploadRes.data); + that.addStudents(data.students); + }, + fail: uploadErr => { + console.error('文件上传失败:', uploadErr); + } + }); + }, + + // 将解析后的学生数据添加到现有数组中 + addStudents(newStudents) { + const currentStudents = this.data.students; + const allStudents = currentStudents.concat(newStudents); // 合并数组 + this.setData({ + students: allStudents + }); + }, + + //点击输入框提示可以输入 + focus: function(){ + wx.showToast({ + title: '可以开始输入了', + icon: 'none', + duration: 2000 + }); + }, + + cantNull: function(){ + wx.showToast({ + title: '输入框不可为空', + icon: 'none', + duration: 2000 + }); + }, + + addProcess: function(){ + if(this.data.input != ""){ + //分割字符串为数组 + let firstArray = this.data.input.split("|"); + console.log(firstArray); + let secondArray = firstArray.map(str => str.split(" ")); + console.log(secondArray) + //遍历secondArray + secondArray.forEach(subArray => { + // 结构法从子数组中提取id和name + //等同于 const id = subArray[0]; const name = subArray[1]; + const { [0]: id, [1]: name } = subArray; + + // 创建一个新的对象来存储这些信息 + const newStu = { + id: id, + name: name, + point: 10, + clazz: this.data.className, + }; + const isDuplicate = this.data.students.some(stu => stu.id === id); + if(!isDuplicate){ + // 将新对象发送到后端服务器 + const classstu = newStu; + //classstu.className = this.data.className;//此时 classstu = {id:"102201",name:"Jhon", className:`${this.data.className}` } + wx.request({ + url: 'http://192.168.152.1:8090/student/set', + method: 'POST', // 请求方法,通常是POST用于发送数据 + header: { + 'Content-Type': 'application/json' // 设置请求头,指定数据格式为JSON + }, + data: newStu, // 要发送的数据,这里直接传入对象,wx.request会自动将其转换为JSON字符串(后端接收json字符串) + success: function(res) { + // 处理后端返回的响应 + console.log('请求成功', res.data); + // 根据需要更新小程序页面的数据或执行其他操作 + }, + fail: function(err) { + // 处理请求失败的情况 + console.error('请求失败', err); + // 可以向用户显示错误信息或执行其他错误处理操作 + } + }); + // 将新对象添加到data.stu数组中 + this.setData({ + ['students[' + this.data.students.length + ']']: newStu //直接将新对象加在数组后面 + }); + } else { + console.log('id重复:${id}'); + } + }) + console.log(this.data.students); + } else { + this.cantNull(); + } + }, + + goToclass_manage: function(){ + wx.navigateTo({ + url: '/pages/class_manage/class_manage' + }); + } +}); \ No newline at end of file diff --git a/前端/pages/add_stu/add_stu.json b/前端/pages/add_stu/add_stu.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/前端/pages/add_stu/add_stu.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/前端/pages/add_stu/add_stu.wxml b/前端/pages/add_stu/add_stu.wxml new file mode 100644 index 0000000..8676f44 --- /dev/null +++ b/前端/pages/add_stu/add_stu.wxml @@ -0,0 +1,12 @@ + + + + + 添加学生 + (添加学生学号 姓名用“|”隔开) +