fix: 主键字段获取调整&其他小优化

This commit is contained in:
meilin.huang
2022-11-14 18:07:27 +08:00
parent 99ce3bd099
commit debc34f0fb
8 changed files with 31 additions and 19 deletions

View File

@@ -116,7 +116,7 @@ const options = {
cursorBlinking: 'smooth',// 光标闪烁样式 cursorBlinking: 'smooth',// 光标闪烁样式
mouseWheelZoom: true, // 在按住Ctrl键的同时使用鼠标滚轮时在编辑器中缩放字体 mouseWheelZoom: true, // 在按住Ctrl键的同时使用鼠标滚轮时在编辑器中缩放字体
overviewRulerBorder: false, // 不要滚动条的边框 overviewRulerBorder: false, // 不要滚动条的边框
tabSize: 2, // tab 缩进长度 tabSize: 4, // tab 缩进长度
fontFamily: 'JetBrainsMono', // 字体 暂时不要设置,否则光标容易错位 fontFamily: 'JetBrainsMono', // 字体 暂时不要设置,否则光标容易错位
fontWeight: 'bold', fontWeight: 'bold',
// fontSize: 12, // fontSize: 12,

View File

@@ -33,7 +33,7 @@
popper-class="el-popover-pupop-user-news" popper-class="el-popover-pupop-user-news"
> >
<template #reference> <template #reference>
<el-badge :is-dot="true" @click="isShowUserNewsPopover = !isShowUserNewsPopover"> <el-badge :is-dot="false" @click="isShowUserNewsPopover = !isShowUserNewsPopover">
<el-icon title="消息"> <el-icon title="消息">
<bell /> <bell />
</el-icon> </el-icon>

View File

@@ -40,7 +40,7 @@ export default {
}; };
// 前往通知中心点击 // 前往通知中心点击
const toMsgCenter = () => { const toMsgCenter = () => {
// window.open('https://gitee.com/lyt-top/vue-next-admin');
}; };
return { return {
onAllReadClick, onAllReadClick,

View File

@@ -387,7 +387,7 @@ const initMonacoEditor = () => {
mouseWheelZoom: true, // 在按住Ctrl键的同时使用鼠标滚轮时在编辑器中缩放字体 mouseWheelZoom: true, // 在按住Ctrl键的同时使用鼠标滚轮时在编辑器中缩放字体
overviewRulerBorder: false, // 不要滚动条的边框 overviewRulerBorder: false, // 不要滚动条的边框
tabSize: 2, // tab 缩进长度 tabSize: 2, // tab 缩进长度
// fontFamily: 'JetBrainsMono', // 字体 暂时不要设置,否则光标容易错位 fontFamily: 'JetBrainsMono', // 字体 暂时不要设置,否则光标容易错位
fontWeight: 'bold', fontWeight: 'bold',
// letterSpacing: 1, 字符间距 // letterSpacing: 1, 字符间距
// quickSuggestions:false, // 禁用代码提示 // quickSuggestions:false, // 禁用代码提示
@@ -1450,12 +1450,13 @@ const cellClick = (row: any, column: any, cell: any) => {
/** /**
* 根据字段列名获取字段列信息。 * 根据字段列名获取字段列信息。
* 若字段列名为空,则返回第一个字段列信息(用于获取主键等,目前先以默认表字段第一个字段 * 若字段列名为空,则返回主键列,若无主键列返回第一个字段列信息(用于获取主键等)
*/ */
const getColumn = async (tableName: string, columnName: string = '') => { const getColumn = async (tableName: string, columnName: string = '') => {
const cols = await getColumns(tableName); const cols = await getColumns(tableName);
if (!columnName) { if (!columnName) {
return cols[0]; const col = cols.find((c: any) => c.columnKey == 'PRI');
return col || cols[0];
} }
return cols.find((c: any) => c.columnName == columnName); return cols.find((c: any) => c.columnName == columnName);
}; };

View File

@@ -15,7 +15,7 @@ require (
github.com/sirupsen/logrus v1.9.0 github.com/sirupsen/logrus v1.9.0
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
go.mongodb.org/mongo-driver v1.9.1 // mongo go.mongodb.org/mongo-driver v1.9.1 // mongo
golang.org/x/crypto v0.1.0 // ssh golang.org/x/crypto v0.2.0 // ssh
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
// gorm // gorm
gorm.io/driver/mysql v1.4.1 gorm.io/driver/mysql v1.4.1
@@ -50,9 +50,9 @@ require (
github.com/xdg-go/stringprep v1.0.2 // indirect github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/image v0.0.0-20220302094943-723b81ca9867 // indirect golang.org/x/image v0.0.0-20220302094943-723b81ca9867 // indirect
golang.org/x/net v0.1.0 // indirect golang.org/x/net v0.2.0 // indirect
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
golang.org/x/sys v0.1.0 // indirect golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect golang.org/x/text v0.4.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/protobuf v1.28.0 // indirect google.golang.org/protobuf v1.28.0 // indirect

View File

@@ -297,6 +297,7 @@ func (r *Redis) SetStringValue(rc *ctx.ReqCtx) {
g := rc.GinCtx g := rc.GinCtx
keyValue := new(form.StringValue) keyValue := new(form.StringValue)
ginx.BindJsonAndValid(g, keyValue) ginx.BindJsonAndValid(g, keyValue)
rc.ReqParam = keyValue
ri := r.RedisApp.GetRedisInstance(uint64(ginx.PathParamInt(g, "id")), ginx.PathParamInt(g, "db")) ri := r.RedisApp.GetRedisInstance(uint64(ginx.PathParamInt(g, "id")), ginx.PathParamInt(g, "db"))
biz.ErrIsNilAppendErr(r.TagApp.CanAccess(rc.LoginAccount.Id, ri.TagPath), "%s") biz.ErrIsNilAppendErr(r.TagApp.CanAccess(rc.LoginAccount.Id, ri.TagPath), "%s")

View File

@@ -50,7 +50,7 @@ func InitRedisRouter(router *gin.RouterGroup) {
}) })
// 删除key // 删除key
deleteKeyL := ctx.NewLogInfo("redis删除key").WithSave(true) deleteKeyL := ctx.NewLogInfo("redis-删除key").WithSave(true)
redis.DELETE(":id/:db/key", func(c *gin.Context) { redis.DELETE(":id/:db/key", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteKeyL).Handle(rs.DeleteKey) ctx.NewReqCtxWithGin(c).WithLog(deleteKeyL).Handle(rs.DeleteKey)
}) })
@@ -61,8 +61,9 @@ func InitRedisRouter(router *gin.RouterGroup) {
}) })
// 设置string类型值 // 设置string类型值
setStringL := ctx.NewLogInfo("redis-setString").WithSave(true)
redis.POST(":id/:db/string-value", func(c *gin.Context) { redis.POST(":id/:db/string-value", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).Handle(rs.SetStringValue) ctx.NewReqCtxWithGin(c).WithLog(setStringL).Handle(rs.SetStringValue)
}) })
// hscan // hscan
@@ -74,13 +75,15 @@ func InitRedisRouter(router *gin.RouterGroup) {
ctx.NewReqCtxWithGin(c).Handle(rs.Hget) ctx.NewReqCtxWithGin(c).Handle(rs.Hget)
}) })
hdelL := ctx.NewLogInfo("redis-hdel").WithSave(true)
redis.DELETE(":id/:db/hdel", func(c *gin.Context) { redis.DELETE(":id/:db/hdel", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).Handle(rs.Hdel) ctx.NewReqCtxWithGin(c).WithLog(hdelL).Handle(rs.Hdel)
}) })
// 设置hash类型值 // 设置hash类型值
setHashValueL := ctx.NewLogInfo("redis-setHashValue").WithSave(true)
redis.POST(":id/:db/hash-value", func(c *gin.Context) { redis.POST(":id/:db/hash-value", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).Handle(rs.SetHashValue) ctx.NewReqCtxWithGin(c).WithLog(setHashValueL).Handle(rs.SetHashValue)
}) })
// 获取set类型值 // 获取set类型值

View File

@@ -74,14 +74,12 @@ func LogHandler(rc *ReqCtx) error {
func getLogMsg(rc *ReqCtx) string { func getLogMsg(rc *ReqCtx) string {
msg := rc.LogInfo.Description + fmt.Sprintf(" ->%dms", rc.timed) msg := rc.LogInfo.Description + fmt.Sprintf(" ->%dms", rc.timed)
if !utils.IsBlank(reflect.ValueOf(rc.ReqParam)) { if !utils.IsBlank(reflect.ValueOf(rc.ReqParam)) {
rb, _ := json.Marshal(rc.ReqParam) msg = msg + fmt.Sprintf("\n--> %s", getDesc(rc.ReqParam))
msg = msg + fmt.Sprintf("\n--> %s", string(rb))
} }
// 返回结果不为空,则记录返回结果 // 返回结果不为空,则记录返回结果
if rc.LogInfo.LogResp && !utils.IsBlank(reflect.ValueOf(rc.ResData)) { if rc.LogInfo.LogResp && !utils.IsBlank(reflect.ValueOf(rc.ResData)) {
respB, _ := json.Marshal(rc.ResData) msg = msg + fmt.Sprintf("\n<-- %s", getDesc(rc.ResData))
msg = msg + fmt.Sprintf("\n<-- %s", string(respB))
} }
return msg return msg
} }
@@ -89,8 +87,7 @@ func getLogMsg(rc *ReqCtx) string {
func getErrMsg(rc *ReqCtx, err interface{}) string { func getErrMsg(rc *ReqCtx, err interface{}) string {
msg := rc.LogInfo.Description msg := rc.LogInfo.Description
if !utils.IsBlank(reflect.ValueOf(rc.ReqParam)) { if !utils.IsBlank(reflect.ValueOf(rc.ReqParam)) {
rb, _ := json.Marshal(rc.ReqParam) msg = msg + fmt.Sprintf("\n--> %s", getDesc(rc.ReqParam))
msg = msg + fmt.Sprintf("\n--> %s", string(rb))
} }
var errMsg string var errMsg string
@@ -104,3 +101,13 @@ func getErrMsg(rc *ReqCtx, err interface{}) string {
} }
return (msg + errMsg) return (msg + errMsg)
} }
// 获取参数的日志描述
func getDesc(param any) string {
if paramStr, ok := param.(string); ok {
return paramStr
}
rb, _ := json.Marshal(param)
return string(rb)
}