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

View File

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

View File

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

View File

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

View File

@@ -15,7 +15,7 @@ require (
github.com/sirupsen/logrus v1.9.0
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
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
// gorm
gorm.io/driver/mysql v1.4.1
@@ -50,9 +50,9 @@ require (
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // 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/sys v0.1.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // 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
keyValue := new(form.StringValue)
ginx.BindJsonAndValid(g, keyValue)
rc.ReqParam = keyValue
ri := r.RedisApp.GetRedisInstance(uint64(ginx.PathParamInt(g, "id")), ginx.PathParamInt(g, "db"))
biz.ErrIsNilAppendErr(r.TagApp.CanAccess(rc.LoginAccount.Id, ri.TagPath), "%s")

View File

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

View File

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