发表于: 2019-12-15 19:29:22

1 1057


今天做了什么

编写接口文档

利用逆向工程生成mapper和实体类



简要描述:

  • 前台作品搜索(支持名称的模糊查询)

请求URL:

  • /task/works/search

请求方式:

  • get

参数:

参数名必选类型说明
work_namestring作品名

返回参数说明

参数名必选类型说明
codenumber状态码
messagestring消息
dataarray数据消息
  • data:
参数名必选类型说明
works_idnumber作品编号,唯一
works_namestring作品名
works_synopsisstring作品简介
works_urlstring作品图片链接
works_videostring作品视频链接
works_authorstring作品作者(工作室)
works_statusnumber作品上下架状态,0下架,1上架
first_idnumber作品一级导航栏id
second_idnumber作品二级导航栏id

简要描述:

  • 一级导航栏

点击一级导航栏上的按钮,从二级导航栏表中返回对应信息

请求URL:

  • /task/first

请求方式:

  • get

参数:

参数名必选类型说明
first_idnumber一级导航栏的id

返回参数说明

参数名必选类型说明
codenumber状态码
messagestring消息
dataarray数据消息
  • data:
参数名必选类型说明
first_idnumber一级导航栏的id,唯一
first_namestring作品一级导航栏标题内容
second_idnumber作品二级导航栏id
second_namestring二级导航栏标题内容

简要描述:

  • 二级导航栏

点击二级导航栏上的按钮,返回对应的图片信息(url),有具体的分类

请求URL:

  • /task/second

请求方式:

  • get

参数:

参数名必选类型说明
second_idnumber二级导航栏的id

返回参数说明

参数名必选类型说明
codenumber状态码
messagestring消息
dataarray数据消息
  • data:
参数名必选类型说明
first_idnumber作品一级导航栏id
second_idnumber作品二级导航栏id
works_idnumber作品的id值,唯一
works_synopsisstring作品简介
works_urlstring作品图片的url
works_videostring作品视频链接
works_authorstring作品作者
works_statusnumber作品上下架状态,0下架,1上架

简要描述:

  • banner图

从数据库中返回需要的banner图的链接

请求URL:

  • /task/banner/id

请求方式:

  • get

参数:

参数名必选类型说明
banner_idnumber界面上需要展示的banner图的id

返回参数说明

参数名必选类型说明
codenumber状态码
messagestring消息
dataarray数据消息
  • data:
参数名必选类型说明
banner_idnumber界面上需要展示的banner图的id
banner_urlstring作品链接
banner_imgstring作品封面(链接)

简要描述:

  • 作品展示

点击作品,返回作品的信息,跟查询返回的作品信息相同

请求URL:

  • /task/works

请求方式:

  • get

参数:

参数名必选类型说明
works_idnumber二级导航栏的id

返回参数说明

参数名必选类型说明
codenumber状态码
messagestring消息
dataarray数据消息
  • data:
参数名必选类型说明
first_idnumber作品一级导航栏id
second_idnumber作品二级导航栏id
works_idnumber作品的id值,唯一
works_namestring作品名字
works_synopsisstring作品简介
works_urlstring作品图片的url
works_videostring作品视频链接
works_authorstring作品作者
works_statusnumber作品上下架状态,0下架,1上架

简要描述:

  • .游客留言表

通过不同作品序号,返回对应的留言内容相同

请求URL:

  • /task/guestbook

请求方式:

  • get

参数:

参数名必选类型说明
works——idnumber被评论的作品id

返回参数说明

参数名必选类型说明
codenumber状态码
messagestring消息
dataarray数据消息
  • data:
参数名必选类型说明
guestbook_idnumber每条留言的id
messagestring留言的内容
visitor_idnumber访客的id,唯一
works_namestring作品名字
adminr_idnumber管理员id,(回复留言)

简要描述:

  • 关于作者和工作室的简介

导航栏三个按钮对应的页面,轨迹,工作室,成员简介

请求URL:

  • /task/synopsis

请求方式:

  • get

参数:

参数名必选类型说明
synopsis_idnumber选择导航栏的哪个简介

返回参数说明

参数名必选类型说明
codenumber状态码
messagestring消息
dataarray数据消息
  • data:
参数名必选类型说明
synopsis_idnumber简介id
synopsis_imgstring简介图片
synopsis_namestring谁的简介
synopsis_contentstring简介的具体内容
synopsis_videostring简介的视频链接


使用逆向工程插件一键生成实体类,dao,mapper

开源工具项目地址:https://github.com/zouzg/mybatis-generator-gui

