Skip to content

User Management

The user management module provides complete CRUD operations for system users, including department-based filtering, status control, password management, and role assignment.

Features

  • User list with pagination, search, and department tree filter
  • Create / edit / delete users
  • Enable / disable user accounts
  • Reset user passwords
  • Assign roles to users
  • Department-based organization

Data Model

The SysUser entity (sys_user table) contains:

FieldTypeDescription
userIdLongPrimary key (auto-increment)
usernameStringLogin username (unique)
nicknameStringDisplay name
emailStringEmail address
phoneStringPhone number
sexIntegerGender (0: female, 1: male)
avatarStringAvatar URL
passwordStringBCrypt-hashed password
statusIntegerAccount status (0: disabled, 1: enabled)
deptIdLongDepartment ID (foreign key)
remarkStringNotes
createTimeDateTimeCreation timestamp
updateTimeDateTimeLast update timestamp

API Endpoints

Admin API (AdminApiController)

MethodEndpointDescription
POST/admin-api/userList users (paginated, with filters)
POST/admin-api/user/createCreate a new user
PUT/admin-api/user/updateUpdate user info
POST/admin-api/user/deleteDelete user(s)
POST/admin-api/user/statusToggle user status
POST/admin-api/user/reset-passwordReset user password
POST/admin-api/user/assign-roleAssign roles to user

RESTful API (SysUserController)

MethodEndpointDescription
GET/system/userList all users
GET/system/user/{id}Get user by ID
GET/system/user/username/{username}Get user by username
POST/system/userCreate user
PUT/system/user/{id}Update user
DELETE/system/user/{id}Delete user
POST/system/user/{id}/reset-passwordReset password
GET/system/user/activeList active users
GET/system/user/dept/{deptId}List users by department

Department Tree Filter

The user list page includes a department tree on the left side. Clicking a department node filters users belonging to that department and its children. The tree data comes from the SysDept entity.

Password Security

  • Passwords are encrypted with BCrypt before storage
  • The frontend encrypts the password with RSA (using the server's public key) before transmitting
  • The server decrypts with the RSA private key, then hashes with BCrypt
  • The RSA private key is configured in arch-smith.rsa-private-key

Service Layer

The SysUserService and UserService classes handle business logic:

  • Username uniqueness validation
  • Department existence check
  • Default role assignment on creation
  • QueryDSL-based dynamic filtering (SysUserPredicates)

Released under the MIT License.