Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bwallet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Go
bwallet
Commits
f076c5b0
Commit
f076c5b0
authored
Dec 15, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
客户端app权限
parent
5d033468
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
345 additions
and
100 deletions
+345
-100
client_app.go
models/client_app.go
+108
-0
user.go
models/user.go
+0
-0
errno.go
pkg/errno/errno.go
+0
-0
client-app.go
routers/api/app/client-app.go
+42
-0
router.go
routers/router.go
+3
-1
client_app.go
service/client_app_service/client_app.go
+93
-0
live_info.go
service/streamer_service/live_info.go
+0
-99
user.go
service/user_service/user.go
+99
-0
No files found.
models/client_app.go
0 → 100644
View file @
f076c5b0
package
models
import
(
"bwallet/pkg/setting"
"github.com/jinzhu/gorm"
"time"
)
type
ClientApp
struct
{
Model
Type
uint8
`gorm:"not null;default:0" json:"type"`
BundleId
string
`gorm:"type:varchar(128)" json:"bundle_id,omitempty"`
AppSignature
string
`gorm:"type:varchar(128)" json:"app_signature,omitempty"`
AppPackage
string
`gorm:"type:varchar(128)" json:"app_package,omitempty"`
AppSecret
string
`gorm:"type:varchar(128)" json:"app_secret,omitempty"`
CreatedAt
int64
`gorm:"type:datetime" json:"created_at,omitempty"`
Deadline
int64
`gorm:"type:datetime" json:"deadline,omitempty"`
}
func
(
a
ClientApp
)
TableName
()
string
{
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_client_app"
}
func
GetClientApp
(
id
int32
)
(
*
ClientApp
,
error
)
{
var
app
ClientApp
err
:=
db
.
Where
(
"id = ?"
,
id
)
.
First
(
&
app
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
err
=
db
.
Model
(
&
app
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
&
app
,
nil
}
func
ExistClientAppById
(
id
int32
)
(
bool
,
error
)
{
var
app
ClientApp
err
:=
db
.
Select
(
"id"
)
.
Where
(
"id = ?"
,
id
)
.
First
(
&
app
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
false
,
err
}
if
app
.
ID
>
0
{
return
true
,
nil
}
return
false
,
nil
}
func
GetClientAppTotal
(
maps
interface
{})
(
int
,
error
)
{
var
count
int
if
err
:=
db
.
Model
(
&
ClientApp
{})
.
Where
(
maps
)
.
Count
(
&
count
)
.
Error
;
err
!=
nil
{
return
0
,
err
}
return
count
,
nil
}
func
GetClientApps
(
pageNum
,
pageSize
int
,
maps
interface
{})
([]
*
ClientApp
,
error
)
{
var
app
[]
*
ClientApp
err
:=
db
.
Where
(
maps
)
.
Order
(
"created_at desc"
)
.
Offset
(
pageNum
)
.
Limit
(
pageSize
)
.
Find
(
&
app
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
app
,
nil
}
func
AddClientApp
(
data
map
[
string
]
interface
{})
(
error
)
{
app
:=
ClientApp
{
Type
:
data
[
"type"
]
.
(
uint8
),
BundleId
:
data
[
"bundle_id"
]
.
(
string
),
AppSignature
:
data
[
"app_signature"
]
.
(
string
),
AppPackage
:
data
[
"app_package"
]
.
(
string
),
AppSecret
:
data
[
"app_secret"
]
.
(
string
),
CreatedAt
:
time
.
Now
()
.
Unix
(),
Deadline
:
data
[
"deadline"
]
.
(
int64
),
}
if
err
:=
db
.
Create
(
&
app
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
EditClientApp
(
id
int32
,
data
interface
{})
error
{
if
err
:=
db
.
Model
(
&
ClientApp
{})
.
Where
(
"id = ?"
,
id
)
.
Updates
(
data
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
DeleteClientApp
(
id
int32
)
error
{
if
err
:=
db
.
Where
(
"id = ?"
,
id
)
.
Delete
(
ClientApp
{})
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
models/
stream
er.go
→
models/
us
er.go
View file @
f076c5b0
File moved
pkg/errno/errno.go
View file @
f076c5b0
This diff is collapsed.
Click to expand it.
routers/api/app/client-app.go
0 → 100644
View file @
f076c5b0
package
app
import
(
"bwallet/pkg/errno"
"bwallet/pkg/handler"
"bwallet/pkg/util"
"bwallet/service/client_app_service"
"github.com/gin-gonic/gin"
)
func
AppSecret
(
c
*
gin
.
Context
)
{
arg
:=
c
.
Query
(
"secret"
)
if
arg
==
""
{
handler
.
SendResponse
(
c
,
errno
.
ErrValidation
,
nil
)
return
}
app_service
:=
client_app_service
.
ClientApp
{
AppSecret
:
arg
,
PageNum
:
util
.
GetPage
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
}
total
,
err
:=
app_service
.
Count
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCountClientApp
,
nil
)
return
}
if
0
==
total
{
handler
.
SendResponse
(
c
,
errno
.
ErrClientAppNotFound
,
nil
)
return
}
app
,
err
:=
app_service
.
GetAll
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
app
[
0
]
.
Deadline
)
}
routers/router.go
View file @
f076c5b0
...
...
@@ -28,13 +28,15 @@ func InitRouter() *gin.Engine {
//r.POST("/upload", api.UploadImage)
client
:=
r
.
Group
(
"/interface"
)
client
.
Use
(
aes
.
Aes
())
client
.
GET
(
"/news"
,
app
.
GetNews
)
client
.
GET
(
"/one-news"
,
app
.
GetOneNews
)
client
.
GET
(
"/articles"
,
app
.
GetArticle
)
client
.
GET
(
"/article"
,
app
.
GetOneArticle
)
client
.
GET
(
"/live-categories"
,
app
.
GetLiveCategories
)
client
.
GET
(
"/transaction-fee"
,
app
.
GetTransactionFee
)
client
.
GET
(
"/secret"
,
app
.
AppSecret
)
client
.
Use
(
aes
.
Aes
())
client
.
POST
(
"/user"
,
app
.
AddUser
)
api
:=
r
.
Group
(
"/api"
)
...
...
service/client_app_service/client_app.go
0 → 100644
View file @
f076c5b0
package
client_app_service
import
(
"bwallet/models"
)
type
ClientApp
struct
{
Id
int32
`json:"omitempty"`
Type
uint8
`json:"omitempty"`
BundleId
string
`json:"omitempty"`
AppSignature
string
`json:"omitempty"`
AppPackage
string
`json:"omitempty"`
AppSecret
string
`json:"omitempty"`
CreatedAt
int64
Deadline
int64
PageNum
int
PageSize
int
}
func
(
a
*
ClientApp
)
GetClientApp
()
(
*
models
.
ClientApp
,
error
)
{
app
,
err
:=
models
.
GetClientApp
(
a
.
Id
)
if
err
!=
nil
{
return
nil
,
err
}
return
app
,
nil
}
func
(
a
*
ClientApp
)
GetAll
()
([]
*
models
.
ClientApp
,
error
)
{
var
app
[]
*
models
.
ClientApp
app
,
err
:=
models
.
GetClientApps
(
a
.
PageNum
,
a
.
PageSize
,
a
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
return
app
,
nil
}
func
(
a
*
ClientApp
)
Add
()
error
{
app
:=
map
[
string
]
interface
{}{
"type"
:
a
.
Type
,
"bundle_id"
:
a
.
BundleId
,
"app_signature"
:
a
.
AppSignature
,
"app_package"
:
a
.
AppPackage
,
"app_secret"
:
a
.
AppSecret
,
"deadline"
:
a
.
Deadline
,
}
if
err
:=
models
.
AddClientApp
(
app
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
a
*
ClientApp
)
Edit
()
error
{
return
models
.
EditClientApp
(
a
.
Id
,
map
[
string
]
interface
{}{
"type"
:
a
.
Type
,
"bundle_id"
:
a
.
BundleId
,
"app_signature"
:
a
.
AppSignature
,
"app_package"
:
a
.
AppPackage
,
"app_secret"
:
a
.
AppSecret
,
"deadline"
:
a
.
Deadline
,
})
}
func
(
a
*
ClientApp
)
ExistById
()
(
bool
,
error
)
{
return
models
.
ExistClientAppById
(
a
.
Id
)
}
func
(
a
*
ClientApp
)
Count
()
(
int
,
error
)
{
return
models
.
GetClientAppTotal
(
a
.
getMaps
())
}
func
(
a
*
ClientApp
)
Delete
()
error
{
return
models
.
DeleteClientApp
(
a
.
Id
)
}
func
(
a
*
ClientApp
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
if
a
.
Id
!=
0
{
maps
[
"id"
]
=
a
.
Id
}
if
a
.
AppSecret
!=
""
{
maps
[
"app_secret"
]
=
a
.
AppSecret
}
return
maps
}
service/streamer_service/live_info.go
deleted
100644 → 0
View file @
5d033468
package
streamer_service
import
(
"bwallet/models"
)
type
Streamer
struct
{
Uid
int32
UserName
string
NickName
string
Password
string
RegTime
int64
LastLoginTime
int64
RegIp
uint32
LastLoginIp
uint32
Status
uint8
PlatformId
int64
PageNum
int
PageSize
int
}
func
(
s
*
Streamer
)
GetOneStreamer
()
(
*
models
.
Streamer
,
error
)
{
streamer
,
err
:=
models
.
GetStreamer
(
s
.
Uid
)
if
err
!=
nil
{
return
nil
,
err
}
return
streamer
,
nil
}
func
(
s
*
Streamer
)
GetAll
()
([]
*
models
.
Streamer
,
error
)
{
var
streamer
[]
*
models
.
Streamer
streamer
,
err
:=
models
.
GetStreamers
(
s
.
PageNum
,
s
.
PageSize
,
s
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
return
streamer
,
nil
}
func
(
s
*
Streamer
)
Add
()
error
{
streamer
:=
map
[
string
]
interface
{}{
"username"
:
s
.
UserName
,
"nickname"
:
s
.
NickName
,
"password"
:
s
.
Password
,
"reg_ip"
:
s
.
RegIp
,
"last_login_ip"
:
s
.
LastLoginIp
,
"status"
:
s
.
Status
,
"platform_id"
:
s
.
PlatformId
,
}
if
err
:=
models
.
AddStreamer
(
streamer
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
s
*
Streamer
)
Edit
()
error
{
return
models
.
EditStreamer
(
s
.
Uid
,
map
[
string
]
interface
{}{
"username"
:
s
.
UserName
,
"nickname"
:
s
.
NickName
,
"password"
:
s
.
Password
,
"reg_ip"
:
s
.
RegIp
,
"last_login_ip"
:
s
.
LastLoginIp
,
"status"
:
s
.
Status
,
"platform_id"
:
s
.
PlatformId
,
})
}
func
(
s
*
Streamer
)
ExistById
()
(
bool
,
error
)
{
return
models
.
ExistStreamerById
(
s
.
Uid
)
}
func
(
s
*
Streamer
)
Count
()
(
int
,
error
)
{
return
models
.
GetStreamerTotal
(
s
.
getMaps
())
}
func
(
s
*
Streamer
)
Delete
()
error
{
return
models
.
DeleteStreamer
(
s
.
Uid
)
}
func
(
s
*
Streamer
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
if
s
.
Uid
!=
0
{
maps
[
"id"
]
=
s
.
Uid
}
if
s
.
PlatformId
!=
0
{
maps
[
"platform_id"
]
=
s
.
PlatformId
}
maps
[
"status"
]
=
s
.
Status
return
maps
}
service/user_service/user.go
0 → 100644
View file @
f076c5b0
package
user_service
import
(
"bwallet/models"
)
type
User
struct
{
Uid
int32
UserName
string
NickName
string
Password
string
RegTime
int64
LastLoginTime
int64
RegIp
uint32
LastLoginIp
uint32
Status
uint8
PlatformId
int64
PageNum
int
PageSize
int
}
func
(
u
*
User
)
GetOneUser
()
(
*
models
.
User
,
error
)
{
user
,
err
:=
models
.
GetUser
(
u
.
Uid
)
if
err
!=
nil
{
return
nil
,
err
}
return
user
,
nil
}
func
(
u
*
User
)
GetAll
()
([]
*
models
.
User
,
error
)
{
var
user
[]
*
models
.
User
user
,
err
:=
models
.
GetUsers
(
u
.
PageNum
,
u
.
PageSize
,
u
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
return
user
,
nil
}
func
(
u
*
User
)
Add
()
error
{
user
:=
map
[
string
]
interface
{}{
"username"
:
u
.
UserName
,
"nickname"
:
u
.
NickName
,
"password"
:
u
.
Password
,
"reg_ip"
:
u
.
RegIp
,
"last_login_ip"
:
u
.
LastLoginIp
,
"status"
:
u
.
Status
,
"platform_id"
:
u
.
PlatformId
,
}
if
err
:=
models
.
AddUser
(
user
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
u
*
User
)
Edit
()
error
{
return
models
.
EditUser
(
u
.
Uid
,
map
[
string
]
interface
{}{
"username"
:
u
.
UserName
,
"nickname"
:
u
.
NickName
,
"password"
:
u
.
Password
,
"reg_ip"
:
u
.
RegIp
,
"last_login_ip"
:
u
.
LastLoginIp
,
"status"
:
u
.
Status
,
"platform_id"
:
u
.
PlatformId
,
})
}
func
(
u
*
User
)
ExistById
()
(
bool
,
error
)
{
return
models
.
ExistUserById
(
u
.
Uid
)
}
func
(
u
*
User
)
Count
()
(
int
,
error
)
{
return
models
.
GetUserTotal
(
u
.
getMaps
())
}
func
(
u
*
User
)
Delete
()
error
{
return
models
.
DeleteUser
(
u
.
Uid
)
}
func
(
u
*
User
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
if
u
.
Uid
!=
0
{
maps
[
"id"
]
=
u
.
Uid
}
if
u
.
PlatformId
!=
0
{
maps
[
"platform_id"
]
=
u
.
PlatformId
}
maps
[
"status"
]
=
u
.
Status
return
maps
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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