mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-02-13 00:05:38 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f91b89f38a |
@@ -70,7 +70,7 @@
|
||||
@clear="selectData"
|
||||
size="small"
|
||||
clearable
|
||||
class="!w-full"
|
||||
class="w-full"
|
||||
highlight-first-item
|
||||
value-key="columnName"
|
||||
ref="condInputRef"
|
||||
@@ -490,7 +490,7 @@ const handlerColumnSelect = (column: any) => {
|
||||
let value = column.columnName + ' = ';
|
||||
// 不是数字类型默认拼接上''
|
||||
if (!DbInst.isNumber(column.dataType)) {
|
||||
value = `${value} ''`;
|
||||
value = `${value}''`;
|
||||
}
|
||||
|
||||
if (lastSpaceIndex != -1) {
|
||||
|
||||
@@ -36,8 +36,8 @@ require (
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/veops/go-ansiterm v0.0.5
|
||||
go.mongodb.org/mongo-driver/v2 v2.3.0 // mongo
|
||||
golang.org/x/crypto v0.47.0 // ssh
|
||||
golang.org/x/oauth2 v0.34.0
|
||||
golang.org/x/crypto v0.48.0
|
||||
golang.org/x/oauth2 v0.35.0
|
||||
golang.org/x/sync v0.19.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
@@ -133,11 +133,11 @@ require (
|
||||
golang.org/x/arch v0.21.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20251002181428-27f1f14c8bb9 // indirect
|
||||
golang.org/x/image v0.31.0 // indirect
|
||||
golang.org/x/mod v0.31.0 // indirect
|
||||
golang.org/x/net v0.48.0 // indirect
|
||||
golang.org/x/sys v0.40.0 // indirect
|
||||
golang.org/x/text v0.33.0 // indirect
|
||||
golang.org/x/tools v0.40.0 // indirect
|
||||
golang.org/x/mod v0.32.0 // indirect
|
||||
golang.org/x/net v0.49.0 // indirect
|
||||
golang.org/x/sys v0.41.0 // indirect
|
||||
golang.org/x/text v0.34.0 // indirect
|
||||
golang.org/x/tools v0.41.0 // indirect
|
||||
google.golang.org/protobuf v1.36.10 // indirect
|
||||
modernc.org/libc v1.66.10 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
|
||||
@@ -21,7 +21,7 @@ type Meta interface {
|
||||
GetDialect(*DbConn) Dialect
|
||||
|
||||
// GetMetadata 获取元数据信息接口
|
||||
// @param *DbConn 数据库连接
|
||||
// - *DbConn 数据库连接
|
||||
GetMetadata(*DbConn) Metadata
|
||||
|
||||
// GetDbDataTypes 获取所有数据库对应的数据类型
|
||||
|
||||
@@ -11,7 +11,7 @@ type DbDialect string
|
||||
type SqlParser interface {
|
||||
|
||||
// sql解析
|
||||
// @param stmt sql语句
|
||||
// - stmt sql语句
|
||||
Parse(stmt string) ([]sqlstmt.Stmt, error)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ type QuoteChar struct {
|
||||
/**
|
||||
* Wrap value with quote character.
|
||||
*
|
||||
* @param value value to be wrapped
|
||||
* - value value to be wrapped
|
||||
* @return wrapped value
|
||||
*/
|
||||
func (qc *QuoteChar) Wrap(value string) string {
|
||||
@@ -20,7 +20,7 @@ func (qc *QuoteChar) Wrap(value string) string {
|
||||
/**
|
||||
* Unwrap value with quote character.
|
||||
*
|
||||
* @param value value to be unwrapped
|
||||
* - value value to be unwrapped
|
||||
* @return unwrapped value
|
||||
*/
|
||||
func (qc *QuoteChar) Unwrap(value string) string {
|
||||
@@ -33,7 +33,7 @@ func (qc *QuoteChar) Unwrap(value string) string {
|
||||
/**
|
||||
* Is wrapped by quote character.
|
||||
*
|
||||
* @param value value to be judged
|
||||
* - value value to be judged
|
||||
* @return is wrapped or not
|
||||
*/
|
||||
func (qc *QuoteChar) IsWrapped(value string) bool {
|
||||
|
||||
@@ -29,8 +29,8 @@ func (p *Procdef) TableName() string {
|
||||
}
|
||||
|
||||
// MatchCondition 是否匹配审批条件,匹配则需要启用该流程
|
||||
// @param bizType 业务类型
|
||||
// @param param 业务参数
|
||||
// - bizType 业务类型
|
||||
// - param 业务参数
|
||||
// Condition返回值为1,则表面该操作需要启用流程
|
||||
func (p *Procdef) MatchCondition(bizType string, param map[string]any) bool {
|
||||
if p.Condition == nil || *p.Condition == "" {
|
||||
|
||||
@@ -36,7 +36,7 @@ type MachineCronJob interface {
|
||||
InitCronJob()
|
||||
|
||||
// 执行cron job
|
||||
// @param key cron job key
|
||||
// - key cron job key
|
||||
RunCronJob(key string)
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ func (c *Cli) GetSession() (*ssh.Session, error) {
|
||||
}
|
||||
|
||||
// Run 执行shell
|
||||
// @param shell shell脚本命令
|
||||
// - shell shell脚本命令
|
||||
// @return 返回执行成功或错误的消息
|
||||
func (c *Cli) Run(shell string) (string, error) {
|
||||
session, err := c.GetSession()
|
||||
|
||||
@@ -11,7 +11,7 @@ var (
|
||||
)
|
||||
|
||||
// 从缓存中获取客户端信息,不存在则回调获取机器信息函数,并新建。
|
||||
// @param 机器的授权凭证名
|
||||
// - 机器的授权凭证名
|
||||
func GetMachineCli(ctx context.Context, authCertName string, getMachine func(string) (*MachineInfo, error)) (*Cli, error) {
|
||||
pool, err := poolGroup.GetCachePool(authCertName, func() (*Cli, error) {
|
||||
mi, err := getMachine(authCertName)
|
||||
|
||||
@@ -30,7 +30,7 @@ type Mongo interface {
|
||||
Delete(ctx context.Context, id uint64) error
|
||||
|
||||
// 获取mongo连接实例
|
||||
// @param id mongo id
|
||||
// - id mongo id
|
||||
GetMongoConn(ctx context.Context, id uint64) (*mgm.MongoConn, error)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ const (
|
||||
)
|
||||
|
||||
// 使用系统默认的私钥解密
|
||||
// @param base64 字符串是否使用base64编码
|
||||
// - base64 字符串是否使用base64编码
|
||||
func DefaultRsaDecrypt(data string, useBase64 bool) (string, error) {
|
||||
// 空字符串不解密
|
||||
if data == "" {
|
||||
|
||||
@@ -49,8 +49,8 @@ type TagTree interface {
|
||||
Delete(ctx context.Context, id uint64) error
|
||||
|
||||
// GetAccountTags 获取指定账号有权限操作的标签列表
|
||||
// @param accountId 账号id
|
||||
// @param query 查询条件
|
||||
// - accountId 账号id
|
||||
// - query 查询条件
|
||||
GetAccountTags(accountId uint64, query *entity.TagTreeQuery) dto.SimpleTagTrees
|
||||
|
||||
// 根据标签类型和标签code获取对应的标签路径列表
|
||||
|
||||
@@ -22,15 +22,15 @@ type App[T model.ModelI] interface {
|
||||
UpdateById(ctx context.Context, e T) error
|
||||
|
||||
// UpdateByCond 更新满足条件的数据
|
||||
// @param values 需为模型结构体指针或map(更新零值等)
|
||||
// @param cond 可为*model.QueryCond也可以为普通查询model
|
||||
// - values 需为模型结构体指针或map(更新零值等)
|
||||
// - cond 可为*model.QueryCond也可以为普通查询model
|
||||
UpdateByCond(ctx context.Context, values any, cond any) error
|
||||
|
||||
// DeleteById 根据实体主键删除实体
|
||||
DeleteById(ctx context.Context, id ...uint64) error
|
||||
|
||||
// DeleteByCond 根据条件进行删除
|
||||
// @param cond 可为*model.QueryCond也可以为普通查询model
|
||||
// - cond 可为*model.QueryCond也可以为普通查询model
|
||||
DeleteByCond(ctx context.Context, cond any) error
|
||||
|
||||
// Save 保存实体,实体IsCreate返回true则新增,否则更新
|
||||
@@ -43,23 +43,23 @@ type App[T model.ModelI] interface {
|
||||
GetByIds(ids []uint64, cols ...string) ([]T, error)
|
||||
|
||||
// GetByCond 根据实体条件查询实体信息(获取单个实体)
|
||||
// @param cond 可为*model.QueryCond也可以为普通查询model
|
||||
// - cond 可为*model.QueryCond也可以为普通查询model
|
||||
GetByCond(cond any) error
|
||||
|
||||
// ListByCondToAny 根据条件查询数据映射至res
|
||||
// @param cond 可为*model.QueryCond也可以为普通查询model
|
||||
// - cond 可为*model.QueryCond也可以为普通查询model
|
||||
ListByCondToAny(cond any, res any) error
|
||||
|
||||
// ListByCond 根据条件查询
|
||||
// @param cond 可为*model.QueryCond也可以为普通查询model
|
||||
// - cond 可为*model.QueryCond也可以为普通查询model
|
||||
ListByCond(cond any, cols ...string) ([]T, error)
|
||||
|
||||
// PageByCond 根据指定条件分页查询
|
||||
// @param cond 可为*model.QueryCond也可以为普通查询model
|
||||
// - cond 可为*model.QueryCond也可以为普通查询model
|
||||
PageByCond(cond any, pageParam model.PageParam, cols ...string) (*model.PageResult[T], error)
|
||||
|
||||
// CountByCond 根据指定条件统计model表的数量
|
||||
// @param cond 可为*model.QueryCond也可以为普通查询model
|
||||
// - cond 可为*model.QueryCond也可以为普通查询model
|
||||
CountByCond(cond any) int64
|
||||
|
||||
// CursorByCond 根据指定条件遍历model表数据
|
||||
@@ -97,8 +97,8 @@ func (ai *AppImpl[T, R]) UpdateById(ctx context.Context, e T) error {
|
||||
}
|
||||
|
||||
// UpdateByCond 更新满足条件的数据
|
||||
// @param values 需为模型结构体指针或map(更新零值等)
|
||||
// @param cond 可为*model.QueryCond也可以为普通查询model
|
||||
// - values 需为模型结构体指针或map(更新零值等)
|
||||
// - cond 可为*model.QueryCond也可以为普通查询model
|
||||
func (ai *AppImpl[T, R]) UpdateByCond(ctx context.Context, values any, cond any) error {
|
||||
return ai.GetRepo().UpdateByCond(ctx, values, cond)
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ type Repo[T model.ModelI] interface {
|
||||
UpdateByIdWithDb(ctx context.Context, db *gorm.DB, e T, columns ...string) error
|
||||
|
||||
// UpdateByCond 更新满足条件的数据
|
||||
// @param values 需要模型结构体或map
|
||||
// @param cond 条件
|
||||
// - values 需要模型结构体或map
|
||||
// - cond 条件
|
||||
UpdateByCond(ctx context.Context, values any, cond any) error
|
||||
|
||||
// UpdateByCondWithDb 更新满足条件的数据
|
||||
// @param values 需要模型结构体或map
|
||||
// - values 需要模型结构体或map
|
||||
UpdateByCondWithDb(ctx context.Context, db *gorm.DB, values any, cond any) error
|
||||
|
||||
// Save 保存实体,实体IsCreate返回true则新增,否则更新
|
||||
@@ -71,7 +71,7 @@ type Repo[T model.ModelI] interface {
|
||||
GetByIds(ids []uint64, cols ...string) ([]T, error)
|
||||
|
||||
// GetByCond 根据实体条件查询实体信息(单个结果集)
|
||||
// @param cond 支持普通结构体或*model.QueryCond。如果cond为model.QueryCond,则需要使用Dest方法绑定值的指针
|
||||
// - cond 支持普通结构体或*model.QueryCond。如果cond为model.QueryCond,则需要使用Dest方法绑定值的指针
|
||||
GetByCond(cond any) error
|
||||
|
||||
// SelectByCondToAny 根据条件查询数据映射至res
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// 断言错误为ni
|
||||
// @param msgAndParams 消息与参数占位符,第一位为错误消息可包含%s等格式化标识。其余为Sprintf格式化值内容
|
||||
// - msgAndParams 消息与参数占位符,第一位为错误消息可包含%s等格式化标识。其余为Sprintf格式化值内容
|
||||
//
|
||||
// ErrIsNil(err)
|
||||
// ErrIsNil(err, "xxxx")
|
||||
@@ -26,7 +26,7 @@ func ErrIsNil(err error, msgAndParams ...any) {
|
||||
}
|
||||
|
||||
// 断言错误为ni
|
||||
// @param msgId i18n消息id
|
||||
// - msgId i18n消息id
|
||||
//
|
||||
// ErrIsNil(err)
|
||||
// ErrIsNil(err, "xxxx")
|
||||
|
||||
@@ -17,7 +17,7 @@ func UndeleteScope(db *gorm.DB) *gorm.DB {
|
||||
// 根据id获取实体对象。model需为指针类型(需要将查询出来的值赋值给model)
|
||||
//
|
||||
// 若error不为nil则为不存在该记录
|
||||
// @param dbModel 数据库映射实体模型
|
||||
// - dbModel 数据库映射实体模型
|
||||
func GetById(dbModel model.ModelI, id uint64, cols ...string) error {
|
||||
return NewQuery(dbModel, model.NewCond().Columns(cols...).Eq(model.IdColumn, id)).GenGdb().First(dbModel).Error
|
||||
}
|
||||
@@ -25,7 +25,7 @@ func GetById(dbModel model.ModelI, id uint64, cols ...string) error {
|
||||
// 根据model获取单个实体对象
|
||||
//
|
||||
// 若 error不为nil,则为不存在该记录
|
||||
// @param cond 查询条件
|
||||
// - cond 查询条件
|
||||
func GetByCond(dbModel model.ModelI, cond *model.QueryCond) error {
|
||||
return NewQuery(dbModel, cond).GenGdb().First(cond.GetDest()).Error
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func ExecSql(sql string, params ...any) error {
|
||||
}
|
||||
|
||||
// 插入model
|
||||
// @param model 数据库映射实体模型
|
||||
// - model 数据库映射实体模型
|
||||
func Insert(model model.ModelI) error {
|
||||
return InsertWithDb(global.Db, model)
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func BatchInsertWithDb[T model.ModelI](db *gorm.DB, models []T) error {
|
||||
}
|
||||
|
||||
// 根据id更新model,更新字段为model中不为空的值,即int类型不为0,ptr类型不为nil这类字段值
|
||||
// @param model 数据库映射实体模型
|
||||
// - model 数据库映射实体模型
|
||||
func UpdateById(model model.ModelI, columns ...string) error {
|
||||
return UpdateByIdWithDb(global.Db, model, columns...)
|
||||
}
|
||||
@@ -132,7 +132,7 @@ func UpdateByCondWithDb(db *gorm.DB, dbModel model.ModelI, values any, cond *mod
|
||||
}
|
||||
|
||||
// 根据id删除model
|
||||
// @param model 数据库映射实体模型
|
||||
// - model 数据库映射实体模型
|
||||
func DeleteById(model_ model.ModelI, id ...uint64) error {
|
||||
return DeleteByIdWithDb(global.Db, model_, id...)
|
||||
}
|
||||
@@ -144,16 +144,16 @@ func DeleteByIdWithDb(db *gorm.DB, model_ model.ModelI, id ...uint64) error {
|
||||
|
||||
// 根据cond条件删除指定model表数据
|
||||
//
|
||||
// @param dbModel 数据库映射实体模型
|
||||
// @param cond 条件
|
||||
// - dbModel 数据库映射实体模型
|
||||
// - cond 条件
|
||||
func DeleteByCond(dbModel model.ModelI, cond *model.QueryCond) error {
|
||||
return DeleteByCondWithDb(global.Db, dbModel, cond)
|
||||
}
|
||||
|
||||
// 根据cond条件删除指定model表数据
|
||||
//
|
||||
// @param dbModel 数据库映射实体模型
|
||||
// @param cond 条件
|
||||
// - dbModel 数据库映射实体模型
|
||||
// - cond 条件
|
||||
func DeleteByCondWithDb(db *gorm.DB, dbModel model.ModelI, cond *model.QueryCond) error {
|
||||
gdb := setGdbWhere(db.Model(dbModel), cond)
|
||||
if !dbModel.LogicDelete() {
|
||||
|
||||
@@ -33,13 +33,13 @@ func (r *Result) IsSuccess() bool {
|
||||
}
|
||||
|
||||
// 返回成功状态的Result
|
||||
// @param data 成功附带的数据消息
|
||||
// - data 成功附带的数据消息
|
||||
func Success(data any) *Result {
|
||||
return &Result{Code: SuccessCode, Msg: SuccessMsg, Data: data}
|
||||
}
|
||||
|
||||
// 返回成功状态的Result
|
||||
// @param data 成功不附带数据
|
||||
// - data 成功不附带数据
|
||||
func SuccessNoData() *Result {
|
||||
return &Result{Code: SuccessCode, Msg: SuccessMsg}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
// StackStr 获取指定堆栈描述信息
|
||||
//
|
||||
// @param skip: 跳过堆栈个数
|
||||
// @param nFrames: 需要描述的堆栈个数
|
||||
// - skip: 跳过堆栈个数
|
||||
// - nFrames: 需要描述的堆栈个数
|
||||
func StackStr(skip, nFrames int) string {
|
||||
pcs := make([]uintptr, nFrames+1)
|
||||
n := runtime.Callers(skip+1, pcs)
|
||||
|
||||
@@ -16,8 +16,8 @@ func parse(t *template.Template, vars any) (string, error) {
|
||||
}
|
||||
|
||||
// 模板字符串解析
|
||||
// @param str 模板字符串
|
||||
// @param vars 参数变量
|
||||
// - str 模板字符串
|
||||
// - vars 参数变量
|
||||
func TemplateParse(str string, vars any) (string, error) {
|
||||
tmpl, err := template.New("tmpl").Parse(str)
|
||||
|
||||
|
||||
@@ -96,8 +96,8 @@ func Translate2Str(data any, err error) string {
|
||||
|
||||
// 获取自定义的错误提示消息
|
||||
//
|
||||
// @param validTag 校验标签,如required等
|
||||
// @param customMsg 自定义错误消息
|
||||
// - validTag 校验标签,如required等
|
||||
// - customMsg 自定义错误消息
|
||||
func getCustomErrMsg(validTag, customMsg string) string {
|
||||
// 解析 msg:"required=用户名不能为空,min=用户名长度不能小于8位"
|
||||
msgs := strings.Split(customMsg, ",")
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
type UserId uint64
|
||||
|
||||
// 客户端读取消息处理函数
|
||||
// @param msg
|
||||
// - msg
|
||||
type ReadMsgHandlerFunc func([]byte)
|
||||
|
||||
type Client struct {
|
||||
|
||||
Reference in New Issue
Block a user