基于javaweb+mysql的二手交易平台二手商城二手物品(前台、后台)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
前台用户:注册、登录、个人信息修改、查询商品、发布和修改商品、收藏、购买、评价等……
后台管理员:登录、分类管理、物品管理、订单管理、用户管理等……
前台用户:
后台管理员:
技术框架
JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) MySQL JavaScript CSS Bootstrap……
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
<div id="review-bar" class="col-md-6 rev1-bar" align="center"
onclick="reviewButton()">
<B style="font-size: 16px; color: #c4c4c4">收到的评论</B>
</div>
<div id="reply-bar" class="col-md-6 rev2-bar" align="center"
onclick="replyButton()">
<B style="font-size: 16px; color: #c4c4c4">收到的回复</B>
</div>
</div>
<div class="col-md-12 r2"
style="background-color: #f9f9f9; padding-bottom: 15px">
<div id="review-body" class="col-md-12 r3"
style="display: none; overflow-y: auto; height: 585px; background-color: #ffffff; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 15px;">
<c:choose>
<c:when test="${reviews.size() == 0}">
<div class="col-md-12" align="center"
style="background-color: #ffffff; margin-top: 150px">
<img src="<c:url value="/statics/image/logo/yihan.png"/>"
width="95%" ; height="170px;">
<p style="color: #c4c4c4; font-size: 16px">抱歉,暂无评论消息!</p>
</div>
function disableUser(userId) {
var dblChoseAlert = simpleAlert({
"content": "确认禁用用户? 用户id:"+userId,
"buttons":{
"确定":function () {
dblChoseAlert.close();
setUserStatus(5, userId);
},
"取消":function () {
dblChoseAlert.close();
}
}
})
}
function deleteUser(userId) {
var dblChoseAlert = simpleAlert({
"content": "确认禁用用户? 用户id:"+userId,
}
System.out.println(user.getMobile());
System.out.println(status);
model.addAttribute("user", user);
model.addAttribute("status", status);
return "home/register";
}
}
package com.demo.controller;
import com.demo.model.FirstType;
import com.demo.model.SecondType;
import com.demo.service.GoodService;
import com.demo.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
List<Good> goods = goodService.getGoodByUserId(user.getId());
List<Order> orders = orderService.getOrderByCustomerId(user.getId());
List<Review> reviews = reviewService.gerReviewByToUserId(user.getId());
List<Reply> replies = reviewService.gerReplyByToUserId(user.getId());
List<Order> sellGoods = orderService.getOrderBySellerId(user.getId());
model.addAttribute("collects", collects);
model.addAttribute("goods", goods);
model.addAttribute("orders", orders);
model.addAttribute("reviews", reviews);
model.addAttribute("replies", replies);
model.addAttribute("sellGoods", sellGoods);
return "user/userProfile";
}
@RequestMapping(value = "/review", method = RequestMethod.GET)
public String getReviewInfo(@RequestParam(required = false) Integer goodId,
@RequestParam(required = false) Integer reviewId) {
System.out.println("reviewId" + reviewId);
if (reviewId != null) {
System.out.println("reviewId" + reviewId);
if (reviewService.updateReviewStatus(1, reviewId) == 1) {
return "redirect:/goods/goodInfo?goodId=" + goodId;
}
}
return "redirect:/user/userProfile";
"newPassword" : password
};
console.log(oldPassword);
console.log(pass)
if (password !== passwordConfirm) {
document.getElementById("passError").innerHTML = "对不起,您2次输入的密码不一致";
} else if (oldPassword === "" || password === "") {
document.getElementById("passError").innerHTML = "对不起,不可以为空!";
} else {
document.getElementById("passError").innerHTML = "";
$.ajax({
type : "POST",
url : "/secondshop/user/password/edit",
contentType : "application/json; charset=UTF-8", //必须这样写
dataType : "json",
data : JSON.stringify(pass),//要提交是json字符串
success : function(data) {
if (data === true) {
alert("密码修改成功!");
} else {
style="background-color: #d2d2d2; height: 92%; padding: 0px;">
<div style="float: right; width: 100%;">
<div id="menu1" onclick="menuBar('menu1')" class="admenu-b"
align="center">
<p>
<B style="font-size: 20px; color: #5c5c5c; cursor: pointer">物品分类管理</B>
</p>
</div>
<div id="menu2" onclick="menuBar('menu2')" class="admenu"
align="center">
<p>
<B style="font-size: 20px; color: #5c5c5c; cursor: pointer">物品管理</B>
</p>
</div>
<div id="menu3" onclick="menuBar('menu3')" class="admenu"
align="center">
<p>
<B style="font-size: 20px; color: #5c5c5c; cursor: pointer">订单管理</B>
</p>
</div>
<div id="menu4" onclick="menuBar('menu4')" class="admenu"
align="center">
<p>
<B style="font-size: 20px; color: #5c5c5c; cursor: pointer">用户管理</B>
import java.text.SimpleDateFormat;
/**
* 物品表
*
* @author WEN
*
*/
public class Good {
private int id;
private String name;
private String photoUrl;
private int firstTypeId;
private int secondTypeId;
private SecondType goodSecondType;
private String describe;
private String uploadDate;
private float prise;
private int statusId;
private int userId;
private User goodUser;
private String update;
<th style="width: 100px">状态</th>
<th>操作</th>
</tr>
</thead>
</table>
</div>
<div class="col-md-12 column"
style="overflow-y: auto; height: 280px;">
<table class="table table-hover">
<tbody id="collectTable">
<c:forEach var="collect" items="${collects}">
<tr style="color: #666666">
<td style="width: 102px"><a target="_blank"
// 生成uuid作为文件名称
String fileName = goodId + randomString.getRandomString(10);
// 获得文件类型(可以判断如果不是图片,禁止上传)
String contentType = mf.getContentType();
// 获得文件后缀名称
String imageName = contentType.substring(contentType
.indexOf("/") + 1);
name = fileName + "." + imageName;
System.out.println("name:" + name);
mf.transferTo(new File(pathRoot , name));
Image image = new Image();
image.setGoodId(goodId);
image.setName(name);
image.setUrl(filePath + "/" + name);
imageService.insertImage(image);
} else {
System.out.println("文件为空!");
}
}
return "redirect:/goods/goodInfo?goodId=" + goodId;
}
@RequestMapping(value = "/goods/userGoods", method = RequestMethod.GET)
public String getUserGoods(ModelMap model,
@RequestParam(value = "userId", required = false) Integer userId) {
$("#secondType-ba").append(secondType);
});
alert("分类添加成功!");
}
}
});
$("#sec").slideUp();
}
function deleteFirst(first_id) {
$.getJSON("/secondshop/type/firstType/delete/"+first_id, function (data) {
if (data === false){
alert("删除失败,请确认该分类下是否还有二级分类!");
} else {
document.getElementById("firstType-ba").innerHTML = "";
$.each(data, function (i, type) {
var firstId = type.id;
String imageName = contentType
.substring(contentType.indexOf("/") + 1);
name = fileName + "." + imageName;
mainFile.transferTo(new File(pathRoot , name));
String photoUrl = filePath + "/" + name;
goodService.updateGoodPhotoUrl(photoUrl, goodId);
}
for (MultipartFile mf : file) {
if (!mf.isEmpty()) {
String contentType = mf.getContentType();
String fileName = goodId + randomString.getRandomString(10);
String imageName = contentType.substring(contentType
.indexOf("/") + 1);
name = fileName + "." + imageName;
System.out.println("name:" + name);
mf.transferTo(new File(pathRoot,name));
Image image = new Image();
image.setGoodId(goodId);
image.setName(name);
image.setUrl(filePath + "/" + name);
imageService.insertImage(image);
}
</div>
<div class="col-md-4">
<img src="<c:url value="${user.photoUrl}"/>" id="img"
height="120px" width="120px">
</div>
</div>
<spring:bind path="name">
<div class="form-group">
<form:label path="name" cssClass="control-label">姓名</form:label>
<form:input path="name" cssClass="form-control"></form:input>
</div>
</spring:bind>
<spring:bind path="gender">
<div class="form-group">
<form:label path="gender" cssClass="control-label">性别</form:label>
<form:select path="gender" id="gender" cssClass="form-control">
<form:option value="男">男</form:option>
<form:option value="女">女</form:option>
</form:select>
</div>
.isEmpty();
System.out.println(goodService.getGoodsAdminByType(secondTypeId));
if (success) {
Integer thisFirstTypeId = typeService.getSecondTypeById(
secondTypeId).getFirstTypeId();
success = typeService.deleteSecondType(secondTypeId);
if (success) {
List<SecondType> secondTypeList = typeService
.getSecondTypeByFirstTypeId(thisFirstTypeId);
if (secondTypeList == null) {
return ResponseEntity.ok("isNull");
}
return ResponseEntity.ok(secondTypeList);
}
}
return ResponseEntity.ok(success);
}
@RequestMapping(value = "/firstType/delete/{firstTypeId}", method = RequestMethod.GET)
List<FirstType> firstTypes = typeService.getAllFirstType();
User user = (User) session.getAttribute("user");
if (user == null) {
return "redirect:/";
}
List<Good> goods = goodService.getAllGoods(0, 5);
if (!(goodService.updateGood(good) > 0)) {
System.out.println("修改物品失败!");
}
List<Image> goodImages = imageService.getImageByGoodId(good.getId());
model.addAttribute("goods", goods);
model.addAttribute("good", good);
model.addAttribute("goodImages", goodImages);
model.addAttribute("firstTypes", firstTypes);
return "goods/userGoodEdit";
}
@RequestMapping(value = "/goods/userGoodEdit/updateImage", method = RequestMethod.POST)
public String updateImage(
HttpSession session,
@RequestParam(value = "goodId", required = false) Integer goodId,
@RequestParam(value = "mainFile", required = false) MultipartFile mainFile,
@RequestParam(value = "file", required = false) MultipartFile[] file)
throws IOException {
User user = (User) session.getAttribute("user");
FileCheck fileCheck = new FileCheck();