mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-02 23:40:24 +08:00
fix: 问题修复
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
"trzsz": "^1.1.5",
|
||||
"uuid": "^9.0.1",
|
||||
"vue": "^3.4.23",
|
||||
"vue-router": "^4.3.0",
|
||||
"vue-router": "^4.3.1",
|
||||
"xterm": "^5.3.0",
|
||||
"xterm-addon-fit": "^0.8.0",
|
||||
"xterm-addon-search": "^0.13.0",
|
||||
@@ -49,14 +49,14 @@
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
||||
"@typescript-eslint/parser": "^6.7.4",
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"@vue/compiler-sfc": "^3.4.21",
|
||||
"@vue/compiler-sfc": "^3.4.23",
|
||||
"code-inspector-plugin": "^0.4.5",
|
||||
"dotenv": "^16.3.1",
|
||||
"eslint": "^8.35.0",
|
||||
"eslint-plugin-vue": "^9.21.1",
|
||||
"eslint-plugin-vue": "^9.25.0",
|
||||
"prettier": "^3.2.5",
|
||||
"sass": "^1.69.0",
|
||||
"typescript": "^5.3.2",
|
||||
"sass": "^1.75.0",
|
||||
"typescript": "^5.4.5",
|
||||
"vite": "^5.2.9",
|
||||
"vue-eslint-parser": "^9.4.2"
|
||||
},
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<template>
|
||||
<div v-if="props.tags">
|
||||
<el-row v-for="(tagPath, idx) in tagPaths?.slice(0, 1)" :key="idx">
|
||||
<TagInfo :tag-path="tagPath" />
|
||||
<span class="ml3">{{ tagPath }}</span>
|
||||
<el-row v-for="(tag, idx) in props.tags?.slice(0, 1)" :key="idx">
|
||||
<TagInfo :tag-path="tag.codePath" />
|
||||
<span class="ml3">{{ tag.codePath }}</span>
|
||||
|
||||
<!-- 展示剩余的标签信息 -->
|
||||
<el-popover :show-after="300" v-if="tagPaths?.length > 1 && idx == 0" placement="top-start" width="230" trigger="hover">
|
||||
<el-popover :show-after="300" v-if="props.tags.length > 1 && idx == 0" placement="top-start" width="230" trigger="hover">
|
||||
<template #reference>
|
||||
<SvgIcon class="mt5 ml5" color="var(--el-color-primary)" name="MoreFilled" />
|
||||
</template>
|
||||
|
||||
<el-row v-for="i in tagPaths.slice(1)" :key="i">
|
||||
<TagInfo :tag-path="i" />
|
||||
<span class="ml3">{{ i }}</span>
|
||||
<el-row v-for="i in props.tags.slice(1)" :key="i">
|
||||
<TagInfo :tag-path="i.codePath" />
|
||||
<span class="ml3">{{ i.codePath }}</span>
|
||||
</el-row>
|
||||
</el-popover>
|
||||
</el-row>
|
||||
@@ -22,18 +22,12 @@
|
||||
<script lang="ts" setup>
|
||||
import SvgIcon from '@/components/svgIcon/index.vue';
|
||||
import TagInfo from './TagInfo.vue';
|
||||
import { computed } from 'vue';
|
||||
import { getTagPath } from './tag';
|
||||
const props = defineProps({
|
||||
tags: {
|
||||
type: [Array<any>],
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const tagPaths = computed(() => {
|
||||
return props.tags?.map((item) => getTagPath(item.codePath)) as any;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss"></style>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
@node-click="treeNodeClick"
|
||||
@node-expand="treeNodeClick"
|
||||
@node-contextmenu="nodeContextmenu"
|
||||
:default-expanded-keys="props.defaultExpandedKeys"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<span @dblclick="treeNodeDblclick(data)" :class="data.type.nodeDblclickFunc ? 'none-select' : ''">
|
||||
@@ -56,6 +57,9 @@ const props = defineProps({
|
||||
type: [Number],
|
||||
required: true,
|
||||
},
|
||||
defaultExpandedKeys: {
|
||||
type: [Array],
|
||||
},
|
||||
tagPathNodeType: {
|
||||
type: [NodeType],
|
||||
required: true,
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { toRefs, reactive, onMounted } from 'vue';
|
||||
import { tagApi } from '../tag/api';
|
||||
import { getTagPath } from './tag';
|
||||
|
||||
//定义事件
|
||||
const emit = defineEmits(['update:modelValue', 'changeTag', 'input']);
|
||||
@@ -54,10 +53,7 @@ const state = reactive({
|
||||
const { tags } = toRefs(state);
|
||||
|
||||
onMounted(async () => {
|
||||
if (props.selectTags) {
|
||||
state.selectTags = props.selectTags.map((item: any) => getTagPath(item));
|
||||
}
|
||||
|
||||
state.selectTags = props.selectTags;
|
||||
state.tags = await tagApi.getTagTrees.request({ type: -1 });
|
||||
});
|
||||
|
||||
|
||||
@@ -171,29 +171,3 @@ export function getTagPathSearchItem(resourceType: number) {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据codepath获取对应的tagPath
|
||||
* @param codePath codePath tag1/tag2/1|testmachien1/
|
||||
* @returns tagPath tag1/tag2/
|
||||
*/
|
||||
export function getTagPath(codePath: string) {
|
||||
// 以资源分隔符 "|" 对字符串进行分割
|
||||
let parts = codePath.split('|');
|
||||
if (parts.length < 2) {
|
||||
return codePath;
|
||||
}
|
||||
|
||||
// 从分割后的第一个子串中提取所需部分
|
||||
let substringBeforeNumber = parts[0];
|
||||
|
||||
// 找到最后一个 "/" 的位置
|
||||
let lastSlashIndex = substringBeforeNumber.lastIndexOf('/');
|
||||
|
||||
// 如果找到最后一个 "/" 符号,则截取子串
|
||||
if (lastSlashIndex !== -1) {
|
||||
return substringBeforeNumber.slice(0, lastSlashIndex + 1);
|
||||
}
|
||||
|
||||
return codePath;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,6 @@ import { TagResourceTypeEnum } from '@/common/commonEnum';
|
||||
import ResourceAuthCertTableEdit from '../component/ResourceAuthCertTableEdit.vue';
|
||||
import { AuthCertCiphertextTypeEnum } from '../tag/enums';
|
||||
import TagTreeSelect from '../component/TagTreeSelect.vue';
|
||||
import { getTagPath } from '../component/tag';
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
@@ -213,7 +212,7 @@ const DefaultForm = {
|
||||
code: '',
|
||||
name: null,
|
||||
host: '',
|
||||
port: null,
|
||||
port: getDbDialect(DbType.mysql).getInfo().defaultPort,
|
||||
extra: '', // 连接需要的额外参数(json字符串)
|
||||
params: null,
|
||||
remark: '',
|
||||
@@ -261,7 +260,6 @@ const getReqForm = async () => {
|
||||
if (!state.form.sshTunnelMachineId) {
|
||||
reqForm.sshTunnelMachineId = -1;
|
||||
}
|
||||
reqForm.tagCodePaths = state.form.tagCodePaths.map((t: any) => getTagPath(t)) as any;
|
||||
if (Object.keys(state.extra).length > 0) {
|
||||
reqForm.extra = JSON.stringify(state.extra);
|
||||
}
|
||||
|
||||
@@ -302,11 +302,12 @@ const NodeTypeDb = new NodeType(SqlExecNodeType.Db)
|
||||
return new TagTreeNode(`${params.id}.${params.db}.schema.${sn}`, sn, NodeTypePostgresSchema).withParams(nParams).withIcon(SchemaIcon);
|
||||
});
|
||||
}
|
||||
return NodeTypeTables(params);
|
||||
|
||||
return getNodeTypeTables(params);
|
||||
})
|
||||
.withNodeClickFunc(nodeClickChangeDb);
|
||||
|
||||
const NodeTypeTables = (params: any) => {
|
||||
const getNodeTypeTables = (params: any) => {
|
||||
let tableKey = `${params.id}.${params.db}.table-menu`;
|
||||
let sqlKey = getSqlMenuNodeKey(params.id, params.db);
|
||||
return [
|
||||
@@ -321,7 +322,7 @@ const NodeTypePostgresSchema = new NodeType(SqlExecNodeType.PgSchema)
|
||||
.withLoadNodesFunc(async (parentNode: TagTreeNode) => {
|
||||
const params = parentNode.params;
|
||||
params.parentKey = parentNode.key;
|
||||
return NodeTypeTables(params);
|
||||
return getNodeTypeTables(params);
|
||||
})
|
||||
.withNodeClickFunc(nodeClickChangeDb);
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ import { MachineProtocolEnum } from './enums';
|
||||
import DrawerHeader from '@/components/drawer-header/DrawerHeader.vue';
|
||||
import { ResourceCodePattern } from '@/common/pattern';
|
||||
import { TagResourceTypeEnum } from '@/common/commonEnum';
|
||||
import { getTagPath } from '../component/tag';
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
@@ -186,7 +185,8 @@ const { isFetching: saveBtnLoading, execute: saveMachineExec } = machineApi.save
|
||||
watchEffect(() => {
|
||||
state.dialogVisible = props.visible;
|
||||
if (!state.dialogVisible) {
|
||||
state.form = defaultForm;
|
||||
state.form = { ...defaultForm };
|
||||
state.form.authCerts = [];
|
||||
return;
|
||||
}
|
||||
const machine: any = props.machine;
|
||||
@@ -236,7 +236,6 @@ const getReqForm = () => {
|
||||
if (!state.form.sshTunnelMachineId || state.form.sshTunnelMachineId <= 0) {
|
||||
reqForm.sshTunnelMachineId = -1;
|
||||
}
|
||||
reqForm.tagCodePaths = state.form.tagCodePaths.map((t: any) => getTagPath(t)) as any;
|
||||
return reqForm;
|
||||
};
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ import { ElMessage } from 'element-plus';
|
||||
import TagTreeSelect from '../component/TagTreeSelect.vue';
|
||||
import SshTunnelSelect from '../component/SshTunnelSelect.vue';
|
||||
import { ResourceCodePattern } from '@/common/pattern';
|
||||
import { getTagPath } from '../component/tag';
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
@@ -160,7 +159,6 @@ const getReqForm = () => {
|
||||
if (!state.form.sshTunnelMachineId || state.form.sshTunnelMachineId <= 0) {
|
||||
reqForm.sshTunnelMachineId = -1;
|
||||
}
|
||||
reqForm.tagCodePaths = state.form.tagCodePaths.map((t: any) => getTagPath(t)) as any;
|
||||
return reqForm;
|
||||
};
|
||||
|
||||
|
||||
@@ -116,7 +116,6 @@ import SshTunnelSelect from '../component/SshTunnelSelect.vue';
|
||||
import ProcdefSelectFormItem from '@/views/flow/components/ProcdefSelectFormItem.vue';
|
||||
import { ResourceCodePattern } from '@/common/pattern';
|
||||
import DrawerHeader from '@/components/drawer-header/DrawerHeader.vue';
|
||||
import { getTagPath } from '../component/tag';
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
@@ -249,7 +248,6 @@ const getReqForm = async () => {
|
||||
if (!state.form.sshTunnelMachineId || state.form.sshTunnelMachineId <= 0) {
|
||||
reqForm.sshTunnelMachineId = -1;
|
||||
}
|
||||
reqForm.tagCodePaths = state.form.tagCodePaths.map((t: any) => getTagPath(t)) as any;
|
||||
return reqForm;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ type Db interface {
|
||||
// 分页获取
|
||||
GetPageList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error)
|
||||
|
||||
Count(condition *entity.DbQuery) int64
|
||||
|
||||
SaveDb(ctx context.Context, entity *entity.Db) error
|
||||
|
||||
// 删除数据库信息
|
||||
@@ -64,10 +62,6 @@ func (d *dbAppImpl) GetPageList(condition *entity.DbQuery, pageParam *model.Page
|
||||
return d.GetRepo().GetDbList(condition, pageParam, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
func (d *dbAppImpl) Count(condition *entity.DbQuery) int64 {
|
||||
return d.GetRepo().Count(condition)
|
||||
}
|
||||
|
||||
func (d *dbAppImpl) SaveDb(ctx context.Context, dbEntity *entity.Db) error {
|
||||
// 查找是否存在
|
||||
oldDb := &entity.Db{Name: dbEntity.Name, InstanceId: dbEntity.InstanceId}
|
||||
@@ -141,7 +135,7 @@ func (d *dbAppImpl) SaveDb(ctx context.Context, dbEntity *entity.Db) error {
|
||||
}
|
||||
}
|
||||
if authCert.Name != old.AuthCertName {
|
||||
return d.tagApp.UpdateParentTagCode(ctx, tagentity.TagTypeDbName, old.Code, authCert.Name, authCert.Username)
|
||||
return d.tagApp.ChangeParentTag(ctx, tagentity.TagTypeDbName, old.Code, tagentity.TagTypeDbAuthCert, authCert.Name)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -33,8 +33,6 @@ type Instance interface {
|
||||
// GetPageList 分页获取数据库实例
|
||||
GetPageList(condition *entity.InstanceQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error)
|
||||
|
||||
Count(condition *entity.InstanceQuery) int64
|
||||
|
||||
TestConn(instanceEntity *entity.DbInstance, authCert *tagentity.ResourceAuthCert) error
|
||||
|
||||
SaveDbInstance(ctx context.Context, instance *SaveDbInstanceParam) (uint64, error)
|
||||
@@ -69,10 +67,6 @@ func (app *instanceAppImpl) GetPageList(condition *entity.InstanceQuery, pagePar
|
||||
return app.GetRepo().GetInstanceList(condition, pageParam, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
func (app *instanceAppImpl) Count(condition *entity.InstanceQuery) int64 {
|
||||
return app.CountByCond(condition)
|
||||
}
|
||||
|
||||
func (app *instanceAppImpl) TestConn(instanceEntity *entity.DbInstance, authCert *tagentity.ResourceAuthCert) error {
|
||||
instanceEntity.Network = instanceEntity.GetNetwork()
|
||||
|
||||
|
||||
@@ -96,15 +96,12 @@ func (app *dbTransferAppImpl) CreateLog(ctx context.Context, taskId uint64) (uin
|
||||
func (app *dbTransferAppImpl) Run(ctx context.Context, taskId uint64, logId uint64) {
|
||||
task, err := app.GetById(new(entity.DbTransferTask), taskId)
|
||||
if err != nil {
|
||||
logx.Errorf("创建DBMS-执行数据迁移日志失败:%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
if err != nil {
|
||||
logx.Errorf("创建DBMS-执行数据迁移日志失败:%v", err)
|
||||
return
|
||||
}
|
||||
defer app.logApp.Flush(logId, true)
|
||||
|
||||
// 修改状态与关联日志id
|
||||
|
||||
@@ -70,10 +70,6 @@ func (r *Redis) Save(rc *req.Ctx) {
|
||||
form := &form.Redis{}
|
||||
redis := req.BindJsonAndCopyTo[*entity.Redis](rc, form, new(entity.Redis))
|
||||
|
||||
// 密码脱敏记录日志
|
||||
form.Password = "****"
|
||||
rc.ReqParam = form
|
||||
|
||||
redisParam := &application.SaveRedisParam{
|
||||
Redis: redis,
|
||||
TagCodePaths: form.TagCodePaths,
|
||||
@@ -86,6 +82,10 @@ func (r *Redis) Save(rc *req.Ctx) {
|
||||
},
|
||||
}
|
||||
|
||||
// 密码脱敏记录日志
|
||||
form.Password = "****"
|
||||
rc.ReqParam = form
|
||||
|
||||
biz.ErrIsNil(r.RedisApp.SaveRedis(rc.MetaCtx, redisParam))
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ func (r *ResourceAuthCert) ListByQuery(rc *req.Ctx) {
|
||||
func (r *ResourceAuthCert) GetCompleteAuthCert(rc *req.Ctx) {
|
||||
acName := rc.Query("name")
|
||||
biz.NotEmpty(acName, "授权凭证名不能为空")
|
||||
rc.ReqParam = acName
|
||||
|
||||
res := &entity.ResourceAuthCert{Name: acName}
|
||||
err := r.ResourceAuthCertApp.GetBy(res)
|
||||
biz.ErrIsNil(err)
|
||||
|
||||
@@ -74,8 +74,8 @@ type TagTree interface {
|
||||
// UpdateTagName 根据标签类型与code更新对应标签名
|
||||
UpdateTagName(ctx context.Context, tagType entity.TagType, tagCode string, tagName string) error
|
||||
|
||||
// UpdateParentTagCode 更新指定类型标签的所有父标签编号
|
||||
UpdateParentTagCode(ctx context.Context, tagType entity.TagType, tagCode string, newParentCode string, newParentName string) error
|
||||
// ChangeParentTag 变更指定类型标签的父标签
|
||||
ChangeParentTag(ctx context.Context, tagType entity.TagType, tagCode string, parentTagType entity.TagType, newParentCode string) error
|
||||
|
||||
// DeleteTagByParam 删除标签,会删除该标签下所有子标签信息以及团队关联的标签信息
|
||||
DeleteTagByParam(ctx context.Context, param *DelResourceTagParam) error
|
||||
@@ -247,11 +247,9 @@ func (p *tagTreeAppImpl) SaveResourceTag(ctx context.Context, param *SaveResourc
|
||||
})
|
||||
}
|
||||
|
||||
// 获取所有关联的子标签
|
||||
// 获取所有关联的父标签
|
||||
var parentTags []*entity.TagTree
|
||||
p.ListByWheres(collx.M{
|
||||
"code_path in ?": parentTagCodePaths,
|
||||
}, &parentTags)
|
||||
p.ListByWheres(collx.M{"code_path in ?": parentTagCodePaths}, &parentTags)
|
||||
if len(parentTags) == 0 || len(parentTags) != len(parentTagCodePaths) {
|
||||
return errorx.NewBiz("保存资源标签失败: 存在错误的关联标签")
|
||||
}
|
||||
@@ -293,11 +291,20 @@ func (p *tagTreeAppImpl) SaveResourceTag(ctx context.Context, param *SaveResourc
|
||||
|
||||
if len(delCodePaths) > 0 {
|
||||
logx.DebugfContext(ctx, "SaveResourceTag-删除标签[%v]", delCodePaths)
|
||||
|
||||
var delTagIds []uint64
|
||||
for _, delCodePath := range delCodePaths {
|
||||
delTag := oldCodePath2Tag[delCodePath]
|
||||
if delTag != nil && delTag.Id != 0 {
|
||||
delTagIds = append(delTagIds, delTag.Id)
|
||||
}
|
||||
}
|
||||
|
||||
// 删除team关联的标签
|
||||
if err := p.tagTreeTeamRepo.DeleteByWheres(ctx, collx.M{"tag_path in ?": delCodePaths}); err != nil {
|
||||
if err := p.tagTreeTeamRepo.DeleteByWheres(ctx, collx.M{"tag_id in ?": delTagIds}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := p.DeleteByWheres(ctx, collx.M{"code_path in ?": delCodePaths}); err != nil {
|
||||
if err := p.DeleteByWheres(ctx, collx.M{"id in ?": delTagIds}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -336,20 +343,18 @@ func (p *tagTreeAppImpl) UpdateTagName(ctx context.Context, tagType entity.TagTy
|
||||
return p.UpdateByWheres(ctx, &entity.TagTree{Name: tagName}, collx.Kvs("code = ?", tagCode, "type = ?", tagType))
|
||||
}
|
||||
|
||||
func (p *tagTreeAppImpl) UpdateParentTagCode(ctx context.Context, tagType entity.TagType, tagCode string, newParentCode string, newParentName string) error {
|
||||
func (p *tagTreeAppImpl) ChangeParentTag(ctx context.Context, tagType entity.TagType, tagCode string, parentTagType entity.TagType, newParentCode string) error {
|
||||
// 获取资源编号对应的资源标签信息
|
||||
var resourceTags []*entity.TagTree
|
||||
p.ListByCond(&entity.TagTree{Type: tagType, Code: tagCode}, &resourceTags)
|
||||
if len(resourceTags) == 0 {
|
||||
logx.WarnfContext(ctx, "UpdateParentTagCode-[%d-%s]标签信息不存在", tagType, tagCode)
|
||||
logx.WarnfContext(ctx, "ChangeParentTag-[%d-%s]标签信息不存在", tagType, tagCode)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取该资源编号对应的所有父资源标签信息
|
||||
var resourceParentTags []*entity.TagTree
|
||||
p.ListByWheres(collx.Kvs("code_path in ?", collx.ArrayMap(resourceTags, func(tag *entity.TagTree) string {
|
||||
return tag.GetParentPath(0)
|
||||
})), &resourceParentTags)
|
||||
if p.CountByCond(&entity.TagTree{Type: parentTagType, Code: newParentCode}) == 0 {
|
||||
return errorx.NewBiz("该父标签不存在")
|
||||
}
|
||||
|
||||
// 获取该资源编号对应的所有子资源标签信息
|
||||
var resourceChildrenTags []*entity.TagTree
|
||||
@@ -362,27 +367,16 @@ func (p *tagTreeAppImpl) UpdateParentTagCode(ctx context.Context, tagType entity
|
||||
pathSection := entity.GetTagPathSections(tag.CodePath)
|
||||
for i, ps := range pathSection {
|
||||
if ps.Type == tagType && ps.Code == tagCode {
|
||||
// 将父标签编号修改为对应的新编号
|
||||
// 将父标签编号修改为对应的新编号与类型
|
||||
pathSection[i-1].Code = newParentCode
|
||||
pathSection[i-1].Type = parentTagType
|
||||
}
|
||||
}
|
||||
tag.CodePath = pathSection.ToCodePath()
|
||||
p.UpdateById(ctx, tag)
|
||||
}
|
||||
|
||||
// 更新资源标签的code与codePath,貌似这段可以不用,先留着
|
||||
for _, parentTag := range resourceParentTags {
|
||||
pathSection := entity.GetTagPathSections(parentTag.CodePath)
|
||||
pathSection[len(pathSection)-1].Code = newParentCode
|
||||
newCodePath := pathSection.ToCodePath()
|
||||
// 若新的父级标签路径已存在,则不更新该父标签,避免出现重复的标签路径
|
||||
if p.CountByCond(&entity.TagTree{CodePath: newCodePath}) > 0 {
|
||||
continue
|
||||
tag.CodePath = pathSection.ToCodePath()
|
||||
if err := p.UpdateById(ctx, tag); err != nil {
|
||||
return err
|
||||
}
|
||||
parentTag.CodePath = newCodePath
|
||||
parentTag.Code = newParentCode
|
||||
parentTag.Name = newParentName
|
||||
p.UpdateById(ctx, parentTag)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -476,7 +470,7 @@ func (p *tagTreeAppImpl) FillTagInfo(resourceTagType entity.TagType, resources .
|
||||
|
||||
for _, tr := range tagResources {
|
||||
// 赋值标签信息
|
||||
resourceCode2Resouce[tr.Code].SetTagInfo(entity.ResourceTag{CodePath: tr.CodePath})
|
||||
resourceCode2Resouce[tr.Code].SetTagInfo(entity.ResourceTag{CodePath: tr.GetTagPath()})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ type teamAppImpl struct {
|
||||
teamRepo repository.Team `inject:"TeamRepo"`
|
||||
teamMemberRepo repository.TeamMember `inject:"TeamMemberRepo"`
|
||||
tagTreeTeamRepo repository.TagTreeTeam `inject:"TagTreeTeamRepo"`
|
||||
tagTreeApp TagTree `inject:"TagTreeApp"`
|
||||
}
|
||||
|
||||
func (p *teamAppImpl) GetPageList(condition *entity.TeamQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
||||
@@ -103,13 +102,7 @@ func (p *teamAppImpl) Save(ctx context.Context, saveParam *SaveTeamParam) error
|
||||
|
||||
addTeamTags := make([]*entity.TagTreeTeam, 0)
|
||||
for _, v := range addIds {
|
||||
tagId := v
|
||||
tag, err := p.tagTreeApp.GetById(new(entity.TagTree), tagId)
|
||||
if err != nil {
|
||||
return errorx.NewBiz("存在非法标签id")
|
||||
}
|
||||
|
||||
ptt := &entity.TagTreeTeam{TeamId: teamId, TagId: tagId, TagPath: tag.CodePath}
|
||||
ptt := &entity.TagTreeTeam{TeamId: teamId, TagId: v}
|
||||
addTeamTags = append(addTeamTags, ptt)
|
||||
}
|
||||
if len(addTeamTags) > 0 {
|
||||
|
||||
@@ -7,6 +7,5 @@ type TagTreeTeam struct {
|
||||
model.Model
|
||||
|
||||
TagId uint64 `json:"tagId"`
|
||||
TagPath string `json:"tagPath"`
|
||||
TeamId uint64 `json:"teamId"`
|
||||
}
|
||||
|
||||
@@ -8,8 +8,5 @@ import (
|
||||
type TagTreeTeam interface {
|
||||
base.Repo[*entity.TagTreeTeam]
|
||||
|
||||
// 获取团队标签信息列表
|
||||
// ListTag(condition *entity.TagTreeTeam, toEntity any, orderBy ...string)
|
||||
|
||||
SelectTagPathsByAccountId(accountId uint64) []string
|
||||
}
|
||||
|
||||
@@ -17,6 +17,23 @@ func newTagTreeTeamRepo() repository.TagTreeTeam {
|
||||
|
||||
func (p *tagTreeTeamRepoImpl) SelectTagPathsByAccountId(accountId uint64) []string {
|
||||
var res []string
|
||||
gormx.GetListBySql2Model("SELECT DISTINCT(t1.tag_path) FROM t_tag_tree_team t1 JOIN t_team_member t2 ON t1.team_id = t2.team_id WHERE t2.account_id = ? AND t1.is_deleted = 0 AND t2.is_deleted = 0 ORDER BY t1.tag_path", &res, accountId)
|
||||
sql := `
|
||||
SELECT
|
||||
DISTINCT(t.code_path)
|
||||
FROM
|
||||
t_tag_tree_team t1
|
||||
JOIN t_team_member t2 ON
|
||||
t1.team_id = t2.team_id
|
||||
JOIN t_tag_tree t ON
|
||||
t.id = t1.tag_id
|
||||
WHERE
|
||||
t2.account_id = ?
|
||||
AND t1.is_deleted = 0
|
||||
AND t2.is_deleted = 0
|
||||
AND t.is_deleted = 0
|
||||
ORDER BY
|
||||
t.code_path
|
||||
`
|
||||
gormx.GetListBySql2Model(sql, &res, accountId)
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ var (
|
||||
func RegisterCustomPatterns() {
|
||||
// 账号用户名校验
|
||||
RegisterPattern("account_username", "^[a-zA-Z0-9_]{5,20}$", "只允许输入5-20位大小写字母、数字、下划线")
|
||||
RegisterPattern("resource_code", "^[a-zA-Z0-9_.:]{1,32}$", "只允许输入1-32位大小写字母、数字、_.:")
|
||||
RegisterPattern("resource_code", "^[a-zA-Z0-9_-.:]{1,32}$", "只允许输入1-32位大小写字母、数字、_-.:")
|
||||
}
|
||||
|
||||
// 注册自定义正则表达式
|
||||
|
||||
@@ -36,7 +36,7 @@ CREATE TABLE `t_db` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL,
|
||||
`name` varchar(191) COLLATE utf8mb4_bin DEFAULT NULL,
|
||||
`database` varchar(191) COLLATE utf8mb4_bin DEFAULT NULL,
|
||||
`database` varchar(1000) COLLATE utf8mb4_bin DEFAULT NULL,
|
||||
`remark` varchar(191) COLLATE utf8mb4_bin DEFAULT NULL,
|
||||
`instance_id` bigint unsigned NOT NULL,
|
||||
`auth_cert_name` varchar(36) NULL COMMENT '授权凭证名',
|
||||
@@ -887,10 +887,9 @@ COMMIT;
|
||||
DROP TABLE IF EXISTS `t_tag_tree`;
|
||||
CREATE TABLE `t_tag_tree` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pid` bigint(20) NOT NULL DEFAULT '0',
|
||||
`type` tinyint NOT NULL DEFAULT '-1' COMMENT '类型: -1.普通标签; 1机器 2db 3redis 4mongo',
|
||||
`code` varchar(36) NOT NULL COMMENT '标识符',
|
||||
`code_path` varchar(555) NOT NULL COMMENT '标识符路径',
|
||||
`code_path` varchar(800) NOT NULL COMMENT '标识符路径',
|
||||
`name` varchar(36) DEFAULT NULL COMMENT '名称',
|
||||
`remark` varchar(255) DEFAULT NULL,
|
||||
`create_time` datetime NOT NULL,
|
||||
@@ -910,7 +909,7 @@ CREATE TABLE `t_tag_tree` (
|
||||
-- Records of t_tag_tree
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `t_tag_tree` VALUES (1, 0, -1, 'default', 'default/', '默认', '默认标签', '2022-10-26 20:04:19', 1, 'admin', '2022-10-26 20:04:19', 1, 'admin', 0, NULL);
|
||||
INSERT INTO `t_tag_tree` VALUES (1, -1, 'default', 'default/', '默认', '默认标签', '2022-10-26 20:04:19', 1, 'admin', '2022-10-26 20:04:19', 1, 'admin', 0, NULL);
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
@@ -920,7 +919,6 @@ DROP TABLE IF EXISTS `t_tag_tree_team`;
|
||||
CREATE TABLE `t_tag_tree_team` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`tag_id` bigint(20) NOT NULL COMMENT '项目树id',
|
||||
`tag_path` varchar(255) DEFAULT NULL,
|
||||
`team_id` bigint(20) NOT NULL COMMENT '团队id',
|
||||
`create_time` datetime NOT NULL,
|
||||
`creator_id` bigint(20) NOT NULL,
|
||||
@@ -938,7 +936,7 @@ CREATE TABLE `t_tag_tree_team` (
|
||||
-- Records of t_tag_tree_team
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `t_tag_tree_team` VALUES (1, 1, 'default/', 1, '2022-10-26 20:04:45', 1, 'admin', '2022-10-26 20:04:45', 1, 'admin', 0, NULL);
|
||||
INSERT INTO `t_tag_tree_team` VALUES (1, 1, 1, '2022-10-26 20:04:45', 1, 'admin', '2022-10-26 20:04:45', 1, 'admin', 0, NULL);
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
|
||||
@@ -139,7 +139,8 @@ FROM
|
||||
and ttt.type = 21
|
||||
and td.is_deleted = 0) as t1;
|
||||
|
||||
UPDATE t_tag_tree SET is_deleted = 0, delete_time = NOW() WHERE `type` = 2;
|
||||
UPDATE t_tag_tree SET is_deleted = 1, delete_time = NOW() WHERE `type` = 2;
|
||||
UPDATE t_tag_tree SET `type` = 2 WHERE `type` = 100;
|
||||
|
||||
ALTER TABLE t_tag_tree DROP COLUMN pid;
|
||||
ALTER TABLE t_tag_tree_team DROP COLUMN tag_path;
|
||||
Reference in New Issue
Block a user