ssm搭建拍卖系统

项目介绍及流程

拍卖系统采用ssm架构搭建,页面数据渲染采用jsp的初级简易拍卖系统,拍卖流程为 普通用户注册、登录后,进入个人中心发布商品后, 系统管理员进行商品审核, 审核不通过,用户发布列表展示拒绝原因, 审核通过后,首页及分类可查询展示,非发布人员进行商品竞价, 竞价完成,发布者进行商品发货, 拍卖获得者进行付款, 完成最终交易。

开发环境:

  1. jdk 8
  2. intellij idea
  3. tomcat 8
  4. mysql 5.7

所用技术:

项目框架:ssm
前端渲染:jsp
前端技术:js/jquery

项目目录结构

项目目录结构

  • controller,视图控制层,
  • service,业务逻辑层
  • dao,数据库操作层
  • jsp,页面进行数据渲染
  • mapper.xml,此文件定义了操作数据库的sql,每个sql是一个statement,映射文件是mybatis的核心
  • jdbc.properties,数据库帐号密码配置

运行效果

  • 注册

注册

  • 首页

首页

  • 发布商品

发布商品

  • 商品竞价

商品竞价

  • 浏览记录

浏览记录

  • 后端-商品管理

后端-商品管理

核心项目配置:

1.spring-mvc.xml配置:


             text/html;charset=UTF-8            
     
     
    
                
   
 
              

2.spring-mybatis.xml配置



  
   com.mysql.jdbc.Driver   jdbc:mysql://localhost:3306/pmxt?characterEncoding=UTF-8
   root   root123  
      
     
 
   
 
 

3.登录验证

@RequestMapping("/checkLogin")
@ResponseBody
public int checkLogin(HttpServletRequest request, String uname, String upassword, String verifyCode) {
 HttpSession session = request.getSession(); String sessionVerifyCode = (String) session.getAttribute("verifyCodeValue"); if (!verifyCode.equalsIgnoreCase(sessionVerifyCode)) { int flag = 4; return flag;
 } else { List pUsersModels = pUserService.checkLogin(uname, upassword); if (pUsersModels.isEmpty()) { return 0;//用户名不存在
 } String relpassword = pUsersModels.get(0).getUpassword(); int utype = pUsersModels.get(0).getUtype(); if (upassword.equals(relpassword)) { session = request.getSession(); session.setAttribute("uname", uname); session.setAttribute("utype", utype); session.setAttribute("pUsersModel", pUsersModels.get(0)); if (utype == 1) { return 3;//管理员
 } return 1;//密码正确
 } else { return 2;//密码不正确
 } }}

4.系统推荐

