基于javaweb的SSM校园二手市场系统(java+ssm+jsp+tomcat+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

140023012402

150023012402

170023012402

180023012402

190023012402

200023012402

200023012403

基于javaweb的SSM校园二手市场系统(java+ssm+jsp+tomcat+mysql)

1
2
3
4
5
6
7
8
9
前台用户:
13600000001 123456
13600000002 123456
13600000003 123456
13600000004 123456
13600000005 123456

后台管理员:
13588888888 123456

本系统分为前后台,主要实现的功能有:

前台:(1)二手物品信息查看、搜索。
(2)学生注册登录、个人信息修改。
(3)二手物品信息发布、编辑。
(4)二手物品评论、回复、举报。
(5)求购信息发布。
(6)求购信息查看。

后台:(1)管理员登录。
(2)系统管理:菜单管理、角色用户管理、权限管理、日志管理、数据库备份。
(3)业务管理:二手物品管理、求购物品管理、学生信息管理、评论管理、举报管理。
(4)站点管理:友情链接管理、站点基本信息(站点名称、logo、版权等)设置。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    // } else {
Integer userId = cur_user.getId();
Purse myPurse = purseService.getPurseByUserId(userId);
ModelAndView mv = new ModelAndView();
mv.addObject("myPurse", myPurse);
mv.setViewName("/goods/pubGoods");
return mv;
}

/**
* 提交发布的商品信息
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/publishGoodsSubmit")
public String publishGoodsSubmit(HttpServletRequest request, Image ima, Goods goods, MultipartFile image)
throws Exception {
// 查询出当前用户cur_user对象,便于使用id
User cur_user = (User) request.getSession().getAttribute("cur_user");
goods.setUserId(cur_user.getId());
goodsService.addGood(goods, 10);// 在goods表中插入物品
// 返回插入的该物品的id
int goodsId = goods.getId();
ima.setGoodsId(goodsId);
imageService.insert(ima);// 在image表中插入商品图片
// 发布商品后,catlog的number+1,user表的goods_num+1,更新session的值
int number = cur_user.getGoodsNum();
Integer calelog_id = goods.getCatelogId();
Catelog catelog = catelogService.selectByPrimaryKey(calelog_id);
catelogService.updateCatelogNum(calelog_id, catelog.getNumber() + 1);
userService.updateGoodsNum(cur_user.getId(), number + 1);
cur_user.setGoodsNum(number + 1);
request.getSession().setAttribute("cur_user", cur_user);// 修改session值
return "redirect:/user/allGoods";
}

/**
* 上传物品
*
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
        List<Image> imageList = imageService.getImagesByGoodsPrimaryKey(goods.getId());
goodsExtend.setGoods(goods);
goodsExtend.setImages(imageList);
goodsExtendList.add(i, goodsExtend);
}
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("goodsExtendList", goodsExtendList);
modelAndView.addObject("catelog", catelog);
modelAndView.addObject("search", str);
modelAndView.setViewName("/goods/catelogGoods");
return modelAndView;
}

/**
* 根据商品id查询该商品详细信息
*
* @param id
* @return
* @throws Exception
*/
@RequestMapping(value = "/goodsId/{id}")
public ModelAndView getGoodsById(HttpServletRequest request, @PathVariable("id") Integer id,
@RequestParam(value = "str", required = false) String str) throws Exception {
Goods goods = goodsService.getGoodsByPrimaryKey(id);
User seller = userService.selectByPrimaryKey(goods.getUserId());
Catelog catelog = catelogService.selectByPrimaryKey(goods.getCatelogId());
GoodsExtend goodsExtend = new GoodsExtend();
List<Image> imageList = imageService.getImagesByGoodsPrimaryKey(id);
CommentExtend CommentExtend = goodsService.selectCommentsByGoodsId(id);
goodsExtend.setGoods(goods);
goodsExtend.setImages(imageList);
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("CommentExtend", CommentExtend);
modelAndView.addObject("goodsExtend", goodsExtend);
modelAndView.addObject("seller", seller);
modelAndView.addObject("search", str);
modelAndView.addObject("catelog", catelog);
modelAndView.setViewName("/goods/detailGoods");
return modelAndView;

}

/**
* 发布评论
*
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    @RequestMapping(value = "/receipt")
public String receipt(HttpServletRequest request) {
Integer orderNum=Integer.parseInt(request.getParameter("orderNum"));
Float balance=Float.parseFloat(request.getParameter("orderPrice"));
Integer goodsId=Integer.parseInt(request.getParameter("goodsId"));
Integer userId=goodsService.getGoodsById(goodsId).getUserId();
ordersService.receiptByOrderNum(orderNum);
purseService.updatePurseByuserId(userId,balance);
/*买家确认收货后,卖家钱包+*/
return "redirect:/orders/myOrders";
}

}
package com.ldu.service.impl;




