feat(用户管理): 添加设备ID筛选用户列表功能
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m38s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m38s
在用户列表查询中新增设备ID筛选条件,支持通过设备ID或设备标识符查询关联用户
This commit is contained in:
parent
d7b56f3edc
commit
1f5eb2784d
@ -21,6 +21,7 @@ type (
|
|||||||
UserId *int64 `form:"user_id,omitempty"`
|
UserId *int64 `form:"user_id,omitempty"`
|
||||||
SubscribeId *int64 `form:"subscribe_id,omitempty"`
|
SubscribeId *int64 `form:"subscribe_id,omitempty"`
|
||||||
UserSubscribeId *int64 `form:"user_subscribe_id,omitempty"`
|
UserSubscribeId *int64 `form:"user_subscribe_id,omitempty"`
|
||||||
|
DeviceId string `form:"device_id,omitempty"`
|
||||||
}
|
}
|
||||||
// GetUserListResponse
|
// GetUserListResponse
|
||||||
GetUserListResponse {
|
GetUserListResponse {
|
||||||
@ -292,4 +293,3 @@ service ppanel {
|
|||||||
@handler GetUserLoginLogs
|
@handler GetUserLoginLogs
|
||||||
get /login/logs (GetUserLoginLogsRequest) returns (GetUserLoginLogsResponse)
|
get /login/logs (GetUserLoginLogsRequest) returns (GetUserLoginLogsResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,7 @@ func (l *GetUserListLogic) GetUserList(req *types.GetUserListRequest) (*types.Ge
|
|||||||
Search: req.Search,
|
Search: req.Search,
|
||||||
SubscribeId: req.SubscribeId,
|
SubscribeId: req.SubscribeId,
|
||||||
UserSubscribeId: req.UserSubscribeId,
|
UserSubscribeId: req.UserSubscribeId,
|
||||||
|
DeviceId: req.DeviceId,
|
||||||
Order: "DESC",
|
Order: "DESC",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package user
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/perfect-panel/server/internal/model/order"
|
"github.com/perfect-panel/server/internal/model/order"
|
||||||
@ -60,6 +61,7 @@ type UserFilterParams struct {
|
|||||||
UserId *int64
|
UserId *int64
|
||||||
SubscribeId *int64
|
SubscribeId *int64
|
||||||
UserSubscribeId *int64
|
UserSubscribeId *int64
|
||||||
|
DeviceId string
|
||||||
Order string // Order by id, e.g., "desc"
|
Order string // Order by id, e.g., "desc"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,19 +134,27 @@ func (m *customUserModel) QueryPageList(ctx context.Context, page, size int, fil
|
|||||||
var list []*User
|
var list []*User
|
||||||
var total int64
|
var total int64
|
||||||
err := m.QueryNoCacheCtx(ctx, &list, func(conn *gorm.DB, v interface{}) error {
|
err := m.QueryNoCacheCtx(ctx, &list, func(conn *gorm.DB, v interface{}) error {
|
||||||
if filter != nil {
|
if filter != nil {
|
||||||
if filter.UserId != nil {
|
if filter.UserId != nil {
|
||||||
conn = conn.Where("user.id =?", *filter.UserId)
|
conn = conn.Where("user.id =?", *filter.UserId)
|
||||||
|
}
|
||||||
|
if filter.Search != "" {
|
||||||
|
conn = conn.Joins("LEFT JOIN user_auth_methods ON user.id = user_auth_methods.user_id").
|
||||||
|
Where("user_auth_methods.auth_identifier LIKE ?", "%"+filter.Search+"%").Or("user.refer_code like ?", "%"+filter.Search+"%")
|
||||||
|
}
|
||||||
|
if filter.DeviceId != "" {
|
||||||
|
conn = conn.Joins("LEFT JOIN user_device ON user.id = user_device.user_id")
|
||||||
|
if id, err := strconv.ParseInt(filter.DeviceId, 10, 64); err == nil {
|
||||||
|
conn = conn.Where("user_device.id = ? OR user_device.identifier = ?", id, filter.DeviceId)
|
||||||
|
} else {
|
||||||
|
conn = conn.Where("user_device.identifier = ?", filter.DeviceId)
|
||||||
}
|
}
|
||||||
if filter.Search != "" {
|
}
|
||||||
conn = conn.Joins("LEFT JOIN user_auth_methods ON user.id = user_auth_methods.user_id").
|
if filter.UserSubscribeId != nil {
|
||||||
Where("user_auth_methods.auth_identifier LIKE ?", "%"+filter.Search+"%").Or("user.refer_code like ?", "%"+filter.Search+"%")
|
conn = conn.Joins("LEFT JOIN user_subscribe ON user.id = user_subscribe.user_id").
|
||||||
}
|
Where("user_subscribe.id =? and `status` IN (0,1)", *filter.UserSubscribeId)
|
||||||
if filter.UserSubscribeId != nil {
|
}
|
||||||
conn = conn.Joins("LEFT JOIN user_subscribe ON user.id = user_subscribe.user_id").
|
if filter.SubscribeId != nil {
|
||||||
Where("user_subscribe.id =? and `status` IN (0,1)", *filter.UserSubscribeId)
|
|
||||||
}
|
|
||||||
if filter.SubscribeId != nil {
|
|
||||||
conn = conn.Joins("LEFT JOIN user_subscribe ON user.id = user_subscribe.user_id").
|
conn = conn.Joins("LEFT JOIN user_subscribe ON user.id = user_subscribe.user_id").
|
||||||
Where("user_subscribe.subscribe_id =? and `status` IN (0,1)", *filter.SubscribeId)
|
Where("user_subscribe.subscribe_id =? and `status` IN (0,1)", *filter.SubscribeId)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1064,6 +1064,7 @@ type GetUserListRequest struct {
|
|||||||
UserId *int64 `form:"user_id,omitempty"`
|
UserId *int64 `form:"user_id,omitempty"`
|
||||||
SubscribeId *int64 `form:"subscribe_id,omitempty"`
|
SubscribeId *int64 `form:"subscribe_id,omitempty"`
|
||||||
UserSubscribeId *int64 `form:"user_subscribe_id,omitempty"`
|
UserSubscribeId *int64 `form:"user_subscribe_id,omitempty"`
|
||||||
|
DeviceId string `form:"device_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUserListResponse struct {
|
type GetUserListResponse struct {
|
||||||
@ -1236,77 +1237,77 @@ type MessageLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ReportLogMessageRequest struct {
|
type ReportLogMessageRequest struct {
|
||||||
Platform string `json:"platform" validate:"required"`
|
Platform string `json:"platform" validate:"required"`
|
||||||
AppVersion string `json:"appVersion"`
|
AppVersion string `json:"appVersion"`
|
||||||
OsName string `json:"osName"`
|
OsName string `json:"osName"`
|
||||||
OsVersion string `json:"osVersion"`
|
OsVersion string `json:"osVersion"`
|
||||||
DeviceId string `json:"deviceId"`
|
DeviceId string `json:"deviceId"`
|
||||||
UserId int64 `json:"userId"`
|
UserId int64 `json:"userId"`
|
||||||
SessionId string `json:"sessionId"`
|
SessionId string `json:"sessionId"`
|
||||||
Level uint8 `json:"level"`
|
Level uint8 `json:"level"`
|
||||||
ErrorCode string `json:"errorCode"`
|
ErrorCode string `json:"errorCode"`
|
||||||
Message string `json:"message" validate:"required"`
|
Message string `json:"message" validate:"required"`
|
||||||
Stack string `json:"stack"`
|
Stack string `json:"stack"`
|
||||||
Context map[string]interface{} `json:"context"`
|
Context map[string]interface{} `json:"context"`
|
||||||
OccurredAt int64 `json:"occurredAt"`
|
OccurredAt int64 `json:"occurredAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReportLogMessageResponse struct {
|
type ReportLogMessageResponse struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetErrorLogMessageListRequest struct {
|
type GetErrorLogMessageListRequest struct {
|
||||||
Page int `form:"page"`
|
Page int `form:"page"`
|
||||||
Size int `form:"size"`
|
Size int `form:"size"`
|
||||||
Platform string `form:"platform"`
|
Platform string `form:"platform"`
|
||||||
Level uint8 `form:"level"`
|
Level uint8 `form:"level"`
|
||||||
UserId int64 `form:"user_id"`
|
UserId int64 `form:"user_id"`
|
||||||
DeviceId string `form:"device_id"`
|
DeviceId string `form:"device_id"`
|
||||||
ErrorCode string `form:"error_code"`
|
ErrorCode string `form:"error_code"`
|
||||||
Keyword string `form:"keyword"`
|
Keyword string `form:"keyword"`
|
||||||
Start int64 `form:"start"`
|
Start int64 `form:"start"`
|
||||||
End int64 `form:"end"`
|
End int64 `form:"end"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ErrorLogMessage struct {
|
type ErrorLogMessage struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Platform string `json:"platform"`
|
Platform string `json:"platform"`
|
||||||
AppVersion string `json:"app_version"`
|
AppVersion string `json:"app_version"`
|
||||||
OsName string `json:"os_name"`
|
OsName string `json:"os_name"`
|
||||||
OsVersion string `json:"os_version"`
|
OsVersion string `json:"os_version"`
|
||||||
DeviceId string `json:"device_id"`
|
DeviceId string `json:"device_id"`
|
||||||
UserId int64 `json:"user_id"`
|
UserId int64 `json:"user_id"`
|
||||||
SessionId string `json:"session_id"`
|
SessionId string `json:"session_id"`
|
||||||
Level uint8 `json:"level"`
|
Level uint8 `json:"level"`
|
||||||
ErrorCode string `json:"error_code"`
|
ErrorCode string `json:"error_code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetErrorLogMessageListResponse struct {
|
type GetErrorLogMessageListResponse struct {
|
||||||
Total int64 `json:"total"`
|
Total int64 `json:"total"`
|
||||||
List []ErrorLogMessage `json:"list"`
|
List []ErrorLogMessage `json:"list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetErrorLogMessageDetailResponse struct {
|
type GetErrorLogMessageDetailResponse struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Platform string `json:"platform"`
|
Platform string `json:"platform"`
|
||||||
AppVersion string `json:"app_version"`
|
AppVersion string `json:"app_version"`
|
||||||
OsName string `json:"os_name"`
|
OsName string `json:"os_name"`
|
||||||
OsVersion string `json:"os_version"`
|
OsVersion string `json:"os_version"`
|
||||||
DeviceId string `json:"device_id"`
|
DeviceId string `json:"device_id"`
|
||||||
UserId int64 `json:"user_id"`
|
UserId int64 `json:"user_id"`
|
||||||
SessionId string `json:"session_id"`
|
SessionId string `json:"session_id"`
|
||||||
Level uint8 `json:"level"`
|
Level uint8 `json:"level"`
|
||||||
ErrorCode string `json:"error_code"`
|
ErrorCode string `json:"error_code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Stack string `json:"stack"`
|
Stack string `json:"stack"`
|
||||||
Context map[string]interface{} `json:"context"`
|
Context map[string]interface{} `json:"context"`
|
||||||
ClientIP string `json:"client_ip"`
|
ClientIP string `json:"client_ip"`
|
||||||
UserAgent string `json:"user_agent"`
|
UserAgent string `json:"user_agent"`
|
||||||
Locale string `json:"locale"`
|
Locale string `json:"locale"`
|
||||||
OccurredAt int64 `json:"occurred_at"`
|
OccurredAt int64 `json:"occurred_at"`
|
||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MigrateServerNodeResponse struct {
|
type MigrateServerNodeResponse struct {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user