基于javaweb的SSM在线图书商城系统(java+ssm+freemarker+bootstrap+mysql+redis)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

590123002402

000123012402

010123012402

030123012402

040123012402

050123012402

060123012402

070123012402

基于javaweb的SSM在线图书商城系统(java+ssm+freemarker+bootstrap+mysql+redis)

项目介绍

本项目分为前后台,有管理员与用户两种角色; 管理员角色包含以下功能: 管理员登录,商品分类管理,商品管理,商品属性管理,商品参数管理,订单管理,退款管理,退货管理,会员等级管理,客户信息管理,评论管理,文章分类管理,公告管理,文章管理,滚动图片管理,广告管理,热门查询管理,查询订单销售,查询商品销售,用户管理,角色管理,资源管理,修改密码,区域管理,配送方式管理,查看系统设置,缓存管理,查询到货通知等功能。

用户角色包含以下功能: 用户登录,查看首页,查看商品详情,查看购物车,提交订单,修改个人信息,修改密码,查看我的订单,添加配送地址,查看收藏夹等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:Eclipse;注:本项目目前仅支持Eclipse,暂不支持IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;  5.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈

  1. 后端:Spring+SpringMVC+Mbytes 2. 前端:Freemarker+css+javascript+bootstrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用Eclipse导入项目,将项目中src目录下的conf.properties配置文件中的数据库配置改为自己的配置; 3. 运行项目,在浏览器中输入localhost:8080/ssm_zxbookshop 用户账号/密码: user/123456 管理员账号/密码:admin/admin

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
			//发送邮件到用户的邮箱
// MailUtil mail = new MailUtil(e.getEmail());//new MailUtil("543089122@qq.com",SystemManager.getInstance().get("from_email_account"),SystemManager.getInstance().get("from_email_password"), SystemManager.getInstance().get("from_eamil_smtpServer"), "myshop注册验证邮件");//用户注册成功发送邮件
// boolean result = mail.startSend("注册邮箱验证","恭喜,您在myshop站点的账号注册成功!点击下面的链接进行验证。有效时间为2小时。http://myshop.itelse.com");
// logger.error("email resule = " + result);

accountService.sendEmail(e, NotifyTemplate.email_reg);
} else {
// 修改密码
// getServer().update(e);
throw new NullPointerException("不支持!");
}

// getSession().setAttribute("checkEmail","checkEmail");
model.addAttribute("uid", e.getId());
// getResponse().sendRedirect(SystemManager.systemSetting.getWww()+"/account/checkEmail.html");
return "redirect:/account/checkEmail.html";
}

/**
* 用户注册--》再次发送邮件
* @return
* @throws IOException
*/
@RequestMapping(value = "sendEmailAgain", method = RequestMethod.POST)
public String sendEmailAgain(String uid, ModelMap model) throws IOException{
if(StringUtils.isBlank(uid)){
throw new NullPointerException("参数不正确!");
}

Account acc = accountService.selectById(uid);
if(acc==null){
throw new NullPointerException("根据用户ID查询不到用户信息!");
}

accountService.sendEmail(acc, NotifyTemplate.email_reg);
model.addAttribute("uid", acc.getId());
// getResponse().sendRedirect(SystemManager.systemSetting.getWww()+"/account/checkEmail.html");
return "redirect:/account/checkEmail.html";
}
/**
* 转到邮箱验证提示页面
* @return
*/
@RequestMapping("checkEmail")
public String checkEmail(){
logger.info("checkEmail");
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
//			logger.error("还没有评价");
// }else{
// logger.error("已经评价过了");
// }

//加载指定商品的评论列表
// Comment commentParam = new Comment();
// commentParam.setProductID(Integer.valueOf(productID));
// selectCommentList(commentParam);
model.addAttribute("e", e);
return "/rate";
}

/**
* 分页加载评论
* @return
* @throws Exception
*/
private PagerModel selectCommentList(Comment commentParam) throws Exception {
HttpServletRequest request = RequestHolder.getRequest();
int offset = 0;
if (request.getParameter("pager.offset") != null) {
offset = Integer
.parseInt(request.getParameter("pager.offset"));
}
if (offset < 0)
offset = 0;
// Comment comment = new Comment();
((PagerModel) commentParam).setOffset(offset);
PagerModel pager = commentService.selectPageList(commentParam);
if(pager==null)pager = new PagerModel();
// 计算总页数
pager.setPagerSize((pager.getTotal() + pager.getPageSize() - 1)
/ pager.getPageSize());

// selectListAfter();
pager.setPagerUrl("rate");
return pager;
}

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
	}
public void setError(String error) {
this.error = error;
}
}

