Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jisan Ahmed
My APIs
Commits
a25c9f3e
Commit
a25c9f3e
authored
Aug 21, 2024
by
Jisan Ahmed
Browse files
clear:a trip request with bidders
parent
6d0d3e8b
Changes
26
Hide whitespace changes
Inline
Side-by-side
Todo_Using_Beego/Todo/go.sum
0 → 100644
View file @
a25c9f3e
github.com/beego/beego/v2 v2.3.0 h1:iECVwzm6egw6iw6tkWrEDqXG4NQtKLQ6QBSYqlM6T/I=
github.com/beego/beego/v2 v2.3.0/go.mod h1:Ob/5BJ9fIKZLd4s9ZV3o9J6odkkIyL83et+p98gyYXo=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 h1:DAYUYH5869yV94zvCES9F51oYtN5oGlwjxJJz7ZCnik=
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Todo_Using_Beego/Todo/main.go
0 → 100644
View file @
a25c9f3e
package
main
import
(
_
"Todo/routers"
beego
"github.com/beego/beego/v2/server/web"
)
func
main
()
{
if
beego
.
BConfig
.
RunMode
==
"dev"
{
beego
.
BConfig
.
WebConfig
.
DirectoryIndex
=
true
beego
.
BConfig
.
WebConfig
.
StaticDir
[
"/swagger"
]
=
"swagger"
}
beego
.
Run
()
}
Todo_Using_Beego/Todo/models/object.go
0 → 100644
View file @
a25c9f3e
package
models
import
(
"errors"
"strconv"
"time"
)
var
(
Objects
map
[
string
]
*
Object
)
type
Object
struct
{
ObjectId
string
Score
int64
PlayerName
string
}
func
init
()
{
Objects
=
make
(
map
[
string
]
*
Object
)
Objects
[
"hjkhsbnmn123"
]
=
&
Object
{
"hjkhsbnmn123"
,
100
,
"astaxie"
}
Objects
[
"mjjkxsxsaa23"
]
=
&
Object
{
"mjjkxsxsaa23"
,
101
,
"someone"
}
}
func
AddOne
(
object
Object
)
(
ObjectId
string
)
{
object
.
ObjectId
=
"astaxie"
+
strconv
.
FormatInt
(
time
.
Now
()
.
UnixNano
(),
10
)
Objects
[
object
.
ObjectId
]
=
&
object
return
object
.
ObjectId
}
func
GetOne
(
ObjectId
string
)
(
object
*
Object
,
err
error
)
{
if
v
,
ok
:=
Objects
[
ObjectId
];
ok
{
return
v
,
nil
}
return
nil
,
errors
.
New
(
"ObjectId Not Exist"
)
}
func
GetAll
()
map
[
string
]
*
Object
{
return
Objects
}
func
Update
(
ObjectId
string
,
Score
int64
)
(
err
error
)
{
if
v
,
ok
:=
Objects
[
ObjectId
];
ok
{
v
.
Score
=
Score
return
nil
}
return
errors
.
New
(
"ObjectId Not Exist"
)
}
func
Delete
(
ObjectId
string
)
{
delete
(
Objects
,
ObjectId
)
}
Todo_Using_Beego/Todo/models/user.go
0 → 100644
View file @
a25c9f3e
package
models
import
(
"errors"
"strconv"
"time"
)
var
(
UserList
map
[
string
]
*
User
)
func
init
()
{
UserList
=
make
(
map
[
string
]
*
User
)
u
:=
User
{
"user_11111"
,
"astaxie"
,
"11111"
,
Profile
{
"male"
,
20
,
"Singapore"
,
"astaxie@gmail.com"
}}
UserList
[
"user_11111"
]
=
&
u
}
type
User
struct
{
Id
string
Username
string
Password
string
Profile
Profile
}
type
Profile
struct
{
Gender
string
Age
int
Address
string
Email
string
}
func
AddUser
(
u
User
)
string
{
u
.
Id
=
"user_"
+
strconv
.
FormatInt
(
time
.
Now
()
.
UnixNano
(),
10
)
UserList
[
u
.
Id
]
=
&
u
return
u
.
Id
}
func
GetUser
(
uid
string
)
(
u
*
User
,
err
error
)
{
if
u
,
ok
:=
UserList
[
uid
];
ok
{
return
u
,
nil
}
return
nil
,
errors
.
New
(
"User not exists"
)
}
func
GetAllUsers
()
map
[
string
]
*
User
{
return
UserList
}
func
UpdateUser
(
uid
string
,
uu
*
User
)
(
a
*
User
,
err
error
)
{
if
u
,
ok
:=
UserList
[
uid
];
ok
{
if
uu
.
Username
!=
""
{
u
.
Username
=
uu
.
Username
}
if
uu
.
Password
!=
""
{
u
.
Password
=
uu
.
Password
}
if
uu
.
Profile
.
Age
!=
0
{
u
.
Profile
.
Age
=
uu
.
Profile
.
Age
}
if
uu
.
Profile
.
Address
!=
""
{
u
.
Profile
.
Address
=
uu
.
Profile
.
Address
}
if
uu
.
Profile
.
Gender
!=
""
{
u
.
Profile
.
Gender
=
uu
.
Profile
.
Gender
}
if
uu
.
Profile
.
Email
!=
""
{
u
.
Profile
.
Email
=
uu
.
Profile
.
Email
}
return
u
,
nil
}
return
nil
,
errors
.
New
(
"User Not Exist"
)
}
func
Login
(
username
,
password
string
)
bool
{
for
_
,
u
:=
range
UserList
{
if
u
.
Username
==
username
&&
u
.
Password
==
password
{
return
true
}
}
return
false
}
func
DeleteUser
(
uid
string
)
{
delete
(
UserList
,
uid
)
}
Todo_Using_Beego/Todo/routers/router.go
0 → 100644
View file @
a25c9f3e
// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package
routers
import
(
"Todo/controllers"
beego
"github.com/beego/beego/v2/server/web"
)
func
init
()
{
ns
:=
beego
.
NewNamespace
(
"/v1"
,
beego
.
NSNamespace
(
"/object"
,
beego
.
NSInclude
(
&
controllers
.
ObjectController
{},
),
),
beego
.
NSNamespace
(
"/user"
,
beego
.
NSInclude
(
&
controllers
.
UserController
{},
),
),
)
beego
.
AddNamespace
(
ns
)
}
Todo_Using_Beego/Todo/tests/default_test.go
0 → 100644
View file @
a25c9f3e
package
test
import
(
"net/http"
"net/http/httptest"
"testing"
"runtime"
"path/filepath"
_
"Todo/routers"
beego
"github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/core/logs"
.
"github.com/smartystreets/goconvey/convey"
)
func
init
()
{
_
,
file
,
_
,
_
:=
runtime
.
Caller
(
0
)
apppath
,
_
:=
filepath
.
Abs
(
filepath
.
Dir
(
filepath
.
Join
(
file
,
".."
+
string
(
filepath
.
Separator
))))
beego
.
TestBeegoInit
(
apppath
)
}
// TestGet is a sample to run an endpoint test
func
TestGet
(
t
*
testing
.
T
)
{
r
,
_
:=
http
.
NewRequest
(
"GET"
,
"/v1/object"
,
nil
)
w
:=
httptest
.
NewRecorder
()
beego
.
BeeApp
.
Handlers
.
ServeHTTP
(
w
,
r
)
logs
.
Info
(
"testing"
,
"TestGet"
,
"Code[%d]
\n
%s"
,
w
.
Code
,
w
.
Body
.
String
())
Convey
(
"Subject: Test Station Endpoint
\n
"
,
t
,
func
()
{
Convey
(
"Status Code Should Be 200"
,
func
()
{
So
(
w
.
Code
,
ShouldEqual
,
200
)
})
Convey
(
"The Result Should Not Be Empty"
,
func
()
{
So
(
w
.
Body
.
Len
(),
ShouldBeGreaterThan
,
0
)
})
})
}
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment