Skip to main content

Generic Organization

Generic organization is an enterprise organizational architecture management element in the JitAuth framework, implementing enterprise personnel management based on department hierarchical structure and role permission system. It handles organizational architecture maintenance, member management, and permission assignment, supporting department hierarchical management, role permission control, and member status management.

The hierarchical structure of standard organization elements is Meta (corps.Meta) → Type (corps.NormalType) → Instance. Developers can quickly create standard organization instance elements through JitAi's visual development tools.

Of course, developers can also create their own Type elements or modify the official corps.NormalType element provided by JitAi in their own App to implement their own encapsulation.

Quick Start

Creating Instance Elements

Directory Structure

Recommended directory structure for standard organization instance elements:

corps/
├── Default/ # Instance element directory (customizable)
│ ├── e.json # Element configuration file
│ └── Default.json # Business configuration file (optional)

e.json File

Basic Configuration Example
{
"allowJoin": 1,
"backendBundleEntry": ".",
"frontBundleEntry": "./Default.json",
"refSpace": false,
"title": "Default Organization Architecture",
"type": "corps.NormalType"
}

Business Configuration File

Default.json Configuration Example
{
"firstMember": {
"memberId": "admin123",
"nick": "Administrator",
"password": "admin123",
"userId": "admin123",
"username": "admin123"
}
}

Usage Example

Getting Organization Instance
# Get standard organization instance
corp = app.getElement("corps.Default")

# Initialize organization
result = corp.initCorp()

# Get organization information
corp_info = corp.getCorpInfo()
print(f"Organization Name: {corp_info['title']}")

Element Configuration

e.json Configuration

Configuration ItemTypeRequiredDescription
allowJoinintNoWhether to allow users to join, 1: allow, 0: not allow
backendBundleEntrystrYesBackend entry, fixed as "."
frontBundleEntrystrNoFrontend configuration file path
refSpaceboolNoWhether to reference space, default false
titlestrYesOrganization display name
typestrYesElement type, fixed as "corps.NormalType"

Business Configuration File

Configuration ItemTypeRequiredDescription
firstMemberdictNoFirst administrator user configuration
firstMember.memberIdstrYesMember ID
firstMember.nickstrYesDisplay nickname
firstMember.passwordstrNoLogin password
firstMember.userIdstrYesUser ID
firstMember.usernamestrNoLogin username

Methods

initCorp

Initialize organizational architecture, create root department and add first administrator user.

Parameter Details

No parameters

Return Value

TypeDescription
dictSuccess returns standard success result

Usage Example

Initialize Organization
corp = app.getElement("corps.Default")
result = corp.initCorp()

addMember

Add organization members, support setting departments and roles, can create authentication information simultaneously.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
nickStextstrYesUser display nickname
deptIdListJitListlistYesDepartment ID list
roleIdListJitListlistNoRole ID list
phonePhonestrNoPhone number
usernameStextstrNoLogin username
passwordStextstrNoLogin password (MD5 format)
memberIdStextstrNoSpecify member ID
userIdStextstrNoSpecify user ID

Return Value

TypeDescription
dictDictionary containing newly created member information

Usage Example

Add Member
corp = app.getElement("corps.Default")

# Add regular member
member_data = corp.addMember(
nick="Zhang San",
deptIdList=["dept001"],
roleIdList=["role001"],
phone="13800138000",
username="zhangsan",
password="123456"
)

createDept

Create organization department.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
nameStextstrYesDepartment name
parentIdStextstrNoParent department ID, defaults to root department

Return Value

TypeDescription
RowDataNewly created department object

Usage Example

Create Department
corp = app.getElement("corps.Default")

# Create first-level department
dept = corp.createDept(name="Technology Department")

# Create sub-department
sub_dept = corp.createDept(name="Frontend Group", parentId=dept.deptId.value)

updateDept

Update department information.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
deptIdStextstrYesDepartment ID
nameStextstrYesNew department name
parentIdStextstrNoNew parent department ID

Return Value

TypeDescription
RowDataUpdated department object

Usage Example

Update Department
corp = app.getElement("corps.Default")

# Update department name
updated_dept = corp.updateDept(
deptId="dept001",
name="Technology R&D Department"
)

deleteDept

Delete department.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
deptIdStextstrYesDepartment ID to delete

Return Value

TypeDescription
dictSuccess returns standard success result

Usage Example

Delete Department
corp = app.getElement("corps.Default")

# Delete department (ensure no sub-departments and members)
result = corp.deleteDept(deptId="dept001")

