Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ELC_elections
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gestion-des-assemblees
ELC_elections
Commits
93941b77
Commit
93941b77
authored
4 years ago
by
Alexis Poyen
Browse files
Options
Downloads
Patches
Plain Diff
Feat : add models for elections
parent
2d18b6c5
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Resolve "Data model"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/models/models.go
+139
-0
139 additions, 0 deletions
internal/models/models.go
with
139 additions
and
0 deletions
internal/models/models.go
+
139
−
0
View file @
93941b77
...
@@ -3,6 +3,7 @@ package models
...
@@ -3,6 +3,7 @@ package models
import
(
import
(
"net/http"
"net/http"
"strings"
"strings"
"time"
"github.com/jinzhu/gorm"
"github.com/jinzhu/gorm"
...
@@ -30,6 +31,144 @@ const ErrorRoleOfLoggedUser = "Could not get role of logged user"
...
@@ -30,6 +31,144 @@ const ErrorRoleOfLoggedUser = "Could not get role of logged user"
// ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource."
// ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource."
const
ErrorNotAuthorizeMethodOnRessource
=
"You're not authorize to execute this method on this ressource."
const
ErrorNotAuthorizeMethodOnRessource
=
"You're not authorize to execute this method on this ressource."
type
election
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
name
string
ballotType
string
areas
[]
area
Rounds
[]
Round
}
type
area
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
electionID
uint
name
string
seatNumber
uint
mapID
string
sections
[]
section
}
type
section
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
areaID
uint
name
string
seatNumber
uint
mapID
string
desks
[]
desk
}
type
desk
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
sectionID
uint
name
string
subscribed
uint
witnessDesk
bool
}
type
party
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
name
string
color
string
candidateList
[]
candidateList
}
type
capturer
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
userID
int
`gorm:"not null;unique"`
name
string
deskRounds
[]
deskRound
}
type
parameter
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
roundID
round
countBalnkAndNull
bool
showOnlyCompleted
bool
showMap
bool
}
type
round
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
ElectionID
uint
parameter
parameter
name
string
date
time
.
Time
tour
uint
deskRounds
[]
deskRound
}
type
deskRound
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
RoundID
uint
completed
bool
dateCompletion
time
.
Time
validated
bool
Votes
[]
Vote
}
type
candidateList
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
PartyID
uint
name
string
candidates
[]
candidate
Votes
[]
Vote
}
type
candidate
struct
{
ID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
candidateListID
uint
fullName
string
rank
uint
communityCounseller
bool
birthdate
time
.
Time
potentialIncompatibility
bool
refused
bool
removed
bool
}
type
vote
struct
{
deskRoundID
uint
`gorm:"primary_key"`
candidateListID
uint
`gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
*
time
.
Time
`json:"-"`
voiceNumber
uint
blank
bool
null
bool
}
// NewDataHandler init a DataHandler and returns a pointer to it
// NewDataHandler init a DataHandler and returns a pointer to it
func
NewDataHandler
()
*
DataHandler
{
func
NewDataHandler
()
*
DataHandler
{
db
,
err
:=
gorm
.
Open
(
"sqlite3"
,
"./data/test.db"
)
db
,
err
:=
gorm
.
Open
(
"sqlite3"
,
"./data/test.db"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment