Skip to content

Instantly share code, notes, and snippets.

@SeniorZhai
Last active December 17, 2019 09:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeniorZhai/053c8aad1657690fb2bb6c2abdc991a9 to your computer and use it in GitHub Desktop.
Save SeniorZhai/053c8aad1657690fb2bb6c2abdc991a9 to your computer and use it in GitHub Desktop.

DAO

负责SQL CRUD

  • insert
    • single insertX(x:X)
    • multiple insertXxList(xxs:List<X>)
  • update updateXXbyYY(xx:X,yy:Y)
  • delete
    • single deleteX(x:X)
    • multiple deleteByYY(yy:Y)
  • read
    • single findXByY(y:Y):X?
    • multiple findXsByY():List<X> findAllX():List<X>
  • suspend 以上后跟Suspend
  • liveData 以上后跟LiveData
  • rxjava 淘汰

Api Service

负责api Get Post Delete Put

  • Get

    • single
      • getXByY(y:Y):Response<X>
      • getX():Response<X>
    • multiple
      • fetchXbyY(y:Y):Response<List<X>>
      • fetchAllX():Response<List<X>>
  • Post

    • single postX(x:X)
    • multiple postXs(xs:List<X>)

其他情况按接口路径命名

  • suspend 以上后跟Suspend
  • rxjava 以上后跟Observable

Repository

整合数据,负责将数据转换成需要的格式

ViewModel

提供数据,负责调度线程、链式操作数据

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment