...
This commit is contained in:
@@ -1,81 +0,0 @@
|
||||
module heromodels
|
||||
|
||||
import time
|
||||
import crypto.blake3
|
||||
import json
|
||||
|
||||
// Group represents a collection of users with roles and permissions
|
||||
@[heap]
|
||||
pub struct Group {
|
||||
pub mut:
|
||||
id string // blake192 hash
|
||||
name string
|
||||
description string
|
||||
members []GroupMember
|
||||
subgroups []string // IDs of child groups
|
||||
parent_group string // ID of parent group
|
||||
created_at i64
|
||||
updated_at i64
|
||||
is_public bool
|
||||
tags []string
|
||||
}
|
||||
|
||||
pub struct GroupMember {
|
||||
pub mut:
|
||||
user_id string
|
||||
role GroupRole
|
||||
joined_at i64
|
||||
}
|
||||
|
||||
pub enum GroupRole {
|
||||
reader
|
||||
writer
|
||||
admin
|
||||
owner
|
||||
}
|
||||
|
||||
pub fn (mut g Group) calculate_id() {
|
||||
content := json.encode(GroupContent{
|
||||
name: g.name
|
||||
description: g.description
|
||||
members: g.members
|
||||
subgroups: g.subgroups
|
||||
parent_group: g.parent_group
|
||||
is_public: g.is_public
|
||||
tags: g.tags
|
||||
})
|
||||
hash := blake3.sum256(content.bytes())
|
||||
g.id = hash.hex()[..48]
|
||||
}
|
||||
|
||||
struct GroupContent {
|
||||
name string
|
||||
description string
|
||||
members []GroupMember
|
||||
subgroups []string
|
||||
parent_group string
|
||||
is_public bool
|
||||
tags []string
|
||||
}
|
||||
|
||||
pub fn new_group(name string, description string) Group {
|
||||
mut group := Group{
|
||||
name: name
|
||||
description: description
|
||||
created_at: time.now().unix()
|
||||
updated_at: time.now().unix()
|
||||
is_public: false
|
||||
}
|
||||
group.calculate_id()
|
||||
return group
|
||||
}
|
||||
|
||||
pub fn (mut g Group) add_member(user_id string, role GroupRole) {
|
||||
g.members << GroupMember{
|
||||
user_id: user_id
|
||||
role: role
|
||||
joined_at: time.now().unix()
|
||||
}
|
||||
g.updated_at = time.now().unix()
|
||||
g.calculate_id()
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
module heromodels
|
||||
|
||||
import time
|
||||
import crypto.blake3
|
||||
import json
|
||||
|
||||
// Project represents a collection of issues organized in swimlanes
|
||||
@[heap]
|
||||
pub struct Project {
|
||||
pub mut:
|
||||
id string // blake192 hash
|
||||
name string
|
||||
description string
|
||||
group_id string // Associated group for permissions
|
||||
swimlanes []Swimlane
|
||||
milestones []Milestone
|
||||
issues []string // IDs of project issues
|
||||
fs_files []string // IDs of linked files
|
||||
status ProjectStatus
|
||||
start_date i64
|
||||
end_date i64
|
||||
created_at i64
|
||||
updated_at i64
|
||||
tags []string
|
||||
}
|
||||
|
||||
pub struct Swimlane {
|
||||
pub mut:
|
||||
id string
|
||||
name string
|
||||
description string
|
||||
order int
|
||||
color string
|
||||
is_done bool
|
||||
}
|
||||
|
||||
pub struct Milestone {
|
||||
pub mut:
|
||||
id string
|
||||
name string
|
||||
description string
|
||||
due_date i64
|
||||
completed bool
|
||||
issues []string // IDs of issues in this milestone
|
||||
}
|
||||
|
||||
pub enum ProjectStatus {
|
||||
planning
|
||||
active
|
||||
on_hold
|
||||
completed
|
||||
cancelled
|
||||
}
|
||||
|
||||
pub fn (mut p Project) calculate_id() {
|
||||
content := json.encode(ProjectContent{
|
||||
name: p.name
|
||||
description: p.description
|
||||
group_id: p.group_id
|
||||
swimlanes: p.swimlanes
|
||||
milestones: p.milestones
|
||||
issues: p.issues
|
||||
fs_files: p.fs_files
|
||||
status: p.status
|
||||
start_date: p.start_date
|
||||
end_date: p.end_date
|
||||
tags: p.tags
|
||||
})
|
||||
hash := blake3.sum256(content.bytes())
|
||||
p.id = hash.hex()[..48]
|
||||
}
|
||||
|
||||
struct ProjectContent {
|
||||
name string
|
||||
description string
|
||||
group_id string
|
||||
swimlanes []Swimlane
|
||||
milestones []Milestone
|
||||
issues []string
|
||||
fs_files []string
|
||||
status ProjectStatus
|
||||
start_date i64
|
||||
end_date i64
|
||||
tags []string
|
||||
}
|
||||
|
||||
pub struct NewProject {
|
||||
pub mut:
|
||||
name string
|
||||
description string
|
||||
group_id string
|
||||
}
|
||||
|
||||
pub fn new_project(params NewProject) !Project {
|
||||
mut project := Project{
|
||||
name: params.name
|
||||
description: params.description
|
||||
group_id: params.group_id
|
||||
status: .planning
|
||||
created_at: time.now().unix()
|
||||
updated_at: time.now().unix()
|
||||
swimlanes: [
|
||||
Swimlane{id: 'todo', name: 'To Do', order: 1, color: '#f1c40f'},
|
||||
Swimlane{id: 'in_progress', name: 'In Progress', order: 2, color: '#3498db'},
|
||||
Swimlane{id: 'done', name: 'Done', order: 3, color: '#2ecc71', is_done: true}
|
||||
]
|
||||
}
|
||||
project.calculate_id()
|
||||
return project
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
module heromodels
|
||||
|
||||
import time
|
||||
import crypto.blake3
|
||||
import json
|
||||
|
||||
// ProjectIssue represents a task, story, bug, or question in a project
|
||||
@[heap]
|
||||
pub struct ProjectIssue {
|
||||
pub mut:
|
||||
id string // blake192 hash
|
||||
title string
|
||||
description string
|
||||
project_id string // Associated project
|
||||
issue_type IssueType
|
||||
priority IssuePriority
|
||||
status IssueStatus
|
||||
swimlane_id string // Current swimlane
|
||||
assignees []string // User IDs
|
||||
reporter string // User ID who created the issue
|
||||
milestone_id string // Associated milestone
|
||||
deadline i64 // Unix timestamp
|
||||
estimate int // Story points or hours
|
||||
fs_files []string // IDs of linked files
|
||||
parent_id string // Parent issue ID (for sub-tasks)
|
||||
children []string // Child issue IDs
|
||||
created_at i64
|
||||
updated_at i64
|
||||
tags []string
|
||||
}
|
||||
|
||||
pub enum IssueType {
|
||||
task
|
||||
story
|
||||
bug
|
||||
question
|
||||
epic
|
||||
subtask
|
||||
}
|
||||
|
||||
pub enum IssuePriority {
|
||||
lowest
|
||||
low
|
||||
medium
|
||||
high
|
||||
highest
|
||||
critical
|
||||
}
|
||||
|
||||
pub enum IssueStatus {
|
||||
open
|
||||
in_progress
|
||||
blocked
|
||||
review
|
||||
testing
|
||||
done
|
||||
closed
|
||||
}
|
||||
|
||||
pub fn (mut i ProjectIssue) calculate_id() {
|
||||
content := json.encode(IssueContent{
|
||||
title: i.title
|
||||
description: i.description
|
||||
project_id: i.project_id
|
||||
issue_type: i.issue_type
|
||||
priority: i.priority
|
||||
status: i.status
|
||||
swimlane_id: i.swimlane_id
|
||||
assignees: i.assignees
|
||||
reporter: i.reporter
|
||||
milestone_id: i.milestone_id
|
||||
deadline: i.deadline
|
||||
estimate: i.estimate
|
||||
fs_files: i.fs_files
|
||||
parent_id: i.parent_id
|
||||
children: i.children
|
||||
tags: i.tags
|
||||
})
|
||||
hash := blake3.sum256(content.bytes())
|
||||
i.id = hash.hex()[..48]
|
||||
}
|
||||
|
||||
struct IssueContent {
|
||||
title string
|
||||
description string
|
||||
project_id string
|
||||
issue_type IssueType
|
||||
priority IssuePriority
|
||||
status IssueStatus
|
||||
swimlane_id string
|
||||
assignees []string
|
||||
reporter string
|
||||
milestone_id string
|
||||
deadline i64
|
||||
estimate int
|
||||
fs_files []string
|
||||
parent_id string
|
||||
children []string
|
||||
tags []string
|
||||
}
|
||||
|
||||
pub fn new_project_issue(title string, project_id string, reporter string, issue_type IssueType) ProjectIssue {
|
||||
mut issue := ProjectIssue{
|
||||
title: title
|
||||
project_id: project_id
|
||||
reporter: reporter
|
||||
issue_type: issue_type
|
||||
priority: .medium
|
||||
status: .open
|
||||
swimlane_id: 'todo'
|
||||
created_at: time.now().unix()
|
||||
updated_at: time.now().unix()
|
||||
}
|
||||
issue.calculate_id()
|
||||
return issue
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
module heromodels
|
||||
|
||||
import time
|
||||
import crypto.blake3
|
||||
import json
|
||||
|
||||
// User represents a person in the system
|
||||
@[heap]
|
||||
pub struct User {
|
||||
pub mut:
|
||||
id string // blake192 hash
|
||||
name string
|
||||
email string
|
||||
public_key string // for encryption/signing
|
||||
phone string
|
||||
address string
|
||||
avatar_url string
|
||||
bio string
|
||||
timezone string
|
||||
created_at i64
|
||||
updated_at i64
|
||||
status UserStatus
|
||||
}
|
||||
|
||||
pub enum UserStatus {
|
||||
active
|
||||
inactive
|
||||
suspended
|
||||
pending
|
||||
}
|
||||
42
lib/hero/heromodels/project.v
Normal file
42
lib/hero/heromodels/project.v
Normal file
@@ -0,0 +1,42 @@
|
||||
module heromodels
|
||||
|
||||
import time
|
||||
|
||||
// Project represents a collection of issues organized in swimlanes
|
||||
@[heap]
|
||||
pub struct Project {
|
||||
pub mut:
|
||||
swimlanes []Swimlane
|
||||
milestones []Milestone
|
||||
issues []string // IDs of project issues
|
||||
fs_files []u32 // IDs of linked files or dirs
|
||||
status ProjectStatus
|
||||
start_date i64
|
||||
end_date i64
|
||||
}
|
||||
|
||||
pub struct Swimlane {
|
||||
pub mut:
|
||||
name string //allways to to_lower and trim_space
|
||||
description string
|
||||
order int
|
||||
color string
|
||||
is_done bool
|
||||
}
|
||||
|
||||
pub struct Milestone {
|
||||
pub mut:
|
||||
name string //allways to to_lower and trim_space
|
||||
description string
|
||||
due_date i64
|
||||
completed bool
|
||||
issues []u32 // IDs of issues in this milestone
|
||||
}
|
||||
|
||||
pub enum ProjectStatus {
|
||||
planning
|
||||
active
|
||||
on_hold
|
||||
completed
|
||||
cancelled
|
||||
}
|
||||
53
lib/hero/heromodels/project_issue.v
Normal file
53
lib/hero/heromodels/project_issue.v
Normal file
@@ -0,0 +1,53 @@
|
||||
module heromodels
|
||||
|
||||
import time
|
||||
import crypto.blake3
|
||||
import json
|
||||
|
||||
// ProjectIssue represents a task, story, bug, or question in a project
|
||||
@[heap]
|
||||
pub struct ProjectIssue {
|
||||
pub mut:
|
||||
title string
|
||||
project_id u32 // Associated project
|
||||
issue_type IssueType
|
||||
priority IssuePriority
|
||||
status IssueStatus
|
||||
swimlane string // Current swimlane, is string corresponds to name, need to be to_lower and trim_space
|
||||
assignees []u32 // User IDs
|
||||
reporter u32 // User ID who created the issue
|
||||
milestone string // Associated milestone, is string corresponds to name, need to be to_lower and trim_space
|
||||
deadline i64 // Unix timestamp
|
||||
estimate int // Story points or hours
|
||||
fs_files []u32 // IDs of linked files
|
||||
parent_id u32 // Parent issue ID (for sub-tasks)
|
||||
children []u32 // Child issue IDs
|
||||
}
|
||||
|
||||
pub enum IssueType {
|
||||
task
|
||||
story
|
||||
bug
|
||||
question
|
||||
epic
|
||||
subtask
|
||||
}
|
||||
|
||||
pub enum IssuePriority {
|
||||
lowest
|
||||
low
|
||||
medium
|
||||
high
|
||||
highest
|
||||
critical
|
||||
}
|
||||
|
||||
pub enum IssueStatus {
|
||||
open
|
||||
in_progress
|
||||
blocked
|
||||
review
|
||||
testing
|
||||
done
|
||||
closed
|
||||
}
|
||||
Reference in New Issue
Block a user