JavaWeb-SSM-超市管理系統(tǒng)_第1頁(yè)
JavaWeb-SSM-超市管理系統(tǒng)_第2頁(yè)
JavaWeb-SSM-超市管理系統(tǒng)_第3頁(yè)
JavaWeb-SSM-超市管理系統(tǒng)_第4頁(yè)
JavaWeb-SSM-超市管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩19頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、南 陽(yáng) 理 工 學(xué) 院Java企業(yè)級(jí)開(kāi)發(fā) 學(xué)院(系) : 軟件學(xué)院 專 業(yè) : 移動(dòng)1班 完成日期 2018 年 12 月目錄1、 項(xiàng)目簡(jiǎn)介2、 項(xiàng)目需求分析3、 功能模塊分析4、 概要設(shè)計(jì) 1. 功能模塊圖2. 數(shù)據(jù)庫(kù)ER圖3. 數(shù)據(jù)表5、 項(xiàng)目實(shí)現(xiàn)1. 項(xiàng)目關(guān)鍵代碼2. 界面抓圖1、 項(xiàng)目簡(jiǎn)介主要是根據(jù)需求分析,該實(shí)驗(yàn)實(shí)現(xiàn)了瀏覽器和瀏覽器服務(wù)器的交互,瀏覽器能夠就行網(wǎng)頁(yè)瀏覽,在瀏覽器中需要地址欄對(duì)指定頁(yè)面進(jìn)行訪問(wèn),需要專門的按鈕進(jìn)行跳轉(zhuǎn),在前后瀏覽頁(yè)面之間要能夠進(jìn)行跳轉(zhuǎn),并且連接數(shù)據(jù)庫(kù)完成增刪改查的操作,開(kāi)發(fā)這個(gè)網(wǎng)站可以正常實(shí)現(xiàn)連接TomCat網(wǎng)絡(luò),能夠進(jìn)行網(wǎng)頁(yè)瀏覽,并且能夠查看頁(yè)面源代碼

2、。頁(yè)面源代碼查看,前進(jìn),后退,主頁(yè),停止,刷新等功能。Tomcat服務(wù)器則實(shí)現(xiàn)了IP設(shè)置,根目錄設(shè)置,統(tǒng)計(jì)信息展示等。在操作不當(dāng)?shù)那闆r下有相應(yīng)的信息提示,錯(cuò)誤處理機(jī)制完備.系統(tǒng)各個(gè)模塊之間都有相應(yīng)錯(cuò)誤處理機(jī)制,功能模塊之前劃分比較細(xì)致,有利于發(fā)現(xiàn)問(wèn)題后的及時(shí)解決,在做好完備的功能模塊詳細(xì)設(shè)計(jì)之后,系統(tǒng)的開(kāi)發(fā)時(shí)間會(huì)大幅減少。2、 項(xiàng)目需求分析該實(shí)驗(yàn)設(shè)計(jì)是基于Windows操作系統(tǒng)平臺(tái)設(shè)計(jì)并實(shí)現(xiàn)的電商網(wǎng)站開(kāi)發(fā)系統(tǒng),其主要目的就是用戶能夠使用該系統(tǒng)進(jìn)行商品的增刪改查操作,以及用戶的注冊(cè)與登陸,同時(shí)方便系統(tǒng)管理員在網(wǎng)絡(luò)直接進(jìn)行各種商品操作。1.用戶登陸與注冊(cè)管理模塊Login + Regist2.網(wǎng)站

3、商品管理模塊Goods三、功能模塊分析1、DAO層: 持久層 主要與數(shù)據(jù)庫(kù)進(jìn)行交互DAO層首先會(huì)創(chuàng)建DAO接口,也就是說(shuō)DAO層里面有一個(gè)專門寫接口的類,然后會(huì)在配置文件(xml文件,也就是寫SQL語(yǔ)句的文件,所以說(shuō)DAO層是與數(shù)據(jù)庫(kù)進(jìn)行交互的層)中定義該接口的實(shí)現(xiàn)類,接著就可以在模塊中就可以調(diào)用DAO 的接口進(jìn)行數(shù)據(jù)業(yè)務(wù)的而處理,并且不用關(guān)注此接口的具體實(shí)現(xiàn)類是哪一個(gè)類。DAO 層的數(shù)據(jù)源和數(shù)據(jù)庫(kù)連接的參數(shù)都是在配置文件中進(jìn)行配置的。2、Entity層: 實(shí)體層 數(shù)據(jù)庫(kù)在項(xiàng)目中的類3、Service層:業(yè)務(wù)層 控制業(yè)務(wù)Service層主要負(fù)責(zé)業(yè)務(wù)模塊的邏輯應(yīng)用設(shè)計(jì)。和DAO層一樣都是先設(shè)計(jì)放

