parent
94b5a8a866
commit
463bd833c0
@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package com.ssm.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ClassMapper {
|
||||
Class getClassById(Integer classId);
|
||||
List<Class> getAllClasses();
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ssm.mapper.ClassMapper">
|
||||
<select id="getClassById" resultType="com.ssm.entity.ClassEntity">
|
||||
SELECT classId, className, grade, major, teacher, studentCount, description
|
||||
FROM class
|
||||
WHERE classId = #{classId}
|
||||
</select>
|
||||
<select id="getAllClasses" resultType="com.ssm.entity.ClassEntity">
|
||||
SELECT classId, className, grade, major, teacher, studentCount, description
|
||||
FROM class
|
||||
ORDER BY classId
|
||||
</select>
|
||||
</mapper>
|
||||
@ -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";
|
||||
}
|
||||
}
|
||||
@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>商品信息</title>
|
||||
<style>
|
||||
.result-container {
|
||||
width: 600px;
|
||||
margin: 20px auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.result-title {
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.result-row {
|
||||
margin: 10px 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
.result-label {
|
||||
font-weight: bold;
|
||||
color: #555;
|
||||
}
|
||||
.success-message {
|
||||
color: green;
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="result-container">
|
||||
<h2 class="result-title">商品添加成功!</h2>
|
||||
<p class="success-message">商品信息已成功提交到服务器</p>
|
||||
|
||||
<div class="result-row">
|
||||
<span class="result-label">商品编号:</span>
|
||||
<span>${product.productId}</span>
|
||||
</div>
|
||||
<div class="result-row">
|
||||
<span class="result-label">商品名称:</span>
|
||||
<span>${product.productName}</span>
|
||||
</div>
|
||||
<div class="result-row">
|
||||
<span class="result-label">是否热门:</span>
|
||||
<span>${product.isPopular}</span>
|
||||
</div>
|
||||
<div class="result-row">
|
||||
<span class="result-label">市场价格:</span>
|
||||
<span>${product.marketPrice} 元</span>
|
||||
</div>
|
||||
<div class="result-row">
|
||||
<span class="result-label">销售价格:</span>
|
||||
<span>${product.salesPrice} 元</span>
|
||||
</div>
|
||||
<div class="result-row">
|
||||
<span class="result-label">分类名称:</span>
|
||||
<span>${product.categoryName}</span>
|
||||
</div>
|
||||
<div class="result-row">
|
||||
<span class="result-label">商品描述:</span>
|
||||
<span>${product.description}</span>
|
||||
</div>
|
||||
<div class="result-row">
|
||||
<span class="result-label">上架日期:</span>
|
||||
<span>${product.listDate}</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -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" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>添加商品</title>
|
||||
<style>
|
||||
.form-container {
|
||||
width: 600px;
|
||||
margin: 20px auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.form-row {
|
||||
margin: 15px 0;
|
||||
}
|
||||
.form-row label {
|
||||
display: inline-block;
|
||||
width: 100px;
|
||||
text-align: right;
|
||||
margin-right: 15px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.form-row input[type="text"],
|
||||
.form-row input[type="number"],
|
||||
.form-row select {
|
||||
width: 250px;
|
||||
padding: 5px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
}
|
||||
.form-row textarea {
|
||||
width: 400px;
|
||||
height: 80px;
|
||||
padding: 5px;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 14px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.form-row input[type="file"] {
|
||||
padding: 5px;
|
||||
}
|
||||
.button-row {
|
||||
margin-left: 115px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.button-row input {
|
||||
padding: 5px 20px;
|
||||
margin-right: 100px;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="form-container">
|
||||
<form action="${pageContext.request.contextPath}/product/addProduct.action" method="post" enctype="multipart/form-data">
|
||||
<div class="form-row">
|
||||
<label>商品编号:</label>
|
||||
<input type="text" name="productId" value="1" readonly style="background-color: #e8f0fe;">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>商品名称:</label>
|
||||
<input type="text" name="productName" value="菠萝">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>是否热门:</label>
|
||||
<select name="isPopular">
|
||||
<option value="是" selected>是</option>
|
||||
<option value="否">否</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>市场价格:</label>
|
||||
<input type="number" name="marketPrice" value="23" step="0.01" style="background-color: #e8f0fe;">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>销售价格:</label>
|
||||
<input type="number" name="salesPrice" value="23" step="0.01" style="background-color: #e8f0fe;">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>商品图片:</label>
|
||||
<input type="file" name="productImage">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>分类名称:</label>
|
||||
<input type="text" name="categoryName" value="水果">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>商品描述:</label>
|
||||
<textarea name="description">菠萝.....</textarea>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>上架日期:</label>
|
||||
<input type="text" name="listDate" value="2025-3-25">
|
||||
</div>
|
||||
<div class="button-row">
|
||||
<input type="reset" value="重置">
|
||||
<input type="submit" value="添加">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue