uid
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
18631081161 2026-04-21 17:44:06 +08:00
parent fa0cf7e41c
commit ecd3a90dcd
4 changed files with 20 additions and 2 deletions

View File

@ -2,7 +2,17 @@ namespace VendingMachine.Domain.Entities;
public class User public class User
{ {
public string Uid { get; set; } = Guid.NewGuid().ToString("N")[..12]; private static readonly Random _random = new();
public string Uid { get; set; } = GenerateUid();
/// <summary>
/// 生成6位随机数字UID不以0开头100000-999999
/// </summary>
public static string GenerateUid()
{
return _random.Next(100000, 999999).ToString();
}
public string Phone { get; set; } = string.Empty; public string Phone { get; set; } = string.Empty;
public string AreaCode { get; set; } = string.Empty; public string AreaCode { get; set; } = string.Empty;
public string Nickname { get; set; } = string.Empty; public string Nickname { get; set; } = string.Empty;

View File

@ -92,8 +92,16 @@ public class UserService : IUserService
if (user == null) if (user == null)
{ {
// 生成唯一的6位UID
string uid;
do
{
uid = User.GenerateUid();
} while (await _db.Users.IgnoreQueryFilters().AnyAsync(u => u.Uid == uid));
user = new User user = new User
{ {
Uid = uid,
Phone = request.Phone, Phone = request.Phone,
AreaCode = request.AreaCode, AreaCode = request.AreaCode,
Nickname = IUserService.GenerateDefaultNickname() Nickname = IUserService.GenerateDefaultNickname()

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="login-page"> <view class="login-page">
<!-- 全屏背景图 --> <!-- 全屏背景图 -->
<image class="bg-image" src="/static/login_bg.png" mode="aspectFill" /> <image class="bg-image" src="/static/logo_bg.png" mode="aspectFill" />
<!-- 自定义导航栏 --> <!-- 自定义导航栏 -->
<view class="custom-nav" :style="{ paddingTop: statusBarHeight + 'px' }"> <view class="custom-nav" :style="{ paddingTop: statusBarHeight + 'px' }">

BIN
mobile/static/logo_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB