JAVA-based SSM online bookstore system

The rapid development of the Internet is affecting today with great depth and breadth and changing people's lives, more and more people come to realize the tremendous economic benefits and opportunities inherent in the Internet, we are actively involved in the conduct of e-commerce activities in the past. The traditional e-commerce business practices carried out electronically, such as online stores, online transactions. Online bookstore is a form of online store, and has been widely applied; In addition, because the book has a simple characterization, identification easy, specifications, features no big differences between similar products and individuals can become e-commerce system in hot commodity type. Therefore, the online bookstore system is slowly becoming popular around the world e-business. In particular, the opening of the Internet, the world of large e-commerce site is almost online bookstore system. As long as the long-term development of the network, online book sales will get a different development. In this paper, online bookstores system as the research target, analyze and research on the process of UML based modeling of e-commerce systems, through in-depth research into new methods, new ideas and technologies in the field of software engineering, UML as the modeling language tools modeling together to integrate online bookstore system in the past, and then analyze and study of the structure and characteristics of the entire online system, but also a detailed analysis of some important key technology textbook system modeling UML-based e-commerce online, the modeling process of UML-based online bookstore system. The project uses the framework for SSM (MYECLIPSE), the choice of development tools for MYECLIPSE. Online bookstore as a background item.
To complete the system, we first need to analyze the needs of the system. An online bookstore should contain user roles administrator user. In order to allow the user a smooth landing system to complete the related operations, landing roles you need to set up an account and password for each field.
In order to complete the function of the system need to set the table for the car textbook books, records Book car information. It defines the relationship between the two in the car textbook table, where the name of the car purchase books and books mingzi corresponding field, books car prices and book jiage corresponding field.

The summary results for all data systems: the administrator (admin), user (yonghu), books (shuji), textbook vehicles (goushuche)

Administrators table

Field Name | Type | property | describe 
the above mentioned id |  INT ( 11 ) |  PRIMARY  KEY  | administrator the above mentioned id 
username |  VARCHAR ( 255 ) |  | account 
password |  VARCHAR ( 255 ) |  | password

 

user table

Field Name | Type | property | describe 
the above mentioned id |  INT ( 11 ) |  PRIMARY  KEY  | user the above mentioned id 
username |  VARCHAR ( 255 ) |  | account 
password |  VARCHAR ( 255 ) |  | password 
Xingming |  VARCHAR ( 255 ) |  | Name 
xingbie |  VARCHAR ( 255 ) |  | gender

 

Table books

Field Name | Type | property | describe 
the above mentioned id |  INT ( 11 ) |  PRIMARY  KEY  | books the above mentioned id 
mingzi |  VARCHAR ( 255 ) |  | name 
leixing |  VARCHAR ( 255 ) |  | type 
jiage |  VARCHAR ( 255 ) |  | Price 
Shuliang |  VARCHAR ( 255 ) |  | number

 

Book car table

Field Name | Type | property | describe 
the above mentioned id |  INT ( 11 ) |  PRIMARY  KEY  | Book car the above mentioned id 
mingzi |  VARCHAR ( 255 ) |  | name 
jiage |  VARCHAR ( 255 ) |  | Price 
Shuliang |  VARCHAR ( 255 ) |  | number

 

 

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.ShujiMapper;

import org.mypro.entity.Shuji;

