Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cicer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
meskio
cicer
Commits
85998571
Commit
85998571
authored
4 years ago
by
meskio
Browse files
Options
Downloads
Patches
Plain Diff
Make num and code the primary keys
parent
d61a9bdf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/db/member.go
+13
-10
13 additions, 10 deletions
api/db/member.go
api/db/product.go
+9
-5
9 additions, 5 deletions
api/db/product.go
with
22 additions
and
15 deletions
api/db/member.go
+
13
−
10
View file @
85998571
...
...
@@ -17,16 +17,19 @@ const (
)
type
Member
struct
{
gorm
.
Model
`json:"-"`
Num
int
`json:"num" gorm:"unique;index"`
Login
string
`json:"login" gorm:"unique;index"`
Name
string
`json:"name"`
Email
string
`json:"email"`
Phone
string
`json:"phone"`
Balance
int
`json:"balance"`
Role
string
`json:"role"`
PassHash
[]
byte
`json:"-"`
Salt
[]
byte
`json:"-"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
gorm
.
DeletedAt
`json:"-" gorm:"index"`
Num
int
`json:"num" gorm:"primaryKey"`
Login
string
`json:"login" gorm:"unique;index"`
Name
string
`json:"name"`
Email
string
`json:"email"`
Phone
string
`json:"phone"`
Balance
int
`json:"balance"`
Role
string
`json:"role"`
PassHash
[]
byte
`json:"-"`
Salt
[]
byte
`json:"-"`
}
type
PasswordReset
struct
{
...
...
This diff is collapsed.
Click to expand it.
api/db/product.go
+
9
−
5
View file @
85998571
...
...
@@ -2,16 +2,20 @@ package db
import
(
"errors"
"time"
"gorm.io/gorm"
)
type
Product
struct
{
gorm
.
Model
`json:"-"`
Code
int
`json:"code" gorm:"unique;index"`
Name
string
`json:"name" gorm:"unique;index"`
Price
int
`json:"price"`
Stock
int
`json:"stock"`
CreatedAt
time
.
Time
`json:"-"`
UpdatedAt
time
.
Time
`json:"-"`
DeletedAt
gorm
.
DeletedAt
`json:"-" gorm:"index"`
Code
int
`json:"code" gorm:"primaryKey"`
Name
string
`json:"name" gorm:"unique;index"`
Price
int
`json:"price"`
Stock
int
`json:"stock"`
}
func
(
d
*
DB
)
AddProduct
(
product
*
Product
)
error
{
...
...
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