Git Product home page Git Product logo

blog-app's Introduction

blog-app

Run

- glide install
- go run src/main/main.go

Model

- User
    ID uint64 			`gorm:"primaryKey;autoIncrement" json:"id"`
    Nickname string		`gorm:"size:20;not null;unique" json:"nickname"`
    Email string		`gorm:"size:50;not null;unique" json:"email"`
    Password string		`gorm:"size:60;not null" json:"password,omitempty"` //the field is omitted from the object if its value is empty,
    CreatedAt time.Time	        `gorm:"DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
    UpdatedAt time.Time	        `gorm:"DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
    Posts []Post                `gorm:"foreignKey:AuthorID;constraint:OnUpdate:CASCADE" json:"posts,omitempty"` //the field is omitted from the object if its value is empty,
- Post
    ID uint64 			`gorm:"primaryKey;autoIncrement" json:"id"`
    Title string 		`gorm:"size:30;not null;unique" json:"title"`
    Content string	        `gorm:"size:255;not null;unique" json:"content"`
    Author User			`gorm:"_" json:"author"` //Skip this field for json encoding
    AuthorID uint64             `gorm:"not null" json:"author_id"`
    CreatedAt time.Time	        `gorm:"default currentTimestamp" json:"created_at"`
    UpdatedAt time.Time	        `gorm:"default currentTimestamp" json:"updated_at"`

Api

- User
    Uri: "/users",
	Method: GET,
	Description: get all users
    
    Uri: "/users",
	Method: POST,
	Description: Create user

    Uri: "/users/{id}",
	Method: GET,
	Description: Get user

    Uri: "/users/{id}",
	Method: PUT,
	Description: Update user

    Uri: "/users/{id}",
	Method: DELETE,
	Description: Delete user
- Post
    Uri: "/posts",
	Method: GET,
	Description: get all posts
    
    Uri: "/posts",
	Method: POST,
	Description: Create post

    Uri: "/posts/{id}",
	Method: GET,
	Description: Get post

    Uri: "/posts/{id}",
	Method: PUT,
	Description: Update post

    Uri: "/posts/{id}",
	Method: DELETE,
	Description: Delete post

- Login
    Uri: "/login",
	Method: http.MethodPost,
	Description: Login (email, password)

blog-app's People

Contributors

chithien0909 avatar

Watchers

James Cloos avatar  avatar

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.