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