1.   学习计划

1、前台系统搭建

2、商城首页展示

3、Cms系统的实现

a)         内容分类管理

b)         内容管理

4、前台内容动态展示

2.   商城首页展示

2.1. 工程搭建

参考e3-manager-web工程,搭建e3-portal-web。

复制e3-manager-web的pom.xml、springmvc.xml和web.xml文件。

2.2导入页面

2.3. 功能分析

请求的url:/index

web.xml中的欢迎页配置:

IndexController.java
package cn.e3mall.portal.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class IndexController {
@RequestMapping("/index")
public String showIndex(){
return "index";
}
}

http://localhost:8083

参数:没有

返回值:String 逻辑视图

测试:

4.   首页动态展示分析

内容信息要从数据库中获得

1、内容需要进行分类

2、分类下有子分类,需要动态管理。

3、分类下有内容列表

4、单点的内容信息

a)         有图片

b)        有链接

c)         有标题

d)        有价格

e)         包含大文本类型,可以作为公告

需要一个内容分类表和一个内容表。内容分类和内容表是一对多的关系。

内容分类表,需要存储树形结构的数据。

内容分类表:tb_content_category

内容表:tb_content

需要有后台来维护内容信息。Cms系统。

需要创建一个内容服务系统。可以参考e3-manager创建。

E3-content:聚合工程打包方式pom

|--e3-content-interface jar

|--e3-content-Service  war

4.   内容服务系统创建

4.1. 工程搭建

可以参考e3-manager工程搭建。

e3-content

e3-content-interface

e3-content-service

复制e3-manager-service以下文件到e3-content-service下,简单修改applicationContext-service.xml下的包名和接口,修改applicationContext-dao.xml下的部分路径,配置web.xml。

4.2. E3-content

Pom文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.e3mall</groupId>
<artifactId>e3-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>e3-content</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>cn.e3mall</groupId>
<artifactId>e3-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<modules>
<module>e3-content-interface</module>
<module>e3-content-service</module>
</modules>
<!-- 配置tomcat插件 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<port>8084</port>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</project>

4.2. E3-content-interface

Pom文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.e3mall</groupId>
<artifactId>e3-content</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>e3-content-interface</artifactId>
<dependencies>
<dependency>
<groupId>cn.e3mall</groupId>
<artifactId>e3-manager-pojo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

4.2. E3-content-service

Pom文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.e3mall</groupId>
<artifactId>e3-content</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>e3-content-service</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>cn.e3mall</groupId>
<artifactId>e3-manager-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.e3mall</groupId>
<artifactId>e3-content-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- spring的依赖 -->
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<!-- dubbo相关 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
</dependency>
</dependencies>
</project>

5.   Cms系统实现

5.1. 内容分类管理

5.1.1.    展示内容分类

功能分析

请求的url:/content/category/list

请求的参数:id,当前节点的id。第一次请求是没有参数,需要给默认值“0”

响应数据:List<EasyUITreeNode>(@ResponseBody)

Json数据。

[{id:1,text:节点名称,state:open(closed)},

{id:2,text:节点名称2,state:open(closed)},

{id:3,text:节点名称3,state:open(closed)}]

业务逻辑:

1、取查询参数id,parentId

2、根据parentId查询tb_content_category,查询子节点列表。

3、得到List<TbContentCategory>

4、把列表转换成List<EasyUITreeNode>

Dao层

使用逆向工程

Service

参数:long parentId

返回值:List<EasyUITreeNode>

package cn.e3mall.content.service.impl;

import java.util.ArrayList;
import java.util.List; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import cn.e3mall.common.pojo.EasyUITreeNode;
import cn.e3mall.content.service.ContentCategoryService;
import cn.e3mall.mapper.TbContentCategoryMapper;
import cn.e3mall.pojo.TbContentCategory;
import cn.e3mall.pojo.TbContentCategoryExample;
import cn.e3mall.pojo.TbContentCategoryExample.Criteria; @Service
public class ContentCategoryServiceImpl implements ContentCategoryService{ @Autowired
private TbContentCategoryMapper contentCategoryMapper; @Override
public List<EasyUITreeNode> getContentCategoryList(long parentId) {
// 1、取查询参数id,parentId
// 2、根据parentId查询tb_content_category,查询子节点列表。
TbContentCategoryExample example = new TbContentCategoryExample();
//设置查询条件
Criteria criteria = example.createCriteria();
criteria.andParentIdEqualTo(parentId);
//执行查询
// 3、得到List<TbContentCategory>
List<TbContentCategory> list = contentCategoryMapper.selectByExample(example);
// 4、把列表转换成List<EasyUITreeNode>ub
List<EasyUITreeNode> resultList = new ArrayList<>();
for (TbContentCategory tbContentCategory : list) {
EasyUITreeNode node = new EasyUITreeNode();
node.setId(tbContentCategory.getId());
node.setText(tbContentCategory.getName());
node.setState(tbContentCategory.getIsParent()?"closed":"open");
//添加到列表
resultList.add(node);
}
return resultList;
} }

