diff --git a/cmd/mysql-kit/template.tpl b/cmd/mysql-kit/template.tpl index a77c15f..3204be5 100644 --- a/cmd/mysql-kit/template.tpl +++ b/cmd/mysql-kit/template.tpl @@ -16,7 +16,7 @@ type ( } {{.Name|UpperType}} struct { updates map[string]any - {{range $val := .Columns}}{{$val.Name|UpperType}} {{$val.GoType}} `db:"{{$val.Name}}"`{{if $val.Comment}}//{{$val.Comment}}{{end}} + {{range $val := .Columns}}{{$val.Name|UpperType}} {{$val.GoType}} `gorm:"column:{{$val.Name}}"`{{if $val.Comment}}//{{$val.Comment}}{{end}} {{end}} } default{{.Name|UpperType}}Model struct { @@ -35,9 +35,10 @@ func New{{.Name|UpperType}}() *{{.Name|UpperType}} { } } {{range $val := .Columns}} -func (s *{{$.Name|UpperType}}) Set{{$val.Name|UpperType}}({{$val.Name|LowerType}} {{$val.GoType}}) { +func (s *{{$.Name|UpperType}}) Set{{$val.Name|UpperType}}({{$val.Name|LowerType}} {{$val.GoType}}) *{{$.Name|UpperType}}{ s.{{$val.Name|UpperType}} = {{$val.Name|LowerType}} s.set("{{$val.Name}}", {{$val.Name|LowerType}}) + return s } {{end}} func (s *{{.Name|UpperType}}) set(key string, val any) { diff --git a/middleware/jwt/token.go b/middleware/jwt/token.go index 3047e1e..ba60250 100644 --- a/middleware/jwt/token.go +++ b/middleware/jwt/token.go @@ -59,7 +59,7 @@ func Parse(key string, tokenStr string) (*UserInfo, error) { } str, err := Decrypt(tokenStr, []byte(key), key) if err != nil { - return nil, err + return nil, errors.Unauthorized("TOKEN_ERROR", err.Error()) } token, err := jwt.Parse(str, func(token *jwt.Token) (interface{}, error) { return []byte(key), nil