You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

package internal
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/imdotdev/im.dev/server/pkg/common"
"github.com/imdotdev/im.dev/server/pkg/config"
)
4 years ago
type Config struct {
4 years ago
AppName string `json:"appName"`
4 years ago
CommonMaxLen int `json:"commonMaxlen"`
Posts *PostsConfig `json:"posts"`
User *UserConfig `json:"user"`
}
4 years ago
type PostsConfig struct {
4 years ago
TitleMaxLen int `json:"titleMaxLen"`
4 years ago
BriefMaxLen int `json:"briefMaxLen"`
WritingEnabled bool `json:"writingEnabled"`
4 years ago
MaxTags int `json:"maxTags"`
}
4 years ago
type UserConfig struct {
NicknameMaxLen int `json:"nicknameMaxLen"`
UsernameMaxLen int `json:"usernameMaxLen"`
}
4 years ago
// 在后台页面配置存储到mysql中
4 years ago
func GetConfig(c *gin.Context) {
conf := &Config{
4 years ago
AppName: config.Data.Common.AppName,
4 years ago
CommonMaxLen: 255,
4 years ago
Posts: &PostsConfig{
4 years ago
TitleMaxLen: config.Data.Posts.TitleMaxLen,
4 years ago
BriefMaxLen: config.Data.Posts.BriefMaxLen,
WritingEnabled: config.Data.Posts.WritingEnabled,
4 years ago
MaxTags: 2,
},
4 years ago
User: &UserConfig{
UsernameMaxLen: 39,
NicknameMaxLen: 64,
},
}
c.JSON(http.StatusOK, common.RespSuccess(conf))
}