67 lines
2.0 KiB
Go
67 lines
2.0 KiB
Go
package sys
|
|
|
|
import (
|
|
"context"
|
|
"hotgo/internal/library/imworkbench"
|
|
"hotgo/internal/model/input/sysin"
|
|
"hotgo/internal/service"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
)
|
|
|
|
type sSysImFeedbackConfig struct{}
|
|
|
|
func NewSysImFeedbackConfig() *sSysImFeedbackConfig { return &sSysImFeedbackConfig{} }
|
|
|
|
func init() {
|
|
service.RegisterSysImFeedbackConfig(NewSysImFeedbackConfig())
|
|
}
|
|
|
|
func (s *sSysImFeedbackConfig) Get(ctx context.Context, in *sysin.ImFeedbackConfigGetInp) (res *sysin.ImFeedbackConfigModel, err error) {
|
|
if err = in.Filter(ctx); err != nil {
|
|
return
|
|
}
|
|
tenant, err := resolveImAdminTenant(ctx, in.TenantId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res = &sysin.ImFeedbackConfigModel{}
|
|
if err = imworkbench.DefaultClient(ctx).Get(ctx, "/internal/admin/workbench/feedback-config", nil, res); err != nil {
|
|
return nil, err
|
|
}
|
|
if res != nil {
|
|
res.TenantId = tenant.Id
|
|
res.TenantName = tenant.Name
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *sSysImFeedbackConfig) Update(ctx context.Context, in *sysin.ImFeedbackConfigUpdateInp) (err error) {
|
|
if err = in.Filter(ctx); err != nil {
|
|
return
|
|
}
|
|
tenant, err := resolveImAdminTenant(ctx, in.TenantId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
categories := `["bug","suggestion","complaint","other"]`
|
|
if in.Categories != nil && in.Categories.String() != "" && in.Categories.String() != "null" {
|
|
categories = in.Categories.String()
|
|
}
|
|
attachmentPolicy := `{"max_files":5,"purpose":"feedback"}`
|
|
if in.AttachmentPolicy != nil && in.AttachmentPolicy.String() != "" && in.AttachmentPolicy.String() != "null" {
|
|
attachmentPolicy = in.AttachmentPolicy.String()
|
|
}
|
|
if err = imworkbench.DefaultClient(ctx).Post(ctx, "/internal/admin/workbench/feedback-config", g.Map{
|
|
"categories": categories,
|
|
"max_length": in.MaxLength,
|
|
"attachment_policy": attachmentPolicy,
|
|
"allow_contact": in.AllowContact,
|
|
"diagnostics_notice": in.DiagnosticsNotice,
|
|
}, nil); err != nil {
|
|
return err
|
|
}
|
|
_ = writeImAdminAudit(ctx, tenant.Id, "im_feedback_config_update", "im_feedback_config", 1, "success", g.Map{"allow_contact": in.AllowContact})
|
|
return nil
|
|
}
|