mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 05:12:32 +08:00
fix 一些使用的小问题
This commit is contained in:
@@ -7,6 +7,8 @@ package admin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
"github.com/gogf/gf/v2/errors/gerror"
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
"github.com/gogf/gf/v2/os/gtime"
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
"hotgo/internal/consts"
|
"hotgo/internal/consts"
|
||||||
@@ -91,7 +93,26 @@ func (s *sAdminDept) Edit(ctx context.Context, in adminin.DeptEditInp) (err erro
|
|||||||
|
|
||||||
// 修改
|
// 修改
|
||||||
if in.Id > 0 {
|
if in.Id > 0 {
|
||||||
_, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
|
||||||
|
// 获取父级tree
|
||||||
|
var pTree gdb.Value
|
||||||
|
pTree, err = dao.AdminDept.Ctx(ctx).Where("id", in.Pid).Fields("tree").Value()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
in.Tree = fmt.Sprintf("%str_%v ", pTree.String(), in.Id)
|
||||||
|
|
||||||
|
err = dao.AdminDept.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
|
||||||
|
// 更新数据
|
||||||
|
_, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果当前部门有子级,更新子级tree关系树
|
||||||
|
return updateChildrenTree(ctx, in.Id, in.Level, in.Tree)
|
||||||
|
})
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +121,27 @@ func (s *sAdminDept) Edit(ctx context.Context, in adminin.DeptEditInp) (err erro
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateChildrenTree(ctx context.Context, _id int64, _level int, _tree string) (err error) {
|
||||||
|
var list []*entity.AdminDept
|
||||||
|
err = dao.AdminDept.Ctx(ctx).Where("pid", _id).Scan(&list)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, child := range list {
|
||||||
|
child.Level = _level + 1
|
||||||
|
child.Tree = fmt.Sprintf("%str_%v ", _tree, child.Id)
|
||||||
|
_, err = dao.AdminDept.Ctx(ctx).Where("id", child.Id).Data("level", child.Level, "tree", child.Tree).Update()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = updateChildrenTree(ctx, child.Id, child.Level, child.Tree)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Status 更新部门状态
|
// Status 更新部门状态
|
||||||
func (s *sAdminDept) Status(ctx context.Context, in adminin.DeptStatusInp) (err error) {
|
func (s *sAdminDept) Status(ctx context.Context, in adminin.DeptStatusInp) (err error) {
|
||||||
if in.Id <= 0 {
|
if in.Id <= 0 {
|
||||||
|
@@ -197,7 +197,7 @@ func (s *sSysLog) AnalysisLog(ctx context.Context) entity.SysLog {
|
|||||||
|
|
||||||
ipData, err := location.GetLocation(ctx, clientIp)
|
ipData, err := location.GetLocation(ctx, clientIp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Log().Debugf(ctx, "location.GetLocation clientIp:%v, err:%+v", clientIp, err)
|
g.Log().Stdout(false).Debugf(ctx, "location.GetLocation clientIp:%v, err:%+v", clientIp, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ipData == nil {
|
if ipData == nil {
|
||||||
|
@@ -43,15 +43,13 @@
|
|||||||
<!--NRadioGroup-->
|
<!--NRadioGroup-->
|
||||||
<template v-else-if="schema.component === 'NRadioGroup'">
|
<template v-else-if="schema.component === 'NRadioGroup'">
|
||||||
<n-radio-group v-model:value="formModel[schema.field]">
|
<n-radio-group v-model:value="formModel[schema.field]">
|
||||||
<n-space>
|
<n-radio-button
|
||||||
<n-radio
|
v-for="item in schema.componentProps.options"
|
||||||
v-for="item in schema.componentProps.options"
|
:key="item.value"
|
||||||
:key="item.value"
|
:value="item.value"
|
||||||
:value="item.value"
|
>
|
||||||
>
|
{{ item.label }}
|
||||||
{{ item.label }}
|
</n-radio-button>
|
||||||
</n-radio>
|
|
||||||
</n-space>
|
|
||||||
</n-radio-group>
|
</n-radio-group>
|
||||||
</template>
|
</template>
|
||||||
<!--动态渲染表单组件-->
|
<!--动态渲染表单组件-->
|
||||||
|
@@ -196,7 +196,7 @@
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
status: number;
|
status: number;
|
||||||
name: string;
|
name: string;
|
||||||
index: string;
|
id: number;
|
||||||
children?: RowData[];
|
children?: RowData[];
|
||||||
};
|
};
|
||||||
const data = ref([]);
|
const data = ref([]);
|
||||||
@@ -318,7 +318,7 @@
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const rowKey = (row: RowData) => row.index;
|
const rowKey = (row: RowData) => row.id;
|
||||||
|
|
||||||
function addTable() {
|
function addTable() {
|
||||||
showModal.value = true;
|
showModal.value = true;
|
||||||
|
Reference in New Issue
Block a user