mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-09-23 19:56:40 +08:00
commit
b353728009
@ -39,7 +39,7 @@ type ViewRes struct {
|
|||||||
|
|
||||||
// EditReq 修改/新增
|
// EditReq 修改/新增
|
||||||
type EditReq struct {
|
type EditReq struct {
|
||||||
entity.AdminNotice
|
entity.SysAttachment
|
||||||
g.Meta `path:"/attachment/edit" method:"post" tags:"附件" summary:"修改/新增附件"`
|
g.Meta `path:"/attachment/edit" method:"post" tags:"附件" summary:"修改/新增附件"`
|
||||||
}
|
}
|
||||||
type EditRes struct{}
|
type EditRes struct{}
|
||||||
@ -62,7 +62,7 @@ type MaxSortRes struct {
|
|||||||
|
|
||||||
// StatusReq 更新状态
|
// StatusReq 更新状态
|
||||||
type StatusReq struct {
|
type StatusReq struct {
|
||||||
entity.AdminNotice
|
entity.SysAttachment
|
||||||
g.Meta `path:"/attachment/status" method:"post" tags:"附件" summary:"更新附件状态"`
|
g.Meta `path:"/attachment/status" method:"post" tags:"附件" summary:"更新附件状态"`
|
||||||
}
|
}
|
||||||
type StatusRes struct{}
|
type StatusRes struct{}
|
||||||
|
@ -69,7 +69,7 @@ func (l *gCurd) generateLogicSwitchFields(ctx context.Context, in *CurdPreviewIn
|
|||||||
if in.options.Step.HasSwitch {
|
if in.options.Step.HasSwitch {
|
||||||
for _, field := range in.masterFields {
|
for _, field := range in.masterFields {
|
||||||
if field.FormMode == "Switch" {
|
if field.FormMode == "Switch" {
|
||||||
buffer.WriteString("\t\tdao." + in.In.DaoName + ".Columns()." + field.GoName + ",\n")
|
buffer.WriteString("\t\t\"" + field.TsName + "\",\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,6 +204,8 @@ func (l *gCurd) generateWebModelFormSchemaEach(buffer *bytes.Buffer, fields []*s
|
|||||||
case FormModeTimeRange:
|
case FormModeTimeRange:
|
||||||
component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n componentProps: {\n type: '%s',\n clearable: true,\n shortcuts: %s,\n onUpdateValue: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NDatePicker", field.Dc, "datetimerange", "defRangeShortcuts()")
|
component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n componentProps: {\n type: '%s',\n clearable: true,\n shortcuts: %s,\n onUpdateValue: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NDatePicker", field.Dc, "datetimerange", "defRangeShortcuts()")
|
||||||
|
|
||||||
|
case FormModeSwitch:
|
||||||
|
fallthrough
|
||||||
case FormModeRadio:
|
case FormModeRadio:
|
||||||
component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n giProps: {\n //span: 24,\n },\n componentProps: {\n options: [],\n onUpdateChecked: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NRadioGroup", field.Dc)
|
component = fmt.Sprintf(" {\n field: '%s',\n component: '%s',\n label: '%s',\n giProps: {\n //span: 24,\n },\n componentProps: {\n options: [],\n onUpdateChecked: (e: any) => {\n console.log(e);\n },\n },\n },\n", field.TsName, "NRadioGroup", field.Dc)
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
|
|
||||||
|
// 获取父级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()
|
_, 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 {
|
||||||
|
@ -479,6 +479,7 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
|
|||||||
|
|
||||||
// 新增用户时的额外属性
|
// 新增用户时的额外属性
|
||||||
var data adminin.MemberAddInp
|
var data adminin.MemberAddInp
|
||||||
|
data.MemberEditInp = in
|
||||||
data.Salt = grand.S(6)
|
data.Salt = grand.S(6)
|
||||||
data.InviteCode = grand.S(12)
|
data.InviteCode = grand.S(12)
|
||||||
data.PasswordHash = gmd5.MustEncryptString(data.Password + data.Salt)
|
data.PasswordHash = gmd5.MustEncryptString(data.Password + data.Salt)
|
||||||
@ -491,10 +492,9 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 默认头像
|
// 默认头像
|
||||||
if in.Avatar == "" {
|
if data.Avatar == "" {
|
||||||
in.Avatar = config.Avatar
|
data.Avatar = config.Avatar
|
||||||
}
|
}
|
||||||
data.MemberEditInp = in
|
|
||||||
|
|
||||||
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||||
id, err := dao.AdminMember.Ctx(ctx).Data(data).InsertAndGetId()
|
id, err := dao.AdminMember.Ctx(ctx).Data(data).InsertAndGetId()
|
||||||
|
@ -7,6 +7,7 @@ package admin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"github.com/gogf/gf/v2/database/gdb"
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
"github.com/gogf/gf/v2/encoding/gjson"
|
"github.com/gogf/gf/v2/encoding/gjson"
|
||||||
"github.com/gogf/gf/v2/errors/gerror"
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
@ -217,7 +218,24 @@ func (s *sAdminRole) Edit(ctx context.Context, in *role.EditReq) (err error) {
|
|||||||
|
|
||||||
// 修改
|
// 修改
|
||||||
if in.Id > 0 {
|
if in.Id > 0 {
|
||||||
|
// 获取父级tree
|
||||||
|
var pTree gdb.Value
|
||||||
|
pTree, err = dao.AdminRole.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.AdminRole.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
|
||||||
|
// 更新数据
|
||||||
_, err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
_, err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果当前角色有子级,更新子级tree关系树
|
||||||
|
return updateRoleChildrenTree(ctx, in.Id, in.Level, in.Tree)
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +244,27 @@ func (s *sAdminRole) Edit(ctx context.Context, in *role.EditReq) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateRoleChildrenTree(ctx context.Context, _id int64, _level int, _tree string) (err error) {
|
||||||
|
var list []*entity.AdminDept
|
||||||
|
err = dao.AdminRole.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.AdminRole.Ctx(ctx).Where("id", child.Id).Data("level", child.Level, "tree", child.Tree).Update()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = updateRoleChildrenTree(ctx, child.Id, child.Level, child.Tree)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (s *sAdminRole) Delete(ctx context.Context, in *role.DeleteReq) (err error) {
|
func (s *sAdminRole) Delete(ctx context.Context, in *role.DeleteReq) (err error) {
|
||||||
if in.Id <= 0 {
|
if in.Id <= 0 {
|
||||||
return gerror.New("ID不正确!")
|
return gerror.New("ID不正确!")
|
||||||
|
@ -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>
|
</n-radio-button>
|
||||||
</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;
|
||||||
|
Loading…
Reference in New Issue
Block a user