JavaWebSSM超市管理系统方案文档格式.docx
《JavaWebSSM超市管理系统方案文档格式.docx》由会员分享,可在线阅读,更多相关《JavaWebSSM超市管理系统方案文档格式.docx(25页珍藏版)》请在冰豆网上搜索。
Goods
1、DAO层:
持久层主要与数据库进行交互
DAO层首先会创建DAO接口,也就是说DAO层里面有一个专门写接口的类,然后会在配置文件(xml文件,也就是写SQL语句的文件,所以说DAO层是与数据库进行交互的层)中定义该接口的实现类,
接着就可以在模块中就可以调用DAO的接口进行数据业务的而处理,并且不用关注此接口的具体实现类是哪一个类。
DAO层的数据源和数据库连接的参数都是在配置文件中进行配置的。
2、Entity层:
实体层数据库在项目中的类
3、Service层:
业务层控制业务
Service层主要负责业务模块的逻辑应用设计。
和DAO层一样都是先设计放接口的类,再创建实现的类,然后在配置文件中进行配置其实现的关联。
接下来就可以在service层调用接口进行业务逻辑应用的处理。
封装Service层的业务逻辑有利于业务逻辑的独立性和重复利用性。
4、Controller层:
控制层控制业务逻辑
Controller层负责具体的业务模块流程的控制,其实就是与前台互交,把前台传进来的参数进行处理,controller层主要调用Service层里面的接口控制具体的业务流程,控制的配置也需要在配置文件中进行。
四、概要设计
Goods表
Goods_user表
已存储的商品信息表
Controller层
商品实现代码:
用户实现代码:
Dao层
对应的mapper文件
对应的实体:
Service层:
controller层:
Goods:
package;
import"
/goods"
)
publicclassGoodsController{
@Autowired
privateGoodsServicegoodsService;
publicGoodsServicegetGoodsService(){
returngoodsService;
}
publicvoidsetGoodsService(GoodsServicegoodsService){
=goodsService;
@RequestMapping("
/selectAll"
publicStringselectAll(HttpServletRequestrequest)throwsException{
List<
Goods>
goods=();
("
goods"
goods);
return"
forward:
/product/"
;
/save"
publicStringsave(Goodsgoods){
(goods);
/goods/"
/delete"
)
publicStringdelete(Integerid)throwsException{
(id);
/selectByID"
publicStringselectByID(Integerid,HttpServletRequestrequest){
Goodsgoods=(id);
/updateGoods"
publicStringupdateGoods(Goodsgoods){
(goods);
}
User:
/user"
publicclassUserController{
privateUserServiceuserService;
publicUserServicegetUserService(){
returnuserService;
publicvoidsetUserService(UserServiceuserService){
=userService;
/"
>
<
mappernamespace="
"
<
selectid="
selectAll"
resultType="
Goods"
>
select*fromgoodsorderbyid
/select>
selectByID"
select*fromgoodswhereid=#{id}
insertid="
save"
<
selectKeykeyProperty="
id"
int"
order="
BEFORE"
selectfromdual
/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>
importinterfaceUserDAO{
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:
publicclassGoods{
privateIntegerid;
privateStringname;
privatedoubleprice;
privateStringdescription;
publicIntegergetId(){
returnid;
publicvoidsetId(Integerid){
=id;
publicStringgetName(){
returnname;
publicvoidsetName(Stringname){
=name;
publicdoublegetPrice(){
returnprice;
publicvoidsetPrice(doubleprice){
=price;
publicStringgetDescription(){
returndescription;
publicvoidsetDescription(Stringdescription){
=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){
=user_name;
publicintgetAge(){
returnage;
publicvoidsetAge(intage){
=age;
publicStringgetPassword(){
returnpassword;
publicvoidsetPassword(Stringpassword){
=password;
publicStringgetSex(){
returnsex;
publicvoidsetSex(Stringsex){
=sex;
publicUser(Stringuser_name,Stringname,intage,Stringpassword,
Stringsex){
publicUser(){
User[user_name="
+user_name+"
age="
+age+"
password="
+password+"
sex="
+sex+"
service层
importinterfaceGoodsService{
//查询所有商品
publicList<
selectAll();
//增加商品
publicvoidsave(Goodsgoods);
//删除商品
publicvoiddelete(Integerid);
//通过ID查询
publicGoodsselectByID(Integerid);
//修改
publicvoidupdateGoods(Goodsgoods);
对应服务层接口:
importclassGoodsServiceImplimplementsGoodsService{
privateGoodsDAOgoodsDAO;
publicGoodsDAOgetGoodsDAO(){
returngoodsDAO;
publicvoidsetGoodsDAO(GoodsDAOgoodsDAO){
=goodsDAO;
//提高查询效率
@Transactional(propagation=,readOnly=true)
selectAll(){
returngoods;
publicvoidsave(Goodsgoods){
publicvoiddelete(Integerid){
publicGoodsselectByID(Integerid){
publicvoidupdateGoods(Goodsgoods){
(goods);
User;
importinterfaceUserService{
//注册
publicvoidregister(Useruser);
//登录
publicUserlogin(Stringuser_name,Stringpassword);
importclassUserServiceImplimplementsUserService{
privateUserDAOuserDAO;
publicUserDAOgetUserDAO(){
returnuserDAO;
publicvoidsetUserDAO(UserDAOuserDAO){
=userDAO;
publicvoidregister(Useruser){
(user);
publicUserlogin(Stringuser_name,Stringpassword){
Useruser=(user_name,password);
returnuser;
结束语:
本次实验的设计与开发,是对本学期学习的一种很好的总结,在本学期的实验中,本次实验很具有挑战性,因此我选择了这个项目作为我的实验项目,在完成了实验的时候,我也遇到了许多困难与错误,在需求不明确的时候盲目的开发造成错误百出,某些知识点的掌握还不够,也有一些地方与预期不相符,我不得不查询各种资料,在一次次探讨之中,我慢慢的掌握的许多知识,在这些知识的认识之下,完成了该实验的设计与开发,技术与业务能力也有所提高,这对以后的事业发展有一定的积极影响作用