Giter VIP home page Giter VIP logo

play-doma-sample's Introduction

Doma Play Sample

本家のKotlin サンプルをScalaに焼き直してPlay2上で動くようにしたものです。

Build

./sbt clean dao/copyResources dist

Run

./sbt run

Play開始後

#DB作成
curl http://localhost:9000/@evolutions/apply/default?redirect=/persons

#全件検索
curl http://localhost:9000/persons

#1件検索
curl http://localhost:9000/persons/1

#登録
curl -X POST -H "Content-Type: application/json" -d '{"name":"WARD","age":20,"address":{"city":"Fukuoka","street":"Gion"}}' http://localhost:9000/persons

#更新
curl -X PUT -H "Content-Type: application/json" -d '{"id":1,"name":"SMITH","age":30,"address":{"city":"Tokyo","street":"Marunouchi"},"version":0}' http://localhost:9000/persons

#削除
curl -X DELETE  http://localhost:9000/persons/2

注意点

  • 注釈処理による自動生成をコンパイル中に実行する必要があるため、3プロジェクト構成になっています。詳細はbuild.sbtを参照。

    プロジェクト 内容
    domala Scala用Domaラッパー
    dao 注釈処理対象クラス
    root (app) Doma利用アプリケーション
  • ドメインクラス、エンベッダブルクラス、エンティティクラス、及びDaoインターフェース、SQLファイルはdaoプロジェクト内に配置しないと自動生成がうまく働きません。

    • ドメインクラスはcase classで実装できます。(Name.scala参照)
    • エンベッダブルクラスはcase classで実装できます。(Address.scala参照)
    • エンティティクラスはcase classで実装できます。(Person.scala参照)
    • Daoインターフェースはtraitで実装できます。(PersonDao.scala参照)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.