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
70214edb
authored
Nov 22, 2019
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
增加协程用来增加数据
parent
dc001bbd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
6 deletions
cmd/static/main.go
internal/dao/scores.go
internal/model/scores.go
cmd/static/main.go
View file @
70214edb
...
...
@@ -5,17 +5,16 @@ import (
"flag"
"github.com/bilibili/kratos/pkg/conf/paladin"
"github.com/bilibili/kratos/pkg/log"
"kaopu-server/internal/model"
"kaopu-server/internal/service"
)
//当前静态算法内的pid和typeID
const
CPID
=
1
const
CTYPE
=
1
var
(
//获取的公司信息
companyData
[]
map
[
string
]
interface
{}
//插入分值的通道
socreRecord
=
make
(
chan
model
.
Scores
,
1000
)
)
...
...
@@ -29,6 +28,8 @@ func main() {
svc
:=
service
.
New
()
ctx
:=
context
.
Background
()
go
insertRecord
()
//调用服务获取公司信息,然后进行全局赋值
companyData
,
_
=
svc
.
GetCompanyCresitsList
(
ctx
)
AddScore
()
...
...
@@ -53,7 +54,14 @@ func getConfig() {
}
//获取计算需要的用户详情
func
getUserDetail
()
{
//协程增加分值记录
func
insertRecord
()
{
for
{
// 从通道中拿出消息
insertRecord
:=
<-
socreRecord
//插入数据
}
}
\ No newline at end of file
internal/dao/scores.go
0 → 100644
View file @
70214edb
package
dao
import
(
"context"
"fmt"
"kaopu-server/internal/model"
)
//增加记录
func
(
d
*
dao
)
insert
(
ctx
context
.
Context
,
score
*
model
.
Scores
)
(
int64
,
error
)
{
stmt
,
_
:=
d
.
db
.
Prepare
(
"INSERT INTO chat_list (roomstr, urid,srid) VALUES (?,?,?)"
)
var
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
()
}
\ No newline at end of file
internal/model/scores.go
0 → 100644
View file @
70214edb
package
model
type
Scores
struct
{
Id
int64
`json:"id"`
Type
int8
`json:"type"`
ProjectPid
int8
`json:"project_pid"`
ProjectId
int8
`json:"project_id"`
TotalScore
float32
`json:"total_score"`
CurrentScore
float32
`json:"current_score"`
Weight
float32
`json:"weight"`
FinalScore
float64
`json:"final_score"`
ComCreditsId
int64
`json:"com_credits_id"`
CreateTime
int64
`json:"create_time"`
UpdateTime
int64
`json:"update_time"`
}
/*CREATE TABLE `lie_scores` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '1 静态模型 2动态模型 3银行端',
`project_pid` smallint(4) unsigned NOT NULL DEFAULT '0' COMMENT '模型pid',
`project_id` smallint(4) unsigned NOT NULL DEFAULT '0' COMMENT '模型id',
`total_score` decimal(6,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '总分',
`current_score` decimal(6,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '得分 没有进行权重运算的得分',
`weight` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '权重',
`final_score` decimal(6,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '最终得分-终评分 进行了权重运算后的得分',
`com_credits_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '关联信用分id',
`create_time` int(11) unsigned NOT NULL DEFAULT '0',
`update_time` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `type_2` (`type`,`project_pid`,`project_id`,`com_credits_id`) USING BTREE,
KEY `type` (`type`,`project_pid`,`project_id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COMMENT='信用分统计-参数评分';*/
\ No newline at end of file
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