基于javaweb的SSM+Maven校园二手交易平台(java+ssm+thymeleaf+html+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

010023132402

020023132402

030023132402

040023132402

050023132402

060023132402

070023132402

基于javaweb的SSM+Maven校园二手交易平台(java+ssm+thymeleaf+html+jquery+mysql)

项目介绍

本次设计的是一个校园二手交易平台(C2C),C2C指个人与个人之间的电子商务,买家可以查看所有卖家发布的商品,并且根据分类进行商品过滤,也可以根据站内搜索引擎进行商品的查询,并且与卖家联系,达成交易的意向,也可以发布求购的信息,让卖家查看之后,与之联系,进行交易。而此次主要是针对校园用户所设计的网站,对于数据的分类应该更多的考虑校园用户的需求,例如二手书籍、二手数码等的分类应该更加细致。由于是C2C的项目,因此本项目无需后台管理。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目  6.数据库:MySql 5.7版本;

技术栈

  1. 后端:Spring SpringMVC MyBatis 2. 前端:Thymeleaf+Html+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/xxx 登录

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

/**
* 注册中心
*/
@Controller
public class RegisterController {
@Resource
private UserPasswordService userPasswordService;

@Resource
private UserInformationService userInformationService;

//开始注册用户
@RequestMapping("/insertUser.do")
@ResponseBody
public BaseResponse insertUser(HttpServletRequest request,
@RequestParam String password, @RequestParam String token) {
//存储与session中的手机号码
String realPhone = (String) request.getSession().getAttribute("phone");
//token,唯一标识
String insertUserToken = (String) request.getSession().getAttribute("token");
//防止重复提交
if (StringUtils.getInstance().isNullOrEmpty(insertUserToken) || !insertUserToken.equals(token)) {
return BaseResponse.fail();
}
//该手机号码已经存在
int uid = userInformationService.selectIdByPhone(realPhone);
if (uid != 0) {
return BaseResponse.fail();
}

//用户信息
UserInformation userInformation = new UserInformation();
userInformation.setPhone(realPhone);
userInformation.setCreatetime(new Date());
String username = (String) request.getSession().getAttribute("name");
userInformation.setUsername(username);
userInformation.setModified(new Date());
int result;
result = userInformationService.insertSelective(userInformation);
//如果用户基本信息写入成功
if (result == 1) {
uid = userInformationService.selectIdByPhone(realPhone);
String newPassword = StringUtils.getInstance().getMD5(password);
UserPassword userPassword = new UserPassword();
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
            ShopInformationBean shopInformationBean = new ShopInformationBean();
shopInformationBean.setId(shopInformation.getId());
shopInformationBean.setName(shopInformation.getName());
shopInformationBean.setLevel(shopInformation.getLevel());
shopInformationBean.setPrice(shopInformation.getPrice().doubleValue());
shopInformationBean.setRemark(shopInformation.getRemark());
shopInformationBean.setSort(stringBuffer);
shopInformationBean.setQuantity(shopInformation.getQuantity());
shopInformationBean.setUid(shopInformation.getUid());
shopInformationBean.setTransaction(shopInformation.getTransaction());
shopInformationBean.setImage(shopInformation.getImage());
list.add(shopInformationBean);
}
model.addAttribute("shopInformationBean", list);
} catch (Exception e) {
e.printStackTrace();
return "page/login_page";
}
return "index";
}

//进入商城
@RequestMapping(value = "/mall_page.do")
public String mallPage(HttpServletRequest request, Model model) {
UserInformation userInformation = (UserInformation) request.getSession().getAttribute("userInformation");
if (StringUtils.getInstance().isNullOrEmpty(userInformation)) {
userInformation = new UserInformation();
model.addAttribute("userInformation", userInformation);
} else {
model.addAttribute("userInformation", userInformation);
}
try {
List<ShopInformation> shopInformations = selectTen(1, 12);
List<ShopInformationBean> list = new ArrayList<>();
int counts = getShopCounts();
model.addAttribute("shopInformationCounts", counts);
String sortName;
for (ShopInformation shopInformation : shopInformations) {
int sort = shopInformation.getSort();
sortName = getSortName(sort);
ShopInformationBean shopInformationBean = new ShopInformationBean();
shopInformationBean.setId(shopInformation.getId());
shopInformationBean.setName(shopInformation.getName());
shopInformationBean.setLevel(shopInformation.getLevel());
shopInformationBean.setRemark(shopInformation.getRemark());
shopInformationBean.setPrice(shopInformation.getPrice().doubleValue());
shopInformationBean.setSort(sortName);
shopInformationBean.setQuantity(shopInformation.getQuantity());
shopInformationBean.setTransaction(shopInformation.getTransaction());
shopInformationBean.setUid(shopInformation.getUid());
shopInformationBean.setImage(shopInformation.getImage());
list.add(shopInformationBean);
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
53
54
//            message.setRecipient(Message.RecipientType.TO, new InternetAddress(phone));
// message.setSubject("来自WSK的验证码");
// message.setContent(text, "text/html;charset=UTF-8");
// //这里先不发生信息,以后要开启的
// ts.sendMessage(message, message.getAllRecipients());
// ts.close();
req.getSession().setAttribute("phone", realPhone);
return BaseResponse.success();
} catch (Exception me) {
me.printStackTrace();
return BaseResponse.fail();
}
}

// get the random phone`s code
private void getRandomForCodePhone(HttpServletRequest req) {
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 4; i++) {
sb.append(random.nextInt(10));
}
System.out.println(sb.toString());
req.getSession().setAttribute("codePhone", sb.toString());
}

// //检验验证码
// private boolean checkPhoto(String photo, HttpServletRequest request) {
// photo = photo.toLowerCase();
// String true_photo = (String) request.getSession().getAttribute("rand");
// return true_photo.equals(photo);
// }

//To determine whether the user's mobile phone number exists
private boolean isUserPhoneExists(String phone) {
boolean result = false;
try {
int id = userInformationService.selectIdByPhone(phone);
if (id == 0) {
return result;
}
UserInformation userInformation = userInformationService.selectByPrimaryKey(id);

if (StringUtils.getInstance().isNullOrEmpty(userInformation)) {
return false;
}
String userPhone = userInformation.getPhone();
result = !userPhone.equals("");
} catch (Exception e) {
e.printStackTrace();
return result;
}
return result;
}

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
            return "redirect:publish_product.do?error=1";
} else {
request.getSession().removeAttribute("goodsToken");
}
// //从session中获得用户的基本信息
UserInformation userInformation = (UserInformation) request.getSession().getAttribute("userInformation");
model.addAttribute("userInformation", userInformation);
if (StringUtils.getInstance().isNullOrEmpty(userInformation)) {
//如果用户不存在,
return "redirect:/login.do";
}
name = StringUtils.getInstance().replaceBlank(name);
remark = StringUtils.getInstance().replaceBlank(remark);
//judge the data`s format
if (StringUtils.getInstance().isNullOrEmpty(name) || StringUtils.getInstance().isNullOrEmpty(level) || StringUtils.getInstance().isNullOrEmpty(remark) || StringUtils.getInstance().isNullOrEmpty(price)
|| StringUtils.getInstance().isNullOrEmpty(sort) || StringUtils.getInstance().isNullOrEmpty(quantity) || name.length() > 25 || remark.length() > 122) {
model.addAttribute("message", "请输入正确的格式!!!!!");
model.addAttribute("token", goodsToken);
request.getSession().setAttribute("goodsToken", goodsToken);
return "page/publish_product";
}
//插入
if (action == 1) {
if (StringUtils.getInstance().isNullOrEmpty(image)) {
model.addAttribute("message", "请选择图片!!!");
model.addAttribute("token", goodsToken);
request.getSession().setAttribute("goodsToken", goodsToken);
return "redirect:publish_product.do?error=请插入图片";
}
String random;
String path = "D:\\", save = "";
random = "image\\" + StringUtils.getInstance().getRandomChar() + System.currentTimeMillis() + ".jpg";
StringBuilder thumbnails = new StringBuilder();
thumbnails.append(path);
thumbnails.append("image/thumbnails/");
StringBuilder wsk = new StringBuilder();
wsk.append(StringUtils.getInstance().getRandomChar()).append(System.currentTimeMillis()).append(".jpg");
thumbnails.append(wsk);
// String fileName = "\\" + random + ".jpg";
File file = new File(path, random);
if (!file.exists()) {
file.mkdir();
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



/**
*/
@Controller
@Slf4j
public class UserController {

@Resource
private UserInformationService userInformationService;
@Resource
private UserPasswordService userPasswordService;
@Resource
private UserCollectionService userCollectionService;
@Resource
private UserReleaseService userReleaseService;
@Resource
private BoughtShopService boughtShopService;
@Resource
private UserWantService userWantService;
@Resource
private ShopCarService shopCarService;
@Resource
private OrderFormService orderFormService;
@Resource
private GoodsOfOrderFormService goodsOfOrderFormService;
@Resource
private UserStateService userStateService;
@Resource
private ShopInformationService shopInformationService;


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