Coder Social home page Coder Social logo

mercari-build-training-2022's Issues

取引モデルの作成

概要

  • 商品の取引状態を保持するためのモデル

DB

カラム名 詳細
id int(PRIMARY KEY) ID
item_id int(FOREIGN KEY) 取引対象になる商品のID
buyer_id int(FOREIGN KEY) 買い手のID
transaction_status_id int(FOREIGN KEY) 取引がどの段階にあるかを表すデータのID
determined_price int 値引き処理によって確定された値段

SQL

create table transactions(
  id integer primary key autoincrement, 
  determined_price integer,
  foreign key (item_id) REFERENCES items(id) ON DELETE CASCADE,
  foreign key (buyer_id) REFERENCES users(id) ON DELETE CASCADE,
  foreign key (transaction_status_id) REFERENCES transaction_statuses(id) ON DELETE CASCADE
);

transaction_status

  • 取引の段階を表すデータを保持する
  • 値段確定前、値段確定、注文済みの2種
カラム名 詳細
id int(PRIMARY KEY) ID
name string 状態の名称

SQL

create table transaction_statuses(
  id integer primary key autoincrement, 
  name text
);

QAモデルの作成

概要

  • チャットボットが提示する質問と、その対になる回答を保持するためのモデル

DB

カラム名 詳細
id int(PRIMARY KEY) ID
item_id int(FOREIGN KEY) 商品のID
question string 質問
answer string 回答
qa_type_id int(FOREIGN KEY) 質問種別のID

SQL

create table qas(
  id integer primary key autoincrement, 
  foreign key (item_id) REFERENCES items(id) ON DELETE CASCADE,
  question text,
  answer text,
  foreign key (qa_type_id) REFERENCES qa_type(id) ON DELETE CASCADE
);

qa_type

  • チャットボットが提示する質問と、その対になる回答の種別
  • 初回メッセージ、商品について2種
カラム名 詳細
id int(PRIMARY KEY) ID
label string 種別に対するラベル(initial_message, about_items)

SQL

create table qa_type(
  id integer primary key autoincrement, 
  label text
);

ユーザーモデルの作成

概要

  • 取引を行うユーザーを保持するためのモデル

DB

id name
int string

SQL

create table users(
  id integer primary key autoincrement, 
  name text
);

ユーザーモデルの作成

TODO

  • テーブル作成SQLの記述
  • ユーザー作成(POST)機能の実装
  • idによるユーザー取得(GET)機能の実装
  • エラーハンドリング

概要

  • 取引を行うユーザーを保持するためのモデルの作成

EndPoints

path HTTP Method 詳細
/users POST name(string)とpassword(string)を受け取って、UserをDBにINSERTする.
/users/:id GET id(int)をパラメータとして受け取り、{ "id": int , "name" : string } のJSONを返す.

DB

id name password
int string string

SQL

create table users(
  id integer primary key autoincrement, 
  name string not null unique,
  password string
);

商品モデルの修正

概要

  • 商品モデルを以下の形式になるよう編集する

DB

カラム名 詳細
id int(PRIMARY KEY) ID
name string 商品名
image string 画像URL
price int 値段(円)
price_lower_limit int 商品値下げの下限
user_id int(FOREIGN KEY) 出品者のID

SQL

create table items(
  id integer primary key autoincrement, 
  name text, 
  image text, 
  price_lower_limit int, 
  foreign key (user_id) REFERENCES users(id) ON DELETE CASCADE
);

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.