代码如下:(只放了works,其他的太多了)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.mapper.WorksDAO">
 <resultMap id="BaseResultMap" type="com.demo.pojo.Works">
   <id column="works_id" jdbcType="INTEGER" property="worksId" />
   <result column="works_name" jdbcType="VARCHAR" property="worksName" />
   <result column="works_synopsis" jdbcType="VARCHAR" property="worksSynopsis" />
   <result column="works_url" jdbcType="VARCHAR" property="worksUrl" />
   <result column="works_video" jdbcType="VARCHAR" property="worksVideo" />
   <result column="works_author" jdbcType="VARCHAR" property="worksAuthor" />
   <result column="works_status" jdbcType="INTEGER" property="worksStatus" />
   <result column="create_time" jdbcType="BIGINT" property="createTime" />
   <result column="create_by" jdbcType="VARCHAR" property="createBy" />
   <result column="update_time" jdbcType="BIGINT" property="updateTime" />
   <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
   <result column="put_time" jdbcType="BIGINT" property="putTime" />
   <result column="put_by" jdbcType="VARCHAR" property="putBy" />
   <result column="first_id" jdbcType="INTEGER" property="firstId" />
   <result column="second_id" jdbcType="INTEGER" property="secondId" />
 </resultMap>
 <sql id="Base_Column_List">
   works_id, works_name, works_synopsis, works_url, works_video, works_author, works_status,
create_time, create_by, update_time, update_by, put_time, put_by, first_id, second_id
</sql>
 <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
   select
<include refid="Base_Column_List" />
   from works
where works_id = #{worksId,jdbcType=INTEGER}
</select>
 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
   delete from works
where works_id = #{worksId,jdbcType=INTEGER}
</delete>
 <insert id="insert" parameterType="com.demo.pojo.Works">
   insert into works (works_id, works_name, works_synopsis,
works_url, works_video, works_author,
works_status, create_time, create_by,
update_time, update_by, put_time,
put_by, first_id, second_id
)
values (#{worksId,jdbcType=INTEGER}, #{worksName,jdbcType=VARCHAR}, #{worksSynopsis,jdbcType=VARCHAR},
#{worksUrl,jdbcType=VARCHAR}, #{worksVideo,jdbcType=VARCHAR}, #{worksAuthor,jdbcType=VARCHAR},
#{worksStatus,jdbcType=INTEGER}, #{createTime,jdbcType=BIGINT}, #{createBy,jdbcType=VARCHAR},
#{updateTime,jdbcType=BIGINT}, #{updateBy,jdbcType=VARCHAR}, #{putTime,jdbcType=BIGINT},
#{putBy,jdbcType=VARCHAR}, #{firstId,jdbcType=INTEGER}, #{secondId,jdbcType=INTEGER}
)
</insert>
 <insert id="insertSelective" parameterType="com.demo.pojo.Works">
   insert into works
<trim prefix="(" suffix=")" suffixOverrides=",">
     <if test="worksId != null">
       works_id,
</if>
     <if test="worksName != null">
       works_name,
</if>
     <if test="worksSynopsis != null">
       works_synopsis,
</if>
     <if test="worksUrl != null">
       works_url,
</if>
     <if test="worksVideo != null">
       works_video,
</if>
     <if test="worksAuthor != null">
       works_author,
</if>
     <if test="worksStatus != null">
       works_status,
</if>
     <if test="createTime != null">
       create_time,
</if>
     <if test="createBy != null">
       create_by,
</if>
     <if test="updateTime != null">
       update_time,
</if>
     <if test="updateBy != null">
       update_by,
</if>
     <if test="putTime != null">
       put_time,
</if>
     <if test="putBy != null">
       put_by,
</if>
     <if test="firstId != null">
       first_id,
</if>
     <if test="secondId != null">
       second_id,
</if>
   </trim>
   <trim prefix="values (" suffix=")" suffixOverrides=",">
     <if test="worksId != null">
       #{worksId,jdbcType=INTEGER},
</if>
     <if test="worksName != null">
       #{worksName,jdbcType=VARCHAR},
</if>
     <if test="worksSynopsis != null">
       #{worksSynopsis,jdbcType=VARCHAR},
</if>
     <if test="worksUrl != null">
       #{worksUrl,jdbcType=VARCHAR},
</if>
     <if test="worksVideo != null">
       #{worksVideo,jdbcType=VARCHAR},
</if>
     <if test="worksAuthor != null">
       #{worksAuthor,jdbcType=VARCHAR},
</if>
     <if test="worksStatus != null">
       #{worksStatus,jdbcType=INTEGER},
</if>
     <if test="createTime != null">
       #{createTime,jdbcType=BIGINT},
</if>
     <if test="createBy != null">
       #{createBy,jdbcType=VARCHAR},
</if>
     <if test="updateTime != null">
       #{updateTime,jdbcType=BIGINT},
</if>
     <if test="updateBy != null">
       #{updateBy,jdbcType=VARCHAR},
</if>
     <if test="putTime != null">
       #{putTime,jdbcType=BIGINT},
</if>
     <if test="putBy != null">
       #{putBy,jdbcType=VARCHAR},
</if>
     <if test="firstId != null">
       #{firstId,jdbcType=INTEGER},
</if>
     <if test="secondId != null">
       #{secondId,jdbcType=INTEGER},
</if>
   </trim>
 </insert>
 <update id="updateByPrimaryKeySelective" parameterType="com.demo.pojo.Works">
   update works
<set>
     <if test="worksName != null">
       works_name = #{worksName,jdbcType=VARCHAR},
</if>
     <if test="worksSynopsis != null">
       works_synopsis = #{worksSynopsis,jdbcType=VARCHAR},
</if>
     <if test="worksUrl != null">
       works_url = #{worksUrl,jdbcType=VARCHAR},
</if>
     <if test="worksVideo != null">
       works_video = #{worksVideo,jdbcType=VARCHAR},
</if>
     <if test="worksAuthor != null">
       works_author = #{worksAuthor,jdbcType=VARCHAR},
</if>
     <if test="worksStatus != null">
       works_status = #{worksStatus,jdbcType=INTEGER},
</if>
     <if test="createTime != null">
       create_time = #{createTime,jdbcType=BIGINT},
</if>
     <if test="createBy != null">
       create_by = #{createBy,jdbcType=VARCHAR},
</if>
     <if test="updateTime != null">
       update_time = #{updateTime,jdbcType=BIGINT},
</if>
     <if test="updateBy != null">
       update_by = #{updateBy,jdbcType=VARCHAR},
</if>
     <if test="putTime != null">
       put_time = #{putTime,jdbcType=BIGINT},
</if>
     <if test="putBy != null">
       put_by = #{putBy,jdbcType=VARCHAR},
</if>
     <if test="firstId != null">
       first_id = #{firstId,jdbcType=INTEGER},
</if>
     <if test="secondId != null">
       second_id = #{secondId,jdbcType=INTEGER},
</if>
   </set>
   where works_id = #{worksId,jdbcType=INTEGER}
</update>
 <update id="updateByPrimaryKey" parameterType="com.demo.pojo.Works">
   update works
set works_name = #{worksName,jdbcType=VARCHAR},
works_synopsis = #{worksSynopsis,jdbcType=VARCHAR},
works_url = #{worksUrl,jdbcType=VARCHAR},
works_video = #{worksVideo,jdbcType=VARCHAR},
works_author = #{worksAuthor,jdbcType=VARCHAR},
works_status = #{worksStatus,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=BIGINT},
create_by = #{createBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=BIGINT},
update_by = #{updateBy,jdbcType=VARCHAR},
put_time = #{putTime,jdbcType=BIGINT},
put_by = #{putBy,jdbcType=VARCHAR},
first_id = #{firstId,jdbcType=INTEGER},
second_id = #{secondId,jdbcType=INTEGER}
where works_id = #{worksId,jdbcType=INTEGER}
</update>
</mapper>


各种对象信息:

VO

即value object值对象。
主要体现在视图的对象,对于一个WEB页面将整个页面的属性封装成一个对象。然后用一个VO对象在控制层与视图层进行传输交换。


DTO

经过处理后的PO,可能增加或者减少PO的属性:Data Transfer Object数据传输对象
主要用于远程调用等需要大量传输对象的地方。
比如我们一张表有100个字段,那么对应的PO就有100个属性。

https://blog.csdn.net/Andrew_Yuan/article/details/83088122

但是我们界面上只要显示10个字段,
客户端用WEB service来获取数据,没有必要把整个PO对象传递到客户端,
这时我们就可以用只有这10个属性的DTO来传递结果到客户端,这样也不会暴露服务端表结构.到达客户端以后,如果用这个对象来对应界面显示,那此时它的身份就转为VO。

POJO

POJO是一种概念或者接口,身份及作用随环境变化而变化:
POJO有一些private的参数作为对象的属性。然后针对每个参数定义了get和set方法作为访问的接口
plain ordinary java object 简单java对象,即POJO是一个简单的普通的Java对象,它不包含业务逻辑或持久逻辑等,但不是JavaBean、EntityBean等,不具有任何特殊角色和不继承或不实现任何其它Java框架的类或接口。
POJO对象有时也被称为Data对象,大量应用于表现现实中的对象。

一个POJO持久化以后就是PO。
直接用它传递、传递过程中就是DTO
直接用来对应表示层就是VO


遇到的问题:

在项目代码中,vo属性和pojo有不同(我现在vo比po属性字段少),如何转换?字段多的时候呢?

个人想法是用多态实现 VO vo= (VO)POJO pojo;(使其父类公有满足多态转换的要求)

不知道有没有什么别的好办法?(写个工具类?)


明天要做的的事情

完成其他的service

编写Controller(restful风格)并进行简单测试;





返回列表 返回列表
评论

    分享到