v1.2.77 - 用户编码从201开始
This commit is contained in:
parent
7e19e2a55d
commit
0dee8a9d53
|
|
@ -13,16 +13,18 @@ router = APIRouter(prefix="/api/auth", tags=["认证"])
|
|||
|
||||
|
||||
def generate_user_code(db):
|
||||
"""生成用户编码,从0001开始"""
|
||||
"""生成用户编码,从201开始,按自然数顺序递增"""
|
||||
# 查找最大的user_code
|
||||
max_code = db.query(User.user_code).filter(User.user_code != None).order_by(User.user_code.desc()).first()
|
||||
if max_code and max_code[0]:
|
||||
try:
|
||||
num = int(max_code[0]) + 1
|
||||
return f"{num:04d}"
|
||||
if num < 201:
|
||||
num = 201
|
||||
return str(num)
|
||||
except:
|
||||
pass
|
||||
return "000501"
|
||||
return "201"
|
||||
|
||||
@router.post("/register", response_model=UserResponse)
|
||||
def register(user_data: UserCreate, db: Session = Depends(get_db)):
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ export default function Admin() {
|
|||
const updateData = {
|
||||
username: editingUser.username,
|
||||
email: editingUser.email,
|
||||
phone: editingUser.phone,
|
||||
phoneVerified: editingUser.phoneVerified,
|
||||
role: editingUser.role,
|
||||
user_code: editingUser.user_code,
|
||||
level: editingUser.level,
|
||||
|
|
@ -253,7 +255,7 @@ export default function Admin() {
|
|||
</div>
|
||||
<div style={{ display: 'flex', gap: '8px' }}>
|
||||
<button
|
||||
onClick={() => setEditingUser({ ...user })}
|
||||
onClick={() => setEditingUser({ ...user, email: user.email || '', phone: user.phone || '', phoneVerified: user.phoneVerified !== false, newPassword: '', confirmPassword: '' })}
|
||||
style={{
|
||||
padding: '6px 12px',
|
||||
borderRadius: '6px',
|
||||
|
|
@ -391,6 +393,28 @@ export default function Admin() {
|
|||
/>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: '16px' }}>
|
||||
<label style={{ display: 'block', color: '#94a3b8', fontSize: '13px', marginBottom: '6px' }}>手机号</label>
|
||||
<input
|
||||
type="text"
|
||||
value={editingUser.phone || ''}
|
||||
onChange={(e) => setEditingUser({ ...editingUser, phone: e.target.value })}
|
||||
style={{ width: '100%', padding: '10px', background: 'rgba(255,255,255,0.05)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '8px', color: '#fff' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: '16px' }}>
|
||||
<label style={{ display: 'flex', alignItems: 'center', color: '#94a3b8', fontSize: '13px', marginBottom: '6px', cursor: 'pointer' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={editingUser.phoneVerified === true}
|
||||
onChange={(e) => setEditingUser({ ...editingUser, phoneVerified: e.target.checked })}
|
||||
style={{ marginRight: '8px' }}
|
||||
/>
|
||||
手机号已验证
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: '16px' }}>
|
||||
<label style={{ display: 'block', color: '#94a3b8', fontSize: '13px', marginBottom: '6px' }}>角色</label>
|
||||
<select
|
||||
|
|
@ -534,18 +558,6 @@ export default function Admin() {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ marginTop: '12px' }}>
|
||||
<label style={{ display: 'flex', alignItems: 'center', color: '#94a3b8', fontSize: '13px', cursor: 'pointer' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={editingUser.phoneVerified || false}
|
||||
onChange={(e) => setEditingUser({ ...editingUser, phoneVerified: e.target.checked })}
|
||||
style={{ marginRight: '8px' }}
|
||||
/>
|
||||
手机号已认证
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: '12px' }}>
|
||||
|
|
|
|||
Loading…
Reference in New Issue