SSM分布式项目之淘淘商城-第四天(IDEA)

文章大纲
一、第四天课程计划
二、门户系统的搭建
三、商城首页展示
四、内容管理系统介绍
五、内容服务系统创建
六、CMS系统实现

淘淘商城课程大纲

课程大纲
一共14天课程
(1)第一天:电商介绍–互联网术语-SOA-分布式-集群介绍-环境配置-框架搭建
(2)第二天:Dubbo介绍_dubbo框架整合_商品列表查询实现_分页_逆向工程
(3)第三天:Git&.Nginx,类目选择,新增商品
(4)第四天:门户网站介绍&商城首页搭建&内容系统创建&CMS实现
(5)第五天:首页轮播图显示实现,Redis环境搭建,Redis实现缓存
(6)第六天:solr索引库搭建&solr搜索功能实现&图片显示问题解决
(7)第七天:solr集群搭建_全局异常处理
(8)第八天:activeMQ介绍_搭建_解决同步索引库问题
(9)第九天:FreeMark入门_静态化页面标签介绍_静态化页面实现
(10)第十天:Nginx代理详解…单点登录系统工程搭建_接口文档讲解
(11)第十一天:SSO系统的搭建&单点登录系统实现_用户名回显_cookie跨域问题
(12)第十二天:购物车订单系统的实现。
(13)第十三天:订单提交的功能实现&项目的部署&服务器的域名规划。
(14)项目总结。

1. 第四天课程计划

1、门户系统的搭建
2、显示商城首页
3、内容管理系统的实现
	a)	内容分类管理
	b)	内容管理

2. 门户系统的搭建

2.1. 什么是门户系统

从广义上来说,它将各种应用系统、数据资源和互联网资源集成到一个信息管理平台之上,并以统一的用户界面提供给用户,并建立企业对客户、企业对内部员工和企业对企业的信息通道,使企业能够释放存储在企业内部和外部的各种信息。
在这里插入图片描述
门户就是访问网站的入口,通俗的说在这里就是首页。比如:jd首页,taotao首页,taobao首页。
门户属于前台系统 :面向广大的互联网网民。
后台系统:面向维护人员,入住的商家,使用。

2.2 系统架构

在这里插入图片描述

2.3 搭建taotao-portal-web工程

参考taotao-manager-web ,搭建taotao-portal-web,右击taotao-parent --> NEW -->Module
这里因为也要有web.xml文件,所以选择模板
在这里插入图片描述
注意不要添加进parent骨架
在这里插入图片描述
在这里插入图片描述

然后Next创建成功。

修改pom.xml 文件
前面用不到taotao-content-interface依赖,可以注释掉。

<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>com.taotao</groupId>
        <artifactId>taotao-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.taotao</groupId>
    <artifactId>taotao-portal-web</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-content-interface</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!-- 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>
        <!-- JSP相关 -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <scope>provided</scope>
        </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>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!-- 配置tomcat插件 -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <port>8082</port>
                    <path>/</path>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

配置web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <display-name>taotao-portal-web</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <!-- 配置dispatcherservlet -->
  <!-- url的拦截形式 -->
  <!-- 加载springmvc.xml -->
  <!-- 解决post乱码 -->
  <filter>
    <filter-name>CharacterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>utf-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>CharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!-- springmvc的前端控制器 -->
  <servlet>
    <servlet-name>taotao-portal-web</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!-- contextConfigLocation不是必须的, 如果不配置contextConfigLocation, springmvc的配置文件默认在:WEB-INF/servlet的name+"-servlet.xml" -->
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring/springmvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>taotao-portal-web</servlet-name>
    <!-- SEO :搜索引擎优化   伪静态化-->
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
</web-app>

SEO:搜索引擎优化,为了提高网站的流量,提高在各搜索引擎中的搜索排名,需要进行优化,那么可以为动态网站伪静态化,以提高排名。

加入配置文件springmvc.xml
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
        http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">

    <context:component-scan base-package="com.taotao.portal.controller" />
    <mvc:annotation-driven />
    <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <!--配置静态资源映射-->
    <!--<mvc:resources location="/WEB-INF/js/" mapping="/js/**"/>
    <mvc:resources location="/WEB-INF/css/" mapping="/css/**"/>-->


    <!-- 引用dubbo服务 -->
    <dubbo:application name="taotao-portal-web"/>
    <dubbo:registry protocol="zookeeper" address="192.168.25.128:2181"/>

    <!--在服务层和表现层都可以设置超时时间。-->
    <!--<dubbo:reference interface="com.taotao.service.TestService" id="testService" timeout="300000" />-->
</beans>

3. 商城首页展示

首页的原型:
在这里插入图片描述

添加静态页面及资源。
页面位置如下:
在这里插入图片描述

3.1 功能分析

请求的url:/index
http://localhost:8082/index.html
参数:没有
返回值:String 逻辑视图

3.2 功能实现

一般:jd,taobao访问时直接访问域名

我们这里能否直接访问: http://localhost:8082/

