This commit is contained in:
hackrobot
2024-04-10 20:28:15 +08:00
parent 0434f76377
commit 402e47e5d0
2 changed files with 4 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ class User(Base):
id = Column(Integer, primary_key=True)
wxid = Column(String)
openId = Column(String)
h5openid = Column(String)
sex = Column(String) #性别 男/女
city = Column(String) #城市
country = Column(String) #"CN"

View File

@@ -25,13 +25,15 @@ from pydantic import BaseModel
# 保存好友信息
def saveWxidInfo(account_wxid, wxid,openId=None):
def saveWxidInfo(account_wxid, wxid,openId=None,h5openid=None):
allFriend = WXBotService.get_address_list(account_wxid)
for friendItem in allFriend['data']["contactList"]:
if friendItem['wxid'] == wxid:
# 存储小程序openid
if openId:
friendItem['openId'] = openId
if h5openid:
friendItem['h5openid'] = openId
friendItemObj = models.User(**friendItem)
db_user = crud.get_user_by_wxid(db=SessionLocal(), wxid=wxid)
if db_user: