diff --git a/api/v1/backend/chat.go b/api/v1/backend/chat.go index e4f27f8..72778d9 100644 --- a/api/v1/backend/chat.go +++ b/api/v1/backend/chat.go @@ -131,9 +131,9 @@ type ChatSimpleUser struct { } type UserInfoItem struct { - Name string - Label string - Description string + Name string `json:"name"` + Label string `json:"label"` + Description string `json:"description"` } type ChatConnectReq struct { diff --git a/internal/controller/backend/chat.go b/internal/controller/backend/chat.go index 4fbeddd..3177090 100644 --- a/internal/controller/backend/chat.go +++ b/internal/controller/backend/chat.go @@ -60,9 +60,7 @@ func (c cChat) Read(ctx context.Context, req *api.MessageReadReq) (res *baseApi. func (c cChat) CancelTransfer(ctx context.Context, _ *api.CancelTransferReq) (res *baseApi.NilRes, err error) { admin := service.AdminCtx().GetUser(ctx) transfer, err := service.ChatTransfer().First(ctx, g.Map{ - "to_admin_id": admin.Id, - "canceled_at is null": nil, - "accepted_at is null": nil, + "to_admin_id": admin.Id, }) if err != nil { return diff --git a/internal/controller/backend/dashboard.go b/internal/controller/backend/dashboard.go index 023bfa3..2d74adc 100644 --- a/internal/controller/backend/dashboard.go +++ b/internal/controller/backend/dashboard.go @@ -4,8 +4,10 @@ import ( "context" v1 "gf-chat/api/v1" api "gf-chat/api/v1/backend" + "gf-chat/internal/consts" "gf-chat/internal/model/do" "gf-chat/internal/service" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" ) @@ -34,9 +36,18 @@ func (c cDashboard) WaitingUserInfo(ctx context.Context, _ *api.DashboardWaiting if err != nil { return } + total, err := service.ChatSession().Count(ctx, g.Map{ + "queried_at >=": gtime.Now().StartOfDay().String(), + "queried_at <=": gtime.Now().EndOfDay().String(), + "customer_id": service.AdminCtx().GetCustomerId(ctx), + "type": consts.ChatSessionTypeNormal, + }) + if err != nil { + return + } res = v1.NewResp(api.DashboardWaitingUserInfo{ Users: user, - TodayTotal: 0, + TodayTotal: total, }) return } diff --git a/internal/logic/admin/admin.go b/internal/logic/admin/admin.go index f6af12b..37615d0 100644 --- a/internal/logic/admin/admin.go +++ b/internal/logic/admin/admin.go @@ -39,11 +39,12 @@ func (s *sAdmin) Login(ctx context.Context, request *ghttp.Request) (admin *mode password := request.Get("password") admin, err = s.First(ctx, do.CustomerAdmins{Username: username.String()}) if err != nil { + err = gerror.NewCode(gcode.CodeBusinessValidationFailed, "账号或密码错误") return } err = bcrypt.CompareHashAndPassword([]byte(admin.Password), password.Bytes()) if err != nil { - err = gerror.NewCode(gcode.CodeValidationFailed, "账号或密码错误") + err = gerror.NewCode(gcode.CodeBusinessValidationFailed, "账号或密码错误") return } canAccess := s.CanAccess(admin) diff --git a/internal/logic/user/user.go b/internal/logic/user/user.go index 18da2a2..e823f3a 100644 --- a/internal/logic/user/user.go +++ b/internal/logic/user/user.go @@ -31,7 +31,17 @@ type sUser struct { } func (s *sUser) GetInfo(ctx context.Context, user *model.User) ([]api.UserInfoItem, error) { - return make([]api.UserInfoItem, 0), nil + r := make([]api.UserInfoItem, 0) + r = append(r, api.UserInfoItem{ + Label: "用户名", + Name: "username", + Description: user.Username, + }, api.UserInfoItem{ + Label: "注册时间", + Name: "created_at", + Description: user.CreatedAt.String(), + }) + return r, nil } func (s *sUser) GetActiveCount(ctx context.Context, date *gtime.Time) (count int, err error) {