Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-common
Commits
7b34d5a3
Commit
7b34d5a3
authored
Mar 24, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步铭牌
parent
2b4fe412
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
group.go
script/model/group.go
+9
-0
sync_group_power_nameplate.go
script/sync_group_power_nameplate.go
+35
-0
utils_test.go
script/utils/utils_test.go
+1
-1
No files found.
script/model/group.go
View file @
7b34d5a3
...
@@ -31,3 +31,12 @@ type GroupInfo struct {
...
@@ -31,3 +31,12 @@ type GroupInfo struct {
CreatedTime
time
.
Time
`gorm:"->"`
CreatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
}
}
type
GroupPower
struct
{
}
type
GroupPowerUser
struct
{
GroupPowerId
uint64
UserId
uint64
Role
int
}
script/sync_group_power_nameplate.go
0 → 100644
View file @
7b34d5a3
package
main
import
(
"git.hilo.cn/hilo-common/script/model"
"git.hilo.cn/hilo-common/script/mysql"
)
func
main
()
{
var
powerOwners
[]
model
.
GroupPowerUser
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
GroupPowerUser
{})
.
Where
(
"role = 2"
)
.
Find
(
&
powerOwners
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
for
_
,
owner
:=
range
powerOwners
{
var
groupInfo
model
.
GroupInfo
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
GroupInfo
{})
.
Where
(
"owner = ?"
,
owner
.
UserId
)
.
First
(
&
groupInfo
)
.
Error
;
err
!=
nil
{
continue
}
var
cutNameplate
[]
rune
n
:=
len
([]
rune
(
groupInfo
.
Name
))
if
n
>
6
{
n
=
6
}
cutNameplate
=
[]
rune
(
groupInfo
.
Name
[
0
:
n
])
if
len
(
cutNameplate
)
<=
0
{
panic
(
"empty nameplate"
)
}
if
owner
.
GroupPowerId
<=
0
{
panic
(
"0 powerId"
)
}
if
err
:=
mysql
.
ProdWriteDB
.
Model
(
model
.
GroupPower
{})
.
Where
(
"id = ?"
,
owner
.
GroupPowerId
)
.
UpdateColumn
(
"nameplate"
,
string
(
cutNameplate
))
.
Error
;
err
!=
nil
{
panic
(
err
)
}
//break
}
}
script/utils/utils_test.go
View file @
7b34d5a3
...
@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
...
@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
}
}
func
TestJwt
(
t
*
testing
.
T
)
{
func
TestJwt
(
t
*
testing
.
T
)
{
token
,
_
:=
jwt
.
GenerateToken
(
7
2
,
"e95ca43da9d545c4937fa933e3348961
"
,
"hiloApi"
)
token
,
_
:=
jwt
.
GenerateToken
(
7
630
,
"4be85abee40f447a964a5bf2db7accba
"
,
"hiloApi"
)
t
.
Logf
(
token
)
t
.
Logf
(
token
)
}
}
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