Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
kaopu-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d0f9bd9e
authored
Nov 21, 2019
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
增加适配模型
parent
47c2cf62
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
25 deletions
cmd/static/main.go
configs/mysql.toml
internal/dao/com_credits.go
internal/dao/dao.go
internal/service/service.go
logs/info.log
cmd/static/main.go
View file @
d0f9bd9e
...
...
@@ -3,9 +3,11 @@ package main
import
(
"context"
"flag"
"fmt"
"github.com/bilibili/kratos/pkg/conf/paladin"
"github.com/bilibili/kratos/pkg/log"
"kaopu-server/internal/service"
"strconv"
)
//当前静态算法内的pid和typeID
...
...
@@ -23,12 +25,17 @@ func main() {
log
.
Init
(
&
log
.
Config
{
Dir
:
"logs"
})
defer
log
.
Close
()
log
.
Info
(
"caipu-server start"
)
//声明service层
svc
:=
service
.
New
()
ctx
:=
context
.
Background
()
//调用会员服务
svc
.
GetCompanyCresitsList
(
ctx
)
userdata
,
_
:=
svc
.
GetCompanyCresitsList
(
ctx
)
for
_
,
v
:=
range
userdata
{
fmt
.
Print
(
strconv
.
Atoi
(
v
[
"create_time"
]
.
(
string
)))
}
}
...
...
configs/mysql.toml
View file @
d0f9bd9e
[
l
iexin_credit]
[
L
iexin_credit]
addr
=
"192.168.2.232:3306"
dsn
=
"liexin_credit:liexin_credit#zsyM@tcp(192.168.2.232:3306)/liexin_credit?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8"
readDSN
=
["liexin_credit:liexin_credit#zsyM@tcp(192.168.2.232:3306)/liexin_credit?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8"]
readDSN
=
["liexin_credit:liexin_credit#zsyM@tcp(192.168.2.232:3306)/liexin_credit?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8"
,"liexin_credit:liexin_credit#zsyM@tcp(192.168.2.232:3306)/liexin_credit?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
]
active
=
20
idle
=
10
idleTimeout
=
"4h"
queryTimeout
=
"200ms"
execTimeout
=
"300ms"
tranTimeout
=
"400ms"
internal/dao/com_credits.go
View file @
d0f9bd9e
...
...
@@ -2,16 +2,48 @@ package dao
import
(
"context"
"fmt"
"github.com/bilibili/kratos/pkg/database/sql"
"github.com/pkg/errors"
"kaopu-server/internal/model"
)
//根据指针行获取所有的参数
func
getAllParam
(
rows
*
sql
.
Rows
)(
res
[]
map
[
string
]
interface
{},
err
error
)
{
cols
,
err
:=
rows
.
Columns
()
if
err
!=
nil
{
fmt
.
Println
(
"get columns fail,err:"
,
err
)
return
}
vals
:=
make
([][]
byte
,
len
(
cols
))
scans
:=
make
([]
interface
{},
len
(
cols
))
for
i
:=
range
vals
{
scans
[
i
]
=
&
vals
[
i
]
}
for
rows
.
Next
(){
err
=
rows
.
Scan
(
scans
...
)
if
err
!=
nil
{
fmt
.
Println
(
"scan fail,err:"
,
err
)
return
}
row
:=
make
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
vals
{
key
:=
cols
[
k
]
row
[
key
]
=
string
(
v
)
}
res
=
append
(
res
,
row
)
}
return
}
//列表方式获取会员信息
func
(
d
*
dao
)
GetCompanyCresitsList
(
ctx
context
.
Context
)
(
res
[]
*
model
.
ComCredits
,
err
error
)
{
func
(
d
*
dao
)
GetCompanyCresitsList
(
ctx
context
.
Context
)
(
res
[]
map
[
string
]
interface
{}
,
err
error
)
{
var
(
rows
*
sql
.
Rows
)
if
rows
,
err
=
d
.
db
.
Query
(
ctx
,
"SELECT * FROM lie_com_credits "
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
...
...
@@ -19,16 +51,11 @@ func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []*model.ComCredit
}
defer
rows
.
Close
()
for
rows
.
Next
()
{
r
:=
&
model
.
ComCredits
{}
if
err
=
rows
.
Scan
(
&
r
.
ComName
,
&
r
.
ComOrganization
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
res
=
nil
return
}
res
=
append
(
res
,
r
)
if
err
!=
nil
{
fmt
.
Println
(
"select fail,err:"
,
err
)
return
}
err
=
rows
.
Err
()
return
return
getAllParam
(
rows
)
}
\ No newline at end of file
internal/dao/dao.go
View file @
d0f9bd9e
...
...
@@ -18,7 +18,7 @@ type Dao interface {
Ping
(
ctx
context
.
Context
)
(
err
error
)
GetUserInfoByUserId
(
ctx
context
.
Context
,
user_id
int64
)
(
r
*
model
.
Users
,
err
error
)
GetUserList
(
ctx
context
.
Context
)
(
r
[]
*
model
.
Users
,
err
error
)
GetCompanyCresitsList
(
ctx
context
.
Context
)
(
r
[]
*
model
.
ComCredits
,
err
error
)
GetCompanyCresitsList
(
ctx
context
.
Context
)
(
r
[]
map
[
string
]
interface
{}
,
err
error
)
}
// dao dao.
...
...
internal/service/service.go
View file @
d0f9bd9e
...
...
@@ -60,11 +60,9 @@ func (s *Service) GetUserList(ctx context.Context) (res []*model.Users, err erro
//获取用户列表
func
(
s
*
Service
)
GetCompanyCresitsList
(
ctx
context
.
Context
)
(
res
[]
*
model
.
ComCredits
,
err
error
)
{
func
(
s
*
Service
)
GetCompanyCresitsList
(
ctx
context
.
Context
)
(
res
[]
map
[
string
]
interface
{}
,
err
error
)
{
//调用DB方法,获取会员数据
res
,
_
=
s
.
dao
.
GetCompanyCresitsList
(
ctx
)
fmt
.
Println
(
res
)
res
,
err
=
s
.
dao
.
GetCompanyCresitsList
(
ctx
)
return
}
\ No newline at end of file
logs/info.log
View file @
d0f9bd9e
...
...
@@ -50,3 +50,35 @@
[2019/11/21 17:35:20.751] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 17:37:29.678] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 17:59:02.082] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 18:45:56.411] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 18:46:48.980] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 18:49:08.615] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 18:56:20.039] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:00:25.701] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:01:09.443] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:01:30.621] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:08:30.137] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:10:13.056] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:10:41.757] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:13:46.905] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:17:28.590] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:18:15.720] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:18:51.319] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:20:34.017] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:21:37.742] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:28:22.747] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:28:53.162] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:29:07.819] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:30:37.659] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:30:48.842] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:34:11.613] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:25] caipu-server start
[2019/11/21 19:34:22.510] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:35:55.724] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:39:18.213] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:52:17.932] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:54:13.744] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:57:39.836] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 19:58:17.249] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 20:00:02.765] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 20:00:14.754] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:26] caipu-server start
[2019/11/21 20:06:30.516] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:27] caipu-server start
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