Merge pull request #261 from 1014TaoTao/2.2.0

1. 后端注册:usertype(完成)
This commit is contained in:
fastapiadmin
2025-12-19 00:22:42 +08:00
committed by GitHub
4 changed files with 33 additions and 90 deletions
@@ -386,9 +386,16 @@ class DictDataService:
返回: 返回:
- dict: 数据字典数据详情字典 - dict: 数据字典数据详情字典
""" """
exist_obj = await DictDataCRUD(auth).get(dict_label=data.dict_label) # 检查相同字典类型下dict_label是否已存在
if exist_obj: exist_label_obj = await DictDataCRUD(auth).get(dict_type=data.dict_type, dict_label=data.dict_label)
raise CustomException(msg='创建失败,该字典数据已存在') if exist_label_obj:
raise CustomException(msg=f'创建失败,该字典类型下的字典标签"{data.dict_label}"已存在')
# 检查相同字典类型下dict_value是否已存在
exist_value_obj = await DictDataCRUD(auth).get(dict_type=data.dict_type, dict_value=data.dict_value)
if exist_value_obj:
raise CustomException(msg=f'创建失败,该字典类型下的字典键值"{data.dict_value}"已存在')
obj = await DictDataCRUD(auth).create_obj_crud(data=data) obj = await DictDataCRUD(auth).create_obj_crud(data=data)
redis_key = f"{RedisInitKeyConfig.SYSTEM_DICT.key}:{data.dict_type}" redis_key = f"{RedisInitKeyConfig.SYSTEM_DICT.key}:{data.dict_type}"
@@ -427,8 +434,17 @@ class DictDataService:
if not exist_obj: if not exist_obj:
raise CustomException(msg='更新失败,该字典数据不存在') raise CustomException(msg='更新失败,该字典数据不存在')
if exist_obj.id != id: # 检查相同字典类型下dict_label是否已存在(排除当前记录)
raise CustomException(msg='更新失败,数据字典数据重复') if exist_obj.dict_label != data.dict_label:
exist_label_obj = await DictDataCRUD(auth).get(dict_type=data.dict_type, dict_label=data.dict_label)
if exist_label_obj:
raise CustomException(msg=f'更新失败,该字典类型下的字典标签"{data.dict_label}"已存在')
# 检查相同字典类型下dict_value是否已存在(排除当前记录)
if exist_obj.dict_value != data.dict_value:
exist_value_obj = await DictDataCRUD(auth).get(dict_type=data.dict_type, dict_value=data.dict_value)
if exist_value_obj:
raise CustomException(msg=f'更新失败,该字典类型下的字典键值"{data.dict_value}"已存在')
# 如果字典类型变更,仅刷新旧类型缓存,不联动字典类型状态 # 如果字典类型变更,仅刷新旧类型缓存,不联动字典类型状态
if exist_obj.dict_type != data.dict_type: if exist_obj.dict_type != data.dict_type:
@@ -427,9 +427,6 @@ class UserService:
data.name = data.username data.name = data.username
create_dict = data.model_dump(exclude_unset=True, exclude={"role_ids", "position_ids"}) create_dict = data.model_dump(exclude_unset=True, exclude={"role_ids", "position_ids"})
# 设置默认用户类型为普通用户
create_dict.setdefault("user_type", "0")
# 设置创建人ID # 设置创建人ID
if auth.user and auth.user.id: if auth.user and auth.user.id:
create_dict["created_id"] = auth.user.id create_dict["created_id"] = auth.user.id
-1
View File
@@ -104,7 +104,6 @@ FastAPI Admin 是一个基于 FastAPI 构建的企业级后台管理系统框架
- 关键字段: - 关键字段:
- username: 用户名/登录账号 - username: 用户名/登录账号
- name: 昵称 - name: 昵称
- user_type: 用户类型(0:系统用户 1:租户用户 2:客户用户)
- dept_id: 所属部门 - dept_id: 所属部门
#### 4.1.2 RoleModel (角色模型) #### 4.1.2 RoleModel (角色模型)
@@ -47,7 +47,6 @@
<div class="auth-panel__brand"> <div class="auth-panel__brand">
<div class="auth-panel__logo-wrap"> <div class="auth-panel__logo-wrap">
<!-- logo --> <!-- logo -->
<!-- <el-image :src="logo" style="width: 84px" /> -->
<el-image <el-image
:src="configStore.configData?.sys_web_logo?.config_value || ''" :src="configStore.configData?.sys_web_logo?.config_value || ''"
class="auth-panel__logo" class="auth-panel__logo"
@@ -182,9 +181,6 @@ onBeforeUnmount(() => {
height: 100%; height: 100%;
padding: clamp(1rem, 3vw, 2rem); padding: clamp(1rem, 3vw, 2rem);
overflow: hidden; overflow: hidden;
background:
radial-gradient(circle at 20% 20%, rgba(64, 128, 255, 0.18), transparent 55%),
radial-gradient(circle at 80% 80%, rgba(22, 93, 255, 0.16), transparent 50%);
&::before { &::before {
position: fixed; position: fixed;
@@ -218,7 +214,6 @@ onBeforeUnmount(() => {
box-shadow 0.3s ease; box-shadow 0.3s ease;
&:hover { &:hover {
box-shadow: 0 16px 40px rgba(22, 93, 255, 0.18);
transform: translateY(-2px); transform: translateY(-2px);
} }
@@ -232,7 +227,7 @@ onBeforeUnmount(() => {
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
background-color: rgba(24, 28, 43, 0.8); background-color: rgba(255, 255, 255, 0.6);
border-color: rgba(64, 128, 255, 0.3); border-color: rgba(64, 128, 255, 0.3);
} }
} }
@@ -263,12 +258,6 @@ onBeforeUnmount(() => {
color: rgba(20, 40, 80, 0.95); color: rgba(20, 40, 80, 0.95);
text-shadow: 0 4px 16px rgba(15, 60, 110, 0.12); text-shadow: 0 4px 16px rgba(15, 60, 110, 0.12);
animation: featureFade 0.8s ease-out; animation: featureFade 0.8s ease-out;
@media (prefers-color-scheme: dark) {
// color: rgba(236, 242, 255, 0.92);
color: rgba(160, 190, 255, 0.95);
text-shadow: none;
}
} }
@media (max-width: 768px) { @media (max-width: 768px) {
@@ -284,9 +273,6 @@ onBeforeUnmount(() => {
.auth-panel { .auth-panel {
width: 100%; width: 100%;
margin-inline: 0; margin-inline: 0;
box-shadow:
0 12px 32px rgba(22, 93, 255, 0.18),
0 2px 8px rgba(22, 93, 255, 0.12);
} }
} }
@@ -302,11 +288,6 @@ onBeforeUnmount(() => {
letter-spacing: 0.08em; letter-spacing: 0.08em;
background: rgba(22, 93, 255, 0.1); background: rgba(22, 93, 255, 0.1);
border-radius: 999px; border-radius: 999px;
@media (prefers-color-scheme: dark) {
color: rgba(160, 190, 255, 0.95);
background: rgba(64, 128, 255, 0.12);
}
} }
.auth-feature__dot { .auth-feature__dot {
@@ -315,10 +296,6 @@ onBeforeUnmount(() => {
background: #165dff; background: #165dff;
border-radius: 50%; border-radius: 50%;
box-shadow: 0 0 12px rgba(22, 93, 255, 0.7); box-shadow: 0 0 12px rgba(22, 93, 255, 0.7);
@media (prefers-color-scheme: dark) {
background: #7aa2ff;
}
} }
.auth-feature__title { .auth-feature__title {
@@ -333,10 +310,6 @@ onBeforeUnmount(() => {
font-size: 1rem; font-size: 1rem;
line-height: 1.7; line-height: 1.7;
color: rgba(35, 40, 65, 0.85); color: rgba(35, 40, 65, 0.85);
// @media (prefers-color-scheme: dark) {
// color: rgba(220, 230, 255, 0.75);
// }
} }
.auth-feature__highlights { .auth-feature__highlights {
@@ -352,9 +325,9 @@ onBeforeUnmount(() => {
align-items: flex-start; align-items: flex-start;
padding: 0.75rem 1rem; padding: 0.75rem 1rem;
font-weight: 500; font-weight: 500;
color: rgba(32, 37, 60, 0.9); color: rgba(26, 32, 48, 0.9);
background: rgba(255, 255, 255, 0.55); background: rgba(230, 236, 255, 0.85);
border: 1px solid rgba(64, 128, 255, 0.08); border: 1px solid rgba(86, 140, 255, 0.28);
border-radius: 12px; border-radius: 12px;
backdrop-filter: blur(6px); backdrop-filter: blur(6px);
@@ -364,18 +337,12 @@ onBeforeUnmount(() => {
color: rgba(22, 93, 255, 0.8); color: rgba(22, 93, 255, 0.8);
} }
} }
}
@media (prefers-color-scheme: dark) { .dark .auth-feature__highlights li {
li { color: rgba(230, 236, 255, 0.85);
color: rgba(230, 236, 255, 0.85); background: rgba(26, 32, 48, 0.9);
background: rgba(18, 22, 36, 0.7); border-color: rgba(22, 93, 255, 0.1);
border-color: rgba(98, 149, 255, 0.18);
span {
color: rgba(122, 162, 255, 0.9);
}
}
}
} }
.auth-panel { .auth-panel {
@@ -396,15 +363,6 @@ onBeforeUnmount(() => {
0 0 0 1px rgba(255, 255, 255, 0.5) inset; 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
backdrop-filter: blur(20px); backdrop-filter: blur(20px);
animation: panelLift 0.7s ease; animation: panelLift 0.7s ease;
@media (prefers-color-scheme: dark) {
background: rgba(18, 20, 32, 0.88);
border-color: rgba(64, 128, 255, 0.25);
box-shadow:
0 20px 60px rgba(0, 0, 0, 0.6),
0 4px 16px rgba(0, 0, 0, 0.4),
0 0 0 1px rgba(90, 140, 255, 0.12) inset;
}
} }
/* 应用内暗黑主题(例如 html/body 上挂 .dark 类)下的登录表单样式 */ /* 应用内暗黑主题(例如 html/body 上挂 .dark 类)下的登录表单样式 */
@@ -425,10 +383,6 @@ onBeforeUnmount(() => {
padding-bottom: 1.25rem; padding-bottom: 1.25rem;
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
border-bottom: 1px solid rgba(22, 93, 255, 0.06); border-bottom: 1px solid rgba(22, 93, 255, 0.06);
@media (prefers-color-scheme: dark) {
border-color: rgba(64, 128, 255, 0.12);
}
} }
.auth-panel__logo-wrap { .auth-panel__logo-wrap {
@@ -537,29 +491,6 @@ onBeforeUnmount(() => {
font-size: 0.875rem; font-size: 0.875rem;
text-align: center; text-align: center;
border-top: 1px solid rgba(22, 93, 255, 0.06); border-top: 1px solid rgba(22, 93, 255, 0.06);
a {
margin-left: 0.25rem;
color: rgba(22, 93, 255, 0.85);
text-decoration: none;
transition: color 0.2s ease;
&:hover {
color: rgba(22, 93, 255, 1);
}
}
@media (prefers-color-scheme: dark) {
border-color: rgba(64, 128, 255, 0.12);
a {
color: rgba(140, 170, 255, 0.88);
&:hover {
color: rgba(160, 190, 255, 1);
}
}
}
} }
@keyframes featureFade { @keyframes featureFade {