setDeptLeaderByDept

Set department leader.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
deptIdStextstrYesDepartment ID
memberIdListJitListlistYesLeader member ID list

Return Value

TypeDescription
listUpdated department member relationship list

Usage Example

Set Department Leader
corp = app.getElement("corps.Default")

# Set department leader
leaders = corp.setDeptLeaderByDept(
deptId="dept001",
memberIdList=["member001", "member002"]
)

createRole

Create role.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
nameStextstrYesRole name
roleGroupIdStextstrYesRole group ID

Return Value

TypeDescription
RowDataNewly created role object

Usage Example

Create Role
corp = app.getElement("corps.Default")

# Create role
role = corp.createRole(
name="Project Manager",
roleGroupId="group001"
)

updateUserInfo

Update member information.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
memberIdStextstrYesMember ID
**updateDictJitDictdictYesUpdate field dictionary

Allowed update fields: nick, phone, email, photo, gender, extendConf

Return Value

No return value

Usage Example

Update Member Information
corp = app.getElement("corps.Default")

# Update member information
corp.updateUserInfo(
memberId="member001",
nick="Li Si",
phone="13900139000",
email="lisi@example.com"
)

changeMemberStatus

Batch modify member status.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
memberIdListJitListlistYesMember ID list
statusNumericintYesTarget status, 1: active, 2: resigned

Return Value

No return value

Usage Example

Modify Member Status
corp = app.getElement("corps.Default")

# Set members as resigned
corp.changeMemberStatus(
memberIdList=["member001", "member002"],
status=2
)

setAdmin

Set organization administrators.

Parameter Details

Parameter NameTypeCorresponding Native TypeRequiredDescription
memberIdListJitListlistYesAdministrator member ID list

Return Value

TypeDescription
dictEmpty dictionary

Usage Example

Set Administrators
corp = app.getElement("corps.Default")

# Set administrators
corp.setAdmin(memberIdList=["member001"])

getAdmin

Get organization administrator list.

Parameter Details

No parameters

Return Value

TypeDescription
listAdministrator member ID list

Usage Example

Get Administrators
corp = app.getElement("corps.Default")

# Get administrator list
admins = corp.getAdmin()
print(f"Administrators: {admins}")

getLocalCorpData

Get complete organizational architecture data.

Parameter Details

No parameters

Return Value

TypeDescription
dictDictionary containing complete organization information

Return data structure:

  • corp: Organization basic information
  • userList: Active user list
  • deptList: Department list (including path information)
  • deptMemberList: Department member relationship list
  • roleList: Role list
  • roleGroupList: Role group list
  • roleMemberSet: Role member relationship list

Usage Example

Get Organization Data
corp = app.getElement("corps.Default")

# Get complete organization data
corp_data = corp.getLocalCorpData()
print(f"User count: {len(corp_data['userList'])}")
print(f"Department count: {len(corp_data['deptList'])}")

Properties

corpFullName

Organization full name, equivalent to fullName property.

title

Organization display title.

fullName

Organization element fullName identifier.

Advanced Features

Organization Initialization Process

Generic organization supports complete initialization process, including root department creation and first administrator addition:

Complete Initialization Example
corp = app.getElement("corps.Default")

# Execute initialization
corp.initCorp()

# Verify initialization result
admins = corp.getAdmin()
corp_data = corp.getLocalCorpData()

print(f"Administrators: {admins}")
print(f"Root Department: {corp_data['deptList'][0]['name']}")

Batch Operation Support

Supports batch management of department members and role members:

Batch Operation Example
corp = app.getElement("corps.Default")

# Batch add department members
corp.addDeptMember(
deptId="dept001",
memberIdList=["member001", "member002", "member003"]
)

# Batch delete department members
corp.deleteDeptMember(
deptId="dept001",
memberIdList=["member003"]
)

# Batch add role members
corp.addRoleMember(
roleId="role001",
memberIdList=["member001", "member002"]
)

Permission and Status Management

Supports fine-grained permission control and member status management:

Permission Management Example
corp = app.getElement("corps.Default")

# Set department restrictions
corp.setDeptLimit(
roleId="role001",
memberId="member001",
deptIdList=["dept001", "dept002"]
)

# Change member status to resigned
corp.changeMemberStatus(
memberIdList=["member002"],
status=2 # Resigned status
)

# Delete resigned members
corp.deleteMember(memberIdList=["member002"])
JitAI AssistantBeta
Powered by JitAI