🐛 Fix back compability of draft state

This commit is contained in:
LittleSheep 2024-07-05 20:56:25 +08:00
parent 5b8eff7a42
commit d7113b5237
3 changed files with 2 additions and 14 deletions

View File

@ -43,7 +43,7 @@ func FilterArticleWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB {
}
func FilterArticleDraft(tx *gorm.DB) *gorm.DB {
return tx.Where("is_draft = ?", false)
return tx.Where("is_draft = ? OR is_draft IS NULL", false)
}
func GetArticleWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (models.Article, error) {

View File

@ -1,12 +0,0 @@
package services
import "golang.org/x/crypto/bcrypt"
func HashPassword(raw string) string {
data, _ := bcrypt.GenerateFromPassword([]byte(raw), 12)
return string(data)
}
func VerifyPassword(text string, password string) bool {
return bcrypt.CompareHashAndPassword([]byte(password), []byte(text)) == nil
}

View File

@ -51,7 +51,7 @@ func FilterPostWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB {
}
func FilterPostDraft(tx *gorm.DB) *gorm.DB {
return tx.Where("is_draft = ?", false)
return tx.Where("is_draft = ? OR is_draft IS NULL", false)
}
func GetPostWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (models.Post, error) {