Refactor comment components and update OIDC configuration

- Updated OIDC configuration to include additional fields in the UpdateOidcConfig method.
- Enhanced CommentService to include IsPrivate field in the comment DTO.
- Refactored comment components: renamed neo-comment to comment, and moved related files.
- Implemented new CommentInput and CommentItem components for better structure and readability.
- Removed obsolete files related to the old comment system.
- Added CSS animations for comment components to improve user experience.
This commit is contained in:
2025-09-09 22:37:27 +08:00
parent 5fb6cd63dd
commit cb3f602663
13 changed files with 190 additions and 179 deletions

View File

@ -110,7 +110,7 @@ func (cr *CommentRepo) UpdateComment(comment *model.Comment) error {
return errs.New(http.StatusBadRequest, "invalid comment ID", nil)
}
if err := GetDB().Updates(comment).Error; err != nil {
if err := GetDB().Select("IsPrivate", "Content").Updates(comment).Error; err != nil {
return err
}
@ -204,6 +204,7 @@ func (cr *CommentRepo) ListComments(currentUserID, targetID, commentID uint, tar
} else {
query = query.Where("target_id = ? AND target_type = ?", targetID, targetType)
}
items, _, err := PaginateQuery[model.Comment](query, page, size, orderBy, desc)
if err != nil {

View File

@ -3,6 +3,9 @@ package repo
import (
"errors"
"fmt"
"os"
"path/filepath"
"github.com/glebarez/sqlite"
"github.com/sirupsen/logrus"
"github.com/snowykami/neo-blog/internal/model"
@ -10,8 +13,6 @@ import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"os"
"path/filepath"
)
var db *gorm.DB

View File

@ -1,9 +1,10 @@
package repo
import (
"net/http"
"github.com/snowykami/neo-blog/internal/model"
"github.com/snowykami/neo-blog/pkg/errs"
"net/http"
)
type oidcRepo struct {
@ -62,7 +63,9 @@ func (o *oidcRepo) UpdateOidcConfig(oidcConfig *model.OidcConfig) error {
if oidcConfig.ID == 0 {
return errs.New(http.StatusBadRequest, "invalid OIDC config ID", nil)
}
if err := GetDB().Select("Enabled").Updates(oidcConfig).Error; err != nil {
if err := GetDB().Select("Name", "ClientID", "ClientSecret",
"DisplayName", "Icon", "OidcDiscoveryUrl",
"Enabled", "Type").Updates(oidcConfig).Error; err != nil {
return err
}
return nil