feat: add tenant entry application pages
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2026 HotGo
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type sSysImTenantEntryFeedback struct{}
|
||||
|
||||
func NewSysImTenantEntryFeedback() *sSysImTenantEntryFeedback {
|
||||
return &sSysImTenantEntryFeedback{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysImTenantEntryFeedback(NewSysImTenantEntryFeedback())
|
||||
}
|
||||
|
||||
// List 获取企业入口反馈列表
|
||||
func (s *sSysImTenantEntryFeedback) List(ctx context.Context, in *sysin.ImTenantEntryFeedbackListInp) (list []*sysin.ImTenantEntryFeedbackListModel, totalCount int, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
mod := s.listModel(ctx)
|
||||
mod = s.applyWhere(mod, in)
|
||||
mod = mod.Page(in.Page, in.PerPage).OrderDesc("created_at").OrderDesc("id")
|
||||
|
||||
if err = mod.ScanAndCount(&list, &totalCount, false); err != nil {
|
||||
return nil, 0, gerror.Wrap(err, "获取企业入口反馈列表失败,请稍后重试!")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysImTenantEntryFeedback) listModel(ctx context.Context) *gdb.Model {
|
||||
return g.DB().Model("im_tenant_entry_feedbacks").Safe().Ctx(ctx).Fields(
|
||||
"id",
|
||||
"feedback_id",
|
||||
"description",
|
||||
"contact",
|
||||
"tenant_code_hint",
|
||||
"status",
|
||||
"submitted_at",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
)
|
||||
}
|
||||
|
||||
func (s *sSysImTenantEntryFeedback) applyWhere(mod *gdb.Model, in *sysin.ImTenantEntryFeedbackListInp) *gdb.Model {
|
||||
if in.FeedbackId != "" {
|
||||
mod = mod.WhereLike("feedback_id", "%"+in.FeedbackId+"%")
|
||||
}
|
||||
if in.Contact != "" {
|
||||
mod = mod.WhereLike("contact", "%"+in.Contact+"%")
|
||||
}
|
||||
if in.TenantCodeHint != "" {
|
||||
mod = mod.WhereLike("tenant_code_hint", "%"+in.TenantCodeHint+"%")
|
||||
}
|
||||
if in.Status != "" {
|
||||
mod = mod.Where("status", in.Status)
|
||||
}
|
||||
if in.Keyword != "" {
|
||||
like := "%" + in.Keyword + "%"
|
||||
mod = mod.Where("(feedback_id LIKE ? OR description LIKE ? OR contact LIKE ? OR tenant_code_hint LIKE ?)", like, like, like, like)
|
||||
}
|
||||
if len(in.CreatedAt) == 2 {
|
||||
mod = mod.WhereBetween("created_at", in.CreatedAt[0], in.CreatedAt[1])
|
||||
}
|
||||
return mod
|
||||
}
|
||||
|
||||
// View 获取企业入口反馈指定信息
|
||||
func (s *sSysImTenantEntryFeedback) View(ctx context.Context, in *sysin.ImTenantEntryFeedbackViewInp) (res *sysin.ImTenantEntryFeedbackViewModel, err error) {
|
||||
if err = in.Filter(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = g.DB().Model("im_tenant_entry_feedbacks").Safe().Ctx(ctx).
|
||||
Fields(
|
||||
"id",
|
||||
"feedback_id",
|
||||
"description",
|
||||
"contact",
|
||||
"tenant_code_hint",
|
||||
"CAST(screenshot_file_ids AS CHAR) screenshot_file_ids",
|
||||
"CAST(client_context AS CHAR) client_context",
|
||||
"idempotency_key",
|
||||
"status",
|
||||
"submitted_at",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
).
|
||||
Where("id", in.Id).
|
||||
Scan(&res); err != nil {
|
||||
return nil, gerror.Wrap(err, "获取企业入口反馈信息失败,请稍后重试!")
|
||||
}
|
||||
if res == nil {
|
||||
return
|
||||
}
|
||||
res.ScreenshotFiles, err = loadImPublicUploads(ctx, parseJSONStringSlice(res.ScreenshotFileIds))
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user