每天记录学习,每天会有好心情。*^_^*
今天记录的项目是基于web的工艺品销售平台,面对市场日益加剧的竞争环境,我国工艺品企业加快发展电子商务和信息化步伐是必然走势,这将有利于企业增加外贸渠道,降低交易成本,简化商务过程和缩短生产周期。采用当前非常流行的B/S体系结构,以JSP作为开发技术,主要依赖SSM技术框架,mysql数据库建立本系统。
做基于web的工艺品销售平台的时候,我们需要用到SSM(MYECLIPSE)框架,开发工具选用最拿手的MYECLIPSE。
基于web的工艺品销售平台项目是一个 后台项目。
开发系统时,需求分析是必不可少的一个环节。基于web的工艺品销售平台拥有的登录角色包括了管理员。
每个账号设置身份、账号、密码是必不可少的,管理员中都包含这些登录角色该有的字段。
在系统的功能中,订单是一个重要的表。这个表使得产品关联了起来。在订单表中订单的名字与产品的mingzi字段对应、订单的价格与产品的jiage字段对应
,他们拥有关联关系。
总结得出基于web的工艺品销售平台项目所有数据为:管理员(admin)、用户(yonghu)、产品(chanpin)、订单(dingdan)、运输(yunshu)
基于web的工艺品销售平台之管理员表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 管理员id username | VARCHAR(255) | | 账号 password | VARCHAR(255) | | 密码 quanxian | VARCHAR(255) | | 权限
基于web的工艺品销售平台之用户表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 用户id xingming | VARCHAR(255) | | 姓名 nianling | VARCHAR(255) | | 年龄 xingbie | VARCHAR(255) | | 性别 username | VARCHAR(255) | | 账号 password | VARCHAR(255) | | 密码
基于web的工艺品销售平台之产品表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 产品id zhonglei | VARCHAR(255) | | 种类 guige | VARCHAR(255) | | 规格 jiage | VARCHAR(255) | | 价格 shuliang | VARCHAR(255) | | 数量 mingzi | VARCHAR(255) | | 名字 jieshao | VARCHAR(255) | | 介绍
基于web的工艺品销售平台之订单表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 订单id mingzi | VARCHAR(255) | | 名字 jiage | VARCHAR(255) | | 价格 shuliang | VARCHAR(255) | | 数量 dizhi | VARCHAR(255) | | 地址 xingming | VARCHAR(255) | | 姓名 lianxifangshi | VARCHAR(255) | | 联系方式
基于web的工艺品销售平台之运输表
字段名 | 类型 | 属性 | 描述 id | INT(11) | PRIMARY KEY | 运输id shifadi | VARCHAR(255) | | 始发地 tujing | VARCHAR(255) | | 途径 shijian | VARCHAR(255) | | 时间
package org.mypro.front; import java.io.File; import java.io.IOException; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.List; import javax.jms.Session; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mypro.dao.DingdanMapper; import org.mypro.entity.Dingdan; import org.mypro.entity.DingdanExample; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.multipart.MultipartFile; @Controller @RequestMapping(value = "/") public class DingdanController { private static final Log logger = LogFactory.getLog(DingdanController.class); @Autowired private DingdanMapper dingdandao; //定义方法tianjiadingdan,响应页面tianjiadingdan请求 @RequestMapping(value = "tianjiadingdan") public String tianjiadingdan(HttpServletRequest request, HttpServletResponse response,HttpSession session,String backurl) { logger.debug("DingdanController.tianjiadingdan ......"); if(backurl != null && backurl.indexOf("tianjiadingdan.action") == -1){ return "forward:/" + backurl; } return "tianjiadingdan"; } @RequestMapping(value = "tianjiadingdanact") public String tianjiadingdanact(HttpServletRequest request,HttpSession session, HttpServletResponse response,Dingdan dingdan,String backurl) throws IOException { logger.debug("DingdanController.tianjiadingdanact ......"); dingdandao.insert(dingdan); request.setAttribute("message", "添加订单成功"); if(backurl != null && backurl.indexOf("tianjiadingdanact.action") == -1){ return "forward:/" + backurl; } //返回tianjiadingdan方法 return "forward:/tianjiadingdan.action"; } //定义dingdanguanli方法响应页面请求 @RequestMapping(value = "dingdanguanli") public String dingdanguanli(HttpServletRequest request,HttpSession session, HttpServletResponse response,String backurl) { logger.debug("DingdanController.dingdanguanli ......"); DingdanExample example = new DingdanExample(); List dingdanall = dingdandao.selectByExample(example); request.setAttribute("dingdanall", dingdanall); if(backurl != null && backurl.indexOf("dingdanguanli.action") == -1){ return "forward:/" + backurl; } return "dingdanguanli"; } // 定义 dingdanchakan方法 @RequestMapping(value = "dingdanchakan") public String dingdanchakan(HttpServletRequest request,HttpSession session, HttpServletResponse response,String backurl) { logger.debug("DingdanController.dingdanchakan ......"); DingdanExample example = new DingdanExample(); List dingdanall = dingdandao.selectByExample(example); request.setAttribute("dingdanall", dingdanall); if(backurl != null && backurl.indexOf("dingdanchakan.action") == -1){ return "forward:/" + backurl; } return "dingdanchakan"; } // 定义 xiugaidingdan方法 @RequestMapping(value = "xiugaidingdan") public String xiugaidingdan(HttpServletRequest request, HttpServletResponse response,HttpSession session,int id,String backurl){ logger.debug("DingdanController.xiugaidingdan ......"); Dingdan dingdan = dingdandao.selectByPrimaryKey(id); request.setAttribute("dingdan", dingdan); if(backurl != null && backurl.indexOf("xiugaidingdan.action") == -1){ return "forward:/" + backurl; } return "xiugaidingdan"; } // 定义xiugaidingdanact处理订单修改 @RequestMapping(value = "xiugaidingdanact") public String xiugaidingdanact(HttpServletRequest request, HttpServletResponse response,Dingdan dingdan,HttpSession session,String backurl) throws IOException { logger.debug("DingdanController.xiugaidingdanact ......"); dingdandao.updateByPrimaryKeySelective(dingdan); request.setAttribute("message", "修改订单信息成功"); if(backurl != null && backurl.indexOf("xiugaidingdanact.action") == -1){ return "forward:/" + backurl; } return "forward:/dingdanguanli.action"; } // 定义shanchudingdan,处理删除订单 @RequestMapping(value = "shanchudingdan") public String shanchudingdan(HttpServletRequest request, HttpServletResponse response,HttpSession session,int id,String backurl){ logger.debug("DingdanController.shanchudingdan ......"); dingdandao.deleteByPrimaryKey(id); request.setAttribute("message", "删除订单成功"); if(backurl != null && backurl.indexOf("shanchudingdan.action") == -1){ return "forward:/" + backurl; } return "forward:/dingdanguanli.action"; } // 定义sousuodingdan方法,处理搜索操作 @RequestMapping(value = "sousuodingdan") public String sousuodingdan(HttpServletRequest request, HttpServletResponse response,HttpSession session,String search,String backurl) { logger.debug("DingdanController.sousuodingdan ......"); DingdanExample example = new DingdanExample(); DingdanExample.Criteria criteria = example.createCriteria(); if(search != null){ criteria.andMingziLike("%" + search + "%"); } List dingdanall = dingdandao.selectByExample(example); request.setAttribute("dingdanall", dingdanall); if(backurl != null && backurl.indexOf("sousuodingdan.action") == -1){ return "forward:/" + backurl; } return "sousuodingdan"; } // 定义DingdanpinglunMapper@RequestMapping (value = "dingdanxiangqing") public String dingdanxiangqing(HttpServletRequest request,HttpSession session, HttpServletResponse response,int id,String backurl) {logger. debug("DingdanController.dingdanxiangqing ......");Dingdan dingdan = dingdandao.selectByPrimaryKey(id);request. setAttribute("dingdan", dingdan); if(backurl != null && backurl.indexOf("dingdanxiangqing.action") == -1){ return "forward:/" + backurl; } return "dingdanxiangqing"; } // 上传文件图片等 public String uploadUtile(MultipartFile file, HttpServletRequest request) throws IOException { // 根据当前时间生成时间字符串 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSS"); String res = sdf.format(new Date()); // uploads文件夹位置 String rootPath = request.getSession().getServletContext().getRealPath("resource/uploads/"); // 原始名称 String originalFileName = file.getOriginalFilename(); // 新文件名 String newFileName = "sliver" + res + originalFileName.substring(originalFileName.lastIndexOf(".")); // 创建年月文件夹 Calendar date = Calendar.getInstance(); File dateDirs = new File(date.get(Calendar.YEAR) + File.separator + (date.get(Calendar.MONTH)+1)); // 新文件 File newFile = new File(rootPath + File.separator + dateDirs + File.separator + newFileName); // 判断目标文件所在目录是否存在 if( !newFile.getParentFile().exists()) { // 如果目标文件所在的目录不存在,则创建父目录newFile. getParentFile().mkdirs(); } System.out.println(newFile); // 将内存中的数据写入磁盘file. transferTo(newFile); // 完整的url String fileUrl = date.get(Calendar.YEAR) + "/" + (date.get(Calendar.MONTH)+1) + "/" + newFileName; return fileUrl; }}
原文地址:https://www.cnblogs.com/hxlk/p/11623008.html
时间: 2024-10-08 06:23:35