Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat(siteinfo): add custom css html response in siteinfo api

LinkinStar08478d82138b
diff --git a/internal/controller/siteinfo_controller.go b/internal/controller/siteinfo_controller.go
index 82d23733..f5665f96 100644
--- a/internal/controller/siteinfo_controller.go
+++ b/internal/controller/siteinfo_controller.go
@@ -55,6 +55,11 @@ func (sc *SiteinfoController) GetSiteInfo(ctx *gin.Context) {
if err != nil {
log.Error(err)
}
+
+ resp.CustomCssHtml, err = sc.siteInfoService.GetSiteCustomCssHTML(ctx)
+ if err != nil {
+ log.Error(err)
+ }
handler.HandleResponse(ctx, nil, resp)
}
diff --git a/internal/controller/user_controller.go b/internal/controller/user_controller.go
index 553f8914..47ebdf30 100644
--- a/internal/controller/user_controller.go
+++ b/internal/controller/user_controller.go
@@ -488,3 +488,17 @@ func (uc *UserController) UserChangeEmailVerify(ctx *gin.Context) {
uc.actionService.ActionRecordDel(ctx, schema.ActionRecordTypeEmail, ctx.ClientIP())
handler.HandleResponse(ctx, err, nil)
}
+
+// UserRanking get user ranking
+// @Summary get user ranking
+// @Description get user ranking
+// @Tags User
+// @Accept json
+// @Produce json
+// @Security ApiKeyAuth
+// @Success 200 {object} handler.RespBody{data=schema.GetUserToSetShowResp}
+// @Router /answer/api/v1/user/ranking [get]
+func (uc *UserController) UserRanking(ctx *gin.Context) {
+ resp, err := uc.userService.UserRanking(ctx)
+ handler.HandleResponse(ctx, err, resp)
+}
diff --git a/internal/entity/user_entity.go b/internal/entity/user_entity.go
index 1c26ab50..5d615482 100644
--- a/internal/entity/user_entity.go
+++ b/internal/entity/user_entity.go
@@ -44,8 +44,8 @@ type User struct {
Website string `xorm:"not null default '' VARCHAR(255) website"`
Location string `xorm:"not null default '' VARCHAR(100) location"`
IPInfo string `xorm:"not null default '' VARCHAR(255) ip_info"`
- //IsAdmin bool `xorm:"not null default false BOOL is_admin"`
- Language string `xorm:"not null default '' VARCHAR(100) language"`
+ IsAdmin bool `xorm:"not null default false BOOL is_admin"`
+ Language string `xorm:"not null default '' VARCHAR(100) language"`
}
// TableName user table name
diff --git a/internal/repo/activity_common/activity_repo.go b/internal/repo/activity_common/activity_repo.go
index efb7d3be..d758d100 100644
--- a/internal/repo/activity_common/activity_repo.go
+++ b/internal/repo/activity_common/activity_repo.go
@@ -3,6 +3,7 @@ package activity_common
import (
"context"
"fmt"
+ "time"
"github.com/answerdev/answer/internal/entity"
"github.com/answerdev/answer/internal/service/activity_common"
@@ -106,3 +107,9 @@ func (ar *ActivityRepo) AddActivity(ctx context.Context, activity *entity.Activi
}
return
}
+
+// GetUsersWhoHasGainedTheMostReputation get users who has gained the most reputation over a period of time
+func (ar *ActivityRepo) GetUsersWhoHasGainedTheMostReputation(
+ ctx context.Context, startTime, endTime time.Time, limit int) (userIDs []string, err error) {
+ return
+}
diff --git a/internal/router/answer_api_router.go b/internal/router/answer_api_router.go
index ff111e54..b691eb39 100644
--- a/internal/router/answer_api_router.go
+++ b/internal/router/answer_api_router.go
@@ -116,6 +116,7 @@ func (a *AnswerAPIRouter) RegisterUnAuthAnswerAPIRouter(r *gin.RouterGroup) {
r.GET("/user/logout", a.userController.UserLogout)
r.PUT("/user/email", a.userController.UserChangeEmailVerify)
r.POST("/user/email/change/code", a.userController.UserChangeEmailSendCode)
+ r.GET("/user/ranking", a.userController.UserRanking)
//answer
r.GET("/answer/info", a.answerController.Get)
diff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.go
index 113cc70a..86961f09 100644
--- a/internal/schema/siteinfo_schema.go
+++ b/internal/schema/siteinfo_schema.go
@@ -131,11 +131,12 @@ type SiteSeoResp SiteSeoReq
// SiteInfoResp get site info response
type SiteInfoResp struct {
- General *SiteGeneralResp `json:"general"`
- Interface *SiteInterfaceResp `json:"interface"`
- Branding *SiteBrandingResp `json:"branding"`
- Login *SiteLoginResp `json:"login"`
- Theme *SiteThemeResp `json:"theme"`
+ General *SiteGeneralResp `json:"general"`
+ Interface *SiteInterfaceResp `json:"interface"`
+ Branding *SiteBrandingResp `json:"branding"`
+ Login *SiteLoginResp `json:"login"`
+ Theme *SiteThemeResp `json:"theme"`
+ CustomCssHtml *SiteCustomCssHTMLResp `json:"custom_css_html"`
}
type TemplateSiteInfoResp struct {
General *SiteGeneralResp `json:"general"`
diff --git a/internal/schema/user_schema.go b/internal/schema/user_schema.go
index e625dedf..7b38d0ba 100644
--- a/internal/schema/user_schema.go
+++ b/internal/schema/user_schema.go
@@ -417,3 +417,22 @@ type UserVerifyEmailSendReq struct {
CaptchaID string `validate:"omitempty,gt=0,lte=500" json:"captcha_id"`
CaptchaCode string `validate:"omitempty,gt=0,lte=500" json:"captcha_code"`
}
+
+// UserRankingResp user ranking response
+type UserRankingResp struct {
+ UsersWithTheMostReputation []*UserRankingSimpleInfo `json:"users_with_the_most_reputation"`
+ UsersWithTheMostVote []*UserRankingSimpleInfo `json:"users_with_the_most_vote"`
+ Staffs []*UserRankingSimpleInfo `json:"staffs"`
+}
+
+// UserRankingSimpleInfo user ranking simple info
+type UserRankingSimpleInfo struct {
+ // username
+ Username string `json:"username"`
+ // rank
+ Rank int `json:"rank"`
+ // display name
+ DisplayName string `json:"display_name"`
+ // avatar
+ Avatar string `json:"avatar"`
+}
diff --git a/internal/service/user_service.go b/internal/service/user_service.go
index a23d9b4a..a3a5397a 100644
--- a/internal/service/user_service.go
+++ b/internal/service/user_service.go
@@ -555,3 +555,9 @@ func (us *UserService) getSiteUrl(ctx context.Context) string {
}
return siteGeneral.SiteUrl
}
+
+// UserRanking get user ranking
+func (us *UserService) UserRanking(ctx context.Context) (resp []*schema.UserRankingResp, err error) {
+ //us.userRepo.GetByUserID()
+ return
+}