Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d27698ee
authored
Jun 14, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: now one channel can belong to multiple groups (close #153)
parent
0e85d0af
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
model/ability.go
+4
-1
web/src/pages/Channel/EditChannel.js
+10
-4
No files found.
model/ability.go
View file @
d27698ee
...
...
@@ -30,16 +30,19 @@ func GetRandomSatisfiedChannel(group string, model string) (*Channel, error) {
func
(
channel
*
Channel
)
AddAbilities
()
error
{
models_
:=
strings
.
Split
(
channel
.
Models
,
","
)
groups_
:=
strings
.
Split
(
channel
.
Group
,
","
)
abilities
:=
make
([]
Ability
,
0
,
len
(
models_
))
for
_
,
model
:=
range
models_
{
for
_
,
group
:=
range
groups_
{
ability
:=
Ability
{
Group
:
channel
.
G
roup
,
Group
:
g
roup
,
Model
:
model
,
ChannelId
:
channel
.
Id
,
Enabled
:
channel
.
Status
==
common
.
ChannelStatusEnabled
,
}
abilities
=
append
(
abilities
,
ability
)
}
}
return
DB
.
Create
(
&
abilities
)
.
Error
}
...
...
web/src/pages/Channel/EditChannel.js
View file @
d27698ee
...
...
@@ -15,8 +15,8 @@ const EditChannel = () => {
key
:
''
,
base_url
:
''
,
other
:
''
,
group
:
'default'
,
models
:
[],
groups
:
[
'default'
]
};
const
[
batch
,
setBatch
]
=
useState
(
false
);
const
[
inputs
,
setInputs
]
=
useState
(
originInputs
);
...
...
@@ -37,6 +37,11 @@ const EditChannel = () => {
}
else
{
data
.
models
=
data
.
models
.
split
(
","
)
}
if
(
data
.
group
===
""
)
{
data
.
groups
=
[]
}
else
{
data
.
groups
=
data
.
group
.
split
(
","
)
}
setInputs
(
data
);
}
else
{
showError
(
message
);
...
...
@@ -94,6 +99,7 @@ const EditChannel = () => {
}
let
res
;
localInputs
.
models
=
localInputs
.
models
.
join
(
","
)
localInputs
.
group
=
localInputs
.
groups
.
join
(
","
)
if
(
isEdit
)
{
res
=
await
API
.
put
(
`/api/channel/`
,
{
...
localInputs
,
id
:
parseInt
(
channelId
)
});
}
else
{
...
...
@@ -185,14 +191,14 @@ const EditChannel = () => {
<
Form
.
Dropdown
label
=
'分组'
placeholder
=
{
'请选择分组'
}
name
=
'group'
name
=
'group
s
'
fluid
search
multiple
selection
allowAdditions
additionLabel
=
{
'请在系统设置页面编辑分组倍率以添加新的分组:'
}
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
group
}
value
=
{
inputs
.
group
s
}
autoComplete
=
'new-password'
options
=
{
groupOptions
}
/
>
...
...
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