import org.mypro.entity.ShujiExample;

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 ShujiController {

private static final Log logger = LogFactory.getLog(ShujiController.class);

@Autowired
private ShujiMapper shujidao;

//定义方法tianjiashuji,响应页面tianjiashuji请求

@RequestMapping(value = "tianjiashuji")

public String tianjiashuji(HttpServletRequest request, HttpServletResponse response,HttpSession session,String backurl) {

logger.debug("ShujiController.tianjiashuji ......");

if(backurl != null && backurl.indexOf("tianjiashuji.action") == -1){

return "forward:/" + backurl; }

return "tianjiashuji";

}

@RequestMapping(value = "tianjiashujiact")

public String tianjiashujiact(HttpServletRequest request,HttpSession session, HttpServletResponse response,Shuji shuji,String backurl) throws IOException {

logger.debug("ShujiController.tianjiashujiact ......");

shujidao.insert(shuji);

request.setAttribute("message", "添加书籍成功");

if(backurl != null && backurl.indexOf("tianjiashujiact.action") == -1){

return "forward:/" + backurl; }

//返回tianjiashuji方法

return "forward:/tianjiashuji.action";

}

//定义shujiguanli方法响应页面请求

@RequestMapping(value = "shujiguanli")

public String shujiguanli(HttpServletRequest request,HttpSession session, HttpServletResponse response,String backurl) {

logger.debug("ShujiController.shujiguanli ......");

ShujiExample example = new ShujiExample();

List shujiall = shujidao.selectByExample(example);

request.setAttribute("shujiall", shujiall);

if(backurl != null && backurl.indexOf("shujiguanli.action") == -1){

return "forward:/" + backurl; }

return "shujiguanli";

}

// 定义 shujichakan方法

@RequestMapping(value = "shujichakan")

public String shujichakan(HttpServletRequest request,HttpSession session, HttpServletResponse response,String backurl) {

logger.debug("ShujiController.shujichakan ......");

ShujiExample example = new ShujiExample();

List shujiall = shujidao.selectByExample(example);

request.setAttribute("shujiall", Shujiall);

if(backurl != null && backurl.indexOf("shujichakan.action") == -1){

return "forward:/" + backurl; }

return "shujichakan";

}

// 定义 xiugaishuji方法

@RequestMapping(value = "xiugaishuji")

public String xiugaishuji(HttpServletRequest request, HttpServletResponse response,HttpSession session,int id,String backurl){

logger.debug("ShujiController.xiugaishuji ......");

Shuji shuji = shujidao.selectByPrimaryKey(id);

request.setAttribute("shuji", shuji);

if(backurl != null && backurl.indexOf("xiugaishuji.action") == -1){

return "forward:/" + backurl; }

return "xiugaishuji";

}

// 定义xiugaishujiact处理书籍修改

@RequestMapping(value = "xiugaishujiact")

public String xiugaishujiact(HttpServletRequest request, HttpServletResponse response,Shuji shuji,HttpSession session,String backurl) throws IOException {

logger.debug("ShujiController.xiugaishujiact ......");

shujidao.updateByPrimaryKeySelective(shuji);

request.setAttribute("message", "Modify the book information successfully " IF);

(backurl != null && backurl.indexOf("xiugaishujiact.action") == -1){

return "forward:/" + backurl; }

return "forward:/shujiguanli.action";

}

// 定义shanchushuji,处理删除书籍

@RequestMapping(value = "shanchushuji")

public String shanchushuji(HttpServletRequest request, HttpServletResponse response,HttpSession session,int id,String backurl){

logger.debug("ShujiController.shanchushuji ......");

shujidao.deleteByPrimaryKey(id);

request.setAttribute("message", "删除书籍成功");

if(backurl != null && backurl.indexOf("shanchushuji.action") == -1){

return "forward:/" + backurl; }

return "forward:/shujiguanli.action";

}

// 定义sousuoshuji方法,处理搜索操作

@RequestMapping(value = "sousuoshuji")

public String sousuoshuji(HttpServletRequest request, HttpServletResponse response,HttpSession session,String search,String backurl) {

logger.debug("ShujiController.sousuoshuji ......");

ShujiExample example = new ShujiExample();

ShujiExample.Criteria criteria = example.createCriteria();

if(search != null){

criteria.andMingziLike("%" + search + "%");

}

List shujiall = shujidao.selectByExample(example);

request.setAttribute("shujiall", shujiall);

if(backurl != null && backurl.indexOf("sousuoshuji.action") == -1){

return "forward:/" + backurl; }

return "sousuoshuji";

}

// 定义ShujipinglunMapper@RequestMapping

(value = "shujixiangqing")

public String shujixiangqing(HttpServletRequest request,HttpSession session, HttpServletResponse response,int id,String backurl) {logger.

debug("ShujiController.shujixiangqing ......");Shuji shuji 

= shujidao.selectByPrimaryKey(id);request.

setAttribute("shuji", shuji);

if(backurl != null && backurl.indexOf("shujixiangqing.action") == -1){

return "forward:/" + backurl; }

return "shujixiangqing";

}

// 上传文件图片等

public String uploadUtile(MultipartFile file, HttpServletRequest request) throws{IOException 

// the current time string generated time 

the SimpleDateFormat SDF = new new the SimpleDateFormat ( "yyyyMMddHHmmssSS" ); 

String RES = sdf.format ( new new a Date ()); 

// uploads folder location 

String rootPath = Request.getSession (). . getServletContext () getRealPath ( "Resource / uploads /" ); 

// original name 

String originalFileName = file.getOriginalFilename (); 

// new file name 

String newfilename = "Sliver" + RES + originalFileName.substring (originalFileName.lastIndexOf ( " . " )); 

// create a date folder 

Calendar DATE =Calendar.getInstance (); 

File dateDirs = new new File (date.get (Calendar.YEAR) File.separator + + (date.get (of the Calendar.MONTH) +1 )); 

// new file 

File newFile = new new File (rootPath + + File.separator dateDirs File.separator + + newfilename); 

// determine whether the target directory where the file exists 

IF (! . newFile.getParentFile () eXISTS ()) { 

// directory where the file if the target does not exist, create parent directory newFile. 

getParentFile () mkdirs ();. 

} 

System.out.println (newFile); 

// the data in memory is written to disk File. 

transferTo (newFile); 

// complete url 

String file specified by fileurl= date.get(Calendar.YEAR) + "/" + (date.get(Calendar.MONTH)+1) + "/" + newFileName;

return fileUrl;

}}

 

 

Books query module:

When the books into the query page in a browser, then the browser address bar is shujiguanli.action, the address will respond shujiController class shujiguanli, in the process, get all the information selectByexample method books, and the information save the request, the page in the cycle show . The part of the core code is as follows:

Generating class sample books, ShujiExample example = new ShujiExample () define the query by example;

Check out all the books Information List shujiall = shujidao.selectByExample (example) by selectByExample method of shujidao;

The book information stored in the request, on display request.setAttribute ( "shujiall", shujiall) page by foreach method;

Return books management interface

return "forward:/shujiguanli.action";

 

Delete books modules:

In the management page, click Delete. Page through the href attribute a label, use the get method books

Id is uploaded to the server, receiving by shujiController shanchushuji class in the server, after calling deleteByPrimaryKey shujiMapper method according to delete the ID. Save the information to delete the message request, the user is given delete successful message in the page, the part of the core code is as follows:

Delete by deleting the corresponding method according shujidao id Books shujidao.deleteByPrimaryKey (id);

Books will be deleted success information, saved to the message request, the user is given prompt request.setAttribute in the page ( "message", "delete successful books");

Return books management interface

return "forward:/shujiguanli.action";

Guess you like

Origin www.cnblogs.com/lqby/p/11568354.html