Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ai
/
ai-workflow
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e3853e3a
authored
Jul 08, 2026
by
sunqi02
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 添加手机号查询功能,重构手机号绑定逻辑,优化代码结构
1 parent
3ea98d0e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
11 deletions
workspace/agent-admin/backend/app/customer_info/api.py
workspace/agent-admin/backend/app/customer_info/schema.py
workspace/agent-admin/backend/app/customer_info/service.py
workspace/agent-admin/backend/app/customer_info/api.py
View file @
e3853e3
...
...
@@ -5,7 +5,7 @@ from sqlalchemy.orm import Session
from
app.infrastructure.database
import
get_db
from
app.schema.common
import
ApiResponse
,
success_response_payload
,
SuccessFlagData
from
app.customer_info.schema
import
PhoneBindingSubmitRequest
from
app.customer_info.schema
import
CustomerGroupPhoneResponse
,
PhoneBindingSubmitRequest
from
app.customer_info.service
import
CustomerInfoService
router
=
APIRouter
(
prefix
=
"/api/v1/customer-info"
,
tags
=
[
"customer-info"
])
...
...
@@ -22,8 +22,20 @@ def submit_phone(
):
"""用户提交手机号绑定。"""
record
=
service
.
bind_phone
(
customer_name
=
req
.
customer_name
,
group_id
=
req
.
group_id
,
phone
=
req
.
phone
group_id
=
req
.
group_id
,
phone
=
req
.
phone
)
if
record
is
None
:
raise
HTTPException
(
status_code
=
404
,
detail
=
"未找到匹配的客户群组记录"
)
return
success_response_payload
(
200
,
SuccessFlagData
(
success
=
True
))
@router.get
(
"/phone"
,
response_model
=
ApiResponse
[
CustomerGroupPhoneResponse
])
def
get_phone
(
group_id
:
str
,
service
:
CustomerInfoService
=
Depends
(
get_customer_info_service
),
):
"""查询群手机号绑定信息。"""
record
=
service
.
get_phone
(
group_id
)
if
record
is
None
:
raise
HTTPException
(
status_code
=
404
,
detail
=
"未找到匹配的客户群组记录"
)
return
success_response_payload
(
200
,
record
)
workspace/agent-admin/backend/app/customer_info/schema.py
View file @
e3853e3
...
...
@@ -3,12 +3,11 @@ from __future__ import annotations
from
datetime
import
datetime
from
typing
import
Optional
from
pydantic
import
BaseModel
,
Field
from
pydantic
import
BaseModel
,
Field
,
field_serializer
from
pydantic.config
import
ConfigDict
class
PhoneBindingSubmitRequest
(
BaseModel
):
customer_name
:
str
=
Field
(
...
,
max_length
=
255
,
description
=
"客户名称"
)
group_id
:
str
=
Field
(
...
,
max_length
=
255
,
description
=
"群ID"
)
phone
:
str
=
Field
(
...
,
max_length
=
20
,
description
=
"手机号码"
)
...
...
@@ -24,3 +23,9 @@ class CustomerGroupPhoneResponse(BaseModel):
last_pushed_at
:
Optional
[
datetime
]
=
None
create_time
:
datetime
update_time
:
datetime
@field_serializer
(
"phone"
)
def
mask_phone
(
self
,
value
:
Optional
[
str
])
->
Optional
[
str
]:
if
value
and
len
(
value
)
==
11
:
return
value
[:
3
]
+
"****"
+
value
[
7
:]
return
value
workspace/agent-admin/backend/app/customer_info/service.py
View file @
e3853e3
...
...
@@ -43,25 +43,30 @@ class CustomerInfoService:
logger
.
info
(
"同步完成: affected=
%
s"
,
affected
)
return
affected
def
bind_phone
(
self
,
customer_name
:
str
,
group_id
:
str
,
phone
:
str
)
->
Optional
[
CustomerGroupPhone
]:
def
bind_phone
(
self
,
group_id
:
str
,
phone
:
str
)
->
Optional
[
CustomerGroupPhone
]:
"""用户填写手机号。"""
record
=
(
self
.
db
.
query
(
CustomerGroupPhone
)
.
filter
(
CustomerGroupPhone
.
customer_name
==
customer_name
,
CustomerGroupPhone
.
group_id
==
group_id
,
)
.
filter
(
CustomerGroupPhone
.
group_id
==
group_id
)
.
first
()
)
if
not
record
:
logger
.
warning
(
"未找到匹配记录:
customer_name=
%
s group_id=
%
s"
,
customer_name
,
group_id
)
logger
.
warning
(
"未找到匹配记录:
group_id=
%
s"
,
group_id
)
return
None
record
.
phone
=
phone
self
.
db
.
commit
()
self
.
db
.
refresh
(
record
)
logger
.
info
(
"手机号绑定成功:
customer_name=
%
s group_id=
%
s"
,
customer_name
,
group_id
)
logger
.
info
(
"手机号绑定成功:
group_id=
%
s"
,
group_id
)
return
record
def
get_phone
(
self
,
group_id
:
str
)
->
Optional
[
CustomerGroupPhone
]:
"""查询群绑定的手机号。"""
return
(
self
.
db
.
query
(
CustomerGroupPhone
)
.
filter
(
CustomerGroupPhone
.
group_id
==
group_id
)
.
first
()
)
def
get_push_candidates
(
self
,
mode
:
str
=
"sync"
)
->
list
[
CustomerGroupPhone
]:
"""获取需要推送的记录。
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment