发表于: 2020-06-16 23:15:11

1 1882


今天完成的事情:

讲昨天的表完善了一下:http://new.wiki.jnshu.com/pages/viewpage.action?pageId=70258271

主要是加了一个作品集表:



使用Navicat创建表:


使用mybatis generator插件:

首先添加依赖:

<plugin>
 <groupId>org.mybatis.generator</groupId>
 <artifactId>mybatis-generator-maven-plugin</artifactId>
 <version>1.3.5</version>
 <dependencies>
   <dependency>
     <groupId>mysql</groupId>
     <artifactId>mysql-connector-java</artifactId>
     <version>5.1.20</version>
   </dependency>
   <!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
   <dependency>
     <groupId>org.mybatis.generator</groupId>
     <artifactId>mybatis-generator-core</artifactId>
     <version>1.3.5</version>
   </dependency>
 </dependencies>
 <configuration>
   <!-- 允许移动生产的文件 -->
   <verbose>true</verbose>
   <!-- 是否覆盖 -->
   <overwrite>true</overwrite>
   <!-- 自动生成的配置 -->
   <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
 </configuration>
</plugin>

在resources文件夹下创建generatorConfig.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
       PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
       "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

<generatorConfiguration>
   <context id="DB2Tables"  targetRuntime="MyBatis3">
       <commentGenerator>
           <property name="suppressDate" value="true"/>
           <!-- 是否去除自动生成的注释 true:是 : false:否 -->
           <property name="suppressAllComments" value="true"/>
       </commentGenerator>

       <!--数据库链接URL,用户名、密码 -->
       <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                       connectionURL="jdbc:mysql://127.0.0.1:3306/task3"
                       userId="root"
                       password="1234">
       </jdbcConnection>

       <javaTypeResolver>
           <property name="forceBigDecimals" value="false"/>
       </javaTypeResolver>


       <!-- 生成模型的包名和位置-->
       <javaModelGenerator targetPackage="com.jnshu.pojo" targetProject="./src/main/java">
           <property name="enableSubPackages" value="true"/>
           <property name="trimStrings" value="true"/>
       </javaModelGenerator>

       <!-- 生成映射文件的包名和位置-->
       <sqlMapGenerator targetPackage="main.resources" targetProject="./src/main/resources">
           <property name="enableSubPackages" value="true"/>
       </sqlMapGenerator>
       <!-- 生成mapper位置-->
       <javaClientGenerator type="XMLMAPPER" targetPackage="com.jnshu.dao" targetProject="./src/main/java">
           <property name="enableSubPackages" value="true"/>
       </javaClientGenerator>

       <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
       <table tableName="account" domainObjectName="Account"
              enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="false"
              selectByExampleQueryId="false">
       </table>
       <table tableName="banner" domainObjectName="Banner"
              enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="false"
              selectByExampleQueryId="false">
       </table>
       <table tableName="message" domainObjectName="Message"
              enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="false"
              selectByExampleQueryId="false">
       </table>
       <table tableName="module" domainObjectName="Module"
              enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="false"
              selectByExampleQueryId="false">
       </table>
       <table tableName="portfolio" domainObjectName="Portfolio"
              enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="false"
              selectByExampleQueryId="false">
       </table>
       <table tableName="role" domainObjectName="Role"
              enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="false"
              selectByExampleQueryId="false">
       </table>
       <table tableName="studio" domainObjectName="Studio"
              enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="false"
              selectByExampleQueryId="false">
       </table>
       <table tableName="works" domainObjectName="Works"
              enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="false"
              selectByExampleQueryId="false">
       </table>

   </context>
</generatorConfiguration>



全部生成好了,真方便啊


接下来写一下接口文档:

1,登录接口

请求地址:Post /a/login

请求参数:

字段类型说明是否必填备注
usernamestring用户名
passwordstring密码

返回参数:

字段类型说明
codenumber状态码
messagestring状态信息


2,Banner管理

2.1 新增banner

请求地址:Post /a/u/banner

请求参数:

字段类型说明是否必填备注
urlstring作品链接
imgstring配图
statenumber状态1为上架,2为不上架

返回参数:

字段类型说明
codenumber状态码
messagestring状态信息


2.2 删除banner

请求地址:DELETE a/u/banner/{id}

返回参数:

字段类型说明
codenumber状态码
messagestring状态信息

2.3 修改banner

请求地址:Put a/u/banner/{id}

请求参数:

字段类型说明是否必填备注
urlstring作品链接
imgstring配图

返回参数:

字段类型说明
codenumber状态码
messagestring状态信息

2.4 上架下架banner

请求地址:Put a/u/banner/state/{id}

请求参数:

字段类型说明是否必填备注
statenumberbanner状态

返回参数:

字段类型说明
codenumber状态码
messagestring状态信息



2.5 查询单个banner

请求地址:Get a/u/banner/{id}

返回参数:

字段类型说明
codenumber状态码
messagestring状态信息
dataobject数据


data

字段类型说明
idnumber自增主键
urlstring作品链接
imgstring
配图
statenumberbanner状态
createBystring
创建人
createAtnumber
创建时间
updateAtnumber
更新时间


2.6 按照条件查询banner

请求地址:Get /a/u/banner/list

请求参数:

字段类型说明是否必填
statenumberbanner状态
createBystring创建人

返回参数:

字段类型说明
codenumber状态码
messagestring状态信息
dataobject数据


data

字段类型说明
idnumber自增主键
urlstring作品链接
imgstring配图
statenumberbanner状态
createBystring创建人
createAtnumber创建时间
updateAtnumber更新时间



收获:学会使用mybatis generator,进一步了解了接口文档的编写规则。


明天计划完成的事情:

完成剩下的接口。



返回列表 返回列表
评论

    分享到