Skip to content

Support 564#583

Merged
BugsGuru merged 5 commits intomainfrom
support-564
Mar 20, 2026
Merged

Support 564#583
BugsGuru merged 5 commits intomainfrom
support-564

Conversation

@LordofAvernus
Copy link
Collaborator

@LordofAvernus LordofAvernus commented Mar 20, 2026

User description

关联的 issue

#564

描述你的变更

增加用户列表筛选

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 新增邮箱、手机号、状态、认证类型和系统筛选

  • 增强模糊搜索功能,匹配 uid/email/phone 与 name

  • 改进查询参数构建逻辑以传递新筛选项

  • 同步更新 Swagger 文档及 API 枚举定义


Diagram Walkthrough

flowchart LR
  A["ListUsers 方法更新"] -- "添加过滤条件" --> B["后端服务增强"]
  A -- "构建新查询参数" --> C["请求透传更新"]
  A -- "更新模糊搜索逻辑" --> D["搜索条件扩展"]
  B -- "同步更新" --> E["Swagger 文档"]
Loading

File Walkthrough

Relevant files
Enhancement
user.go
更新后端用户过滤条件实现                                                                                         

internal/dms/service/user.go

  • 添加邮箱、手机号筛选逻辑
  • 添加状态、认证类型及系统过滤
  • 增强模糊搜索条件(uid/email/phone)
  • 转换字符串枚举为对应 uint 值
+70/-0   
user.go
更新 API 请求参数及枚举定义                                                                                 

pkg/dms-common/api/dms/v1/user.go

  • 新增 UserStatFilter 枚举
  • 添加邮箱、手机号、状态、认证类型和系统查询参数
  • 更新接口请求参数注释和说明
+25/-0   
user.go
更新请求参数透传逻辑                                                                                             

pkg/dms-common/dmsobject/user.go

  • 修改请求 URL 拼装逻辑
  • 新增透传各过滤参数的处理
  • 使用 url.Values 构建查询字符串
+42/-3   
Documentation
swagger.json
更新 Swagger 文档 JSON 定义                                                                       

api/swagger.json

  • 添加新筛选项描述
  • 更新状态枚举定义及说明
  • 同步 API 文档变化
+66/-3   
swagger.yaml
更新 Swagger 文档 YAML 定义                                                                       

api/swagger.yaml

  • 同步新增 query 参数
  • 更新枚举描述及文档包路径
  • 保持文档一致性
+69/-3   

…ation type, and system in user listing requests
- Changed FilterByStat in ListUserReq from a pointer to a uint to a string enum for better clarity and type safety.
- Updated ListUsers method to handle the new string enum for user status filtering, converting it to the corresponding uint value.
- Adjusted parameter handling in the user listing request to reflect the new enum type.
@github-actions
Copy link

PR Reviewer Guide 🔍

🎫 Ticket compliance analysis 🔶

564 - Partially compliant

Compliant requirements:

  • 扩展筛选入参并透传查询参数
  • 模糊搜索扩展到多个字段
  • swagger 文档更新

Non-compliant requirements:

Requires further human verification:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

状态转换

请确认在处理用户状态筛选时,将字符串枚举转换为 uint 的逻辑能够覆盖所有预期取值,并考虑兼容可能的旧取值格式。

// 按用户状态过滤
if req.FilterByStat != "" {
	// 将字符串枚举转换为 uint
	var statValue uint
	switch req.FilterByStat {
	case dmsCommonV1.UserStatFilterNormal:
		statValue = 0
	case dmsCommonV1.UserStatFilterDisabled:
		statValue = 1
	default:
		return nil, fmt.Errorf("invalid user stat filter: %s", req.FilterByStat)
	}
	andConditions = append(andConditions, pkgConst.FilterCondition{
		Field:    string(biz.UserFieldStat),
		Operator: pkgConst.FilterOperatorEqual,
		Value:    statValue,
	})
}
模糊搜索扩展

新增的模糊搜索条件通过 OR 组合 uid、邮箱和手机号字段,请验证该逻辑在实际使用中是否达到预期效果。

if req.FuzzyKeyword != "" {
	filterByOptions.Groups = append(filterByOptions.Groups, pkgConst.NewConditionGroup(
		pkgConst.FilterLogicOr,
		pkgConst.FilterCondition{
			Field:    string(biz.UserFieldName),
			Operator: pkgConst.FilterOperatorContains,
			Value:    req.FuzzyKeyword,
		},
		pkgConst.FilterCondition{
			Field:    string(biz.UserFieldUID),
			Operator: pkgConst.FilterOperatorContains,
			Value:    req.FuzzyKeyword,
		},
		pkgConst.FilterCondition{
			Field:    string(biz.UserFieldEmail),
			Operator: pkgConst.FilterOperatorContains,
			Value:    req.FuzzyKeyword,
		},
		pkgConst.FilterCondition{
			Field:    string(biz.UserFieldPhone),
			Operator: pkgConst.FilterOperatorContains,
			Value:    req.FuzzyKeyword,
		},
	))
查询参数构造

查询参数的构造存在一定重复,可以考虑封装复用逻辑以提高代码的可维护性。

reply := &dmsV1.ListUserReply{}

// 构建查询参数
params := url.Values{}
params.Set("page_size", strconv.FormatUint(uint64(req.PageSize), 10))
if req.PageIndex > 0 {
	params.Set("page_index", strconv.FormatUint(uint64(req.PageIndex), 10))
}
if req.OrderBy != "" {
	params.Set("order_by", string(req.OrderBy))
}
if req.FilterByName != "" {
	params.Set("filter_by_name", req.FilterByName)
}
if req.FilterByUids != "" {
	params.Set("filter_by_uids", req.FilterByUids)
}
if req.FilterDeletedUser {
	params.Set("filter_del_user", "true")
}
if req.FuzzyKeyword != "" {
	params.Set("fuzzy_keyword", req.FuzzyKeyword)
}
if req.FilterByEmail != "" {
	params.Set("filter_by_email", req.FilterByEmail)
}
if req.FilterByPhone != "" {
	params.Set("filter_by_phone", req.FilterByPhone)
}
if req.FilterByStat != "" {
	params.Set("filter_by_stat", string(req.FilterByStat))
}
if req.FilterByAuthenticationType != "" {
	params.Set("filter_by_authentication_type", string(req.FilterByAuthenticationType))
}
if req.FilterBySystem != "" {
	params.Set("filter_by_system", string(req.FilterBySystem))
}

@github-actions
Copy link

PR Code Suggestions ✨

No code suggestions found for the PR.

@LordofAvernus LordofAvernus requested a review from BugsGuru March 20, 2026 06:11
@BugsGuru BugsGuru merged commit 9cd1221 into main Mar 20, 2026
1 check passed
@BugsGuru BugsGuru deleted the support-564 branch March 20, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants