作者 陈志颖

feat:增加pg自动建表

正在显示 31 个修改的文件 包含 258 行增加5 行删除
swagger: "2.0"
info:
title: ""
description: 合伙人后管平台
contact:
name: SteveChan
email: steve.d.chan@qq.com
home: ""
version: 0.0.1
consumes:
- application/json
- application/xml
produces:
- application/json
- application/xml
paths:
/column-settings:
get:
tags:
- column_setting
summary: 返回栏目设置增删改查列表
description: 返回栏目设置增删改查列表
operationId: column_setting#listColumnSetting
parameters:
- name: offset
in: query
description: 查询偏离量
required: false
type: integer
- name: limit
in: query
description: 查询限制
required: false
type: integer
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ColumnSettingListColumnSettingResponseBody'
schemes:
- http
post:
tags:
- column_setting
summary: 重置栏目设置
description: 重置栏目设置
operationId: column_setting#resetColumn
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ColumnSettingResetColumnResponseBody'
schemes:
- http
/column-settings/{columnSettingId}:
get:
tags:
- column_setting
summary: 返回栏目设置增删改查
description: 返回栏目设置增删改查
operationId: column_setting#getColumnSetting
parameters:
- name: columnSettingId
in: path
description: 栏目设置id
required: true
type: integer
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ColumnSettingGetColumnSettingResponseBody'
schemes:
- http
put:
tags:
- column_setting
summary: 更新栏目设置增删改查
description: 更新栏目设置增删改查
operationId: column_setting#updateColumnSetting
parameters:
- name: columnSettingId
in: path
description: 栏目设置id
required: true
type: integer
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ColumnSettingUpdateColumnSettingResponseBody'
schemes:
- http
delete:
tags:
- column_setting
summary: 移除栏目设置增删改查
description: 移除栏目设置增删改查
operationId: column_setting#removeColumnSetting
parameters:
- name: columnSettingId
in: path
description: 栏目设置id
required: true
type: integer
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ColumnSettingRemoveColumnSettingResponseBody'
schemes:
- http
definitions:
ColumnSettingCreateColumnSettingRequestBody:
title: ColumnSettingCreateColumnSettingRequestBody
type: object
properties:
description:
type: string
description: 栏目设置描述
required:
- description
userName:
type: string
description: 栏目设置关联用户名称
required:
- userName
ColumnSettingCreateColumnSettingResponseBody:
title: 'Mediatype identifier: ColumnSettingCreateColumnSettingResponseBody'
type: object
properties:
column_setting:
$ref: '#/definitions/column_settingResponseBody'
ColumnSettingGetColumnSettingResponseBody:
title: 'Mediatype identifier: ColumnSettingGetColumnSettingResponseBody'
type: object
properties:
column_setting:
$ref: '#/definitions/column_settingResponseBody'
ColumnSettingListColumnSettingResponseBody:
title: 'Mediatype identifier: ColumnSettingListColumnSettingResponseBody'
type: object
properties:
column_setting:
$ref: '#/definitions/column_settingResponseBody'
count:
type: integer
description: 匹配数目
required:
- count
ColumnSettingRemoveColumnSettingResponseBody:
title: 'Mediatype identifier: ColumnSettingRemoveColumnSettingResponseBody'
type: object
properties:
column_setting:
$ref: '#/definitions/column_settingResponseBody'
ColumnSettingResetColumnResponseBody:
title: 'Mediatype identifier: ColumnSettingResetColumnResponseBody'
type: object
properties:
column_setting:
$ref: '#/definitions/column_settingResponseBody'
ColumnSettingUpdateColumnSettingResponseBody:
title: 'Mediatype identifier: ColumnSettingUpdateColumnSettingResponseBody'
type: object
properties:
column_setting:
$ref: '#/definitions/column_settingResponseBody'
column_settingResponseBody:
title: column_settingResponseBody
type: object
properties:
columnSettingId:
type: integer
description: 栏目设置id
required:
- columnSettingId
companyId:
type: integer
description: 栏目设置关联用户公司id
required:
- companyId
createdAt:
type: string
description: 栏目设置创建时间
required:
- createdAt
description:
type: string
description: 栏目设置描述
required:
- description
key:
type: string
description: 栏目设置模块名称
required:
- key
uid:
type: integer
description: 栏目设置关联用户uid
required:
- uid
updatedAt:
type: string
description: 栏目设置更新时间
required:
- updatedAt
userName:
type: string
description: 栏目设置关联用户名称
required:
- userName
value:
type: array
items:
$ref: '#/definitions/columnResponseBody'
description: 栏目数组
description: 栏目设置
columnResponseBody:
title: columnResponseBody
type: object
properties:
columnId:
type: string
description: 列标记
required:
- columnId
paramCn:
type: string
description: 列标记中文
required:
- paramCn
paramFix:
type: integer
description: 列标记是否固定,1:固定,2:不固定
required:
- paramFix
description: 栏目项
... ...
... ... @@ -7,7 +7,7 @@ var POSTGRESQL_USER = "postgres"
var POSTGRESQL_PASSWORD = "1993618jack" // eagle1010
var POSTGRESQL_HOST = "127.0.0.1" // 114.55.200.59
var POSTGRESQL_PORT = "5432" // 31543
var DISABLE_CREATE_TABLE = true
var DISABLE_CREATE_TABLE = false
var DISABLE_SQL_GENERATE_PRINT = false
func init() {
... ...
... ... @@ -21,7 +21,7 @@ type ColumnSetting struct {
// 栏目设置关联用户名称
UserName string `json:"userName"`
// 栏目数组
Value []*Column `json:"valuea"`
Value []Column `json:"value"`
}
type ColumnSettingRepository interface {
... ... @@ -64,7 +64,7 @@ func (columnSetting *ColumnSetting) Update(data map[string]interface{}) error {
columnSetting.UserName = userName.(string)
}
if value, ok := data["value"]; ok {
columnSetting.Value = value.([]*Column)
columnSetting.Value = value.([]Column)
}
return nil
}
... ...
... ... @@ -5,7 +5,9 @@ import (
"fmt"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/log"
)
... ... @@ -21,6 +23,20 @@ func init() {
if !constant.DISABLE_SQL_GENERATE_PRINT {
DB.AddQueryHook(SqlGeneratePrintHook{})
}
if !constant.DISABLE_CREATE_TABLE {
for _, model := range []interface{}{
&models.ColumnSetting{},
} {
err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
Temp: false,
IfNotExists: true,
FKConstraints: true,
})
if err != nil {
panic(err)
}
}
}
}
type SqlGeneratePrintHook struct{}
... ...
... ... @@ -6,7 +6,6 @@ import (
)
type ColumnSetting struct {
TableName string `pg:"column_settings,alias:column_setting"`
// 栏目设置id
Id int64
// 栏目设置关联用户公司id
... ... @@ -24,5 +23,5 @@ type ColumnSetting struct {
// 栏目设置关联用户名称
UserName string
// 栏目数组
Value []*domain.Column `pg:",array"`
Value []domain.Column `pg:",array"`
}
... ...