style: golint

pull/351/head
textworld 1 year ago
parent f0c92e1d01
commit 6d3f54ecee

@ -184,8 +184,8 @@ func convertToWpPost(postEntity *entity.Post) *wp.PostDTO {
var postDTO = &wp.PostDTO{
Date: postEntity.CreateTime.Format(timeFormat),
DateGmt: postEntity.CreateTime.UTC().Format(timeFormat),
Guid: nil,
Id: postEntity.ID,
GUID: nil,
ID: postEntity.ID,
Link: "",
Modified: "",
ModifiedGmt: "",

@ -12,6 +12,10 @@ import (
"strings"
)
var (
basicAuthRegexp = regexp.MustCompile(`^Basic [a-z\\d/+]*={0,2}`)
)
type ApplicationPasswordMiddleware struct {
PasswordService service.ApplicationPasswordService
UserService service.UserService
@ -30,7 +34,6 @@ func (a *ApplicationPasswordMiddleware) Get() error {
}
func (a *ApplicationPasswordMiddleware) GetWrapHandler() gin.HandlerFunc {
return func(ctx *gin.Context) {
header := ctx.GetHeader("Authorization")
if len(header) == 0 {
@ -91,6 +94,5 @@ func abortUnauthorized(ctx *gin.Context) {
}
func verifyHeader(header string) bool {
compile, err := regexp.Compile("^Basic [a-z\\d/+]*={0,2}")
return err != nil || compile.MatchString(header)
return basicAuthRegexp.MatchString(header)
}

@ -373,7 +373,6 @@ func (s *Server) RegisterRouters() {
contentAPIRouter.GET("/options/comment", s.wrapHandler(s.ContentAPIOptionHandler.Comment))
}
}
}

@ -270,7 +270,6 @@ func (s *Server) wrapWpHandler(handler wrapperHandler) gin.HandlerFunc {
}
ctx.JSON(http.StatusOK, data)
return
}
}

@ -4,6 +4,6 @@ type ApplicationPasswordDTO struct {
Name string `json:"name"`
Password string `json:"password"`
LastActivateTime int64 `json:"last_activate_time"`
LastActivateIp string `json:"last_activate_ip"`
LastActiveIP string `json:"last_activate_ip"`
CreateTime int64 `json:"create_time"`
}

@ -3,8 +3,8 @@ package wp
type PostDTO struct {
Date string `json:"date"`
DateGmt string `json:"date_gmt"`
Guid map[string]interface{} `json:"guid"`
Id int32 `json:"id"`
GUID map[string]interface{} `json:"guid"`
ID int32 `json:"id"`
Link string `json:"link"`
Modified string `json:"modified"`
ModifiedGmt string `json:"modified_gmt"`

@ -3,8 +3,8 @@ package param
type WpPost struct {
Date string `json:"date"`
DateGmt string `json:"date_gmt"`
Guid map[string]interface{} `json:"guid"`
Id int32 `json:"id"`
GUID map[string]interface{} `json:"guid"`
ID int32 `json:"id"`
Link string `json:"link"`
Modified string `json:"modified"`
ModifiedGmt string `json:"modified_gmt"`

@ -11,6 +11,6 @@ type ApplicationPasswordService interface {
CreatePwd(ctx context.Context, appPwdParam *param.ApplicationPasswordParam) (*dto.ApplicationPasswordDTO, error)
DeletePwd(ctx context.Context, appPwdParam *param.ApplicationPasswordParam) error
List(ctx context.Context) ([]*dto.ApplicationPasswordDTO, error)
Verify(ctx context.Context, userId int32, pwd string) (*entity.ApplicationPassword, error)
Update(ctx context.Context, entityId int32, ip string) error
Verify(ctx context.Context, userID int32, pwd string) (*entity.ApplicationPassword, error)
Update(ctx context.Context, entityID int32, ip string) error
}

@ -123,9 +123,9 @@ func (a *applicationPasswordServiceImpl) List(ctx context.Context) ([]*dto.Appli
return appPwdDTOList, nil
}
func (a *applicationPasswordServiceImpl) Verify(ctx context.Context, userId int32, pwd string) (*entity.ApplicationPassword, error) {
func (a *applicationPasswordServiceImpl) Verify(ctx context.Context, userID int32, pwd string) (*entity.ApplicationPassword, error) {
appPwdDAL := dal.GetQueryByCtx(ctx).ApplicationPassword
entityList, err := appPwdDAL.WithContext(ctx).Where(appPwdDAL.UserID.Eq(userId)).Find()
entityList, err := appPwdDAL.WithContext(ctx).Where(appPwdDAL.UserID.Eq(userID)).Find()
if err != nil {
return nil, WrapDBErr(err)
}
@ -140,11 +140,11 @@ func (a *applicationPasswordServiceImpl) Verify(ctx context.Context, userId int3
return nil, nil
}
func (a *applicationPasswordServiceImpl) Update(ctx context.Context, entityId int32, ip string) error {
func (a *applicationPasswordServiceImpl) Update(ctx context.Context, entityID int32, ip string) error {
appPwdDAL := dal.GetQueryByCtx(ctx).ApplicationPassword
now := time.Now()
_, err := appPwdDAL.WithContext(ctx).Where(appPwdDAL.ID.Eq(entityId)).Updates(entity.ApplicationPassword{
_, err := appPwdDAL.WithContext(ctx).Where(appPwdDAL.ID.Eq(entityID)).Updates(entity.ApplicationPassword{
LastActivateIP: ip,
LastActivateTime: &now,
})
@ -163,7 +163,7 @@ func (a *applicationPasswordServiceImpl) ConvertToDTO(appPwdEntity *entity.Appli
}
appPwdDTO := &dto.ApplicationPasswordDTO{
Name: appPwdEntity.Name,
LastActivateIp: appPwdEntity.LastActivateIP,
LastActiveIP: appPwdEntity.LastActivateIP,
LastActivateTime: lastActivateTime,
CreateTime: appPwdEntity.CreateTime.Unix(),
}

Loading…
Cancel
Save