Skip to content

Commit

Permalink
fix:add commont can modify api url config
Browse files Browse the repository at this point in the history
  • Loading branch information
No8blackball committed May 28, 2024
1 parent 734f290 commit f988cfb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/common/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func (cn *Common) appConfig(c *wkhttp.Context) {
SendWelcomeMessageOn: appConfigM.SendWelcomeMessageOn,
InviteSystemAccountJoinGroupOn: appConfigM.InviteSystemAccountJoinGroupOn,
RegisterUserMustCompleteInfoOn: appConfigM.RegisterUserMustCompleteInfoOn,
CanModifyApiUrl: appConfigM.CanModifyApiUrl,
})
}

Expand Down Expand Up @@ -492,6 +493,7 @@ type appConfigResp struct {
SendWelcomeMessageOn int `json:"send_welcome_message_on"` // 开启注册登录发送欢迎语
InviteSystemAccountJoinGroupOn int `json:"invite_system_account_join_group_on"` // 开启系统账号加入群聊
RegisterUserMustCompleteInfoOn int `json:"register_user_must_complete_info_on"` // 注册用户必须填写完整信息
CanModifyApiUrl int `json:"can_modify_api_url"` // 允许修改api地址
}

type appVersionReq struct {
Expand Down
6 changes: 6 additions & 0 deletions modules/common/api_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func (m *Manager) updateConfig(c *wkhttp.Context) {
InviteSystemAccountJoinGroupOn int `json:"invite_system_account_join_group_on"` // 开启系统账号加入群聊
RegisterUserMustCompleteInfoOn int `json:"register_user_must_complete_info_on"` // 注册用户必须填写完整信息
ChannelPinnedMessageMaxCount int `json:"channel_pinned_message_max_count"` // 频道置顶消息最大数量
CanModifyApiUrl int `json:"can_modify_api_url"` // 是否可以修改api地址
}
var req reqVO
if err := c.BindJSON(&req); err != nil {
Expand All @@ -225,6 +226,7 @@ func (m *Manager) updateConfig(c *wkhttp.Context) {
configMap["invite_system_account_join_group_on"] = req.InviteSystemAccountJoinGroupOn
configMap["register_user_must_complete_info_on"] = req.RegisterUserMustCompleteInfoOn
configMap["channel_pinned_message_max_count"] = req.ChannelPinnedMessageMaxCount
configMap["can_modify_api_url"] = req.CanModifyApiUrl
err = m.appconfigDB.updateWithMap(configMap, appConfigM.Id)
if err != nil {
m.Error("修改app配置信息错误", zap.Error(err))
Expand Down Expand Up @@ -254,6 +256,7 @@ func (m *Manager) appconfig(c *wkhttp.Context) {
var inviteSystemAccountJoinGroupOn = 0
var registerUserMustCompleteInfoOn = 0
var channelPinnedMessageMaxCount = 10
var canModifyApiUrl = 0
if appconfig != nil {
revokeSecond = appconfig.RevokeSecond
welcomeMessage = appconfig.WelcomeMessage
Expand All @@ -264,6 +267,7 @@ func (m *Manager) appconfig(c *wkhttp.Context) {
inviteSystemAccountJoinGroupOn = appconfig.InviteSystemAccountJoinGroupOn
registerUserMustCompleteInfoOn = appconfig.RegisterUserMustCompleteInfoOn
channelPinnedMessageMaxCount = appconfig.ChannelPinnedMessageMaxCount
canModifyApiUrl = appconfig.CanModifyApiUrl
}
if revokeSecond == 0 {
revokeSecond = 120
Expand All @@ -281,6 +285,7 @@ func (m *Manager) appconfig(c *wkhttp.Context) {
InviteSystemAccountJoinGroupOn: inviteSystemAccountJoinGroupOn,
RegisterUserMustCompleteInfoOn: registerUserMustCompleteInfoOn,
ChannelPinnedMessageMaxCount: channelPinnedMessageMaxCount,
CanModifyApiUrl: canModifyApiUrl,
})
}

Expand All @@ -294,6 +299,7 @@ type managerAppConfigResp struct {
InviteSystemAccountJoinGroupOn int `json:"invite_system_account_join_group_on"` // 开启系统账号加入群聊
RegisterUserMustCompleteInfoOn int `json:"register_user_must_complete_info_on"` // 注册用户必须填写完整信息
ChannelPinnedMessageMaxCount int `json:"channel_pinned_message_max_count"` // 频道置顶消息最大数量
CanModifyApiUrl int `json:"can_modify_api_url"` // 是否可以修改api地址
}

type managerAppModule struct {
Expand Down
1 change: 1 addition & 0 deletions modules/common/db_app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ type appConfigModel struct {
InviteSystemAccountJoinGroupOn int // 开启系统账号加入群聊
RegisterUserMustCompleteInfoOn int // 注册用户是否必须完善个人信息
ChannelPinnedMessageMaxCount int // 频道置顶消息最大数量
CanModifyApiUrl int // 是否可以修改API地址
ldb.BaseModel
}
3 changes: 3 additions & 0 deletions modules/common/sql/common-20240528-01.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- +migrate Up

ALTER TABLE `app_config` ADD COLUMN can_modify_api_url smallint not null DEFAULT 10 COMMENT '是否能修改服务器地址';
9 changes: 9 additions & 0 deletions modules/common/swagger/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ paths:
channel_pinned_message_max_count:
type: integer
description: "频道置顶消息最大数量"
can_modify_api_url:
type: integer
description: "是否允许修改api地址 1.允许"
400:
description: "错误"
schema:
Expand Down Expand Up @@ -108,6 +111,9 @@ paths:
channel_pinned_message_max_count:
type: integer
description: "频道置顶消息最大数量"
can_modify_api_url:
type: integer
description: "是否允许修改api地址 1.允许"
responses:
200:
description: "返回"
Expand Down Expand Up @@ -542,6 +548,9 @@ paths:
channel_pinned_message_max_count:
type: integer
description: "频道置顶消息最大数量"
can_modify_api_url:
type: integer
description: "是否允许修改api地址 1.允许"
400:
description: "错误"
schema:
Expand Down

0 comments on commit f988cfb

Please sign in to comment.