4、接口的類,再創(chuàng)建實(shí)現(xiàn)的類,然后在配置文件中進(jìn)行配置其實(shí)現(xiàn)的關(guān)聯(lián)。接下來(lái)就可以在service層調(diào)用接口進(jìn)行業(yè)務(wù)邏輯應(yīng)用的處理。封裝Service層的業(yè)務(wù)邏輯有利于業(yè)務(wù)邏輯的獨(dú)立性和重復(fù)利用性。4、Controller層: 控制層 控制業(yè)務(wù)邏輯Controller層負(fù)責(zé)具體的業(yè)務(wù)模塊流程的控制,其實(shí)就是與前臺(tái)互交,把前臺(tái)傳進(jìn)來(lái)的參數(shù)進(jìn)行處理,controller層主要調(diào)用Service層里面的接口控制具體的業(yè)務(wù)流程,控制的配置也需要在配置文件中進(jìn)行。四、概要設(shè)計(jì)1.功能模塊圖電商網(wǎng)站用戶商品登陸注冊(cè)退出增查改刪顯示2.數(shù)據(jù)庫(kù)ER圖3.數(shù)據(jù)表Goods表Goods_user表已存儲(chǔ)的商品信息表五、

5、項(xiàng)目實(shí)現(xiàn)Controller層商品實(shí)現(xiàn)代碼:Controller層用戶實(shí)現(xiàn)代碼:Dao層商品實(shí)現(xiàn)代碼:對(duì)應(yīng)的mapper文件Dao層商品實(shí)現(xiàn)代碼:對(duì)應(yīng)的mapper文件對(duì)應(yīng)的實(shí)體:Service層:controller層:Goods:package com.controller;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.ster

6、eotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import com.entity.Goods;import com.service.GoodsService;ControllerRequestMapping("/goods")public class GoodsController Autowiredprivate GoodsService goodsService;public GoodsService getGoodsService() return goo

7、dsService;public void setGoodsService(GoodsService goodsService) this.goodsService = goodsService;RequestMapping("/selectAll")public String selectAll(HttpServletRequest request) throws ExceptionList<Goods> goods = goodsService.selectAll();request.setAttribute("goods", goods

8、);return "forward:/product/productlist.jsp"RequestMapping("/save")public String save(Goods goods)goodsService.save(goods);return "forward:/goods/selectAll.do"RequestMapping("/delete") public String delete(Integer id) throws ExceptiongoodsService.delete(id);ret

