add json annotations for model

This commit is contained in:
yinw 2016-02-26 16:07:20 +08:00
parent 61f12f089d
commit 3229d9ea45
7 changed files with 19 additions and 23 deletions

View File

@ -16,7 +16,6 @@ package dao
import (
"fmt"
// "fmt"
"log"
"os"
"testing"
@ -116,11 +115,8 @@ func TestMain(m *testing.M) {
os.Setenv("MYSQL_USR", dbUser)
os.Setenv("MYSQL_PWD", dbPassword)
os.Setenv("AUTH_MODE", "db_auth")
fmt.Println("a")
InitDB()
fmt.Println("b")
clearUp(username)
fmt.Println("c")
os.Exit(m.Run())
}

View File

@ -19,11 +19,11 @@ import (
)
type AccessLog struct {
LogID int `orm:"column(log_id)"`
UserID int `orm:"column(user_id)"`
ProjectID int64 `orm:"column(project_id)"`
LogID int `orm:"column(log_id)" json:"LogId"`
UserID int `orm:"column(user_id)" json:"UserId"`
ProjectID int64 `orm:"column(project_id)" json:"ProjectId"`
RepoName string `orm:"column(repo_name)"`
GUID string `orm:"column(GUID)"`
GUID string `orm:"column(GUID)" json:"Guid"`
Operation string `orm:"column(operation)"`
OpTime time.Time `orm:"column(op_time)"`
Username string

View File

@ -23,7 +23,7 @@ type Notification struct {
}
type Event struct {
ID string
ID string `json:"Id"`
TimeStamp time.Time
Action string
Target *Target
@ -35,7 +35,7 @@ type Target struct {
MediaType string
Digest string
Repository string
URL string
URL string `json:"Url"`
}
type Actor struct {
@ -43,7 +43,7 @@ type Actor struct {
}
type Request struct {
ID string
ID string `json:"Id"`
Method string
UserAgent string
}

View File

@ -19,13 +19,13 @@ import (
)
type Project struct {
ProjectID int64 `orm:"column(project_id)"`
OwnerID int `orm:"column(owner_id)"`
ProjectID int64 `orm:"column(project_id)" json:"ProjectId"`
OwnerID int `orm:"column(owner_id)" json:"OwnerId"`
Name string `orm:"column(name)"`
CreationTime time.Time `orm:"column(creation_time)"`
CreationTimeStr string
Deleted int `orm:"column(deleted)"`
UserID int
UserID int `json:"UserId"`
OwnerName string
Public int `orm:"column(public)"`
//This field does not have correspondent column in DB, this is just for UI to disable button

View File

@ -15,7 +15,7 @@
package models
type ProjectRole struct {
PrID int `orm:"column(pr_id)"`
ProjectID int64 `orm:"column(project_id)"`
RoleID int `orm:"column(role_id)"`
PrID int `orm:"column(pr_id)" json:"PrId"`
ProjectID int64 `orm:"column(project_id)" json:"ProjectId"`
RoleID int `orm:"column(role_id)" json:"RoleId"`
}

View File

@ -15,7 +15,7 @@
package models
type User struct {
UserID int `orm:"column(user_id)"`
UserID int `orm:"column(user_id)" json:"UserId"`
Username string `orm:"column(username)"`
Email string `orm:"column(email)"`
Password string `orm:"column(password)"`
@ -23,9 +23,9 @@ type User struct {
Comment string `orm:"column(comment)"`
Deleted int `orm:"column(deleted)"`
Rolename string
RoleID int
RoleID int `json:"RoleId"`
RoleList []Role
HasAdminRole int
ResetUUID string `orm:"column(reset_uuid)"`
ResetUUID string `orm:"column(reset_uuid)" json:"ResetUuid"`
Salt string `orm:"column(salt)"`
}

View File

@ -15,7 +15,7 @@
package models
type UserProjectRole struct {
UprID int `orm:"column(upr_id)"`
UserID int `orm:"column(user_id)"`
PrID int64 `orm:"column(pr_id)"`
UprID int `orm:"column(upr_id)" json:"UprId"`
UserID int `orm:"column(user_id)" json:"UserId"`
PrID int64 `orm:"column(pr_id)" json:"PrId"`
}