JavaWebSSM超市管理系统Word文档下载推荐.docx

上传人:b****3 文档编号:16846344 上传时间:2022-11-26 格式:DOCX 页数:28 大小:702.99KB
下载 相关 举报
JavaWebSSM超市管理系统Word文档下载推荐.docx_第1页
第1页 / 共28页
JavaWebSSM超市管理系统Word文档下载推荐.docx_第2页
第2页 / 共28页
JavaWebSSM超市管理系统Word文档下载推荐.docx_第3页
第3页 / 共28页
JavaWebSSM超市管理系统Word文档下载推荐.docx_第4页
第4页 / 共28页
JavaWebSSM超市管理系统Word文档下载推荐.docx_第5页
第5页 / 共28页
点击查看更多>>
下载资源
资源描述

JavaWebSSM超市管理系统Word文档下载推荐.docx

《JavaWebSSM超市管理系统Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《JavaWebSSM超市管理系统Word文档下载推荐.docx(28页珍藏版)》请在冰豆网上搜索。

JavaWebSSM超市管理系统Word文档下载推荐.docx

DAO层的数据源和数据库连接的参数都是在配置文件中进行配置的。

2、Entity层:

实体层数据库在项目中的类

3、Service层:

业务层控制业务

Service层主要负责业务模块的逻辑应用设计。

和DAO层一样都是先设计放接口的类,再创建实现的类,然后在配置文件中进行配置其实现的关联。

接下来就可以在service层调用接口进行业务逻辑应用的处理。

封装Service层的业务逻辑有利于业务逻辑的独立性和重复利用性。

4、Controller层:

控制层控制业务逻辑

Controller层负责具体的业务模块流程的控制,其实就是与前台互交,把前台传进来的参数进行处理,controller层主要调用Service层里面的接口控制具体的业务流程,控制的配置也需要在配置文件中进行。

四、概要设计

Goods表

Goods_user表

已存储的商品信息表

五、项目实现

Controller层

商品实现代码:

用户实现代码:

Dao层

对应的mapper文件

对应的实体:

Service层:

controller层:

Goods:

packagecom.controller;

importjava.util.List;

importjavax.servlet.http.HttpServletRequest;

importorg.springframework.beans.factory.annotation.Autowired;

importorg.springframework.stereotype.Controller;

importorg.springframework.web.bind.annotation.RequestMapping;

importcom.entity.Goods;

importcom.service.GoodsService;

@Controller