@Service("userService")
public class UserServiceImpl implements UserService {

@Resource
private UserMapper userMapper;

public void addUser(User user) {
userMapper.insert(user);
}

public User getUserByPhone(String phone) {
User user = userMapper.getUserByPhone(phone);
return user;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
        Integer userId = cur_user.getId();
Purse myPurse = purseService.getPurseByUserId(userId);
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("goodsExtend", goodsExtend);
modelAndView.addObject("myPurse", myPurse);
modelAndView.setViewName("/user/pay");
return modelAndView;
}

}
package com.ldu.controller;



/**
*/
@Controller
@RequestMapping(value = "/admin")
public class AdminController {

@Resource
private UserService userService;

@Resource
private GoodsService goodsService;

@Resource
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@RequestMapping(value = "/basic")
public ModelAndView basic(HttpServletRequest request) {
User cur_user = (User) request.getSession().getAttribute("cur_user");
Integer userId = cur_user.getId();
Purse myPurse = purseService.getPurseByUserId(userId);
ModelAndView mv = new ModelAndView();
mv.addObject("myPurse", myPurse);
mv.setViewName("/user/basic");
return mv;
}

/**
* 我的闲置 查询出所有的用户商品以及商品对应的图片
*
* @return 返回的model为 goodsAndImage对象,该对象中包含goods 和 images,参考相应的类
*/
@RequestMapping(value = "/allGoods")
public ModelAndView goods(HttpServletRequest request) {
User cur_user = (User) request.getSession().getAttribute("cur_user");
Integer userId = cur_user.getId();
List<Goods> goodsList = goodsService.getGoodsByUserId(userId);
List<GoodsExtend> goodsAndImage = new ArrayList<GoodsExtend>();
for (int i = 0; i < goodsList.size(); i++) {
// 将用户信息和image信息封装到GoodsExtend类中,传给前台
GoodsExtend goodsExtend = new GoodsExtend();
Goods goods = goodsList.get(i);
List<Image> images = imageService.getImagesByGoodsPrimaryKey(goods.getId());
goodsExtend.setGoods(goods);
goodsExtend.setImages(images);
goodsAndImage.add(i, goodsExtend);
}
Purse myPurse = purseService.getPurseByUserId(userId);
ModelAndView mv = new ModelAndView();
mv.addObject("goodsAndImage", goodsAndImage);
mv.setViewName("/user/goods");
mv.addObject("myPurse", myPurse);
return mv;
}

/**
* 我的关注 查询出所有的用户商品以及商品对应的图片
*
* @return 返回的model为 goodsAndImage对象,该对象中包含goods 和 images,参考相应的类
*/
@RequestMapping(value = "/allFocus")
public ModelAndView focus(HttpServletRequest request) {
User cur_user = (User) request.getSession().getAttribute("cur_user");
Integer userId = cur_user.getId();
List<Focus> focusList = focusService.getFocusByUserId(userId);
List<GoodsExtend> goodsAndImage = new ArrayList<GoodsExtend>();
for (int i = 0; i < focusList.size(); i++) {
// 将用户信息和image信息封装到GoodsExtend类中,传给前台
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@Controller
@RequestMapping(value = "/goods")
public class GoodsController {
@Autowired
private GoodsService goodsService;
@Autowired
private ImageService imageService;
@Autowired
private CatelogService catelogService;
@Autowired
private UserService userService;
@Resource
private PurseService purseService;

public static String file_path = "C:\\Users\\joey\\Desktop\\SSM校园二手市场系统(java+ssm+jsp+tomcat+mysql)\\db\\web\\upload";


/**
* 首页显示商品,每一类商品查询6件,根据最新上架排序 key的命名为catelogGoods1、catelogGoods2....
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/homeGoods")
public ModelAndView homeGoods() throws Exception {
ModelAndView modelAndView = new ModelAndView();
// 商品种类数量
int catelogSize = 7;
// 每个种类显示商品数量
int goodsSize = 6;

List<Goods> goodsList = null;
List<GoodsExtend> goodsAndImage = null;

/* 获取最新发布列表 */
goodsList = goodsService.getGoodsOrderByDate(goodsSize);
goodsAndImage = new ArrayList<GoodsExtend>();
for (int j = 0; j < goodsList.size(); j++) {
// 将用户信息和image信息封装到GoodsExtend类中,传给前台
GoodsExtend goodsExtend = new GoodsExtend();
Goods goods = goodsList.get(j);
List<Image> images = imageService.getImagesByGoodsPrimaryKey(goods.getId());
goodsExtend.setGoods(goods);
goodsExtend.setImages(images);
goodsAndImage.add(j, goodsExtend);
}


项目链接:
https://javayms.github.io?id=571422282105200dz
https://javayms.pages.dev?id=571422282105200dz