-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated booking app to go.mod Updated chat, facebook, others app to add in go file in the root Updated travis to run tests in windows Updated travis to exclude testing fasthttp on windows
- Loading branch information
1 parent
5b25a51
commit dc75997
Showing
18 changed files
with
300 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
//go:generate swagger generate spec -o swagger.json | ||
|
||
// Package classification Swagger Hotel Example. | ||
// Swagger Hotel Example | ||
// | ||
// | ||
// | ||
// Schemes: https | ||
// Host: hotel.example.revelframework.com | ||
// BasePath: / | ||
// Version: 1.0.0 | ||
// License: MIT http://opensource.org/licenses/MIT | ||
// Contact: Name<[email protected]> https://www.somewhere.com | ||
// | ||
// Consumes: | ||
// - application/json | ||
// - application/x-www-form-urlencoded | ||
// | ||
// Produces: | ||
// - text/html | ||
// | ||
// | ||
// | ||
// | ||
// swagger:meta | ||
|
||
package controllers | ||
|
||
import ( | ||
|
@@ -11,7 +37,7 @@ import ( | |
"github.com/revel/examples/booking/app/models" | ||
"github.com/revel/examples/booking/app/routes" | ||
|
||
"gopkg.in/Masterminds/squirrel.v1" | ||
"github.com/Masterminds/squirrel" | ||
) | ||
|
||
type Hotels struct { | ||
|
@@ -40,6 +66,69 @@ func (c Hotels) Index() revel.Result { | |
return c.Render(bookings) | ||
} | ||
|
||
// swagger:route GET /hotels/ListJson enter demo | ||
// | ||
// Enter Demo | ||
// | ||
// | ||
// Consumes: | ||
// - application/x-www-form-urlencoded | ||
// | ||
// Produces: | ||
// - text/html | ||
// | ||
// Schemes: https | ||
// | ||
// | ||
// Responses: | ||
// 200: Success | ||
// 401: Invalid User | ||
|
||
// swagger:operation GET /demo demo | ||
// | ||
// Enter Demo | ||
// | ||
// | ||
// --- | ||
// produces: | ||
// - text/html | ||
// parameters: | ||
// - name: user | ||
// in: formData | ||
// description: user | ||
// required: true | ||
// type: string | ||
// - name: demo | ||
// in: formData | ||
// description: demo | ||
// required: true | ||
// type: string | ||
// responses: | ||
// '200': | ||
// description: Success | ||
// '401': | ||
// description: Invalid User | ||
func (c Hotels) ListJson(search string, size, page uint64) revel.Result { | ||
if page == 0 { | ||
page = 1 | ||
} | ||
nextPage := page + 1 | ||
search = strings.TrimSpace(search) | ||
|
||
var hotels []*models.Hotel | ||
builder := c.Db.SqlStatementBuilder.Select("*").From("Hotel").Offset((page - 1) * size).Limit(size) | ||
if search != "" { | ||
search = "%" + strings.ToLower(search) + "%" | ||
builder = builder.Where(squirrel.Or{ | ||
squirrel.Expr("lower(Name) like ?", search), | ||
squirrel.Expr("lower(City) like ?", search)}) | ||
} | ||
if _, err := c.Txn.Select(&hotels, builder); err != nil { | ||
c.Log.Fatal("Unexpected error loading hotels", "error", err) | ||
} | ||
|
||
return c.RenderJSON(map[string]interface{}{"hotels":hotels, "search":search, "size":size, "page":page, "nextPage":nextPage}) | ||
} | ||
func (c Hotels) List(search string, size, page uint64) revel.Result { | ||
if page == 0 { | ||
page = 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module github.com/revel/examples/booking | ||
|
||
go 1.12 | ||
|
||
require ( | ||
github.com/Masterminds/squirrel v1.3.0 | ||
github.com/go-gorp/gorp v2.2.0+incompatible | ||
github.com/lib/pq v1.5.0 // indirect | ||
github.com/mattn/go-sqlite3 v2.0.3+incompatible | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/poy/onpar v1.0.0 // indirect | ||
github.com/revel/cmd v0.21.1 | ||
github.com/revel/modules v0.21.0 | ||
github.com/revel/revel v0.21.0 | ||
github.com/valyala/fasthttp v1.12.0 | ||
golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 | ||
gopkg.in/gorp.v2 v2.2.0 // indirect | ||
) | ||
|
Oops, something went wrong.