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 af8326d..0000000 Binary files a/out/production/grademanagement-SpringMVCProject/com/ssm/controller/ProductController.class and /dev/null differ diff --git a/out/production/grademanagement-SpringMVCProject/com/ssm/entity/Product.class b/out/production/grademanagement-SpringMVCProject/com/ssm/entity/Product.class deleted file mode 100644 index f13a703..0000000 Binary files a/out/production/grademanagement-SpringMVCProject/com/ssm/entity/Product.class and /dev/null differ