style: style all project

pull/351/head
textworld 1 year ago
parent 9ba3842513
commit ad38517fd7

@ -2,6 +2,7 @@ package admin
import ( import (
"errors" "errors"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
"github.com/go-sonic/sonic/handler/trans" "github.com/go-sonic/sonic/handler/trans"

@ -116,11 +116,10 @@ func parsePostParam(ctx *gin.Context) (*param.Post, error) {
log.CtxInfo(ctx, "wpPost: "+string(bytes)) log.CtxInfo(ctx, "wpPost: "+string(bytes))
return convertToPostParam(&wpPost) return convertToPostParam(&wpPost)
} }
func convertToPostParam(wpPost *param.WpPost) (*param.Post, error) { func convertToPostParam(wpPost *param.WpPost) (*param.Post, error) {
var paramPostStatus = sonicconst.PostStatusPublished paramPostStatus := sonicconst.PostStatusPublished
if strings.ToLower(wpPost.Status) == "draft" { if strings.ToLower(wpPost.Status) == "draft" {
paramPostStatus = sonicconst.PostStatusDraft paramPostStatus = sonicconst.PostStatusDraft
} }
@ -168,9 +167,9 @@ func convertToPostParam(wpPost *param.WpPost) (*param.Post, error) {
func convertToWpPost(postEntity *entity.Post) *wp.PostDTO { func convertToWpPost(postEntity *entity.Post) *wp.PostDTO {
timeFormat := time.RFC3339 timeFormat := time.RFC3339
var wpStatus = "publish" wpStatus := "publish"
var wpCommentStatus = "open" wpCommentStatus := "open"
var wpContent = make(map[string]interface{}) wpContent := make(map[string]interface{})
if postEntity.Status == sonicconst.PostStatusDraft { if postEntity.Status == sonicconst.PostStatusDraft {
wpStatus = "draft" wpStatus = "draft"
@ -183,7 +182,7 @@ func convertToWpPost(postEntity *entity.Post) *wp.PostDTO {
wpContent["rendered"] = postEntity.OriginalContent wpContent["rendered"] = postEntity.OriginalContent
wpContent["protected"] = false wpContent["protected"] = false
var postDTO = &wp.PostDTO{ postDTO := &wp.PostDTO{
Date: postEntity.CreateTime.Format(timeFormat), Date: postEntity.CreateTime.Format(timeFormat),
DateGmt: postEntity.CreateTime.UTC().Format(timeFormat), DateGmt: postEntity.CreateTime.UTC().Format(timeFormat),
GUID: nil, GUID: nil,

@ -1,13 +1,14 @@
package wp package wp
import ( import (
"strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-sonic/sonic/model/dto/wp" "github.com/go-sonic/sonic/model/dto/wp"
"github.com/go-sonic/sonic/model/entity" "github.com/go-sonic/sonic/model/entity"
"github.com/go-sonic/sonic/model/param" "github.com/go-sonic/sonic/model/param"
"github.com/go-sonic/sonic/service" "github.com/go-sonic/sonic/service"
"github.com/go-sonic/sonic/util/xerr" "github.com/go-sonic/sonic/util/xerr"
"strings"
) )
type TagHandler struct { type TagHandler struct {

@ -14,9 +14,7 @@ import (
"github.com/go-sonic/sonic/service" "github.com/go-sonic/sonic/service"
) )
var ( var basicAuthRegexp = regexp.MustCompile(`^Basic [a-z\\d/+]*={0,2}`)
basicAuthRegexp = regexp.MustCompile(`^Basic [a-z\\d/+]*={0,2}`)
)
type ApplicationPasswordMiddleware struct { type ApplicationPasswordMiddleware struct {
PasswordService service.ApplicationPasswordService PasswordService service.ApplicationPasswordService

@ -2,6 +2,7 @@ package service
import ( import (
"context" "context"
"github.com/go-sonic/sonic/model/dto" "github.com/go-sonic/sonic/model/dto"
"github.com/go-sonic/sonic/model/entity" "github.com/go-sonic/sonic/model/entity"
"github.com/go-sonic/sonic/model/param" "github.com/go-sonic/sonic/model/param"

@ -149,7 +149,6 @@ func (a *applicationPasswordServiceImpl) Update(ctx context.Context, entityID in
LastActivateIP: ip, LastActivateIP: ip,
LastActivateTime: &now, LastActivateTime: &now,
}) })
if err != nil { if err != nil {
return WrapDBErr(err) return WrapDBErr(err)
} }

Loading…
Cancel
Save