176
社区成员




Team member | student ID | Division of labor |
---|---|---|
张佳卉 | 832101214 | Login and registration interface |
王鑫瑜 | 832101203 | Login and registration interface |
卞晴 | 832101204 | Login and registration interface |
陈璐歆 | 832101316 | scientific calculator |
陈俪文 | 832101315 | scientific calculator |
黄阳烁 | 832101124 |
Interest rate calculator |
高畅 | 832101323 |
Interest rate calculator |
林璟玟 | 832101318 | Establish GitHub team repository |
郑梓欣 | 832101120 | blogging |
Team member | 张佳卉832101214 | 王鑫瑜832101203 | 卞晴832101204 | 陈璐歆832101316 | 陈俪文832101315 | 黄阳烁832101124 | 高畅832101323 | 林璟玟832101318 | 郑梓欣832101120 |
---|---|---|---|---|---|---|---|---|---|
score | 10 | 9 | 11 | 9 | 11 | 14 | 13 | 13 | 10 |
- js:
- <!DOCTYPE html>
- <html>
-
- <head>
- <meta charset="UTF-8">
- <title>CalBeta</title>
-
- <link rel="stylesheet" href="./cal.css">
- <style>
- </style>
- <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js">
- </script>
- <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
-
-
- </head>
-
- <body>
-
- <div class="calculator" id="app" style="background-color: green;">
- <input type="text" v-model="infos" class="display" disabled>
-
- <button @click="getNumber1('(')">(</button>
- <button @click="getNumber1(')')">)</button>
- <button @click="getOperator('%')">%</button>
- <button @click="clearDisplay()">C</button>
-
- <button @click="getNumber1('sin(')">sin</button>
- <button @click="getNumber1('cos(')">cos</button>
- <button @click="getNumber1('tan(')">tan</button>
- <button @click="def">deg</button>
-
- <button @click="getNumber('7')">7</button>
- <button @click="getNumber('8')">8</button>
- <button @click="getNumber('9')">9</button>
- <button @click="getOperator('/')">/</button>
-
- <button @click="getNumber('4')">4</button>
- <button @click="getNumber('5')">5</button>
- <button @click="getNumber('6')">6</button>
- <button @click="getOperator('*')">*</button>
-
- <button @click="getNumber('1')">1</button>
- <button @click="getNumber('2')">2</button>
- <button @click="getNumber('3')">3</button>
- <button @click="getOperator('-')">-</button>
-
- <button @click="getNumber('0')">0</button>
- <button @click="getNumber('.')">.</button>
- <button @click="calculate">=</button>
- <button @click="getOperator('+')">+</button>
-
-
-
- </div>
-
- <script src="./calBeta.js"></script>
-
- <script>
- var app = new Vue({
- el: '#app',
- data: {
- message: 'Hello Vue!',
- firstnum: "",
- endnum: "",
- operator: "",
- fscod: true,
- infos:"",
- listNum:1
-
- },
- methods: {
- def(){
- this.getList(this.listNum)
- },
- clearDisplay() {
- this.infos = "";
- this.firstnum = "";
- this.endnum = ""
- },
- getNumber(e) {
- if (this.fscod) {
- this.firstnum += e+""
- this.infos = this.firstnum + ""
- }else{
- this.endnum += e+""
- this.infos = this.firstnum+this.operator + ""+ this.endnum + ""
- }
-
- console.log("111", e)
- },
- getNumber1(e) {
- console.log("222", e)
- },
- getOperator(e) {
- this.fscod = false
- this.operator = e
- console.log("333", e)
- this.infos = this.firstnum+this.operator+""
- },
-
-
- calculate() {
- var that = this
- $.ajax({
- url: 'http://localhost:8081/jisuanji/jisuan',// 请求的URL
- method: 'GET', // 请求方法(GET、POST等)
- dataType: 'text',
- async: "true",
- data:{
- number1:this.firstnum,
- number2:this.endnum,
- type:this.operator
- },
- success: function (response) {
- that.infos = response// 请求成功时的回调函数
- that.firstnum = ""
- that.endnum = ""
- that.operator = ""
- that.fscod=true
- that.listNum = 1
- console.log(response); // 打印服务器返回的数据
- },
- error: function (xhr, status, error) { // 请求失败时的回调函数
- console.log('请求失败');
- console.log(xhr);
- console.log(status);
- console.log(error);
- }
- });
-
- },
- getList(str) {
- var that = this
- $.ajax({
- url: 'http://localhost:8081/jisuanji/list',// 请求的URL
- method: 'GET', // 请求方法(GET、POST等)
- dataType: 'json',
- async: "true",
- data:{
- str:str
- },
- success: function (response) {
- // 请求成功时的回调函数
- that.fscod=true
- that.listNum += 1
- that.infos =response.jg + ""
- console.log(that.infos); // 打印服务器返回的数据
- },
- error: function (xhr, status, error) { // 请求失败时的回调函数
- console.log('请求失败');
- console.log(xhr);
- console.log(status);
- console.log(error);
- }
- });
-
- }
- }
- });
- </script>
-
- </body>
-
- </html>
- <style>
-
- .calculator {
- width: 400px;
- margin: 0 auto;
- padding: 20px;
- background: #ddd;
- border-radius: 10px;
- display: grid;
- grid-template-columns: repeat(4, 1fr);
- grid-gap: 5px;
- }
-
- .display {
- grid-column: span 4;
- height: 50px;
- font-size: 20px;
- margin-bottom: 10px;
- padding: 5px;
- border: none;
- background: #fff;
- height: 120px;
- }
-
- button {
- width: 100%;
- height: 40px;
- font-size: 14px;
- margin: 5px;
- border-radius: 5px;
- border: none;
- background: #ffffff;
- cursor: pointer;
- }
- </style>
- java:
-
- package com.jisuanji.controller;
-
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.jisuanji.config.jisuan;
- import com.jisuanji.entity.JsjHistory;
- import com.jisuanji.service.IJsjHistoryService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
-
- import java.math.BigDecimal;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- /**
- */
- @RestController
- @RequestMapping("/jisuanji")
- public class JsjHistoryController {
- @Autowired
- IJsjHistoryService iJsjHistoryService;
- @RequestMapping("/list")
- public JsjHistory list(String str){
- QueryWrapper<JsjHistory> queryWrapper = new QueryWrapper<>();
- QueryWrapper<JsjHistory> queryWrapper1 = queryWrapper.orderByDesc("id");
- List<JsjHistory> list = iJsjHistoryService.list(queryWrapper1);
- Map<String,JsjHistory> map = new HashMap<>();
- for (int i = 1; i <= list.size(); i++) {
- map.put(i+"",list.get(i-1));
- }
- JsjHistory jsjHistory = map.get(str);
- return jsjHistory;
- }
- @RequestMapping("/jisuan")
- public String jisuan(String number1,String number2,String type) throws Exception {
- jisuan js = null;
- if (type.equals("+")){
- js = new add();
- } else if (type.equals("-")) {
- js = new subtract();
- } else if (type.equals("*")) {
- js = new multiply();
- }else if (type.equals("/")){
- js = new divide();
- }
- else if (type.equals("%")){
- js = new yu();
- }else {
- throw new Exception("计算方式输入错误");
- }
- String jisuan = js.jisuan(number1, number2);
- JsjHistory jsjHistory = new JsjHistory();
- jsjHistory.setType(type);
- jsjHistory.setNumber1(number1);
- jsjHistory.setNumber2(number2);
- jsjHistory.setJg(jisuan);
- iJsjHistoryService.save(jsjHistory);
- return jisuan;
-
- }
- }
- class add implements jisuan{
- @Override
- public String jisuan(String number1, String number2) {
- BigDecimal bigDecimal = new BigDecimal(number1);
- BigDecimal bigDecimal1 = new BigDecimal(number2);
- BigDecimal add = bigDecimal.add(bigDecimal1);
- return add.toString();
- }
- }
- class subtract implements jisuan{
-
- @Override
- public String jisuan(String number1, String number2) {
- BigDecimal bigDecimal = new BigDecimal(number1);
- BigDecimal bigDecimal1 = new BigDecimal(number2);
- BigDecimal add = bigDecimal.subtract(bigDecimal1);
- return add.toString();
- }
- }
- class multiply implements jisuan{
-
- @Override
- public String jisuan(String number1, String number2) {
- BigDecimal bigDecimal = new BigDecimal(number1);
- BigDecimal bigDecimal1 = new BigDecimal(number2);
- BigDecimal add = bigDecimal.multiply(bigDecimal1);
- return add.toString();
- }
- }
- class divide implements jisuan{
-
- @Override
- public String jisuan(String number1, String number2) {
- BigDecimal bigDecimal = new BigDecimal(number1);
- BigDecimal bigDecimal1 = new BigDecimal(number2);
- BigDecimal add = bigDecimal.divide(bigDecimal1,8,BigDecimal.ROUND_HALF_UP);
- return add.toString();
- }
- }
- class yu implements jisuan{
-
- @Override
- public String jisuan(String number1, String number2) {
- int a = Integer.parseInt(number1)%Integer.parseInt(number2);
- return a+"";
- }
- }
Backend: Define a route for processing POST requests to receive computing requests:
- @app.route('/t/calculate', methods=['POST'])
- def calculator():
- data = request.get_json() # 获取来自前端的 JSON 数据
- evalString = data['expression']
- displayString = calculate_expression(evalString)
- cursor.execute("INSERT INTO calculations (expression, result) VALUES (%s, %s)", (evalString, displayString))
- conn.commit()
-
- return jsonify({'status': 'success'})
Define a route for processing GET requests to obtain calculation records:
- @app.route('/t/calculate-records', methods=['GET'])
- def get_calculation_records():
- cursor.execute("SELECT expression, result FROM calculations ORDER BY id DESC LIMIT 10")
- records = cursor.fetchall()
-
- response = []
- for record in records:
- expression, result = record
- response.append({'expression': expression, 'result': result})
-
- return jsonify(response)
Using a function to calculate the expression returned by the front-end:
- def calculate_expression(expression):
- try:
- expression = expression.replace("π", str(math.pi))
- expression = expression.replace("e", str(math.e))
- result = eval(expression)
- return result
- except Exception as e:
- print("计算错误:", str(e))
- return None
Front end:
- var requestData = {
- expression: expression
- };
-
- fetch('/t/calculate', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(requestData)
- })
- .then(response => response.json())
- .then(data => {
- show(data.result);
- console.log(data);
- })
- .catch(error => {
- console.error('Error:', error);
- });
- } catch {
- show("error");
- }
- }
Read the history of the calculator and click the "ans" button to obtain the latest calculation record:
- $(".operators[value='ans']").click(function() {
- fetch('/t/calculate-records')
- .then(response => response.json())
- .then(data => {
- const List = document.getElementById('records-container');
- List.innerHTML = '';
- data.forEach(record => {
- const calculationItem = document.createElement('li');
- calculationItem.textContent =record.expression +"="+ record.result;
- List.appendChild(calculationItem);
- });
- });
- });
Used to clear the display interface:
- function clr() {
- displayString = "0";
- evalString = "0";
- show(displayString); // 更新显示区域
- }
- from flask import Flask, render_template,request
- import pymysql
-
-
-
- app = Flask(__name__)
-
- @app.route("/add/user",methods=["GET","POST"])
- def test():
- if request.method=="GET":
- return render_template("login.html")
- u1 = request.form.get("email")
-
- u2 = request.form.get("password")
- conn = pymysql.connect(host='localhost', user='root', password='123456', charset='utf8', db='12')
- # 创建游标
- cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
- # 插入
- sql = "insert into user1(email,password)values(%s,%s)"
- cursor.execute(sql, [u1,u2])
- conn.commit()
-
- cursor.close()
- conn.close()
- return render_template("calculator.html")
- app.route("/show/user")
- def show():
- conn = pymysql.connect(host='localhost', user='root', password='123456', charset='utf8', db='12')
- # 创建游标
- cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
-
- # 查询
- sql="select*from user1"
- # cursor.execute(sql)
- #data=cursor.fetchall()
-
- #cursor.close()
- #conn.close()
-
-
-
-
- if __name__ == "__main__":
- app.run()
https://github.com/ilemontea/teamwork/tree/main
张佳卉
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 30 | 30 |
Estimate | 10 | 10 |
Development | 150 | 120 |
Analysis | 30 | 30 |
Design Spec | 20 | 40 |
Design Review | 40 | 30 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 120 | 100 |
Code Review | 10 | 20 |
Test | 30 | 20 |
Reporting | 10 | 10 |
Test Report | 10 | 10 |
Size Measurement | 10 | 10 |
Postmortem & Process Improvement Plan | 20 | 20 |
Sum | 570 | 530 |
王鑫瑜
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 30 | 30 |
Estimate | 10 | 10 |
Development | 150 | 120 |
Analysis | 30 | 30 |
Design Spec | 20 | 20 |
Design Review | 40 | 30 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 120 | 100 |
Code Review | 10 | 20 |
Test | 30 | 20 |
Reporting | 0 | 0 |
Test Report | 10 | 10 |
Size Measurement | 10 | 10 |
Postmortem & Process Improvement Plan | 20 | 20 |
Sum | 560 | 500 |
卞晴
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 20 | 20 |
Estimate | 10 | 10 |
Development | 150 | 120 |
Analysis | 30 | 30 |
Design Spec | 20 | 20 |
Design Review | 40 | 30 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 120 | 100 |
Code Review | 10 | 20 |
Test | 30 | 20 |
Reporting | 0 | 0 |
Test Report | 0 | 0 |
Size Measurement | 10 | 10 |
Postmortem & Process Improvement Plan | 20 | 20 |
Sum | 540 | 480 |
陈璐歆
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 30 | 30 |
Estimate | 10 | 10 |
Development | 150 | 120 |
Analysis | 30 | 30 |
Design Spec | 20 | 20 |
Design Review | 40 | 30 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 150 | 150 |
Code Review | 10 | 20 |
Test | 30 | 20 |
Reporting | 0 | 0 |
Test Report | 10 | 10 |
Size Measurement | 10 | 10 |
Postmortem & Process Improvement Plan | 20 | 20 |
Sum | 590 | 550 |
陈俪文
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 30 | 30 |
Estimate | 10 | 10 |
Development | 150 | 180 |
Analysis | 30 | 30 |
Design Spec | 20 | 20 |
Design Review | 40 | 30 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 120 | 100 |
Code Review | 10 | 20 |
Test | 30 | 20 |
Reporting | 10 | 10 |
Test Report | 10 | 10 |
Size Measurement | 10 | 10 |
Postmortem & Process Improvement Plan | 20 | 20 |
Sum | 570 | 570 |
黄阳烁
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 30 | 30 |
Estimate | 10 | 10 |
Development | 150 | 120 |
Analysis | 30 | 30 |
Design Spec | 20 | 20 |
Design Review | 40 | 30 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 160 | 170 |
Code Review | 10 | 20 |
Test | 30 | 20 |
Reporting | 0 | 0 |
Test Report | 10 | 10 |
Size Measurement | 10 | 10 |
Postmortem & Process Improvement Plan | 20 | 20 |
Sum | 600 | 570 |
高畅
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 20 | 20 |
Estimate | 10 | 10 |
Development | 180 | 170 |
Analysis | 30 | 30 |
Design Spec | 20 | 20 |
Design Review | 40 | 30 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 160 | 150 |
Code Review | 10 | 20 |
Test | 30 | 20 |
Reporting | 0 | 0 |
Test Report | 10 | 10 |
Size Measurement | 10 | 10 |
Postmortem & Process Improvement Plan | 20 | 20 |
Sum | 620 | 590 |
林璟玟
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 30 | 30 |
Estimate | 10 | 10 |
Development | 100 | 90 |
Analysis | 80 | 80 |
Design Spec | 20 | 20 |
Design Review | 90 | 80 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 120 | 100 |
Code Review | 50 | 50 |
Test | 40 | 40 |
Reporting | 0 | 0 |
Test Report | 0 | 0 |
Size Measurement | 10 | 10 |
Postmortem & Process Improvement Plan | 20 | 20 |
Sum | 630 | 610 |
郑梓欣
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
Planning | 30 | 30 |
Estimate | 10 | 10 |
Development | 150 | 120 |
Analysis | 50 | 40 |
Design Spec | 20 | 20 |
Design Review | 40 | 30 |
Coding Standard | 30 | 20 |
Design | 50 | 60 |
Coding | 30 | 30 |
Code Review | 10 | 20 |
Test | 30 | 20 |
Reporting | 10 | 20 |
Test Report | 10 | 10 |
Size Measurement | 70 | 80 |
Postmortem & Process Improvement Plan | 60 | 60 |
Sum | 560 | 570 |