发布服务

<!-- 声明需要暴露的服务接口 -->

<dubbo:service interface="cn.e3mall.content.service.ContentCategoryService" ref="contentCategoryServiceImpl" timeout="600000"/>

表现层

E3-manager-web

依赖e3-content-interface模块

Springmvc.xml中添加服务的引用:

 <dubbo:reference interface="cn.e3mall.content.service.ContentCategoryService" id="contentCategoryService"/>

Controller

    @RequestMapping("/content/category/list")
@ResponseBody
public List<EasyUITreeNode> getContentCatList(
@RequestParam(value="id", defaultValue="0") Long parentId) { List<EasyUITreeNode> list = contentCategoryService.getContentCategoryList(parentId);
return list;
}

5.1.2.    新增节点

功能分析

请求的url:/content/category/create

请求的参数:

Long parentId

String name

响应的结果:

json数据,E3Result,其中包含一个对象,对象有id属性,新生产的内容分类id

业务逻辑:

1、接收两个参数:parentId、name

2、向tb_content_category表中插入数据。

a)         创建一个TbContentCategory对象

b)        补全TbContentCategory对象的属性

c)         向tb_content_category表中插入数据

3、判断父节点的isparent是否为true,不是true需要改为true。

4、需要主键返回。

5、返回E3Result,其中包装TbContentCategory对象

Dao层

可以使用逆向工程。

需要添加主键返回:

Service层

参数:parentId、name

返回值:返回E3Result,其中包装TbContentCategory对象

    @Override
public E3Result addContentCategory(long parentId, String name) {
// 1、接收两个参数:parentId、name
// 2、向tb_content_category表中插入数据。
// a)创建一个TbContentCategory对象
TbContentCategory tbContentCategory = new TbContentCategory();
// b)补全TbContentCategory对象的属性
tbContentCategory.setIsParent(false);
tbContentCategory.setName(name);
tbContentCategory.setParentId(parentId);
//排列序号,表示同级类目的展现次序,如数值相等则按名称次序排列。取值范围:大于零的整数
tbContentCategory.setSortOrder(1);
//状态。可选值:1(正常),2(删除)
tbContentCategory.setStatus(1);
tbContentCategory.setCreated(new Date());
tbContentCategory.setUpdated(new Date());
// c)向tb_content_category表中插入数据
contentCategoryMapper.insert(tbContentCategory);
// 3、判断父节点的isparent是否为true,不是true需要改为true。
TbContentCategory parentNode = contentCategoryMapper.selectByPrimaryKey(parentId);
if (!parentNode.getIsParent()) {
parentNode.setIsParent(true);
//更新父节点
contentCategoryMapper.updateByPrimaryKey(parentNode);
}
// 4、需要主键返回。
// 5、返回E3Result,其中包装TbContentCategory对象
return E3Result.ok(tbContentCategory);
}

发布服务。(前面已经发过了)

表现层

请求的url:/content/category/create

请求的参数:

Long parentId

String name

响应的结果:

json数据,E3Result

@RequestMapping("/create")
@ResponseBody
public E3Result createCategory(Long parentId, String name) {
E3Result result = contentCategoryService.addContentCategory(parentId, name);
return result;
}

5.2. 内容管理

新增内容

功能分析

新增内容,必须指定一个内容分类。

提交表单请求的url:/content/save

参数:表单的数据。使用pojo接收TbContent

返回值:E3Result(json数据)

业务逻辑:

1、把TbContent对象属性补全。

2、向tb_content表中插入数据。

3、返回E3Result

Dao

逆向工程

Service

参数:TbContent

返回值:E3Result

@Service
public class ContentServiceImpl implements ContentService { @Autowired
private TbContentMapper contentMapper; @Override
public E3Result addContent(TbContent content) {
//补全属性
content.setCreated(new Date());
content.setUpdated(new Date());
//插入数据
contentMapper.insert(content);
return E3Result.ok();
} }

发布服务

<dubbo:service interface="cn.e3mall.content.service.ContentService" ref="contentServiceImpl" timeout="600000"/>

引用服务

<dubbo:reference interface="cn.e3mall.content.service.ContentService" id="contentService" />

Controller

提交表单请求的url:/content/save

参数:表单的数据。使用pojo接收TbContent

返回值:E3Result(json数据)

@Controller
public class ContentController { @Autowired
private ContentService contentService; @RequestMapping("/content/save")
@ResponseBody
public E3Result addContent(TbContent content) {
E3Result result = contentService.addContent(content);
return result;
}
}