(http://localhost:8082/相当于访问域名,后面部署的时候将会换成域名访问)
答案是否定的,要想实现此功能,修改:web.xml。

添加红色部分如下:
在这里插入图片描述
效果如下:
在这里插入图片描述

4. 内容管理系统介绍

4.1 首页大广告位开发实现分析

可以根据首页大广告位的数据结构设计一张表,进行增删改查管理
其他部分的展示内容同样可以设计表,进行增删改查

存在的问题:
如果每一个前端展示内容(大广告位、小广告位等等),单独建立表,进行CRUD操作,会有以下问题:

1.首页页面信息大量堆积,发布显的异常繁琐沉重;
2.内容繁杂,管理效率低下;
3.许多工作都需要其他技术人员配合完成;
4.改版工作量大,维护,扩展性差;

使用内容管理系统解决以上问题。

4.2 内容管理系统

内容管理系统(content management system,CMS)是一种位于WEB 前端(Web 服务器)和后端办公系统或流程(内容创作、编辑)之间的软件系统。内容的创作人员、编辑人员、发布人员使用内容管理系统来提交、修改、审批、发布内容。这里指的“内容”可能包括文件、表格、图片、数据库中的数据甚至视频等一切你想要发布到Internet网站的信息。

就是后台管理维护前台的页面和页面中的内容可以动态展示。

4.3 动态展示分析

对首页展示功能进行分析,抽取,发现应当有以下的字段属性:

有图片
有链接
有标题
有价格
图片提示
包含大文本类型,可以作为公告

把首页的每个展示功能(大广告位,淘淘快报等),看作是一个分类,每个展示功能里面展示的多条信息,看作是分类下的内容

例如:首页大广告,对应的是大广告分类,而大广告位展示的多张图片,就是大广告分类下的内容
前台需要获取大广告的图片,只需要根据大广告的id查询对应的内容即可

需要一个内容分类表和一个内容表。内容分类和内容表是一对多的关系。
在这里插入图片描述
内容分类表,需要存储树形结构的数据。(大分类下有小分类)
内容分类表:tb_content_category
内容表:tb_content

分类表结构:
在这里插入图片描述
内容表结构:
在这里插入图片描述

需要有后台来维护内容信息CMS系统。
在这里插入图片描述

需要创建一个内容服务系统

5. 内容服务系统创建

可以参考taotao-manager创建。

	taotao-content:聚合工程打包方式pom
	|--taotao-content-interface  jar
	|--taotao-content-Service  war
		//直接依赖POJO过来
		//直接依赖dao过来

5.1 创建taotao-content

右击taotao-parent --> NEW -->Module
不用选择模板,直接next,注意不要添加到parent骨架,命名为taotao-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>com.taotao</groupId>
        <artifactId>taotao-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.taotao</groupId>
    <artifactId>taotao-content</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>taotao-content-interface</module>
        <module>taotao-content-service</module>
    </modules>
    <dependencies>
        <!-- 依赖taotao-manager-common -->
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!-- 配置tomcat插件 -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <port>8083</port>
                    <path>/</path>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

5.2 taotao-content-interface

选择taotao-content 右击鼠标–>NEW —>Module,这里就需要加入content骨架,不用点击那个None了。接下来命名taotao-content-interface,点击Next就行了。

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>com.taotao</groupId>
        <artifactId>taotao-content</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>taotao-content-interface</artifactId>
    <dependencies>
        <!-- pojo -->
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-manager-pojo</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

5.3 taotao-content-service

选择taotao-content 右击鼠标–>NEW —>Module,因为需要有web.xml文件,所以选择模板
在这里插入图片描述
点击Next,命名为taotao-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>com.taotao</groupId>
        <artifactId>taotao-content</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>taotao-content-service</artifactId>
    <packaging>war</packaging>
    <dependencies>
        <!-- 添加接口的依赖 -->
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-content-interface</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-manager-dao</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!-- 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>
        <!-- jedis -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>${jedis.version}</version>
        </dependency>
    </dependencies>
</project>

5.4 框架整合

参考taotao-manager
在这里插入图片描述

6. CMS系统实现

6.1 展示内容分类

内容分类管理
a) 原型图
在这里插入图片描述

b) 功能分析
在这里插入图片描述

请求的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
创建接口ContentCategoryService

public interface ContentCategoryService {
    //通过节点的id查询该节点的子节点列表
    public List<EasyUITreeNode> getContentCategoryList(Long parentId);
}

在这里插入图片描述

@Service
public class ContentCategoryServiceImpl implements ContentCategoryService {
    @Autowired
    private TbContentCategoryMapper mapper;

    @Override
    public List<EasyUITreeNode> getContentCategoryList(Long parentId) {
        //1.注入Mapper
        //2.创建example
        TbContentCategoryExample example = new TbContentCategoryExample();
        //3.设置条件
        TbContentCategoryExample.Criteria criteria = example.createCriteria();
        criteria.andParentIdEqualTo(parentId);//select * form tbcontentcategory where parent_id=1
        //4.执行查询
        List<TbContentCategory> list = mapper.selectByExample(example);
        //5.转成EasyUITreeNode列表
        List<EasyUITreeNode> nodes = new ArrayList<>();
        for (TbContentCategory tbContentCategory : list
        ) {
            EasyUITreeNode node = new EasyUITreeNode();
            node.setId(tbContentCategory.getId());
            node.setState(tbContentCategory.getIsParent()?"closed":"open");
            node.setText(tbContentCategory.getName());//分类名称
            nodes.add(node);
        }
        //6.返回
        return nodes;
    }

在这里插入图片描述

e) 发布服务
修改application-service文件
在这里插入图片描述

