feat(auth): 用户/角色模型与数据访问层
- constants: 用户状态、性别、角色代码常量定义 - model: User/Role/UserRole GORM 模型 - dao: UserDAO (CRUD + 账号查询) + RoleDAO (角色分配/查询/检查) - provider: Auth 模块 Wire Provider Set Made-with: Cursor
This commit is contained in:
15
backend/go-service/app/constants/role_code.go
Normal file
15
backend/go-service/app/constants/role_code.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package constants
|
||||
|
||||
// 角色代码
|
||||
const (
|
||||
RoleUser = "user" // 普通用户
|
||||
RoleAdmin = "admin" // 管理员
|
||||
RoleSuperAdmin = "super_admin" // 超级管理员
|
||||
)
|
||||
|
||||
// RoleNameMap 角色代码到中文名的映射
|
||||
var RoleNameMap = map[string]string{
|
||||
RoleUser: "普通用户",
|
||||
RoleAdmin: "管理员",
|
||||
RoleSuperAdmin: "超级管理员",
|
||||
}
|
||||
23
backend/go-service/app/constants/user_status.go
Normal file
23
backend/go-service/app/constants/user_status.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Package constants 定义系统全局常量
|
||||
package constants
|
||||
|
||||
// 用户账号状态
|
||||
const (
|
||||
UserStatusActive = 1 // 正常
|
||||
UserStatusDisabled = 2 // 禁用(管理员封禁)
|
||||
UserStatusDeleted = 3 // 注销(用户主动注销)
|
||||
)
|
||||
|
||||
// UserStatusMap 用户状态中文映射
|
||||
var UserStatusMap = map[int]string{
|
||||
UserStatusActive: "正常",
|
||||
UserStatusDisabled: "禁用",
|
||||
UserStatusDeleted: "注销",
|
||||
}
|
||||
|
||||
// 用户性别
|
||||
const (
|
||||
GenderUnknown = 0 // 未知
|
||||
GenderMale = 1 // 男
|
||||
GenderFemale = 2 // 女
|
||||
)
|
||||
Reference in New Issue
Block a user