/**
* 库存检查错误消息对象
*/
class StockErrorProduct{
String id;//商品ID
String tips;//错误消息

public StockErrorProduct(){}

public StockErrorProduct(String id,String tips){
this.id = id;
this.tips = tips;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getTips() {
return tips;
}

public void setTips(String tips) {
this.tips = tips;
}
}

/**
* 购物车页面,单个商品返回的信息对象
*/
class CartProductInfo {
String code;//返回代码
String msg;//返回消息
String total0;//小计金额
String amount;//总计金额
int totalExchangeScore;//兑换此商品所需总积分
int amountExchangeScore;//积分汇总

public String getCode() {
return code;
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
	e.setOffset(offset);
PagerModel pager = getService().selectPageList(e);
if (pager == null) {
pager = new PagerModel();
}
// 计算总页数
pager.setPagerSize((pager.getTotal() + pager.getPageSize() - 1)
/ pager.getPageSize());
pager.setPagerUrl("myCarts");
model.addAttribute("pager", pager);
return "redirect:/account/orders";
}

/**
* 删除我的订单信息
*/
@RequestMapping("deletes")
public String deletes(String[] ids, HttpServletRequest request, @ModelAttribute("e") Order e, ModelMap model) throws Exception {
getService().deletes(ids);
return selectList(request, e, model);
}

/**
* 退订或取消指定的订单
* @return
* @throws Exception
*/
@RequestMapping("shouhuo")
public String shouhuo(String id,HttpServletRequest request, @ModelAttribute("e") Order e, ModelMap model) throws Exception {
Order order = orderService.selectById(id);
order.setStatus("ok");
orderService.update(order);
int offset = 0;//分页偏移量
if (request.getParameter("pager.offset") != null) {
offset = Integer.parseInt(request.getParameter("pager.offset"));
}
if (offset < 0)
offset = 0;
e.setOffset(offset);
PagerModel pager = getService().selectPageList(e);
if (pager == null) {
pager = new PagerModel();
}
// 计算总页数
pager.setPagerSize((pager.getTotal() + pager.getPageSize() - 1)
/ pager.getPageSize());
pager.setPagerUrl("myCarts");
model.addAttribute("pager", pager);
return "redirect:/account/orders";
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
		e.clear();
// if(productList==null){
// logger.error("productList=0");
// }else{
// logger.error("productList="+productList.size());
// }
return "productList";
}

/**
* 根据商品属性加载商品列表
* @return
* @throws Exception
*/
@RequestMapping("productListByAttrID")
public String productListByAttrID(ModelMap model, @ModelAttribute("e")Product e) throws Exception{
try {
// logger.error("attributeID="+attributeID);
// getE().setAttrID(this.attributeID);
// Attribute attr = SystemManager.attrsMap.get(String.valueOf(this.attributeID));
// this.catalogID = attr.getCatalogID();
// logger.error("productListByAttrID catalogID = "+catalogID);
// productList = selectProductList0();
productList(model, e);
} catch (Exception ex) {
logger.error("productListByAttrID()异常:"+ex.getMessage());
ex.printStackTrace();
throw ex;
}
return "productList";
}

/**
* 根据商品目录、子目录、属性、排序等规则分页加载商品列表信息。此方法为商品加载的通用方法。
* @return
* @throws Exception
*/
@RequestMapping("productList")
public String productList(ModelMap model, @ModelAttribute("e")Product e) throws Exception{
try {
String catalogCode = getCatalogCode();
logger.error("special="+e.getSpecial() + ",orderBy="+e.getOrderBy() + ",catalogCode="+catalogCode);

Catalog item = systemManager.getCatalogsCodeMap().get(catalogCode);
if(item==null){
throw new NullPointerException("目录为空!");
}
logger.error("item.getId()="+item.getId());

// getSession().setAttribute("selectMenu", item.getId());//设置选择的商品目录
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
			return toLogin;
}
// selectLeftMenu = "address";
String id = address.getId();
if(StringUtils.isBlank(id)){
throw new NullPointerException("id is null!");
}
Address add = new Address();
add.setId(id);
addressService.delete(add);

return address(model, address);
}

/**
* 编辑指定的配送地址
* @return
*/
@RequestMapping("editAddress")
public String editAddress(ModelMap model, Address address){
Account acc = LoginUserHolder.getLoginAccount();
if (acc == null || StringUtils.isBlank(acc.getAccount())) {
return toLogin;
}
// selectLeftMenu = "address";
String id = address.getId();
if(StringUtils.isBlank(id)){
throw new NullPointerException("id is null!");
}
address = addressService.selectById(id);

//获取区域列表
if(StringUtils.isNotBlank(address.getArea())){
// address.getArea()
Map<String, Area> areaMap = SystemManager.getInstance().getAreaMap();
Area area = areaMap.get(address.getProvince());
if(area!=null && area.getChildren()!=null && area.getChildren().size()>0){
for(int i=0;i<area.getChildren().size();i++){
Area city = area.getChildren().get(i);
if(city.getCode().equals(address.getCity())){

logger.error("address.getCity()="+address.getCity());
logger.error(city.toString());
address.setAreaList(city.getChildren());
break;
}
}
}
}


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