g) 引用服务
打开taotao-manager-web,修改pom.xml

依赖taotao-content-interface模块
在这里插入图片描述
修改springmvc.xml文件
在这里插入图片描述

创建Controller
在这里插入图片描述

@Controller
public class ContentCategoryController {
    @Autowired
    private ContentCategoryService service;
    /**
     * url : '/content/category/list',
     * 		animate: true,
     * 		method : "GET",
     **/
    @RequestMapping(value = "/content/category/list", method = RequestMethod.GET)
    @ResponseBody
    public List<EasyUITreeNode> getContentCategoryList(@RequestParam(value = "id",defaultValue = "0") Long parentId){
        //1.引入服务
        //2.注入服务
        //3.调用
        return service.getContentCategoryList(parentId);
    }

6.2 新增节点

功能分析
在这里插入图片描述

请求的url:/content/category/create
请求的参数:
Long parentId
String name
响应的结果:
json数据,TaotaoResult,其中包含一个对象,对象有id属性,新生产的内容分类id
插入数据结点之后需要判断,如果在原结点是叶子节点的时候添加,更新其父节点(is_parent属性设置为1

业务逻辑:

1、接收两个参数:parentId、name
2、向tb_content_category表中插入数据。
	a)	创建一个TbContentCategory对象
	b)	补全TbContentCategory对象的属性
	c)	向tb_content_category表中插入数据
3、判断父节点的isparent是否为true,不是true需要改为true4、需要主键返回。
5、返回TaotaoResult,其中包装TbContentCategory对象

创建Dao层
可以使用逆向工程。

需要添加主键返回:
修改TbContentCategoryMapper.xml文件在这里插入图片描述
注意两个Insert有关的都要改
在这里插入图片描述

注意:修改完代码后,需要向本地仓库安装taotao-manager-dao包

创建Service层

参数:parentId、name
返回值:返回TaotaoResult,其中包装TbContentCategory对象

添加接口

在这里插入图片描述
实现接口

@Override
    public TaotaoResult createContentCategory(Long parentId, String name) {
        //1.构建对象 补全其他属性
        TbContentCategory category = new TbContentCategory();
        category.setCreated(new Date());
        category.setIsParent(false);//新增的节点都是叶子节点
        category.setName(name);
        category.setParentId(parentId);
        category.setSortOrder(1);
        category.setStatus(1);
        category.setUpdated(category.getCreated());
        //2.插入contentcategory表数据
        mapper.insertSelective(category);
        //3.判断如果要添加的节点的父节点本身是叶子节点,需要更新其为父节点
        TbContentCategory parent = mapper.selectByPrimaryKey(parentId);
        if (parent.getIsParent() == false){//原本就是叶子节点
            parent.setIsParent(true);
            mapper.updateByPrimaryKeySelective(parent);//更新节点的is_parent属性为true
        }
        //4.返回taotaoResult 包含内容分类的id 需要主键返回
        return TaotaoResult.ok(category);
    }

发布服务。

表现层

请求的url:/content/category/create
请求的参数:
Long parentId
String name
响应的结果:
json数据,TaotaoResult
    @RequestMapping(value = "/content/category/create",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult createContentCategory (Long parentId, String name){
        return service.createContentCategory(parentId,name);
    }

6.3 内容管理

功能点分析

1、内容列表查询
2、新增内容
3、编辑内容
4、删除内容

新增内容
功能分析

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

提交表单请求的url:/content/save
参数:表单的数据。使用pojo接收TbContent
返回值:TaotaoResult(json数据)
业务逻辑:
1、把TbContent对象属性补全。
2、向tb_content表中插入数据。
3、返回TaotaoResult

Dao
逆向工程
Service
创建接口
在这里插入图片描述

参数:TbContent
返回值:TaotaoResult

实现接口

@Service
public class ContentServiceImpl implements ContentService {
    @Autowired
    private TbContentMapper mapper;

    @Override
    public TaotaoResult saveContent(TbContent content) {
        //1.注入Mapper
        //2.补全其他属性
        content.setCreated(new Date());
        content.setUpdated(content.getCreated());
        //3.插入内容表中
        mapper.insertSelective(content);
        return TaotaoResult.ok();
    }
}

发布服务

引用服务
Toatao-manager-web工程中引用。

Controller

提交表单请求的url:/content/save
参数:表单的数据。使用pojo接收TbContent
返回值:TaotaoResult(json数据)
@Controller
public class ContentController {
    @Autowired
    private ContentService service;
    @RequestMapping(value = "/content/save",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult saveContent(TbContent content){
        //1.引入服务
        //2.注入服务
        //3.调用
        return service.saveContent(content);
    }
}

6.4 实现效果

查看数据库
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值