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
c66f1d59
authored
Nov 25, 2019
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
增加增加记录的协程
parent
70214edb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
31 deletions
cmd/static/company_info.go
cmd/static/main.go
internal/dao/dao.go
internal/dao/scores.go
internal/model/scores.go
internal/service/service.go
logs/info.log
cmd/static/company_info.go
View file @
c66f1d59
package
main
import
"fmt"
//公司信息计算
func
CompanyInfo
()
{
fmt
.
Print
(
companyData
)
EstablishmentTime
()
CompanyNature
()
ChangeslegalInFiveYears
()
...
...
@@ -17,12 +15,19 @@ func CompanyInfo() {
//成立时间(1分)
func
EstablishmentTime
()
{
setInserScoreHeader
(
1
,
1
,
8
)
inserScoreMsg
.
TotalScore
=
5
inserScoreMsg
.
FinalScore
=
5
inserScoreMsg
.
CurrentScore
=
2
inserScoreMsg
.
Weight
=
50
inserScoreMsg
.
ComCreditsId
=
2
socreRecordChan
<-
inserScoreMsg
}
//公司性质(1分)
func
CompanyNature
()
{
setInserScoreHeader
(
1
,
1
,
9
)
}
//5年内法人变更次数(1分)
...
...
cmd/static/main.go
View file @
c66f1d59
...
...
@@ -3,18 +3,22 @@ package main
import
(
"context"
"flag"
"fmt"
"github.com/bilibili/kratos/pkg/conf/paladin"
"github.com/bilibili/kratos/pkg/log"
"kaopu-server/internal/model"
"kaopu-server/internal/service"
"time"
)
var
(
//获取的公司信息
companyData
[]
map
[
string
]
interface
{}
//插入分值的通道
socreRecord
=
make
(
chan
model
.
Scores
,
1000
)
//插入分值的通道,限制一千,超过等待
socreRecordChan
=
make
(
chan
model
.
Scores
,
1000
)
//
inserScoreMsg
model
.
Scores
)
...
...
@@ -24,19 +28,18 @@ func main() {
getConfig
()
//声明service层
svc
:=
service
.
New
()
ctx
:=
context
.
Background
()
go
insertRecord
()
//调用服务获取公司信息,然后进行全局赋值
companyData
,
_
=
svc
.
GetCompanyCresitsList
(
ctx
)
AddScore
()
CompanyInfo
()
EnterPriseCredit
()
HistoryBussiness
()
PersonalCredit
()
//fmt.Print(companyData)
//EnterPriseCredit()
//HistoryBussiness()
//PersonalCredit()
//AddScore()
time
.
Sleep
(
1
*
time
.
Millisecond
)
}
...
...
@@ -56,12 +59,24 @@ func getConfig() {
//协程增加分值记录
func
insertRecord
()
{
//声明service层
svc
:=
service
.
New
()
ctx
:=
context
.
Background
()
for
{
// 从通道中拿出消息
insertRecord
:=
<-
socreRecord
insertRecord
:=
<-
socreRecordChan
svc
.
in
fmt
.
Print
(
insertRecord
)
//插入数据
}
}
//设置插入的分数头
func
setInserScoreHeader
(
_typy
,
project_pid
,
project_id
int8
)
{
inserScoreMsg
.
Type
=
_typy
inserScoreMsg
.
ProjectPid
=
project_pid
inserScoreMsg
.
ProjectId
=
project_id
}
\ No newline at end of file
internal/dao/dao.go
View file @
c66f1d59
...
...
@@ -12,14 +12,21 @@ import (
xtime
"github.com/bilibili/kratos/pkg/time"
)
// Dao dao interface
type
Dao
interface
{
Close
()
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
[]
map
[
string
]
interface
{},
err
error
)
}
type
(
// Dao dao interface
Dao
interface
{
Close
()
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
[]
map
[
string
]
interface
{},
err
error
)
InsertScores
(
ctx
context
.
Context
,
score
*
model
.
Scores
)
(
insertId
int64
,
err
error
)
//---静态结束
}
)
// dao dao.
type
dao
struct
{
...
...
internal/dao/scores.go
View file @
c66f1d59
...
...
@@ -7,15 +7,16 @@ import (
)
//增加记录
func
(
d
*
dao
)
insert
(
ctx
context
.
Context
,
score
*
model
.
Scores
)
(
int64
,
error
)
{
func
(
d
*
dao
)
insert
Scores
(
ctx
context
.
Context
,
score
*
model
.
Scores
)
(
res
int64
,
err
error
)
{
stmt
,
_
:=
d
.
db
.
Prepare
(
"INSERT INTO chat_list (roomstr, urid,srid) VALUES (?,?,?)"
)
var
row
,
err
=
stmt
.
Exec
(
ctx
,
score
.
CreateTime
,
score
.
CurrentScore
)
row
,
err
:
=
stmt
.
Exec
(
ctx
,
score
.
CreateTime
,
score
.
CurrentScore
)
if
err
!=
nil
{
fmt
.
Println
(
"select fail,err:"
,
err
)
}
defer
d
.
db
.
Close
()
return
row
.
LastInsertId
()
res
,
_
=
row
.
LastInsertId
()
return
}
\ No newline at end of file
internal/model/scores.go
View file @
c66f1d59
...
...
@@ -10,7 +10,7 @@ type Scores struct {
TotalScore
float32
`json:"total_score"`
CurrentScore
float32
`json:"current_score"`
Weight
float32
`json:"weight"`
FinalScore
float
64
`json:"final_score"`
FinalScore
float
32
`json:"final_score"`
ComCreditsId
int64
`json:"com_credits_id"`
CreateTime
int64
`json:"create_time"`
UpdateTime
int64
`json:"update_time"`
...
...
internal/service/service.go
View file @
c66f1d59
...
...
@@ -59,11 +59,23 @@ func (s *Service) GetUserList(ctx context.Context) (res []*model.Users, err erro
}
//获取用户列表
//----------静态开始
// 获取公司用户列表
func
(
s
*
Service
)
GetCompanyCresitsList
(
ctx
context
.
Context
)
(
res
[]
map
[
string
]
interface
{},
err
error
)
{
//调用DB方法,获取会员数据
res
,
err
=
s
.
dao
.
GetCompanyCresitsList
(
ctx
)
fmt
.
Print
(
err
)
return
}
\ No newline at end of file
}
//插入分数记录
func
(
s
*
Service
)
insertScores
(
ctx
context
.
Context
,
score
*
model
.
Scores
)
(
inserId
int64
,
err
error
)
{
//调用DB方法,获取会员数据
inserId
,
_
=
s
.
dao
.
InsertScores
(
ctx
,
score
)
return
}
//----------静态结束
\ No newline at end of file
logs/info.log
View file @
c66f1d59
...
...
@@ -133,3 +133,9 @@
[2019/11/22 14:43:04.310] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:46] caipu-server start
[2019/11/22 14:43:25.337] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:48] caipu-server start
[2019/11/22 14:46:08.195] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:49] caipu-server start
[2019/11/25 10:06:06.845] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:56] caipu-server start
[2019/11/25 10:08:30.374] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:56] caipu-server start
[2019/11/25 10:09:29.481] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:56] caipu-server start
[2019/11/25 10:10:40.606] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:56] caipu-server start
[2019/11/25 10:17:03.956] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:56] caipu-server start
[2019/11/25 10:17:41.843] [INFO] [/usr/local/var/www/ichunt/kaopu-server/cmd/static/main.go:59] 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