feat: refine IM admin management workflows
This commit is contained in:
@@ -77,7 +77,12 @@ func (c *cImGroup) Governance(ctx context.Context, req *imgroup.GovernanceReq) (
|
||||
|
||||
// GovernanceUpdate 更新IM群治理配置
|
||||
func (c *cImGroup) GovernanceUpdate(ctx context.Context, req *imgroup.GovernanceUpdateReq) (res *imgroup.GovernanceUpdateRes, err error) {
|
||||
err = service.SysImGroup().GovernanceUpdate(ctx, &req.ImGroupGovernanceUpdateInp)
|
||||
data, err := service.SysImGroup().GovernanceUpdate(ctx, &req.ImGroupGovernanceUpdateInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = new(imgroup.GovernanceUpdateRes)
|
||||
res.ImGroupCommandModel = data
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,13 +99,23 @@ func (c *cImGroup) ProfileUpdate(ctx context.Context, req *imgroup.ProfileUpdate
|
||||
|
||||
// Dissolve 解散IM群
|
||||
func (c *cImGroup) Dissolve(ctx context.Context, req *imgroup.DissolveReq) (res *imgroup.DissolveRes, err error) {
|
||||
err = service.SysImGroup().Dissolve(ctx, &req.ImGroupDissolveInp)
|
||||
data, err := service.SysImGroup().Dissolve(ctx, &req.ImGroupDissolveInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = new(imgroup.DissolveRes)
|
||||
res.ImGroupCommandModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Mute 禁言IM群成员
|
||||
func (c *cImGroup) Mute(ctx context.Context, req *imgroup.MuteReq) (res *imgroup.MuteRes, err error) {
|
||||
err = service.SysImGroup().Mute(ctx, &req.ImGroupMuteInp)
|
||||
data, err := service.SysImGroup().Mute(ctx, &req.ImGroupMuteInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = new(imgroup.MuteRes)
|
||||
res.ImGroupCommandModel = data
|
||||
return
|
||||
}
|
||||
|
||||
@@ -117,7 +132,12 @@ func (c *cImGroup) MemberMute(ctx context.Context, req *imgroup.MemberMuteReq) (
|
||||
|
||||
// Unmute 解除IM群成员禁言
|
||||
func (c *cImGroup) Unmute(ctx context.Context, req *imgroup.UnmuteReq) (res *imgroup.UnmuteRes, err error) {
|
||||
err = service.SysImGroup().Unmute(ctx, &req.ImGroupUnmuteInp)
|
||||
data, err := service.SysImGroup().Unmute(ctx, &req.ImGroupUnmuteInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = new(imgroup.UnmuteRes)
|
||||
res.ImGroupCommandModel = data
|
||||
return
|
||||
}
|
||||
|
||||
@@ -157,7 +177,12 @@ func (c *cImGroup) JoinRequestReject(ctx context.Context, req *imgroup.JoinReque
|
||||
|
||||
// RoleUpdate 更新IM群成员角色
|
||||
func (c *cImGroup) RoleUpdate(ctx context.Context, req *imgroup.RoleUpdateReq) (res *imgroup.RoleUpdateRes, err error) {
|
||||
err = service.SysImGroup().RoleUpdate(ctx, &req.ImGroupRoleUpdateInp)
|
||||
data, err := service.SysImGroup().RoleUpdate(ctx, &req.ImGroupRoleUpdateInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = new(imgroup.RoleUpdateRes)
|
||||
res.ImGroupCommandModel = data
|
||||
return
|
||||
}
|
||||
|
||||
@@ -185,7 +210,12 @@ func (c *cImGroup) AdminRemove(ctx context.Context, req *imgroup.AdminRemoveReq)
|
||||
|
||||
// OwnerTransfer 转让IM群主
|
||||
func (c *cImGroup) OwnerTransfer(ctx context.Context, req *imgroup.OwnerTransferReq) (res *imgroup.OwnerTransferRes, err error) {
|
||||
err = service.SysImGroup().OwnerTransfer(ctx, &req.ImGroupOwnerTransferInp)
|
||||
data, err := service.SysImGroup().OwnerTransfer(ctx, &req.ImGroupOwnerTransferInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = new(imgroup.OwnerTransferRes)
|
||||
res.ImGroupCommandModel = data
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
|
||||
"hotgo/internal/library/queue"
|
||||
)
|
||||
|
||||
type response struct {
|
||||
Status string `json:"status"`
|
||||
Checks map[string]string `json:"checks"`
|
||||
}
|
||||
|
||||
// Serve exposes an unauthenticated dependency health endpoint for container probes.
|
||||
func Serve(r *ghttp.Request) {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
r.Response.Header().Set("Allow", http.MethodGet+", "+http.MethodHead)
|
||||
r.Response.WriteStatusExit(http.StatusMethodNotAllowed, "method not allowed")
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Second)
|
||||
defer cancel()
|
||||
checks := map[string]string{}
|
||||
statusCode := http.StatusOK
|
||||
|
||||
if err := g.DB().Ctx(ctx).Raw("SELECT 1").Scan(new(int)); err != nil {
|
||||
checks["mysql"] = err.Error()
|
||||
statusCode = http.StatusServiceUnavailable
|
||||
} else {
|
||||
checks["mysql"] = "ok"
|
||||
}
|
||||
|
||||
if _, err := g.Redis().Do(ctx, "PING"); err != nil {
|
||||
checks["redis"] = err.Error()
|
||||
statusCode = http.StatusServiceUnavailable
|
||||
} else {
|
||||
checks["redis"] = "ok"
|
||||
}
|
||||
|
||||
if strings.EqualFold(strings.TrimSpace(g.Cfg().MustGet(ctx, "queue.driver").String()), "kafka") {
|
||||
if err := queue.KafkaHealthCheck(ctx); err != nil {
|
||||
checks["kafka"] = err.Error()
|
||||
statusCode = http.StatusServiceUnavailable
|
||||
} else {
|
||||
checks["kafka"] = "ok"
|
||||
}
|
||||
} else {
|
||||
checks["kafka"] = "disabled"
|
||||
}
|
||||
|
||||
body := response{Status: "ok", Checks: checks}
|
||||
if statusCode != http.StatusOK {
|
||||
body.Status = "error"
|
||||
}
|
||||
r.Response.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
r.Response.WriteHeader(statusCode)
|
||||
if r.Method != http.MethodHead {
|
||||
r.Response.WriteJsonExit(body)
|
||||
return
|
||||
}
|
||||
r.Exit()
|
||||
}
|
||||
Reference in New Issue
Block a user