9、urn "forward:/goods/selectAll.do"RequestMapping("/selectByID")public String selectByID(Integer id,HttpServletRequest request)Goods goods = goodsService.selectByID(id);request.setAttribute("goods", goods);return "forward:/product/update.jsp"RequestMapping("

10、;/updateGoods")public String updateGoods(Goods goods)System.out.println(goods);goodsService.updateGoods(goods);return "forward:/goods/selectAll.do"User:package com.controller;import javax.servlet.http.HttpSession;import org.springframework.beans.factory.annotation.Autowired;import org

11、.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import com.entity.User;import com.service.UserService;ControllerRequestMapping("/user")public class UserController Autowiredprivate UserService userService;public UserService getUserService

12、() return userService;public void setUserService(UserService userService) this.userService = userService;/注冊(cè)RequestMapping("/register") /接受數(shù)據(jù)public String register(User user) throws Exception/調(diào)用Service 中的注冊(cè)功能userService.register(user);/跳轉(zhuǎn)器return "forward:/user/login.html"/登錄Reque

13、stMapping("/login")public String login(String user_name,String password,HttpSession session) throws ExceptionUser user = userService.login(user_name, password);if(user!=null)session.setAttribute("name", user.getUser_name();String name = (String)session.getAttribute("name&quo

14、t;);System.out.println(name);/跳轉(zhuǎn)頁(yè)面return "forward:/goods/selectAll.do"elsereturn "forward:/user/login.html"dao層Goods:package com.dao;import java.util.List;import com.entity.Goods;public interface GoodsDAO /查詢所有商品public List<Goods> selectAll();/添加商品public void save(Goods goo

15、ds);/刪除商品public void delete(Integer id);/通過(guò)ID查詢public Goods selectByID(Integer id);/修改商品信息public void updateGoods(Goods goods);對(duì)應(yīng)mapper文件<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//DTD Mapper 3.0/EN" "./mybatis-3-mapper.dtd

16、" ><mapper namespace="com.dao.GoodsDAO" > <select id="selectAll" resultType="Goods"> select * from goods order by id </select> <select id="selectByID" resultType="Goods"> select * from goods where id=#id </select>

17、; <insert id="save"> <selectKey keyProperty="id" resultType="int" order="BEFORE" > select a.nextval from dual </selectKey> insert into goods(id,name,price,description) values(#id,#name,#price,#description) </insert> <delete id="

18、delete"> delete from goods where id=#id </delete> <update id="updateGoods"> update goods <set> <if test="name!=null"> name=#name, </if> <if test="price!=null"> price=#price, </if> <if test="description">

19、description=#description </if> where id =#id </set> </update></mapper>User:package com.dao;import org.apache.ibatis.annotations.Param;import com.entity.User;public interface UserDAO /插入一條數(shù)據(jù) public void save(User user); /通過(guò)user_name和password查詢 public User selectByUsernameAndPa

20、ssword(Param("u")String user_name,Param("p")String password);對(duì)應(yīng)mapper文件<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//DTD Mapper 3.0/EN" "./mybatis-3-mapper.dtd" ><mapper namespace="com.dao.

21、UserDAO"> <insert id="save"> insert into goods_user (user_name,name,age,password,sex) values(#user_name,#name,#age,#password,#sex) </insert> <select id="selectByUsernameAndPassword" resultType="User"> select * from goods_user where user_name=#u

22、 and password=#p </select></mapper>Entity層:goods:package com.entity;public class Goods private Integer id;private String name;private double price;private String description;public Integer getId() return id;public void setId(Integer id) this.id = id;public String getName() return name;pu

23、blic void setName(String name) = name;public double getPrice() return price;public void setPrice(double price) this.price = price;public String getDescription() return description;public void setDescription(String description) this.description = description;public Goods(Integer id, String

24、name, double price, String description) this.id = id; = name;this.price = price;this.description = description;public Goods() super();/ TODO Auto-generated constructor stubOverridepublic String toString() return "Goods id=" + id + ", name=" + name + ", price="

25、+ price+ ", description=" + description + ""User:package com.entity;public class User private String user_name;private String name;private int age;private String password;private String sex;public String getUser_name() return user_name;public void setUser_name(String user_name) t

26、his.user_name = user_name;public String getName() return name;public void setName(String name) = name;public int getAge() return age;public void setAge(int age) this.age = age;public String getPassword() return password;public void setPassword(String password) this.password = password;publ

27、ic String getSex() return sex;public void setSex(String sex) this.sex = sex;public User(String user_name, String name, int age, String password,String sex) this.user_name = user_name; = name;this.age = age;this.password = password;this.sex = sex;public User() super();/ TODO Auto-generated c

28、onstructor stubOverridepublic String toString() return "User user_name=" + user_name + ", name=" + name + ", age="+ age + ", password=" + password + ", sex=" + sex + ""service層Goods:package com.service;import java.util.List;import com.entit

29、y.Goods;public interface GoodsService /查詢所有商品public List<Goods> selectAll();/增加商品public void save(Goods goods);/刪除商品public void delete(Integer id);/通過(guò)ID查詢public Goods selectByID(Integer id);/修改public void updateGoods(Goods goods);對(duì)應(yīng)服務(wù)層接口:package com.service;import java.util.List;import org.spr

30、ingframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Propagation;import org.springframework.transaction.annotation.Transactional;import com.dao.GoodsDAO;import com.entity.Goods;ServiceTransactionalpublic class

31、 GoodsServiceImpl implements GoodsServiceAutowiredprivate GoodsDAO goodsDAO;public GoodsDAO getGoodsDAO() return goodsDAO;public void setGoodsDAO(GoodsDAO goodsDAO) this.goodsDAO = goodsDAO;Override/提高查詢效率Transactional(propagation=Propagation.SUPPORTS,readOnly=true)public List<Goods> selectAll

32、() List<Goods> goods = goodsDAO.selectAll();return goods;Overridepublic void save(Goods goods) goodsDAO.save(goods);Overridepublic void delete(Integer id) goodsDAO.delete(id);Overridepublic Goods selectByID(Integer id) Goods goods = goodsDAO.selectByID(id);return goods;Overridepublic void updateGoods(Goods goods) goodsDAO.updateGoods(goods);User;package com.service;import java.util.List;import com.entity.User;public interface UserService /注冊(cè)public void registe

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論