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
f993de2f
Commit
f993de2f
authored
Jan 07, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步群组靓号
parent
afe6d833
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
0 deletions
+81
-0
group.go
model/group.go
+33
-0
Makefile
script/Makefile
+2
-0
sync_group_code.go
script/sync_group_code.go
+46
-0
No files found.
model/group.go
0 → 100644
View file @
f993de2f
package
model
import
"time"
type
GroupInfo
struct
{
Id
int64
ImGroupId
string
TxGroupId
string
Type
uint16
Code
string
OriginCode
string
Owner
uint64
OwnerExternalId
string
`gorm:"-"`
OwnerCode
string
`gorm:"-"`
Name
string
Introduction
string
Notification
string
FaceUrl
string
Country
string
ChannelId
string
Password
string
EntryLevel
uint32
// obsolete
MicOn
bool
LoadHistory
bool
ThemeId
int16
TouristMic
uint8
TouristSendMsg
uint8
TouristSendPic
uint8
MemberFee
uint64
MicNumType
uint8
CreatedTime
time
.
Time
`gorm:"->"`
UpdatedTime
time
.
Time
`gorm:"->"`
}
script/Makefile
0 → 100644
View file @
f993de2f
sync_group_code
:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
sync_group_code sync_group_code.go
\ No newline at end of file
script/sync_group_code.go
0 → 100644
View file @
f993de2f
package
main
import
(
"fmt"
"github.com/hilo-common/model"
"github.com/hilo-common/mysql"
)
func
main
()
{
type
GroupConsume
struct
{
GroupId
string
Total
int
}
type
UpdateGroupCode
struct
{
GroupId
string
OldCode
string
NewCode
string
}
var
updates
[]
UpdateGroupCode
var
rows
[]
GroupConsume
sql
:=
"SELECT group_id,SUM(diamond) AS total FROM `room_month_consume` group by group_id HAVING total > 1000000;"
if
err
:=
mysql
.
ProdReadOnlyDB
.
Raw
(
sql
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
for
_
,
row
:=
range
rows
{
groupInfo
:=
new
(
model
.
GroupInfo
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
GroupInfo
{})
.
Where
(
"im_group_id = ?"
,
row
.
GroupId
)
.
First
(
groupInfo
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
owner
:=
new
(
model
.
User
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
User
{})
.
Where
(
"id = ?"
,
groupInfo
.
Owner
)
.
First
(
owner
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
if
owner
.
Code
!=
owner
.
OriginCode
&&
owner
.
Code
!=
groupInfo
.
Code
{
updates
=
append
(
updates
,
UpdateGroupCode
{
GroupId
:
groupInfo
.
ImGroupId
,
OldCode
:
groupInfo
.
Code
,
NewCode
:
owner
.
Code
,
})
}
}
for
_
,
update
:=
range
updates
{
sql
:=
fmt
.
Sprintf
(
"UPDATE group_info SET code = '%s' WHERE im_group_id = '%s' AND code = '%s' limit 1"
,
update
.
NewCode
,
update
.
GroupId
,
update
.
OldCode
)
fmt
.
Println
(
sql
)
}
}
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