基于javaweb+mysql的ssm鲜花商城管理系统(java+ssm+bootstrap+jsp+jquery+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM鲜花商城管理系统(java+ssm+bootstrap+jsp+jquery+mysql)
管理员
admin 123456
用户
user1 123456
user2 123456
user3 123456
项目介绍
系统功能: 用户:登录、注册、商品查询、公告预览、留言、订单管理、商品商城、修改密码、个人信息修改、商品查询。 管理员:登录、类别管理、用户管理、商品管理、订单管理、公告管理、留言管理
环境需要
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/8.0等版本均可;
技术栈
后台框架:Spring、SpringMVC、MyBatis UI界面:JSP、jQuery 、BootStrap
数据库:MySQL
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目; 3. 将项目中db.xml配置文件中的数据库配置改为自己的配置,然后运行;
itemCategoryService.insert(itemCategory);
return "redirect:/itemCategory/findBySql.action";
}
/**
* 转向到修改一级类目页面
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model){
ItemCategory obj = itemCategoryService.load(id);
model.addAttribute("obj",obj);
return "itemCategory/update";
}
/**
* 修改一级类目
*/
@RequestMapping("/exUpdate")
public String exUpdate(ItemCategory itemCategory){
itemCategoryService.updateById(itemCategory);
return "redirect:/itemCategory/findBySql.action";
}
/**
* 删除类目
*/
@RequestMapping("/delete")
public String delete(Integer id){
//删除本身
ItemCategory load = itemCategoryService.load(id);
load.setIsDelete(1);
itemCategoryService.updateById(load);
//将下级也删除
String sql = "update item_category set isDelete=1 where pid="+id;
itemCategoryService.updateBysql(sql);
return "redirect:/itemCategory/findBySql.action";
}
/**
* 查看二级类目
*/
@RequestMapping("/findBySql2")
public String findBySql2(ItemCategory itemCategory,Model model){
String sql = "select * from item_category where isDelete=0 and pid="+itemCategory.getPid()+" order by id";
Pager<ItemCategory> pagers = itemCategoryService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",itemCategory);
return "itemCategory/itemCategory2";
}
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/uLogin";
}
//保存到收藏表
Integer userId = Integer.valueOf(attribute.toString());
sc.setUserId(userId);
scService.insert(sc);
//商品表收藏数+1
Item item = itemService.load(sc.getItemId());
item.setScNum(item.getScNum()+1);
itemService.updateById(item);
return "redirect:/sc/findBySql.action";
}
/**
* 收藏列表
*/
@RequestMapping("/findBySql")
public String findBySql(Model model,HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
String sql = "select * from sc where user_id="+userId+" order by id desc";
Pager<Sc> pagers = scService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
return "sc/my";
}
/**
* 取消收藏
*/
@RequestMapping("/delete")
public String delete(Integer id,HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/uLogin";
}
scService.deleteById(id);
return "redirect:/sc/findBySql.action";
}
}
return "item/item";
}
/**
* 添加商品入口
*/
@RequestMapping("/add")
public String add(Model model){
String sql = "select * from item_category where isDelete = 0 and pid is not null order by id";
List<ItemCategory> listBySqlReturnEntity = itemCategoryService.listBySqlReturnEntity(sql);
model.addAttribute("types",listBySqlReturnEntity);
return "item/add";
}
/**
* 执行添加商品
*/
@RequestMapping("/exAdd")
public String exAdd(Item item, @RequestParam("file")CommonsMultipartFile[] files, HttpServletRequest request) throws IOException {
itemCommon(item, files, request);
item.setGmNum(0);
item.setIsDelete(0);
item.setScNum(0);
itemService.insert(item);
return "redirect:/item/findBySql.action";
}
/**
* 修改商品入口
*/
@RequestMapping("/update")
public String update(Integer id,Model model){
Item obj = itemService.load(id);
String sql = "select * from item_category where isDelete = 0 and pid is not null order by id";
List<ItemCategory> listBySqlReturnEntity = itemCategoryService.listBySqlReturnEntity(sql);
model.addAttribute("types",listBySqlReturnEntity);
model.addAttribute("obj",obj);
return "item/update";
}
/**
* 执行修改商品
*/
@RequestMapping("/exUpdate")
public String exUpdate(Item item, @RequestParam("file")CommonsMultipartFile[] files, HttpServletRequest request) throws IOException {
itemCommon(item, files, request);
itemService.updateById(item);
return "redirect:/item/findBySql.action";
}
/**
* 订单管理
*/
@Controller
@RequestMapping("/itemOrder")
public class ItemOrderController extends BaseController {
@Autowired
private ItemOrderService itemOrderService;
@Autowired
private UserService userService;
@Autowired
private CarService carService;
@Autowired
private OrderDetailService orderDetailService;
@Autowired
private ItemService itemService;
/**
* 订单管理列表
*/
@RequestMapping("/findBySql")
public String findBySql(ItemOrder itemOrder, Model model){
//分页查询
String sql = "select * from item_order where 1=1 ";
sql += " order by (price+0) desc";
}
if(!isEmpty(item.getGmNum())){
sql += " order by gmNum desc";
}
if(isEmpty(item.getPrice())&&isEmpty(item.getGmNum())){
sql += " order by id desc";
}
Pager<Item> pagers = itemService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",item);
return "item/shoplist";
}
@RequestMapping("/view")
public String view(Integer id,Model model){
Item obj = itemService.load(id);
model.addAttribute("obj",obj);
return "item/view";
}
}
/**
* 类目c层
*/
@Controller
itemCategoryService.updateBysql(sql);
return "redirect:/itemCategory/findBySql.action";
}
/**
* 查看二级类目
*/
@RequestMapping("/findBySql2")
public String findBySql2(ItemCategory itemCategory,Model model){
String sql = "select * from item_category where isDelete=0 and pid="+itemCategory.getPid()+" order by id";
Pager<ItemCategory> pagers = itemCategoryService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",itemCategory);
return "itemCategory/itemCategory2";
}
/**
* 转向到新增二级类目页面
*/
@RequestMapping(value = "/add2")
public String add2(int pid,Model model){
model.addAttribute("pid",pid);
return "itemCategory/add2";
}
/**
* 新增二级类目保存功能
*/
@RequestMapping("/exAdd2")
public String exAdd2(ItemCategory itemCategory){
itemCategory.setIsDelete(0);
itemCategoryService.insert(itemCategory);
return "redirect:/itemCategory/findBySql2.action?pid="+itemCategory.getPid();
}
/**
* 转向到修改二级类目页面
*/
@RequestMapping(value = "/update2")
public String update2(Integer id,Model model){
ItemCategory obj = itemCategoryService.load(id);
model.addAttribute("obj",obj);
return "itemCategory/update2";
}
/**
* 修改二级类目
*/
@RequestMapping("/exUpdate2")
public String exUpdate2(ItemCategory itemCategory){
itemCategoryService.updateById(itemCategory);
/**
* 留言管理
*/
@Controller
@RequestMapping("/message")
public class MessageController extends BaseController {
@Autowired
private MessageService messageService;
/**
* 留言列表
*/
@RequestMapping("/findBySql")
public String findBySql(Message message, Model model){
String sql = "select * from message where 1=1 ";
if(!isEmpty(message.getName())){
sql += " and name like '%"+message.getName()+"%'";
}
sql += " order by id desc";
Pager<Message> pagers = messageService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",message);
return "message/message";
}
/**
* 删除留言
*/
@RequestMapping("/delete")
public String delete(Integer id){
messageService.deleteById(id);
return "redirect:/message/findBySql";
}
/**
* 发表留言进入
}
if(!isEmpty(item.getGmNum())){
sql += " order by gmNum desc";
}
if(isEmpty(item.getPrice())&&isEmpty(item.getGmNum())){
sql += " order by id desc";
}
Pager<Item> pagers = itemService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",item);
return "item/shoplist";
}
@RequestMapping("/view")
public String view(Integer id,Model model){
Item obj = itemService.load(id);
model.addAttribute("obj",obj);
return "item/view";
}
}
}
sql += " order by id desc";
Pager<Message> pagers = messageService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",message);
return "message/message";
}
/**
* 删除留言
*/
@RequestMapping("/delete")
public String delete(Integer id){
messageService.deleteById(id);
return "redirect:/message/findBySql";
}
/**
* 发表留言进入
*/
@RequestMapping("/add")
public String add(){
return "message/add";
}
/**
* 发表留言
*/
@RequestMapping("/exAdd")
@ResponseBody
public String exAdd(Message message){
messageService.insert(message);
JSONObject js = new JSONObject();
js.put("message","添加成功");
return js.toString();
}
}
/**
* 分页查询类目列表
*/
@RequestMapping("/findBySql")
public String findBySql(Model model,ItemCategory itemCategory){
String sql = "select * from item_category where isDelete = 0 and pid is null order by id";
Pager<ItemCategory> pagers = itemCategoryService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",itemCategory);
return "itemCategory/itemCategory";
}
/**
* 转向到新增一级类目页面
*/
@RequestMapping(value = "/add")
public String add(){
return "itemCategory/add";
}
/**
* 新增一级类目保存功能
*/
@RequestMapping("/exAdd")
public String exAdd(ItemCategory itemCategory){
itemCategory.setIsDelete(0);
itemCategoryService.insert(itemCategory);
return "redirect:/itemCategory/findBySql.action";
}
/**
* 转向到修改一级类目页面
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model){
ItemCategory obj = itemCategoryService.load(id);
model.addAttribute("obj",obj);
return "itemCategory/update";
}
/**
* 修改一级类目
*/
@RequestMapping("/exUpdate")
public String exUpdate(ItemCategory itemCategory){
itemCategoryService.updateById(itemCategory);
return "redirect:/itemCategory/findBySql.action";
}
/**
* 删除类目
*/
/**
* 添加商品入口
*/
@RequestMapping("/add")
public String add(Model model){
String sql = "select * from item_category where isDelete = 0 and pid is not null order by id";
List<ItemCategory> listBySqlReturnEntity = itemCategoryService.listBySqlReturnEntity(sql);
model.addAttribute("types",listBySqlReturnEntity);
return "item/add";
}
/**
* 执行添加商品
*/
@RequestMapping("/exAdd")
public String exAdd(Item item, @RequestParam("file")CommonsMultipartFile[] files, HttpServletRequest request) throws IOException {
itemCommon(item, files, request);
item.setGmNum(0);
item.setIsDelete(0);
item.setScNum(0);
itemService.insert(item);
return "redirect:/item/findBySql.action";
}
/**
* 修改商品入口
*/
@RequestMapping("/update")
public String update(Integer id,Model model){
Item obj = itemService.load(id);
String sql = "select * from item_category where isDelete = 0 and pid is not null order by id";
List<ItemCategory> listBySqlReturnEntity = itemCategoryService.listBySqlReturnEntity(sql);
model.addAttribute("types",listBySqlReturnEntity);
model.addAttribute("obj",obj);
return "item/update";
}
/**
* 执行修改商品
*/
@RequestMapping("/exUpdate")
public String exUpdate(Item item, @RequestParam("file")CommonsMultipartFile[] files, HttpServletRequest request) throws IOException {
itemCommon(item, files, request);
itemService.updateById(item);
return "redirect:/item/findBySql.action";
}
/**
public class ItemCategoryController extends BaseController {
@Autowired
private ItemCategoryService itemCategoryService;
/**
* 分页查询类目列表
*/
@RequestMapping("/findBySql")
public String findBySql(Model model,ItemCategory itemCategory){
String sql = "select * from item_category where isDelete = 0 and pid is null order by id";
Pager<ItemCategory> pagers = itemCategoryService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",itemCategory);
return "itemCategory/itemCategory";
}
/**
* 转向到新增一级类目页面
*/
@RequestMapping(value = "/add")
public String add(){
return "itemCategory/add";
}
/**
* 新增一级类目保存功能
*/
@RequestMapping("/exAdd")
public String exAdd(ItemCategory itemCategory){
itemCategory.setIsDelete(0);
itemCategoryService.insert(itemCategory);
return "redirect:/itemCategory/findBySql.action";
}
/**
* 转向到修改一级类目页面
*/
@RequestMapping(value = "/update")
public String update(Integer id,Model model){
ItemCategory obj = itemCategoryService.load(id);
model.addAttribute("obj",obj);
return "itemCategory/update";
}
/**
* 修改一级类目
*/
@RequestMapping("/exUpdate")
public String exUpdate(ItemCategory itemCategory){
itemCategoryService.updateById(itemCategory);
return "redirect:/itemCategory/findBySql.action";
*/
@Controller
@RequestMapping("/comment")
public class CommentController extends BaseController {
@Autowired
private CommentService commentService;
/**
* 添加执行
*/
@RequestMapping("/exAdd")
public String exAdd(Comment comment, HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/toLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
comment.setAddTime(new Date());
comment.setUserId(userId);
commentService.insert(comment);
return "redirect:/itemOrder/my.action";
}
}
/**
* 订单详情c层
*/
@Controller
@RequestMapping("/orderDetail")
public class OrderDetailController {
@Autowired
private OrderDetailService orderDetailService;
@RequestMapping("/ulist")
public String ulist(OrderDetail orderDetail, Model model){
//分页查询
String sql = "select * from order_detail where order_id="+orderDetail.getOrderId();
Pager<OrderDetail> pagers = orderDetailService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj",orderDetail);
return "orderDetail/ulist";
}
*/
@RequestMapping("toLogin")
public String toLogin(Manage manage, HttpServletRequest request){
Manage byEntity = manageService.getByEntity(manage);
if(byEntity==null){
return "redirect:/login/mtuichu";
}
request.getSession().setAttribute(Consts.MANAGE,byEntity);
return "/login/mIndex";
}
/**
* 管理员退出
*/
@RequestMapping("mtuichu")
public String mtuichu(HttpServletRequest request){
request.getSession().setAttribute(Consts.MANAGE,null);
return "/login/mLogin";
}
/**
* 前端首页
*/
@RequestMapping("/uIndex")
public String uIndex(Model model, Item item,HttpServletRequest request){
String sql1 = "select * from item_category where isDelete=0 and pid is null order by name";
List<ItemCategory> fatherList = itemCategoryService.listBySqlReturnEntity(sql1);
List<CategoryDto> list = new ArrayList<>();
if(!CollectionUtils.isEmpty(fatherList)){
for(ItemCategory ic:fatherList){
CategoryDto dto = new CategoryDto();
dto.setFather(ic);
//查询二级类目
String sql2 = "select * from item_category where isDelete=0 and pid="+ic.getId();
List<ItemCategory> childrens = itemCategoryService.listBySqlReturnEntity(sql2);
dto.setChildrens(childrens);
list.add(dto);
model.addAttribute("lbs",list);
}
}
//折扣商品
List<Item> zks = itemService.listBySqlReturnEntity("select * from item where isDelete=0 and zk is not null order by zk desc limit 0,10");
model.addAttribute("zks",zks);
//热销商品
/**
* 执行修改用户信息的操作
*/
@RequestMapping("/exUpdate")
public String exUpdate(User user,HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/uLogin";
}
user.setId(Integer.valueOf(attribute.toString()));
userService.updateById(user);
return "redirect:/user/view.action";
}
}
/**
* 留言管理
*/
@Controller
@RequestMapping("/message")
public class MessageController extends BaseController {
@Autowired
private MessageService messageService;
/**普通用户登录入口*/
@RequestMapping("/uLogin")
public String uLogin(){
return "login/uLogin";
}
/**执行普通用户登录*/
@RequestMapping("/utoLogin")
public String utoLogin(User u,HttpServletRequest request){
User byEntity = userService.getByEntity(u);
if(byEntity==null){
return "redirect:/login/uLogin";
}else {
request.getSession().setAttribute("role",2);
request.getSession().setAttribute(Consts.USERNAME,byEntity.getUserName());
request.getSession().setAttribute(Consts.USERID,byEntity.getId());
return "redirect:/login/uIndex.action";
}
}
/**前端用户退出*/
@RequestMapping("/uTui")
public String uTui(HttpServletRequest request){
HttpSession session = request.getSession();
session.invalidate();
return "redirect:/login/uIndex.action";
}
/**
* 修改密码入口
*/
@RequestMapping("/pass")
public String pass(HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
User load = userService.load(userId);
request.setAttribute("obj",load);
return "login/pass";
}
/**
* 修改密码操作
*/
@Autowired
private ItemOrderService itemOrderService;
@Autowired
private UserService userService;
@Autowired
private CarService carService;
@Autowired
private OrderDetailService orderDetailService;
@Autowired
private ItemService itemService;
/**
* 订单管理列表
*/
@RequestMapping("/findBySql")
public String findBySql(ItemOrder itemOrder, Model model){
//分页查询
String sql = "select * from item_order where 1=1 ";
if(!(isEmpty(itemOrder.getCode()))){
sql +=" and code like '%"+itemOrder.getCode()+"%' ";
}
sql += " order by id desc";
Pager<ItemOrder> pagers = itemOrderService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
//存储查询条件
model.addAttribute("obj",itemOrder);
return "itemOrder/itemOrder";
}
/**
* 我的订单
*/
@RequestMapping("/my")
public String my(Model model, HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
//全部订单
String sql = "select * from item_order where user_id="+userId+" order by id desc";
List<ItemOrder> all = itemOrderService.listBySqlReturnEntity(sql);
//待发货
String sql2 = "select * from item_order where user_id="+userId+" and status=0 order by id desc";
List<ItemOrder> dfh = itemOrderService.listBySqlReturnEntity(sql2);
//已取消
String sql3 = "select * from item_order where user_id="+userId+" and status=1 order by id desc";
List<ItemOrder> yqx = itemOrderService.listBySqlReturnEntity(sql3);
//已发货
String sql4 = "select * from item_order where user_id="+userId+" and status=2 order by id desc";
List<ItemOrder> dsh = itemOrderService.listBySqlReturnEntity(sql4);
//已收货
String sql5 = "select * from item_order where user_id="+userId+" and status=3 order by id desc";