From 463bd833c063e25c4700eb2980f6a501693bedea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=80=9D=E6=99=97?= <3428954377@qq.com> Date: Tue, 19 May 2026 21:49:57 +0800 Subject: [PATCH] renwu 89 --- .../src/com/ssm/entity/Class.java | 52 +++++++ .../src/com/ssm/mapper/ClassMapper.java | 8 + .../src/com/ssm/mapper/ClassMapper.xml | 16 ++ .../ssm/controller/ClassEntityController.java | 64 ++++++++ .../com/ssm/controller/ProductController.java | 26 ---- .../src/com/ssm/entity/ClassEntity.java | 51 ++++++ .../src/com/ssm/entity/Product.java | 146 ------------------ .../web/WEB-INF/view/showClassEntity.jsp | 35 +++++ .../web/WEB-INF/view/showGetData.jsp | 82 ---------- .../web/addClassEntity.jsp | 23 +++ .../web/addProduct.jsp | 107 ------------- .../ssm/controller/ProductController.class | Bin 1426 -> 0 bytes .../com/ssm/entity/Product.class | Bin 4123 -> 0 bytes 13 files changed, 249 insertions(+), 361 deletions(-) create mode 100644 grademanagement-MyBatisProject/src/com/ssm/entity/Class.java create mode 100644 grademanagement-MyBatisProject/src/com/ssm/mapper/ClassMapper.java create mode 100644 grademanagement-MyBatisProject/src/com/ssm/mapper/ClassMapper.xml create mode 100644 grademanagement-SpringMVCProject/src/com/ssm/controller/ClassEntityController.java delete mode 100644 grademanagement-SpringMVCProject/src/com/ssm/controller/ProductController.java create mode 100644 grademanagement-SpringMVCProject/src/com/ssm/entity/ClassEntity.java delete mode 100644 grademanagement-SpringMVCProject/src/com/ssm/entity/Product.java create mode 100644 grademanagement-SpringMVCProject/web/WEB-INF/view/showClassEntity.jsp delete mode 100644 grademanagement-SpringMVCProject/web/WEB-INF/view/showGetData.jsp create mode 100644 grademanagement-SpringMVCProject/web/addClassEntity.jsp delete mode 100644 grademanagement-SpringMVCProject/web/addProduct.jsp delete mode 100644 out/production/grademanagement-SpringMVCProject/com/ssm/controller/ProductController.class delete mode 100644 out/production/grademanagement-SpringMVCProject/com/ssm/entity/Product.class diff --git a/grademanagement-MyBatisProject/src/com/ssm/entity/Class.java b/grademanagement-MyBatisProject/src/com/ssm/entity/Class.java new file mode 100644 index 0000000..daaf89a --- /dev/null +++ b/grademanagement-MyBatisProject/src/com/ssm/entity/Class.java @@ -0,0 +1,52 @@ +package com.ssm.entity; + +public class Class { + private Integer classId; // 班级ID + private String className; // 班级名称 + private String grade; // 年级 + private String major; // 专业 + + public Integer getClassId() { + return classId; + } + + public void setClassId(Integer classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getGrade() { + return grade; + } + + public void setGrade(String grade) { + this.grade = grade; + } + + public String getMajor() { + return major; + } + + public void setMajor(String major) { + this.major = major; + } + + + @Override + public String toString() { + return "ClassEntity{" + + "classId=" + classId + + ", className='" + className + '\'' + + ", grade='" + grade + '\'' + + ", major='" + major + '\'' + + '}'; + } + +} diff --git a/grademanagement-MyBatisProject/src/com/ssm/mapper/ClassMapper.java b/grademanagement-MyBatisProject/src/com/ssm/mapper/ClassMapper.java new file mode 100644 index 0000000..97ab5ec --- /dev/null +++ b/grademanagement-MyBatisProject/src/com/ssm/mapper/ClassMapper.java @@ -0,0 +1,8 @@ +package com.ssm.mapper; + +import java.util.List; + +public interface ClassMapper { + Class getClassById(Integer classId); + List getAllClasses(); +} diff --git a/grademanagement-MyBatisProject/src/com/ssm/mapper/ClassMapper.xml b/grademanagement-MyBatisProject/src/com/ssm/mapper/ClassMapper.xml new file mode 100644 index 0000000..0cf4597 --- /dev/null +++ b/grademanagement-MyBatisProject/src/com/ssm/mapper/ClassMapper.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/grademanagement-SpringMVCProject/src/com/ssm/controller/ClassEntityController.java b/grademanagement-SpringMVCProject/src/com/ssm/controller/ClassEntityController.java new file mode 100644 index 0000000..77275c1 --- /dev/null +++ b/grademanagement-SpringMVCProject/src/com/ssm/controller/ClassEntityController.java @@ -0,0 +1,64 @@ +package com.ssm.controller; + +import com.ssm.entity.ClassEntity; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +public class ClassEntityController { + @RequestMapping("/addClassEntity") + public String add(ClassEntity classEntity, Model model) { + try { + System.out.println("===== 组长刘思晗-班级模块 ====="); + System.out.println("接收数据:" + classEntity); + if (classEntity.getClassId() == null || classEntity.getClassId() <= 0) { + model.addAttribute("msg", "班级ID不能为空!"); + return "addClassEntity"; + } + if (classEntity.getClassName() == null || classEntity.getClassName().trim().length() <= 0) { + model.addAttribute("msg", "班级名称不能为空!"); + return "addClassEntity"; + } + if (classEntity.getGrade() == null || classEntity.getGrade().trim().length() <= 0){ + model.addAttribute("msg", "班级年级不能为空!"); + return "addClassEntity"; + } + if (classEntity.getMajor() == null || classEntity.getMajor().trim().length() <= 0) { + model.addAttribute("msg", "班级专业不能为空!"); + return "addClassEntity"; + } + + // 验证通过,将数据添加到model并跳转到展示页面 + model.addAttribute("classEntity", classEntity); + return "showClassEntity"; + } catch (Exception e) { + System.err.println("数据处理异常:" + e.getMessage()); + model.addAttribute("msg", "数据提交失败,请检查输入格式!"); + return "addClassEntity"; + } + } + @RequestMapping("/submitClassEntity") + public String submitClass(ClassEntity classEntity, Model model) { + try { + System.out.println("===== 班级提交 ====="); + System.out.println("接收数据:" + classEntity); + + // 将表单信息添加到Model中,传递到页面 + model.addAttribute("classEntity", classEntity); + + return "showClassEntity"; + } catch (Exception e) { + System.err.println("数据处理异常:" + e.getMessage()); + model.addAttribute("msg", "数据提交失败,请检查输入格式!"); + return "addClassEntity"; + } + } + @ExceptionHandler(Exception.class) + public String handleException(Exception e, Model model) { + System.err.println("系统异常:" + e.getMessage()); + model.addAttribute("msg", "系统错误:" + e.getMessage()); + return "addClassEntity"; + } +} diff --git a/grademanagement-SpringMVCProject/src/com/ssm/controller/ProductController.java b/grademanagement-SpringMVCProject/src/com/ssm/controller/ProductController.java deleted file mode 100644 index ebb0e96..0000000 --- a/grademanagement-SpringMVCProject/src/com/ssm/controller/ProductController.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ssm.controller; - -import com.ssm.entity.Product; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@Controller -@RequestMapping("product") -public class ProductController { - - // 进入添加商品页面 - @RequestMapping("add") - public String addProductPage() { - return "redirect:/addProduct.jsp"; - } - - // 处理添加商品请求 - @RequestMapping("addProduct") - public String addProduct(Product product, Model model) { - System.out.println("添加商品:" + product); - model.addAttribute("product", product); - return "showGetData"; - } -} diff --git a/grademanagement-SpringMVCProject/src/com/ssm/entity/ClassEntity.java b/grademanagement-SpringMVCProject/src/com/ssm/entity/ClassEntity.java new file mode 100644 index 0000000..a011e30 --- /dev/null +++ b/grademanagement-SpringMVCProject/src/com/ssm/entity/ClassEntity.java @@ -0,0 +1,51 @@ +package com.ssm.entity; + +public class ClassEntity { + private Integer classId; // 班级ID + private String className; // 班级名称 + private String grade; // 年级 + private String major; // 专业 + + public Integer getClassId() { + return classId; + } + + public void setClassId(Integer classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getGrade() { + return grade; + } + + public void setGrade(String grade) { + this.grade = grade; + } + + public String getMajor() { + return major; + } + + public void setMajor(String major) { + this.major = major; + } + + + @Override + public String toString() { + return "ClassEntity{" + + "classId=" + classId + + ", className='" + className + '\'' + + ", grade='" + grade + '\'' + + ", major='" + major + '\'' + + '}'; + } +} diff --git a/grademanagement-SpringMVCProject/src/com/ssm/entity/Product.java b/grademanagement-SpringMVCProject/src/com/ssm/entity/Product.java deleted file mode 100644 index 6355990..0000000 --- a/grademanagement-SpringMVCProject/src/com/ssm/entity/Product.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.ssm.entity; - -public class Product { - private Integer productId; // 商品编号 - private String productName; // 商品名称 - private String isPopular; // 是否热门 - private Double marketPrice; // 市场价格 - private Double salesPrice; // 销售价格 - private String productImage; // 商品图片路径 - private String categoryName; // 分类名称 - private String description; // 商品描述 - private String listDate; // 上架日期 - - public Product() { - } - - public Product(Integer productId, String productName, String isPopular, - Double marketPrice, Double salesPrice, String productImage, - String categoryName, String description, String listDate) { - this.productId = productId; - this.productName = productName; - this.isPopular = isPopular; - this.marketPrice = marketPrice; - this.salesPrice = salesPrice; - this.productImage = productImage; - this.categoryName = categoryName; - this.description = description; - this.listDate = listDate; - } - - public Integer getProductId() { - return productId; - } - - public void setProductId(Integer productId) { - this.productId = productId; - } - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public String getIsPopular() { - return isPopular; - } - - public void setIsPopular(String isPopular) { - this.isPopular = isPopular; - } - - public Double getMarketPrice() { - return marketPrice; - } - - public void setMarketPrice(Double marketPrice) { - this.marketPrice = marketPrice; - } - - public Double getSalesPrice() { - return salesPrice; - } - - public void setSalesPrice(Double salesPrice) { - this.salesPrice = salesPrice; - } - - public String getProductImage() { - return productImage; - } - - public void setProductImage(String productImage) { - this.productImage = productImage; - } - - public String getCategoryName() { - return categoryName; - } - - public void setCategoryName(String categoryName) { - this.categoryName = categoryName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getListDate() { - return listDate; - } - - public void setListDate(String listDate) { - this.listDate = listDate; - } - - @Override - public String toString() { - return "Product{" + - "productId=" + productId + - ", productName='" + productName + '\'' + - ", isPopular='" + isPopular + '\'' + - ", marketPrice=" + marketPrice + - ", salesPrice=" + salesPrice + - ", productImage='" + productImage + '\'' + - ", categoryName='" + categoryName + '\'' + - ", description='" + description + '\'' + - ", listDate='" + listDate + '\'' + - '}'; - } - - // 计算折扣率 - public Double getDiscountRate() { - if (marketPrice != null && marketPrice > 0 && salesPrice != null) { - return (salesPrice / marketPrice) * 10; - } - return 0.0; - } - - // 判断是否有优惠 - public boolean hasDiscount() { - if (marketPrice != null && salesPrice != null) { - return salesPrice < marketPrice; - } - return false; - } - - // 获取节省金额 - public Double getSavedAmount() { - if (marketPrice != null && salesPrice != null) { - return marketPrice - salesPrice; - } - return 0.0; - } - - // 判断是否为热门商品 - public boolean isHotProduct() { - return "是".equals(isPopular) || "true".equalsIgnoreCase(isPopular) || "1".equals(isPopular); - } -} diff --git a/grademanagement-SpringMVCProject/web/WEB-INF/view/showClassEntity.jsp b/grademanagement-SpringMVCProject/web/WEB-INF/view/showClassEntity.jsp new file mode 100644 index 0000000..f3d757d --- /dev/null +++ b/grademanagement-SpringMVCProject/web/WEB-INF/view/showClassEntity.jsp @@ -0,0 +1,35 @@ +<%-- + Created by IntelliJ IDEA. + User: HP + Date: 2026/5/19 + Time: 21:31 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 提交成功 + + +

提交成功

+ + + + + + + + + + + + + + + + +
班级ID:${classEntity.classId}
班级名称:${classEntity.className}
班级年级:${classEntity.grade}
班级专业:${classEntity.major}
+ + + + diff --git a/grademanagement-SpringMVCProject/web/WEB-INF/view/showGetData.jsp b/grademanagement-SpringMVCProject/web/WEB-INF/view/showGetData.jsp deleted file mode 100644 index b9cf43d..0000000 --- a/grademanagement-SpringMVCProject/web/WEB-INF/view/showGetData.jsp +++ /dev/null @@ -1,82 +0,0 @@ -<%-- - Created by IntelliJ IDEA. - User: DELL - Date: 2026/4/27 - Time: 15:09 - To change this template use File | Settings | File Templates. ---%> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - 商品信息 - - - -
-

商品添加成功!

-

商品信息已成功提交到服务器

- -
- 商品编号: - ${product.productId} -
-
- 商品名称: - ${product.productName} -
-
- 是否热门: - ${product.isPopular} -
-
- 市场价格: - ${product.marketPrice} 元 -
-
- 销售价格: - ${product.salesPrice} 元 -
-
- 分类名称: - ${product.categoryName} -
-
- 商品描述: - ${product.description} -
-
- 上架日期: - ${product.listDate} -
-
- - \ No newline at end of file diff --git a/grademanagement-SpringMVCProject/web/addClassEntity.jsp b/grademanagement-SpringMVCProject/web/addClassEntity.jsp new file mode 100644 index 0000000..2b0ac5f --- /dev/null +++ b/grademanagement-SpringMVCProject/web/addClassEntity.jsp @@ -0,0 +1,23 @@ +<%-- + Created by IntelliJ IDEA. + User: HP + Date: 2026/5/19 + Time: 21:31 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 班级信息 + + +

班级信息

+
+ 班级ID:
+ 班级名称:
+ 年级:
+ 专业:
+ +
+ + diff --git a/grademanagement-SpringMVCProject/web/addProduct.jsp b/grademanagement-SpringMVCProject/web/addProduct.jsp deleted file mode 100644 index 68dbe38..0000000 --- a/grademanagement-SpringMVCProject/web/addProduct.jsp +++ /dev/null @@ -1,107 +0,0 @@ -<%-- - Created by IntelliJ IDEA. - User: DELL - Date: 2026/5/11 - Time: 14:00 - To change this template use File | Settings | File Templates. ---%> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - 添加商品 - - - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - diff --git a/out/production/grademanagement-SpringMVCProject/com/ssm/controller/ProductController.class b/out/production/grademanagement-SpringMVCProject/com/ssm/controller/ProductController.class deleted file mode 100644 index af8326d9884f7eca426a579469075489c4e2b4c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1426 zcma)6%Tg0T6g|!4MKT5m4?%gTU|<^X#OzPkPIgw@inj;c^Hg5nRF55UvF=6U23fz`QVpTwqWV3WI1KT0)+%U@Q_!-ODQ(LzxUH?(R?f}J<(enO z5Y=eouH~=xb{0wAVj| zWXm#+!Kc z2ZwJy9KL&f`1aMWZ|_yy!ko9HRLrA4h}$X_a3_enDi*QC5OKDw-TPdw=#uD;{f}Z8 zI_vn4GTTJ;m}_H??pL6BS}r~4ttd%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