@RequestMapping("/sysRecommend")
public String sysRecommend(HttpSession session, Model model, String page)
{
 PUsersModel pUsersModel=(PUsersModel)session.getAttribute("pUsersModel"); //先判断当前用户是否已经浏览过商品
 LookshistoryModel lookModel=new LookshistoryModel(); lookModel.setUserid(pUsersModel.getUid()); List lists=lookshistoryService.selectLookshistory(lookModel);      //查询总记录并做降序处理
 Map gmap=new HashMap(); if(lists!=null&lists.size()>0){                                           //根据做商品过滤筛选 精准推荐
 int hits=0;                                                          //获取浏览总数
 for(LookshistoryModel m:lists){ gmap.put(m.getPgtype(),m.getHits());                                 //填充商品占比情况
 hits+=m.getHits();                                              //叠加浏览次数
 } Map gpmap=new HashMap();                               //对象储存转换,类型--->>次数 模式
 for (Map.Entry entry : gmap.entrySet()) { BigDecimal percentage=new BigDecimal(entry.getValue()).divide(new BigDecimal(hits),2,BigDecimal.ROUND_HALF_DOWN);     //当前最高商品的占比
 int result=percentage.multiply(new BigDecimal(12)).intValue();                   //推荐每个商品出现的占比情况
 gpmap.put(entry.getKey(),result); } List afterGoodsModels =new ArrayList(); int afterPageNums =0; for (Map.Entry entry : gmap.entrySet()) {                         //最终推荐出商品情况
 int afterPageItem = goodsService.countAfterGoodsByKinds(entry.getKey()); final int afterPageSize = entry.getValue(); if (page == null) { page = "1"; } PageUtil afterPageUtil = new PageUtil(afterPageItem, afterPageSize, Integer.parseInt(page)); int afterPageNum = afterPageUtil.getPageNum(); afterPageNums+=afterPageNum; int afterStartRow = afterPageUtil.getStartRow(); List goodsModels = goodsService.getAfterCheckGoodsByPageBykinds(afterStartRow, afterPageSize, entry.getKey()); Boolean afterHasNextPage = (Integer.parseInt(page) != afterPageNum) && (afterPageNum != 0); model.addAttribute("afterHasPrePage", Integer.parseInt(page) != 1); model.addAttribute("afterHasNextPage", afterHasNextPage); model.addAttribute("afterGoodsModels", afterGoodsModels); model.addAttribute("afterPageItem", afterPageItem);
 model.addAttribute("nowPage", Integer.parseInt(page)); afterGoodsModels.addAll(goodsModels); } model.addAttribute("afterPrePage", Integer.parseInt(page) - 1); model.addAttribute("afterNextPage", Integer.parseInt(page) + 1); model.addAttribute("afterPageNum", afterPageNums);    //总页面
 model.addAttribute("afterGoodsModels", afterGoodsModels);//总商品
 }else{                                                             //根据大众浏览推荐
 lists=lookshistoryService.selectLookshistory(new LookshistoryModel());          //根据大众浏览次数多的多推荐
 if(lists!=null&lists.size()>0){ int hits=0;                                                          //获取浏览总数
 for(LookshistoryModel m:lists){ gmap.put(m.getPgtype(),m.getHits());                                 //填充商品占比情况
 hits+=m.getHits();                                              //叠加浏览次数
 } Map gpmap=new HashMap();//商品占比存储对象
 for (Map.Entry entry : gmap.entrySet()) { BigDecimal percentage=new BigDecimal(entry.getValue()).divide(new BigDecimal(hits));      //当前最高商品的占比
 int result=percentage.multiply(new BigDecimal(12)).intValue();                   //推荐每个商品出现的占比情况
 gpmap.put(entry.getKey(),result); } List afterGoodsModels =new ArrayList(); int afterPageNums =0; for (Map.Entry entry : gmap.entrySet()) {             //最终推荐出商品情况
 int afterPageItem = goodsService.countAfterGoodsByKinds(entry.getKey()); final int afterPageSize = entry.getValue(); if (page == null) { page = "1"; }`` PageUtil afterPageUtil = new PageUtil(afterPageItem, afterPageSize, Integer.parseInt(page)); int afterPageNum = afterPageUtil.getPageNum(); afterPageNums+=afterPageNum; int afterStartRow = afterPageUtil.getStartRow(); List goodsModels = goodsService.getAfterCheckGoodsByPageBykinds(afterStartRow, afterPageSize, entry.getKey()); Boolean afterHasNextPage = (Integer.parseInt(page) != afterPageNum) && (afterPageNum != 0); model.addAttribute("afterHasPrePage", Integer.parseInt(page) != 1); model.addAttribute("afterHasNextPage", afterHasNextPage); model.addAttribute("afterGoodsModels", afterGoodsModels); model.addAttribute("afterPageItem", afterPageItem);
 model.addAttribute("nowPage", Integer.parseInt(page)); afterGoodsModels.addAll(goodsModels); } model.addAttribute("afterPrePage", Integer.parseInt(page) - 1); model.addAttribute("afterNextPage", Integer.parseInt(page) + 1); model.addAttribute("afterPageNum", afterPageNums);    //总页面
 model.addAttribute("afterGoodsModels", afterGoodsModels);//总商品
 }else{ int lindid=(int)Math.random()*(1);                         //没有浏览次数系统随机推荐
 int afterPageItem = goodsService.countAfterGoodsByKinds(lindid); final int afterPageSize = 12; if (page == null) { page = "1"; } PageUtil afterPageUtil = new PageUtil(afterPageItem, afterPageSize, Integer.parseInt(page)); int afterPageNum = afterPageUtil.getPageNum(); int afterStartRow = afterPageUtil.getStartRow(); List afterGoodsModels = goodsService.getAfterCheckGoodsByPageBykinds(afterStartRow, afterPageSize, 0); Boolean afterHasNextPage = (Integer.parseInt(page) != afterPageNum) && (afterPageNum != 0); model.addAttribute("afterHasPrePage", Integer.parseInt(page) != 1); model.addAttribute("afterHasNextPage", afterHasNextPage); model.addAttribute("afterPrePage", Integer.parseInt(page) - 1); model.addAttribute("afterNextPage", Integer.parseInt(page) + 1); model.addAttribute("afterGoodsModels", afterGoodsModels); model.addAttribute("afterPageItem", afterPageItem); model.addAttribute("afterPageNum", afterPageNum); model.addAttribute("nowPage", Integer.parseInt(page)); } } return "otherkinds";}

项目总结

目前此版本为简易拍卖系统,其他拍卖逻辑或者额外功能,后续迭代排期开发,敬请关注!

你可能感兴趣的:(ssm,jsp,mysql,javascript,jquery)