mirror of
https://github.com/beego/bee.git
synced 2024-11-22 10:10:53 +00:00
update the status cide
This commit is contained in:
parent
f11cad19ec
commit
e2ee2a8a79
27
g_appcode.go
27
g_appcode.go
@ -362,12 +362,12 @@ func getTableObjects(tableNames []string, db *sql.DB, dbTransformer DbTransforme
|
|||||||
// and fill in Table struct
|
// and fill in Table struct
|
||||||
func (*MysqlDB) GetConstraints(db *sql.DB, table *Table, blackList map[string]bool) {
|
func (*MysqlDB) GetConstraints(db *sql.DB, table *Table, blackList map[string]bool) {
|
||||||
rows, err := db.Query(
|
rows, err := db.Query(
|
||||||
`SELECT
|
`SELECT
|
||||||
c.constraint_type, u.column_name, u.referenced_table_schema, u.referenced_table_name, referenced_column_name, u.ordinal_position
|
c.constraint_type, u.column_name, u.referenced_table_schema, u.referenced_table_name, referenced_column_name, u.ordinal_position
|
||||||
FROM
|
FROM
|
||||||
information_schema.table_constraints c
|
information_schema.table_constraints c
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
information_schema.key_column_usage u ON c.constraint_name = u.constraint_name
|
information_schema.key_column_usage u ON c.constraint_name = u.constraint_name
|
||||||
WHERE
|
WHERE
|
||||||
c.table_schema = database() AND c.table_name = ? AND u.table_schema = database() AND u.table_name = ?`,
|
c.table_schema = database() AND c.table_name = ? AND u.table_schema = database() AND u.table_name = ?`,
|
||||||
table.Name, table.Name) // u.position_in_unique_constraint,
|
table.Name, table.Name) // u.position_in_unique_constraint,
|
||||||
@ -412,9 +412,9 @@ func (mysqlDB *MysqlDB) GetColumns(db *sql.DB, table *Table, blackList map[strin
|
|||||||
// retrieve columns
|
// retrieve columns
|
||||||
colDefRows, _ := db.Query(
|
colDefRows, _ := db.Query(
|
||||||
`SELECT
|
`SELECT
|
||||||
column_name, data_type, column_type, is_nullable, column_default, extra
|
column_name, data_type, column_type, is_nullable, column_default, extra
|
||||||
FROM
|
FROM
|
||||||
information_schema.columns
|
information_schema.columns
|
||||||
WHERE
|
WHERE
|
||||||
table_schema = database() AND table_name = ?`,
|
table_schema = database() AND table_name = ?`,
|
||||||
table.Name)
|
table.Name)
|
||||||
@ -537,7 +537,7 @@ func (*PostgresDB) GetTableNames(db *sql.DB) (tables []string) {
|
|||||||
// GetConstraints for PostgreSQL
|
// GetConstraints for PostgreSQL
|
||||||
func (*PostgresDB) GetConstraints(db *sql.DB, table *Table, blackList map[string]bool) {
|
func (*PostgresDB) GetConstraints(db *sql.DB, table *Table, blackList map[string]bool) {
|
||||||
rows, err := db.Query(
|
rows, err := db.Query(
|
||||||
`SELECT
|
`SELECT
|
||||||
c.constraint_type,
|
c.constraint_type,
|
||||||
u.column_name,
|
u.column_name,
|
||||||
cu.table_catalog AS referenced_table_catalog,
|
cu.table_catalog AS referenced_table_catalog,
|
||||||
@ -545,13 +545,13 @@ func (*PostgresDB) GetConstraints(db *sql.DB, table *Table, blackList map[string
|
|||||||
cu.column_name AS referenced_column_name,
|
cu.column_name AS referenced_column_name,
|
||||||
u.ordinal_position
|
u.ordinal_position
|
||||||
FROM
|
FROM
|
||||||
information_schema.table_constraints c
|
information_schema.table_constraints c
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
information_schema.key_column_usage u ON c.constraint_name = u.constraint_name
|
information_schema.key_column_usage u ON c.constraint_name = u.constraint_name
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
information_schema.constraint_column_usage cu ON cu.constraint_name = c.constraint_name
|
information_schema.constraint_column_usage cu ON cu.constraint_name = c.constraint_name
|
||||||
WHERE
|
WHERE
|
||||||
c.table_catalog = current_database() AND c.table_schema = 'public' AND c.table_name = $1
|
c.table_catalog = current_database() AND c.table_schema = 'public' AND c.table_name = $1
|
||||||
AND u.table_catalog = current_database() AND u.table_schema = 'public' AND u.table_name = $2`,
|
AND u.table_catalog = current_database() AND u.table_schema = 'public' AND u.table_name = $2`,
|
||||||
table.Name, table.Name) // u.position_in_unique_constraint,
|
table.Name, table.Name) // u.position_in_unique_constraint,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -606,7 +606,7 @@ func (postgresDB *PostgresDB) GetColumns(db *sql.DB, table *Table, blackList map
|
|||||||
column_default,
|
column_default,
|
||||||
'' AS extra
|
'' AS extra
|
||||||
FROM
|
FROM
|
||||||
information_schema.columns
|
information_schema.columns
|
||||||
WHERE
|
WHERE
|
||||||
table_catalog = current_database() AND table_schema = 'public' AND table_name = $1`,
|
table_catalog = current_database() AND table_schema = 'public' AND table_name = $1`,
|
||||||
table.Name)
|
table.Name)
|
||||||
@ -1167,14 +1167,15 @@ func (c *{{ctrlName}}Controller) URLMapping() {
|
|||||||
// @Title Post
|
// @Title Post
|
||||||
// @Description create {{ctrlName}}
|
// @Description create {{ctrlName}}
|
||||||
// @Param body body models.{{ctrlName}} true "body for {{ctrlName}} content"
|
// @Param body body models.{{ctrlName}} true "body for {{ctrlName}} content"
|
||||||
// @Success 200 {int} models.{{ctrlName}}.Id
|
// @Success 201 {int} models.{{ctrlName}}
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (c *{{ctrlName}}Controller) Post() {
|
func (c *{{ctrlName}}Controller) Post() {
|
||||||
var v models.{{ctrlName}}
|
var v models.{{ctrlName}}
|
||||||
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
||||||
if id, err := models.Add{{ctrlName}}(&v); err == nil {
|
if _, err := models.Add{{ctrlName}}(&v); err == nil {
|
||||||
c.Data["json"] = map[string]int64{"id": id}
|
c.Ctx.Output.SetStatus(201)
|
||||||
|
c.Data["json"] = v
|
||||||
} else {
|
} else {
|
||||||
c.Data["json"] = err.Error()
|
c.Data["json"] = err.Error()
|
||||||
}
|
}
|
||||||
@ -1208,7 +1209,7 @@ func (c *{{ctrlName}}Controller) GetOne() {
|
|||||||
// @Param limit query string false "Limit the size of result set. Must be an integer"
|
// @Param limit query string false "Limit the size of result set. Must be an integer"
|
||||||
// @Param offset query string false "Start position of result set. Must be an integer"
|
// @Param offset query string false "Start position of result set. Must be an integer"
|
||||||
// @Success 200 {object} models.{{ctrlName}}
|
// @Success 200 {object} models.{{ctrlName}}
|
||||||
// @Failure 403
|
// @Failure 403
|
||||||
// @router / [get]
|
// @router / [get]
|
||||||
func (c *{{ctrlName}}Controller) GetAll() {
|
func (c *{{ctrlName}}Controller) GetAll() {
|
||||||
var fields []string
|
var fields []string
|
||||||
|
@ -88,7 +88,7 @@ func (c *{{controllerName}}Controller) URLMapping() {
|
|||||||
// @Title Post
|
// @Title Post
|
||||||
// @Description create {{controllerName}}
|
// @Description create {{controllerName}}
|
||||||
// @Param body body models.{{controllerName}} true "body for {{controllerName}} content"
|
// @Param body body models.{{controllerName}} true "body for {{controllerName}} content"
|
||||||
// @Success 200 {int} models.{{controllerName}}.Id
|
// @Success 201 {object} models.{{controllerName}}
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (c *{{controllerName}}Controller) Post() {
|
func (c *{{controllerName}}Controller) Post() {
|
||||||
@ -128,7 +128,7 @@ func (c *{{controllerName}}Controller) GetAll() {
|
|||||||
// @Failure 403 :id is not int
|
// @Failure 403 :id is not int
|
||||||
// @router /:id [put]
|
// @router /:id [put]
|
||||||
func (c *{{controllerName}}Controller) Put() {
|
func (c *{{controllerName}}Controller) Put() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title Delete
|
// @Title Delete
|
||||||
@ -138,7 +138,7 @@ func (c *{{controllerName}}Controller) Put() {
|
|||||||
// @Failure 403 id is empty
|
// @Failure 403 id is empty
|
||||||
// @router /:id [delete]
|
// @router /:id [delete]
|
||||||
func (c *{{controllerName}}Controller) Delete() {
|
func (c *{{controllerName}}Controller) Delete() {
|
||||||
|
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -170,14 +170,15 @@ func (c *{{controllerName}}Controller) URLMapping() {
|
|||||||
// @Title Post
|
// @Title Post
|
||||||
// @Description create {{controllerName}}
|
// @Description create {{controllerName}}
|
||||||
// @Param body body models.{{controllerName}} true "body for {{controllerName}} content"
|
// @Param body body models.{{controllerName}} true "body for {{controllerName}} content"
|
||||||
// @Success 200 {int} models.{{controllerName}}.Id
|
// @Success 201 {int} models.{{controllerName}}
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (c *{{controllerName}}Controller) Post() {
|
func (c *{{controllerName}}Controller) Post() {
|
||||||
var v models.{{controllerName}}
|
var v models.{{controllerName}}
|
||||||
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
||||||
if id, err := models.Add{{controllerName}}(&v); err == nil {
|
if _, err := models.Add{{controllerName}}(&v); err == nil {
|
||||||
c.Data["json"] = map[string]int64{"id": id}
|
c.Ctx.Output.SetStatus(201)
|
||||||
|
c.Data["json"] = v
|
||||||
} else {
|
} else {
|
||||||
c.Data["json"] = err.Error()
|
c.Data["json"] = err.Error()
|
||||||
}
|
}
|
||||||
@ -211,7 +212,7 @@ func (c *{{controllerName}}Controller) GetOne() {
|
|||||||
// @Param limit query string false "Limit the size of result set. Must be an integer"
|
// @Param limit query string false "Limit the size of result set. Must be an integer"
|
||||||
// @Param offset query string false "Start position of result set. Must be an integer"
|
// @Param offset query string false "Start position of result set. Must be an integer"
|
||||||
// @Success 200 {object} models.{{controllerName}}
|
// @Success 200 {object} models.{{controllerName}}
|
||||||
// @Failure 403
|
// @Failure 403
|
||||||
// @router / [get]
|
// @router / [get]
|
||||||
func (c *{{controllerName}}Controller) GetAll() {
|
func (c *{{controllerName}}Controller) GetAll() {
|
||||||
var fields []string
|
var fields []string
|
||||||
|
Loading…
Reference in New Issue
Block a user