Skip to content

Commit

Permalink
fixed user info
Browse files Browse the repository at this point in the history
  • Loading branch information
zjwshisb committed Jan 5, 2025
1 parent e1b40ad commit 0759d79
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
6 changes: 3 additions & 3 deletions api/v1/backend/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions internal/controller/backend/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion internal/controller/backend/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion internal/logic/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion internal/logic/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0759d79

Please sign in to comment.