Day 2

Pronunciation

Gradle https://www.youtube.com/watch?v=KgsruLblTmc 1:21
Mybatis https://www.youtube.com/watch?v=JyythoOXdbU
HATEOAS https://www.youtube.com/watch?v=aThIuSsb_OA

Spring Boot Tuto

https://spring.io/guides/gs/rest-service/#scratch

  • Gradle https://www.jetbrains.com/help/idea/gradle-tool-window.html

功能流程与技术分辨

商品类别 HTTP GET

  • 子类,列表

商品信息 HTTP GET

  • 文字,图片

开团

  • 微信认证登录 (用户认证 (需考虑安全性问题)?) iOS/微信接口/返回微信身份信息?
  • 开团订单信息 HTTP GET
  • 支付iOS/微信支付接口/返回支付信息?
  • 收货地址iOS
  • 返回,邀请好友,返回 iOS
  • 返回开团订单信息 缓存

订单列表,订单详细信息HTTP GET

API Gateway: HTTP 请求入口HTTP服务器,设计API

  • 用户/登录服务: 用户/登录相关功能?微信用户静默登录数据?
  • 商品服务: 商品相关功能JSON
  • 订单服务: 订单相关功能JSON

编写单元测试,Cover所有的路径?

Meet REST

https://spring.io/understanding/REST
entity at a URI

  • use HTTP URIs to distinguish between nouns, or entities, in the system
  • HTTP URIs are a natural way to describe hierarchies, or relationship
    • REST API

https://spring.io/guides/tutorials/bookmarks/

  • Level2, 3?
  • URI
    • represent data
    • content-negotiation mechanism to deferred to http
    • manipulation depend on http methods
      • Get, Delete, Post, Put
  • Controller
    • map http request to methods
    • Spring MVC will extract those portions of the URI, and make them available as arguments of the same name that are passed to the controller method and annotated with @PathVariable
    • HttpMessageConverter s work in both directions: incoming requests bodies are converted to Java objects, and Java objects are converted into HTTP response bodies
      *validateUser UserNotFoundException HTTP status code (404) . Spring MVC provides a lotof different places to cleanly layer in generic, application-global and controller-local error handling logic.
  • Test: Spring MVC provides great support for unit testing HTTP endpoints. It provides a very nice middle ground between unit-testing and integration-testing. https://spring.io/guides/tutorials/bookmarks/

Design

功能流程 -> HTTP Methods

API

https://en.wikipedia.org/wiki/Representational_state_transfer#Uniform_interface
HATEOAS http://projects.spring.io/spring-hateoas/

Model

Record -> Entity Class-> SQL -> Spring Data repositories/Spring Data?
Spring MyBatis Integration?

  • CommandLineRunner

Securing

MySQL

https://dev.mysql.com/doc/refman/5.7/en/mysql-installation-windows-path.html
https://dev.mysql.com/doc/refman/5.7/en/tutorial.html

Mybatis + Spring Boot

http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/

  • Installation
    + Mybatis Gradle Dependency http://www.mybatis.org/mybatis-3/dependency-info.html

  • Quick Setup

    • Datasource
      https://spring.io/guides/gs/accessing-data-mysql/
    • Mapper
      http://www.mybatis.org/mybatis-3/java-api.html
    • City
      https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/domain/City.java\
  • Gradle Project
    https://www.jetbrains.com/help/idea/creating-a-gradle-project-or-a-gradle-module.html

Code

MySQL

MySQL: port 3306
root password yeweiya
user: newbieProject password: yeweiya
windows server name: MySQL57

MyBatis

http://www.mybatis.org/mybatis-3/getting-started.html

你可能感兴趣的:(Day 2)