用户登录和接口鉴权

This commit is contained in:
2025-09-07 21:13:15 +08:00
parent c4522b974b
commit 565cf3fa6a
380 changed files with 18330 additions and 16854 deletions

View File

@@ -8,10 +8,12 @@ import (
"github.com/jackc/pgx/v5/pgconn"
)
// The error codes to map PostgreSQL errors to gorm errors, here is the PostgreSQL error codes reference https://www.postgresql.org/docs/current/errcodes-appendix.html.
var errCodes = map[string]error{
"23505": gorm.ErrDuplicatedKey,
"23503": gorm.ErrForeignKeyViolated,
"42703": gorm.ErrInvalidField,
"23514": gorm.ErrCheckConstraintViolated,
}
type ErrMessage struct {

View File

@@ -38,6 +38,7 @@ WHERE
`
var typeAliasMap = map[string][]string{
"int": {"integer"},
"int2": {"smallint"},
"int4": {"integer"},
"int8": {"bigint"},
@@ -50,6 +51,15 @@ var typeAliasMap = map[string][]string{
"timestamp with time zone": {"timestamptz"},
"bool": {"boolean"},
"boolean": {"bool"},
"serial2": {"smallserial"},
"serial4": {"serial"},
"serial8": {"bigserial"},
"varbit": {"bit varying"},
"char": {"character"},
"varchar": {"character varying"},
"float4": {"real"},
"float8": {"double precision"},
"timetz": {"time with time zone"},
}
type Migrator struct {
@@ -312,7 +322,7 @@ func (m Migrator) AlterColumn(value interface{}, field string) error {
fileType := clause.Expr{SQL: m.DataTypeOf(field)}
// check for typeName and SQL name
isSameType := true
if fieldColumnType.DatabaseTypeName() != fileType.SQL {
if !strings.EqualFold(fieldColumnType.DatabaseTypeName(), fileType.SQL) {
isSameType = false
// if different, also check for aliases
aliases := m.GetTypeAliases(fieldColumnType.DatabaseTypeName())