@RequestMapping("

/goods"

publicclassGoodsController{

@Autowired

privateGoodsServicegoodsService;

publicGoodsServicegetGoodsService(){

returngoodsService;

}

publicvoidsetGoodsService(GoodsServicegoodsService){

this.goodsService=goodsService;

@RequestMapping("

/selectAll"

publicStringselectAll(HttpServletRequestrequest)throwsException{

List<

Goods>

goods=goodsService.selectAll();

request.setAttribute("

goods"

goods);

return"

forward:

/product/productlist.jsp"

;

/save"

publicStringsave(Goodsgoods){

goodsService.save(goods);

/goods/selectAll.do"

/delete"

publicStringdelete(Integerid)throwsException{

goodsService.delete(id);

/selectByID"

publicStringselectByID(Integerid,HttpServletRequestrequest){

Goodsgoods=goodsService.selectByID(id);

/product/update.jsp"

/updateGoods"

publicStringupdateGoods(Goodsgoods){

System.out.println(goods);

goodsService.updateGoods(goods);

}

User:

importjavax.servlet.http.HttpSession;

importcom.entity.User;

importcom.service.UserService;

/user"

publicclassUserController{

privateUserServiceuserService;

publicUserServicegetUserService(){

returnuserService;

publicvoidsetUserService(UserServiceuserService){

this.userService=userService;

//注册

/register"

)//接受数据

publicStringregister(Useruser)throwsException{

//调用Service中的注册功能

userService.register(user);

//跳转器

/user/login.html"

//登录

/login"

publicStringlogin(Stringuser_name,Stringpassword,HttpSessionsession)throwsException{

Useruser=userService.login(user_name,password);

if(user!

=null){

session.setAttribute("

name"

user.getUser_name());

Stringname=(String)session.getAttribute("

);

System.out.println(name);

//跳转页面

return"

}else{

}

dao层

packagecom.dao;

publicinterfaceGoodsDAO{

//查询所有商品

publicList<

selectAll();

//添加商品

publicvoidsave(Goodsgoods);

//删除商品

publicvoiddelete(Integerid);

//通过ID查询

publicGoodsselectByID(Integerid);

//修改商品信息

publicvoidupdateGoods(Goodsgoods);

对应mapper文件

<

?

xmlversion="

1.0"

encoding="

UTF-8"

>

!

DOCTYPEmapperPUBLIC"

-//mybatis.org//DTDMapper3.0//EN"

"

../mybatis-3-mapper.dtd"

>

mappernamespace="

com.dao.GoodsDAO"

<

selectid="

selectAll"

resultType="

Goods"

select*fromgoodsorderbyid

/select>

selectByID"

select*fromgoodswhereid=#{id}

insertid="

save"

<

selectKeykeyProperty="

id"

int"

order="

BEFORE"

selecta.nextvalfromdual

/selectKey>

insertintogoods(id,name,price,description)values(#{id},#{name},#{price},#{description})

/insert>

deleteid="

delete"

deletefromgoodswhereid=#{id}

/delete>

updateid="

updateGoods"

updategoods

set>

<

iftest="

name!

=null"

name=#{name},

/if>

price!

price=#{price},

description"

description=#{description}

whereid=#{id}

/set>

/update>

/mapper>

importorg.apache.ibatis.annotations.Param;

publicinterfaceUserDAO{

//插入一条数据

publicvoidsave(Useruser);

//通过user_name和password查询

publicUserselectByUsernameAndPassword(@Param("

u"

)Stringuser_name,@Param("

p"

)Stringpassword);

com.dao.UserDAO"

insertintogoods_user(user_name,name,age,password,sex)values(#{user_name},#{name},#{age},#{password},#{sex})

selectByUsernameAndPassword"

User"

select*fromgoods_userwhereuser_name=#{u}andpassword=#{p}

Entity层:

goods:

packagecom.entity;

publicclassGoods{

privateIntegerid;

privateStringname;

privatedoubleprice;

privateStringdescription;

publicIntegergetId(){

returnid;

publicvoidsetId(Integerid){

this.id=id;

publicStringgetName(){

returnname;

publicvoidsetName(Stringname){

this.name=name;

publicdoublegetPrice(){

returnprice;

publicvoidsetPrice(doubleprice){

this.price=price;

publicStringgetDescription(){

returndescription;

publicvoidsetDescription(Stringdescription){

this.description=description;

publicGoods(Integerid,Stringname,doubleprice,Stringdescription){

publicGoods(){

super();

//TODOAuto-generatedconstructorstub

@Override

publicStringtoString(){

Goods[id="

+id+"

name="

+name+"

price="

+price

+"

description="

+description+"

]"

publicclassUser{

privateStringuser_name;

privateintage;

privateStringpassword;

privateStringsex;

publicStringgetUser_name(){

returnuser_name;

publicvoidsetUser_name(Stringuser_name){

this.user_name=user_name;

publicintgetAge(){

returnage;

publicvoidsetAge(intage){

this.age=age;

publicStringgetPassword(){

returnpassword;

publicvoidsetPassword(Stringpassword){

this.password=password;

publicStringgetSex(){

returnsex;

publicvoidsetSex(Stringsex){

this.sex=sex;

publicUser(Stringuser_name,Stringname,intage,Stringpassword,

Stringsex){

publicUser(){

User[user_name="

+user_name+"

age="

+age+"

password="

+password+"

sex="

+sex+"

service层

packagecom.service;

publicinterfaceGoodsService{

//增加商品

//修改

对应服务层接口:

importorg.springframework.stereotype.Service;

importorg.springframework.transaction.annotation.Propagation;

importorg.springframework.transaction.annotation.Transactional;

importcom.dao.GoodsDAO;

@Service

@Transactional

publicclassGoodsServiceImplimplementsGoodsService{

privateGoodsDAOgoodsDAO;

publicGoodsDAOgetGoodsDAO(){

returngoodsDAO;

publicvoidsetGoodsDAO(GoodsDAOgoodsDAO){

this.goodsDAO=goodsDAO;

//提高查询效率

@Transactional(propagation=Propagation.SUPPORTS,readOnly=true)

selectAll(){

goods=goodsDAO.selectAll();

returngoods;

publicvoidsave(Goodsgoods){

goodsDAO.save(goods);

publi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1