# Copyright 2026 zhaoxi826 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from sqlmodel import SQLModel, Field from enum import IntEnum class UserAuthority(IntEnum): """UserAuthority 核心组件类。 这是一个领域数据模型或功能封装类,承载了 UserAuthority 相关的内聚属性定义与状态维护。它的存在隔离了局部的业务复杂性,并对外提供了类型安全的访问接口。""" SUPER_ADMINISTRATOR = 100 ADMINISTRATOR = 50 USER = 20 UNAUTHORIZED_USER = 10 GUEST = 0 class User(SQLModel, table=True): """User 核心组件类。 这是一个领域数据模型或功能封装类,承载了 User 相关的内聚属性定义与状态维护。它的存在隔离了局部的业务复杂性,并对外提供了类型安全的访问接口。""" __tablename__ = "user" user_id: str = Field(primary_key=True) user_name: str = Field(index=True) hashed_password: str user_authority: UserAuthority = Field(default=UserAuthority.USER)