mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-07 17:10:07 +08:00
fix: 解决设置默认分组的问题 (#385)
This commit is contained in:
parent
01bb6b7c01
commit
d70c22dde8
@ -13,6 +13,7 @@ type GroupSearch struct {
|
|||||||
type GroupUpdate struct {
|
type GroupUpdate struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
IsDefault bool `json:"isDefault"`
|
IsDefault bool `json:"isDefault"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ type IGroupRepo interface {
|
|||||||
Create(group *model.Group) error
|
Create(group *model.Group) error
|
||||||
Update(id uint, vars map[string]interface{}) error
|
Update(id uint, vars map[string]interface{}) error
|
||||||
Delete(opts ...DBOption) error
|
Delete(opts ...DBOption) error
|
||||||
CancelDefault() error
|
CancelDefault(groupType string) error
|
||||||
WithByIsDefault(isDefault bool) DBOption
|
WithByIsDefault(isDefault bool) DBOption
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +64,6 @@ func (u *GroupRepo) Delete(opts ...DBOption) error {
|
|||||||
return db.Delete(&model.Group{}).Error
|
return db.Delete(&model.Group{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *GroupRepo) CancelDefault() error {
|
func (u *GroupRepo) CancelDefault(groupType string) error {
|
||||||
return global.DB.Model(&model.Group{}).Where("`is_default` = 1").Updates(map[string]interface{}{"is_default": 0}).Error
|
return global.DB.Model(&model.Group{}).Where("is_default = ? AND type = ?", 1, groupType).Updates(map[string]interface{}{"is_default": 0}).Error
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ func (u *GroupService) Delete(id uint) error {
|
|||||||
|
|
||||||
func (u *GroupService) Update(req dto.GroupUpdate) error {
|
func (u *GroupService) Update(req dto.GroupUpdate) error {
|
||||||
if req.IsDefault {
|
if req.IsDefault {
|
||||||
if err := groupRepo.CancelDefault(); err != nil {
|
if err := groupRepo.CancelDefault(req.Type); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@ const saveGroup = async (formEl: FormInstance, group: Group.GroupInfo) => {
|
|||||||
|
|
||||||
const setDefault = (group: Group.GroupInfo) => {
|
const setDefault = (group: Group.GroupInfo) => {
|
||||||
group.isDefault = true;
|
group.isDefault = true;
|
||||||
|
group.type = type.value;
|
||||||
UpdateGroup(group).then(() => {
|
UpdateGroup(group).then(() => {
|
||||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||||
search();
|
search();
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else-if="mfaShow">
|
<div v-else-if="mfaShow">
|
||||||
<div class="login-form">
|
<div class="login-form">
|
||||||
<el-form @submit.prevent="mfaLogin()">
|
<el-form @submit.prevent>
|
||||||
<div class="login-title">{{ $t('commons.login.mfaTitle') }}</div>
|
<div class="login-title">{{ $t('commons.login.mfaTitle') }}</div>
|
||||||
<el-form-item class="no-border">
|
<el-form-item class="no-border">
|
||||||
<el-input
|
<el-input
|
||||||
|
Loading…
x
Reference in New Issue
Block a user