SSM商城项目(五)的更多相关文章

  1. SSM商城项目(二)

    1. 学习计划 1.将工程改造为基于SOA架构 2.商品列表查询功能实现. 2. 将工程改造为SOA架构 2.1. 分析 由于商城是基于soa的架构,表现层和服务层是不同的工程.所以要实现商品列表查询 ...

  2. SSM商城项目(一)

    1. 学习计划 1.电商行业的背景. 2.宜立方商城介绍 3.宜立方商城的系统架构 a) 功能介绍 b) 架构讲解 4.工程搭建-后台工程 a) 使用maven搭建工程 b) 使用maven的tomc ...

  3. SSM商城项目(四)

    1. 学习计划 1.图片服务器 2.图片服务器安装 3.图片服务器的使用 4.图片上传功能 5.富文本编辑器的使用方法 6.商品添加功能实现 2. 图片服务器 1.存储空间可扩展. 2.提供一个统一的 ...

  4. SSM商城项目(十)

    1.   学习计划 1.使用freemarker实现网页静态化 a)Freemarker的使用方法 b)Freemarker模板的语法 c)Freemarker整合springmvc 2.Active ...

  5. SSM商城项目(八)

    1.   学习计划 1.solr集群搭建 2.使用solrj管理solr集群 3.把搜索功能切换到集群版 4.添加商品同步到索引库 2.   什么是SolrCloud SolrCloud(solr 云 ...

  6. SSM商城项目(七)

    1.   学习计划 1.Solr服务搭建 2.Solrj使用测试 3.把数据库中的数据导入索引库 4.搜索功能的实现 2.   Solr服务搭建 2.1. Solr的环境 Solr是java开发. 需 ...

  7. SSM商城项目(六)

    1.学习计划 1.Redis服务器搭建 2.Redis持久化 3.Redis集群搭建 4.Jedis 5.Solr服务器安装 2.Redis的安装 2.1. Redis的安装 Redis是c语言开发的 ...

  8. SSM商城项目(三)

    1. 学习计划 1.商品类目选择 2.图片上传 a) 图片服务器FastDFS b) 图片上传功能实现 3.富文本编辑器的使用KindEditor 2. 商品类目选择 2.1. 原型 2.2. 功能分 ...

  9. SSM商城项目(十三)

    1.   学习计划 1.订单系统 2.提交订单 3.MyCAT 2.   订单系统 2.1. 功能分析 1.在购物车页面点击“去结算”按钮跳转到订单确认页面. a)         展示商品列表 b) ...

随机推荐

  1. vs2017 编译vue 错误 TS2307 Build:找不到模块“webpack”。

    升级了vs2017之后,编译之前正常的工程,发现出现了对vue的编译错误, 提示一些列找不到模块的错误 错误 TS2307 Build:找不到模块“webpack”. ...... 错误 TS2345 ...

  2. flask中如何生成迁移文件

    在flask网站开发中,如果直接对数据库进行修改的话,风险比较高,最好的是由迁移文件生成,这样确保了数据的误操作. 在Flask中可以使用Flask-Migrate扩展,来实现数据迁移.并且集成到Fl ...

  3. Python全栈之路----类型转换

    显式转换 int(x [,base]) ⇒ 将x转换为一个十进制的整数 long(x [,base]) ⇒ 将x转换为一个十进制的长整数 float(x) ⇒ 将x转换为一个浮点数 str(objec ...

  4. Combining Lexical and Grammatical Features to Improve Readability Measures for First and Second Language Texts.-paper

    http://www.aclweb.org/anthology/N07-1058 Volume:Human Language Technologies 2007: The Conference of ...

  5. windows 2008R2系统程序运行提示无法定位程序输入点ucrtbase.terminate

    1.用python写了个脚本,打成exe程序,在一些机器上正常运行,再另外一些机器上运行提示 无法定位程序输入点ucrtbase.terminate 应该是缺少库文件支持 2.网上搜了下.https: ...

  6. oracle命令2

    使用DDL创建和管理表 DBA角色:拥有全部特权,是系统最高权限,只有DBA才可以创建数据库结构,并且系统权限也需要DBA授出,且DBA用户可以操作全体用户的任意基表,包括删除 grant dba t ...

  7. HTTPS协议加密原理解析

    用 HTTP 协议,看个新闻还没有问题,但是换到更加严肃的场景中,就存在很多的安全风险.例如你要下单做一次支付,如果还是使用普通的 HTTP 协议,那你很可能会被黑客盯上. 比如,你发送一个请求,说我 ...

  8. 在 sql 语句出现 warning 之后,立刻执行 `show warnings;` 就可以看到 warning 提示信息

    在 sql 语句出现 warning 之后,立刻执行 show warnings; 就可以看到 warning 提示信息

  9. Linux下usb设备驱动详解

    USB驱动分为两块,一块是USB的bus驱动,这个东西,Linux内核已经做好了,我们可以不管,我们只需要了解它的功能.形象的说,USB的bus驱动相当于铺出一条路来,让所有的信息都可以通过这条USB ...

  10. 黄聪:OTP动态密码_Java代码实现

    OTP认知 动态口令(OTP,One-Time Password)又称一次性密码,是使用密码技术实现的在客户端和服务器之间通过共享秘密的一种认证技术,是一种强认证技术,是增强目前静态口令认证的一种非常 ...