refactor: interface{} -> any

feat: 新增外链菜单
This commit is contained in:
meilin.huang
2023-06-01 12:31:32 +08:00
parent 9900b236ef
commit 17d96acceb
106 changed files with 316 additions and 312 deletions

View File

@@ -164,7 +164,7 @@ func (d *Db) ExecSql(rc *req.Ctx) {
}
}
colAndRes := make(map[string]interface{})
colAndRes := make(map[string]any)
colAndRes["colNames"] = execResAll.ColNames
colAndRes["res"] = execResAll.Res
rc.ResData = colAndRes

View File

@@ -21,7 +21,7 @@ import (
type Db interface {
// 分页获取
GetPageList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Count(condition *entity.DbQuery) int64
@@ -58,7 +58,7 @@ type dbAppImpl struct {
}
// 分页获取数据库信息列表
func (d *dbAppImpl) GetPageList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (d *dbAppImpl) GetPageList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return d.dbRepo.GetDbList(condition, pageParam, toEntity, orderBy...)
}
@@ -108,19 +108,19 @@ func (d *dbAppImpl) Save(dbEntity *entity.Db) {
dbId := dbEntity.Id
old := d.GetById(dbId)
var oldDbs []interface{}
var oldDbs []any
for _, v := range strings.Split(old.Database, " ") {
// 关闭数据库连接
CloseDb(dbEntity.Id, v)
oldDbs = append(oldDbs, v)
}
var newDbs []interface{}
var newDbs []any
for _, v := range strings.Split(dbEntity.Database, " ") {
newDbs = append(newDbs, v)
}
// 比较新旧数据库列表,需要将移除的数据库相关联的信息删除
_, delDb, _ := utils.ArrayCompare(newDbs, oldDbs, func(i1, i2 interface{}) bool {
_, delDb, _ := utils.ArrayCompare(newDbs, oldDbs, func(i1, i2 any) bool {
return i1.(string) == i2.(string)
})
for _, v := range delDb {
@@ -295,7 +295,7 @@ func (d *DbInstance) Close() {
// 客户端连接缓存,指定时间内没有访问则会被关闭, key为数据库实例id:数据库
var dbCache = cache.NewTimedCache(constant.DbConnExpireTime, 5*time.Second).
WithUpdateAccessTime(true).
OnEvicted(func(key interface{}, value interface{}) {
OnEvicted(func(key any, value any) {
global.Log.Info(fmt.Sprintf("删除db连接缓存 id = %s", key))
value.(*DbInstance).Close()
})
@@ -353,7 +353,7 @@ func GetDbConn(d *entity.Db, db string) (*sql.DB, error) {
return DB, nil
}
func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]interface{}, error) {
func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]any, error) {
rows, err := db.Query(selectSql)
if err != nil {
return nil, nil, err
@@ -367,7 +367,7 @@ func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]interf
}()
colTypes, _ := rows.ColumnTypes()
// 这里表示一行填充数据
scans := make([]interface{}, len(colTypes))
scans := make([]any, len(colTypes))
// 这里表示一行所有列的值,用[]byte表示
vals := make([][]byte, len(colTypes))
// 这里scans引用vals把数据填充到[]byte里
@@ -375,7 +375,7 @@ func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]interf
scans[k] = &vals[k]
}
result := make([]map[string]interface{}, 0)
result := make([]map[string]any, 0)
// 列名用于前端表头名称按照数据库与查询字段顺序显示
colNames := make([]string, 0)
// 是否第一次遍历,列名数组只需第一次遍历时加入
@@ -387,7 +387,7 @@ func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]interf
return nil, nil, err
}
// 每行数据
rowData := make(map[string]interface{})
rowData := make(map[string]any)
// 把vals中的数据复制到row中
for i, v := range vals {
colType := colTypes[i]
@@ -406,7 +406,7 @@ func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]interf
}
// 将查询的值转为对应列类型的实际值,不全部转为字符串
func valueConvert(data []byte, colType *sql.ColumnType) interface{} {
func valueConvert(data []byte, colType *sql.ColumnType) any {
if data == nil {
return nil
}
@@ -455,7 +455,7 @@ func valueConvert(data []byte, colType *sql.ColumnType) interface{} {
}
// 查询数据结果映射至struct。可参考sqlx库
func Select2StructByDb(db *sql.DB, selectSql string, dest interface{}) error {
func Select2StructByDb(db *sql.DB, selectSql string, dest any) error {
rows, err := db.Query(selectSql)
if err != nil {
return err

View File

@@ -26,7 +26,7 @@ type DbSqlExecReq struct {
type DbSqlExecRes struct {
ColNames []string
Res []map[string]interface{}
Res []map[string]any
}
// 合并执行结果主要用于执行多条sql使用
@@ -52,7 +52,7 @@ type DbSqlExec interface {
DeleteBy(condition *entity.DbSqlExec)
// 分页获取
GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
}
func newDbSqlExecApp(dbExecSqlRepo repository.DbSqlExec) DbSqlExec {
@@ -151,7 +151,7 @@ func (d *dbSqlExecAppImpl) DeleteBy(condition *entity.DbSqlExec) {
d.dbSqlExecRepo.DeleteBy(condition)
}
func (d *dbSqlExecAppImpl) GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (d *dbSqlExecAppImpl) GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return d.dbSqlExecRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
}
@@ -256,8 +256,8 @@ func doExec(sql string, dbInstance *DbInstance) (*DbSqlExecRes, error) {
if err != nil {
execRes = err.Error()
}
res := make([]map[string]interface{}, 0)
resData := make(map[string]interface{})
res := make([]map[string]any, 0)
resData := make(map[string]any)
resData["rowsAffected"] = rowsAffected
resData["sql"] = sql
resData["result"] = execRes

View File

@@ -62,7 +62,7 @@ type DbMetadata interface {
// 获取指定表的数据-分页查询
// @return columns: 列字段名result: 结果集error: 错误
GetTableRecord(tableName string, pageNum, pageSize int) ([]string, []map[string]interface{}, error)
GetTableRecord(tableName string, pageNum, pageSize int) ([]string, []map[string]any, error)
}
// ------------------------- 元数据sql操作 -------------------------

View File

@@ -156,6 +156,6 @@ func (mm *MysqlMetadata) GetCreateTableDdl(tableName string) string {
return res[0]["Create Table"].(string)
}
func (mm *MysqlMetadata) GetTableRecord(tableName string, pageNum, pageSize int) ([]string, []map[string]interface{}, error) {
func (mm *MysqlMetadata) GetTableRecord(tableName string, pageNum, pageSize int) ([]string, []map[string]any, error) {
return mm.di.SelectData(fmt.Sprintf("SELECT * FROM %s LIMIT %d, %d", tableName, (pageNum-1)*pageSize, pageSize))
}

View File

@@ -175,6 +175,6 @@ func (pm *PgsqlMetadata) GetCreateTableDdl(tableName string) string {
return res[0]["sql"].(string)
}
func (pm *PgsqlMetadata) GetTableRecord(tableName string, pageNum, pageSize int) ([]string, []map[string]interface{}, error) {
func (pm *PgsqlMetadata) GetTableRecord(tableName string, pageNum, pageSize int) ([]string, []map[string]any, error) {
return pm.di.SelectData(fmt.Sprintf("SELECT * FROM %s OFFSET %d LIMIT %d", tableName, (pageNum-1)*pageSize, pageSize))
}

View File

@@ -11,7 +11,7 @@ import (
)
// 将结果scan至结构体copy至 sqlx库: https://github.com/jmoiron/sqlx
func scanAll(rows *sql.Rows, dest interface{}, structOnly bool) error {
func scanAll(rows *sql.Rows, dest any, structOnly bool) error {
var v, vp reflect.Value
value := reflect.ValueOf(dest)
@@ -50,7 +50,7 @@ func scanAll(rows *sql.Rows, dest interface{}, structOnly bool) error {
}
if !scannable {
var values []interface{}
var values []any
var m *Mapper = mapper()
fields := m.TraversalsByName(base, columns)
@@ -58,7 +58,7 @@ func scanAll(rows *sql.Rows, dest interface{}, structOnly bool) error {
if f, err := missingFields(fields); err != nil {
return fmt.Errorf("missing destination name %s in %T", columns[f], dest)
}
values = make([]interface{}, len(columns))
values = make([]any, len(columns))
for rows.Next() {
// create a new struct type (which returns PtrTo) and indirect it
@@ -178,7 +178,7 @@ func missingFields(transversals [][]int) (field int, err error) {
// when iterating over many rows. Empty traversals will get an interface pointer.
// Because of the necessity of requesting ptrs or values, it's considered a bit too
// specialized for inclusion in reflectx itself.
func fieldsByTraversal(v reflect.Value, traversals [][]int, values []interface{}, ptrs bool) error {
func fieldsByTraversal(v reflect.Value, traversals [][]int, values []any, ptrs bool) error {
v = reflect.Indirect(v)
if v.Kind() != reflect.Struct {
return errors.New("argument not a struct")
@@ -186,7 +186,7 @@ func fieldsByTraversal(v reflect.Value, traversals [][]int, values []interface{}
for i, traversal := range traversals {
if len(traversal) == 0 {
values[i] = new(interface{})
values[i] = new(any)
continue
}
f := FieldByIndexes(v, traversal)

View File

@@ -7,7 +7,7 @@ import (
type Db interface {
// 分页获取机器信息列表
GetDbList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetDbList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Count(condition *entity.DbQuery) int64

View File

@@ -11,5 +11,5 @@ type DbSqlExec interface {
DeleteBy(condition *entity.DbSqlExec)
// 分页获取
GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
}

View File

@@ -17,10 +17,10 @@ func newDbRepo() repository.Db {
}
// 分页获取数据库信息列表
func (d *dbRepoImpl) GetDbList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (d *dbRepoImpl) GetDbList(condition *entity.DbQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
sql := "SELECT d.* FROM t_db d WHERE 1 = 1 "
values := make([]interface{}, 0)
values := make([]any, 0)
if condition.Host != "" {
sql = sql + " AND d.host LIKE ?"
values = append(values, "%"+condition.Host+"%")
@@ -41,7 +41,7 @@ func (d *dbRepoImpl) GetDbList(condition *entity.DbQuery, pageParam *model.PageP
}
func (d *dbRepoImpl) Count(condition *entity.DbQuery) int64 {
where := make(map[string]interface{})
where := make(map[string]any)
if len(condition.TagIds) > 0 {
where["tag_id"] = condition.TagIds
}

View File

@@ -22,6 +22,6 @@ func (d *dbSqlExecRepoImpl) DeleteBy(condition *entity.DbSqlExec) {
}
// 分页获取
func (d *dbSqlExecRepoImpl) GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (d *dbSqlExecRepoImpl) GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity, orderBy...)
}

View File

@@ -8,7 +8,7 @@ import (
)
type AuthCert interface {
GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Save(ac *entity.AuthCert)
@@ -29,7 +29,7 @@ type authCertAppImpl struct {
authCertRepo repository.AuthCert
}
func (a *authCertAppImpl) GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (a *authCertAppImpl) GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return a.authCertRepo.GetPageList(condition, pageParam, toEntity)
}

View File

@@ -30,7 +30,7 @@ type Machine interface {
GetById(id uint64, cols ...string) *entity.Machine
// 分页获取机器信息列表
GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
// 获取机器连接
GetCli(id uint64) *machine.Cli
@@ -52,7 +52,7 @@ type machineAppImpl struct {
}
// 分页获取机器信息列表
func (m *machineAppImpl) GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *machineAppImpl) GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return m.machineRepo.GetMachineList(condition, pageParam, toEntity, orderBy...)
}

View File

@@ -17,7 +17,7 @@ import (
type MachineFile interface {
// 分页获取机器文件信息列表
GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
// 根据条件获取
GetMachineFile(condition *entity.MachineFile, cols ...string) error
@@ -67,7 +67,7 @@ type machineFileAppImpl struct {
}
// 分页获取机器脚本信息列表
func (m *machineFileAppImpl) GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *machineFileAppImpl) GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return m.machineFileRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
}

View File

@@ -9,7 +9,7 @@ import (
type MachineScript interface {
// 分页获取机器脚本信息列表
GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
// 根据条件获取
GetMachineScript(condition *entity.MachineScript, cols ...string) error
@@ -40,7 +40,7 @@ const Common_Script_Machine_Id = 9999999
// machineScriptRepo: persistence.MachineScriptDao}
// 分页获取机器脚本信息列表
func (m *machineScriptAppImpl) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *machineScriptAppImpl) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return m.machineScriptRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
}

View File

@@ -6,7 +6,7 @@ import (
)
type AuthCert interface {
GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Insert(ac *entity.AuthCert)

View File

@@ -7,7 +7,7 @@ import (
type Machine interface {
// 分页获取机器信息列表
GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Count(condition *entity.MachineQuery) int64

View File

@@ -7,7 +7,7 @@ import (
type MachineFile interface {
// 分页获取机器脚本信息列表
GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
// 根据条件获取
GetMachineFile(condition *entity.MachineFile, cols ...string) error

View File

@@ -7,7 +7,7 @@ import (
type MachineScript interface {
// 分页获取机器脚本信息列表
GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
// 根据条件获取
GetMachineScript(condition *entity.MachineScript, cols ...string) error

View File

@@ -6,7 +6,7 @@ import (
)
type MachineTaskConfig interface {
GetPageList(condition *entity.MachineTaskConfig, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.MachineTaskConfig, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
// 根据条件获取
GetBy(condition *entity.MachineTaskConfig, cols ...string) error

View File

@@ -140,7 +140,7 @@ func (c *Cli) GetMachine() *Info {
// 机器客户端连接缓存,指定时间内没有访问则会被关闭
var cliCache = cache.NewTimedCache(constant.MachineConnExpireTime, 5*time.Second).
WithUpdateAccessTime(true).
OnEvicted(func(_, value interface{}) {
OnEvicted(func(_, value any) {
value.(*Cli).Close()
})
@@ -172,7 +172,7 @@ func DeleteCli(id uint64) {
// 从缓存中获取客户端信息,不存在则回调获取机器信息函数,并新建
func GetCli(machineId uint64, getMachine func(uint64) *Info) (*Cli, error) {
cli, err := cliCache.ComputeIfAbsent(machineId, func(_ interface{}) (interface{}, error) {
cli, err := cliCache.ComputeIfAbsent(machineId, func(_ any) (any, error) {
me := getMachine(machineId)
err := IfUseSshTunnelChangeIpPort(me, getMachine)
if err != nil {

View File

@@ -68,7 +68,7 @@ func TestTemplateRev(t *testing.T) {
//next := temp[ei:]
//key := temp[index+1 : ei-1]
//value := SubString(str, index, UnicodeIndex(str, next))
res := make(map[string]interface{})
res := make(map[string]any)
utils.ReverStrTemplate(temp, str, res)
fmt.Println(res)
}

View File

@@ -57,7 +57,7 @@ func (rec *Recorder) WriteHeader(height, width int) {
}
func (rec *Recorder) WriteData(rectype RecType, data string) {
recData := make([]interface{}, 3)
recData := make([]any, 3)
recData[0] = float64(time.Since(rec.StartTime).Microseconds()) / float64(1000000)
recData[1] = rectype
recData[2] = data

View File

@@ -13,7 +13,7 @@ func newAuthCertRepo() repository.AuthCert {
return new(authCertRepoImpl)
}
func (m *authCertRepoImpl) GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *authCertRepoImpl) GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity)
}

View File

@@ -15,10 +15,10 @@ func newMachineRepo() repository.Machine {
}
// 分页获取机器信息列表
func (m *machineRepoImpl) GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *machineRepoImpl) GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
sql := "SELECT m.* FROM t_machine m WHERE 1 = 1 "
values := make([]interface{}, 0)
values := make([]any, 0)
if condition.Ip != "" {
sql = sql + " AND m.ip LIKE ?"
values = append(values, "%"+condition.Ip+"%")
@@ -40,7 +40,7 @@ func (m *machineRepoImpl) GetMachineList(condition *entity.MachineQuery, pagePar
}
func (m *machineRepoImpl) Count(condition *entity.MachineQuery) int64 {
where := make(map[string]interface{})
where := make(map[string]any)
if len(condition.TagIds) > 0 {
where["tag_id"] = condition.TagIds
}

View File

@@ -14,7 +14,7 @@ func newMachineFileRepo() repository.MachineFile {
}
// 分页获取机器文件信息列表
func (m *machineFileRepoImpl) GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *machineFileRepoImpl) GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity, orderBy...)
}

View File

@@ -14,7 +14,7 @@ func newMachineScriptRepo() repository.MachineScript {
}
// 分页获取机器信息列表
func (m *machineScriptRepoImpl) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *machineScriptRepoImpl) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity, orderBy...)
}

View File

@@ -10,30 +10,30 @@ type Mongo struct {
}
type MongoCommand struct {
Database string `binding:"required" json:"database"`
Collection string `binding:"required" json:"collection"`
Filter map[string]interface{} `json:"filter"`
Database string `binding:"required" json:"database"`
Collection string `binding:"required" json:"collection"`
Filter map[string]any `json:"filter"`
}
type MongoRunCommand struct {
Database string `binding:"required" json:"database"`
Command map[string]interface{} `json:"command"`
Database string `binding:"required" json:"database"`
Command map[string]any `json:"command"`
}
type MongoFindCommand struct {
MongoCommand
Sort map[string]interface{} `json:"sort"`
Sort map[string]any `json:"sort"`
Skip int64
Limit int64
}
type MongoUpdateByIdCommand struct {
MongoCommand
DocId interface{} `binding:"required" json:"docId"`
Update map[string]interface{} `json:"update"`
DocId any `binding:"required" json:"docId"`
Update map[string]any `json:"update"`
}
type MongoInsertCommand struct {
MongoCommand
Doc map[string]interface{} `json:"doc"`
Doc map[string]any `json:"doc"`
}

View File

@@ -23,7 +23,7 @@ import (
type Mongo interface {
// 分页获取机器脚本信息列表
GetPageList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Count(condition *entity.MongoQuery) int64
@@ -54,7 +54,7 @@ type mongoAppImpl struct {
}
// 分页获取数据库信息列表
func (d *mongoAppImpl) GetPageList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (d *mongoAppImpl) GetPageList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return d.mongoRepo.GetList(condition, pageParam, toEntity, orderBy...)
}
@@ -102,7 +102,7 @@ func (d *mongoAppImpl) GetMongoCli(id uint64) *mongo.Client {
// mongo客户端连接缓存指定时间内没有访问则会被关闭
var mongoCliCache = cache.NewTimedCache(constant.MongoConnExpireTime, 5*time.Second).
WithUpdateAccessTime(true).
OnEvicted(func(key interface{}, value interface{}) {
OnEvicted(func(key any, value any) {
global.Log.Info("删除mongo连接缓存: id = ", key)
value.(*MongoInstance).Close()
})
@@ -122,7 +122,7 @@ func init() {
// 获取mongo的连接实例
func GetMongoInstance(mongoId uint64, getMongoEntity func(uint64) *entity.Mongo) (*MongoInstance, error) {
mi, err := mongoCliCache.ComputeIfAbsent(mongoId, func(_ interface{}) (interface{}, error) {
mi, err := mongoCliCache.ComputeIfAbsent(mongoId, func(_ any) (any, error) {
c, err := connect(getMongoEntity(mongoId))
if err != nil {
return nil, err

View File

@@ -7,7 +7,7 @@ import (
type Mongo interface {
// 分页获取列表
GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Count(condition *entity.MongoQuery) int64

View File

@@ -17,14 +17,14 @@ func newMongoRepo() repository.Mongo {
}
// 分页获取数据库信息列表
func (d *mongoRepoImpl) GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (d *mongoRepoImpl) GetList(condition *entity.MongoQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
sql := "SELECT d.* FROM t_mongo d WHERE 1=1 "
if len(condition.TagIds) > 0 {
sql = sql + " AND d.tag_id IN " + fmt.Sprintf("(%s)", strings.Join(utils.NumberArr2StrArr(condition.TagIds), ","))
}
values := make([]interface{}, 0)
values := make([]any, 0)
if condition.TagPathLike != "" {
values = append(values, condition.TagPathLike+"%")
sql = sql + " AND d.tag_path LIKE ?"
@@ -34,7 +34,7 @@ func (d *mongoRepoImpl) GetList(condition *entity.MongoQuery, pageParam *model.P
}
func (d *mongoRepoImpl) Count(condition *entity.MongoQuery) int64 {
where := make(map[string]interface{})
where := make(map[string]any)
if len(condition.TagIds) > 0 {
where["tag_id"] = condition.TagIds
}

View File

@@ -30,29 +30,29 @@ type KeyInfo struct {
type StringValue struct {
KeyInfo
Value interface{} `binding:"required" json:"value"`
Value any `binding:"required" json:"value"`
}
type HashValue struct {
KeyInfo
Value []map[string]interface{} `binding:"required" json:"value"`
Value []map[string]any `binding:"required" json:"value"`
}
type SetValue struct {
KeyInfo
Value []interface{} `binding:"required" json:"value"`
Value []any `binding:"required" json:"value"`
}
type ListValue struct {
KeyInfo
Value []interface{} `binding:"required" json:"value"`
Value []any `binding:"required" json:"value"`
}
// list lset命令参数入参
type ListSetValue struct {
Key string `binding:"required" json:"key"`
Index int64
Value interface{} `binding:"required" json:"value"`
Value any `binding:"required" json:"value"`
}
type RedisScanForm struct {

View File

@@ -23,7 +23,7 @@ func (r *Redis) Hscan(rc *req.Ctx) {
keySize, err := cmdable.HLen(contextTodo, key).Result()
biz.ErrIsNilAppendErr(err, "hlen err: %s")
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"keys": keys,
"cursor": nextCursor,
"keySize": keySize,

View File

@@ -22,7 +22,7 @@ func (r *Redis) GetListValue(rc *req.Ctx) {
res, err := cmdable.LRange(ctx, key, int64(start), int64(stop)).Result()
biz.ErrIsNilAppendErr(err, "获取list值失败: %s")
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"len": len,
"list": res,
}

View File

@@ -185,7 +185,7 @@ func (r *Redis) ClusterInfo(rc *req.Ctx) {
}
nodesRes = append(nodesRes, node)
}
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"clusterInfo": info,
"clusterNodes": nodesRes,
}

View File

@@ -49,7 +49,7 @@ func (r *Redis) Sscan(rc *req.Ctx) {
cmd := r.getRedisIns(rc).GetCmdable()
keys, cursor, err := cmd.SScan(context.TODO(), scan.Key, scan.Cursor, scan.Match, scan.Count).Result()
biz.ErrIsNilAppendErr(err, "sscan失败: %s")
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"keys": keys,
"cursor": cursor,
}

View File

@@ -28,7 +28,7 @@ func (r *Redis) ZScan(rc *req.Ctx) {
keys, cursor, err := ri.GetCmdable().ZScan(context.TODO(), key, cursor, match, int64(count)).Result()
biz.ErrIsNilAppendErr(err, "sscan失败: %s")
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"keys": keys,
"cursor": cursor,
}

View File

@@ -23,7 +23,7 @@ import (
type Redis interface {
// 分页获取机器脚本信息列表
GetPageList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Count(condition *entity.RedisQuery) int64
@@ -55,7 +55,7 @@ type redisAppImpl struct {
}
// 分页获取机器脚本信息列表
func (r *redisAppImpl) GetPageList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (r *redisAppImpl) GetPageList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return r.redisRepo.GetRedisList(condition, pageParam, toEntity, orderBy...)
}
@@ -251,7 +251,7 @@ func getRedisDialer(machineId int) func(ctx context.Context, network, addr strin
// redis客户端连接缓存指定时间内没有访问则会被关闭
var redisCache = cache.NewTimedCache(constant.RedisConnExpireTime, 5*time.Second).
WithUpdateAccessTime(true).
OnEvicted(func(key interface{}, value interface{}) {
OnEvicted(func(key any, value any) {
global.Log.Info(fmt.Sprintf("删除redis连接缓存 id = %s", key))
value.(*RedisInstance).Close()
})

View File

@@ -7,7 +7,7 @@ import (
type Redis interface {
// 分页获取机器信息列表
GetRedisList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetRedisList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Count(condition *entity.RedisQuery) int64

View File

@@ -17,9 +17,9 @@ func newRedisRepo() repository.Redis {
}
// 分页获取机器信息列表
func (r *redisRepoImpl) GetRedisList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (r *redisRepoImpl) GetRedisList(condition *entity.RedisQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
sql := "SELECT d.* FROM t_redis d WHERE 1=1 "
values := make([]interface{}, 0)
values := make([]any, 0)
if condition.Host != "" {
sql = sql + " AND d.host LIKE ?"
values = append(values, "%"+condition.Host+"%")
@@ -36,7 +36,7 @@ func (r *redisRepoImpl) GetRedisList(condition *entity.RedisQuery, pageParam *mo
}
func (r *redisRepoImpl) Count(condition *entity.RedisQuery) int64 {
where := make(map[string]interface{})
where := make(map[string]any)
if len(condition.TagIds) > 0 {
where["tag_id"] = condition.TagIds
}

View File

@@ -57,7 +57,7 @@ func (a *Account) Login(rc *req.Ctx) {
// 保存登录消息
go a.saveLogin(account, clientIp)
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"token": req.CreateToken(account.Id, account.Username),
"name": account.Name,
"username": account.Username,
@@ -84,7 +84,7 @@ func (a *Account) GetPermissions(rc *req.Ctx) {
}
// 保存该账号的权限codes
req.SavePermissionCodes(account.Id, permissions)
rc.ResData = map[string]interface{}{
rc.ResData = map[string]any{
"menus": menus.ToTrees(0),
"permissions": permissions,
}
@@ -268,20 +268,20 @@ func (a *Account) SaveRoles(rc *req.Ctx) {
// 将,拼接的字符串进行切割
idsStr := strings.Split(form.RoleIds, ",")
var newIds []interface{}
var newIds []any
for _, v := range idsStr {
id, _ := strconv.Atoi(v)
newIds = append(newIds, uint64(id))
}
// 将[]uint64转为[]interface{}
// 将[]uint64转为[]any
oIds := a.RoleApp.GetAccountRoleIds(uint64(form.Id))
var oldIds []interface{}
var oldIds []any
for _, v := range oIds {
oldIds = append(oldIds, v)
}
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 interface{}) bool {
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 any) bool {
return i1.(uint64) == i2.(uint64)
})

View File

@@ -7,5 +7,5 @@ import (
func GenerateCaptcha(rc *req.Ctx) {
id, image := captcha.Generate()
rc.ResData = map[string]interface{}{"base64Captcha": image, "cid": id}
rc.ResData = map[string]any{"base64Captcha": image, "cid": id}
}

View File

@@ -7,7 +7,7 @@ type ResourceForm struct {
Name string `binding:"required"`
Type int `binding:"required,oneof=1 2"`
Weight int
Meta map[string]interface{}
Meta map[string]any
}
type MenuResourceMeta struct {

View File

@@ -69,20 +69,20 @@ func (r *Role) SaveResource(rc *req.Ctx) {
// 将,拼接的字符串进行切割
idsStr := strings.Split(form.ResourceIds, ",")
var newIds []interface{}
var newIds []any
for _, v := range idsStr {
id, _ := strconv.Atoi(v)
newIds = append(newIds, uint64(id))
}
// 将[]uint64转为[]interface{}
// 将[]uint64转为[]any
oIds := r.RoleApp.GetRoleResourceIds(uint64(form.Id))
var oldIds []interface{}
var oldIds []any
for _, v := range oIds {
oldIds = append(oldIds, v)
}
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 interface{}) bool {
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 any) bool {
return i1.(uint64) == i2.(uint64)
})

View File

@@ -13,7 +13,7 @@ import (
type Account interface {
GetAccount(condition *entity.Account, cols ...string) error
GetPageList(condition *entity.Account, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Account, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Create(account *entity.Account)
@@ -37,7 +37,7 @@ func (a *accountAppImpl) GetAccount(condition *entity.Account, cols ...string) e
return a.accountRepo.GetAccount(condition, cols...)
}
func (a *accountAppImpl) GetPageList(condition *entity.Account, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (a *accountAppImpl) GetPageList(condition *entity.Account, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return a.accountRepo.GetPageList(condition, pageParam, toEntity)
}

View File

@@ -13,7 +13,7 @@ import (
const SysConfigKeyPrefix = "sys:config:"
type Config interface {
GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Save(config *entity.Config)
@@ -31,7 +31,7 @@ type configAppImpl struct {
configRepo repository.Config
}
func (a *configAppImpl) GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (a *configAppImpl) GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return a.configRepo.GetPageList(condition, pageParam, toEntity)
}

View File

@@ -9,7 +9,7 @@ import (
)
type Msg interface {
GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Create(msg *entity.Msg)
@@ -27,7 +27,7 @@ type msgAppImpl struct {
msgRepo repository.Msg
}
func (a *msgAppImpl) GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (a *msgAppImpl) GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return a.msgRepo.GetPageList(condition, pageParam, toEntity)
}

View File

@@ -9,17 +9,17 @@ import (
)
type Resource interface {
GetResourceList(condition *entity.Resource, toEntity interface{}, orderBy ...string)
GetResourceList(condition *entity.Resource, toEntity any, orderBy ...string)
GetById(id uint64, cols ...string) *entity.Resource
GetByIdIn(ids []uint64, toEntity interface{}, cols ...string)
GetByIdIn(ids []uint64, toEntity any, cols ...string)
Save(entity *entity.Resource)
Delete(id uint64)
GetAccountResources(accountId uint64, toEntity interface{})
GetAccountResources(accountId uint64, toEntity any)
}
func newResourceApp(resourceRepo repository.Resource) Resource {
@@ -32,7 +32,7 @@ type resourceAppImpl struct {
resourceRepo repository.Resource
}
func (r *resourceAppImpl) GetResourceList(condition *entity.Resource, toEntity interface{}, orderBy ...string) {
func (r *resourceAppImpl) GetResourceList(condition *entity.Resource, toEntity any, orderBy ...string) {
r.resourceRepo.GetResourceList(condition, toEntity, orderBy...)
}
@@ -40,7 +40,7 @@ func (r *resourceAppImpl) GetById(id uint64, cols ...string) *entity.Resource {
return r.resourceRepo.GetById(id, cols...)
}
func (r *resourceAppImpl) GetByIdIn(ids []uint64, toEntity interface{}, orderBy ...string) {
func (r *resourceAppImpl) GetByIdIn(ids []uint64, toEntity any, orderBy ...string) {
r.resourceRepo.GetByIdIn(ids, toEntity, orderBy...)
}
@@ -84,7 +84,7 @@ func (r *resourceAppImpl) Delete(id uint64) {
model.DeleteByCondition(&entity.RoleResource{ResourceId: id})
}
func (r *resourceAppImpl) GetAccountResources(accountId uint64, toEntity interface{}) {
func (r *resourceAppImpl) GetAccountResources(accountId uint64, toEntity any) {
r.resourceRepo.GetAccountResources(accountId, toEntity)
}

View File

@@ -8,7 +8,7 @@ import (
)
type Role interface {
GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
SaveRole(role *entity.Role)
@@ -16,7 +16,7 @@ type Role interface {
GetRoleResourceIds(roleId uint64) []uint64
GetRoleResources(roleId uint64, toEntity interface{})
GetRoleResources(roleId uint64, toEntity any)
// 保存角色资源关联记录
SaveRoleResource(rr *entity.RoleResource)
@@ -32,7 +32,7 @@ type Role interface {
DeleteAccountRole(accountId, roleId uint64)
GetAccountRoles(accountId uint64, toEntity interface{})
GetAccountRoles(accountId uint64, toEntity any)
}
func newRoleApp(roleRepo repository.Role) Role {
@@ -45,7 +45,7 @@ type roleAppImpl struct {
roleRepo repository.Role
}
func (m *roleAppImpl) GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *roleAppImpl) GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return m.roleRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
}
@@ -71,7 +71,7 @@ func (m *roleAppImpl) GetRoleResourceIds(roleId uint64) []uint64 {
return m.roleRepo.GetRoleResourceIds(roleId)
}
func (m *roleAppImpl) GetRoleResources(roleId uint64, toEntity interface{}) {
func (m *roleAppImpl) GetRoleResources(roleId uint64, toEntity any) {
m.roleRepo.GetRoleResources(roleId, toEntity)
}
@@ -95,6 +95,6 @@ func (m *roleAppImpl) DeleteAccountRole(accountId, roleId uint64) {
m.roleRepo.DeleteAccountRole(accountId, roleId)
}
func (m *roleAppImpl) GetAccountRoles(accountId uint64, toEntity interface{}) {
func (m *roleAppImpl) GetAccountRoles(accountId uint64, toEntity any) {
m.roleRepo.GetAccountRoles(accountId, toEntity)
}

View File

@@ -13,7 +13,7 @@ import (
)
type Syslog interface {
GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
// 从请求上下文的参数保存系统日志
SaveFromReq(req *req.Ctx)
@@ -29,7 +29,7 @@ type syslogAppImpl struct {
syslogRepo repository.Syslog
}
func (m *syslogAppImpl) GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *syslogAppImpl) GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return m.syslogRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
}

View File

@@ -9,7 +9,7 @@ type Account interface {
// 根据条件获取账号信息
GetAccount(condition *entity.Account, cols ...string) error
GetPageList(condition *entity.Account, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Account, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Insert(account *entity.Account)

View File

@@ -6,7 +6,7 @@ import (
)
type Config interface {
GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Insert(config *entity.Config)

View File

@@ -6,7 +6,7 @@ import (
)
type Msg interface {
GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Insert(msg *entity.Msg)
}

View File

@@ -6,16 +6,16 @@ import (
type Resource interface {
// 获取资源列表
GetResourceList(condition *entity.Resource, toEntity interface{}, orderBy ...string)
GetResourceList(condition *entity.Resource, toEntity any, orderBy ...string)
GetById(id uint64, cols ...string) *entity.Resource
GetByIdIn(ids []uint64, toEntity interface{}, orderBy ...string)
GetByIdIn(ids []uint64, toEntity any, orderBy ...string)
Delete(id uint64)
GetByCondition(condition *entity.Resource, cols ...string) error
// 获取账号资源列表
GetAccountResources(accountId uint64, toEntity interface{})
GetAccountResources(accountId uint64, toEntity any)
}

View File

@@ -6,14 +6,14 @@ import (
)
type Role interface {
GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Delete(id uint64)
// 获取角色拥有的资源id数组从role_resource表获取
GetRoleResourceIds(roleId uint64) []uint64
GetRoleResources(roleId uint64, toEntity interface{})
GetRoleResources(roleId uint64, toEntity any)
SaveRoleResource(rr *entity.RoleResource)
@@ -27,5 +27,5 @@ type Role interface {
DeleteAccountRole(accountId, roleId uint64)
// 获取账号角色信息列表
GetAccountRoles(accountId uint64, toEntity interface{})
GetAccountRoles(accountId uint64, toEntity any)
}

View File

@@ -6,7 +6,7 @@ import (
)
type Syslog interface {
GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Insert(log *entity.Syslog)
}

View File

@@ -17,10 +17,10 @@ func (a *accountRepoImpl) GetAccount(condition *entity.Account, cols ...string)
return model.GetBy(condition, cols...)
}
func (m *accountRepoImpl) GetPageList(condition *entity.Account, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *accountRepoImpl) GetPageList(condition *entity.Account, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
sql := "SELECT * FROM t_sys_account "
username := condition.Username
values := make([]interface{}, 0)
values := make([]any, 0)
if username != "" {
sql = sql + " WHERE username LIKE ?"
values = append(values, "%"+username+"%")

View File

@@ -13,7 +13,7 @@ func newConfigRepo() repository.Config {
return new(configRepoImpl)
}
func (m *configRepoImpl) GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *configRepoImpl) GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity)
}

View File

@@ -13,7 +13,7 @@ func newMsgRepo() repository.Msg {
return new(msgRepoImpl)
}
func (m *msgRepoImpl) GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *msgRepoImpl) GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity)
}

View File

@@ -13,7 +13,7 @@ func newResourceRepo() repository.Resource {
return new(resourceRepoImpl)
}
func (r *resourceRepoImpl) GetResourceList(condition *entity.Resource, toEntity interface{}, orderBy ...string) {
func (r *resourceRepoImpl) GetResourceList(condition *entity.Resource, toEntity any, orderBy ...string) {
model.ListByOrder(condition, toEntity, orderBy...)
}
@@ -26,7 +26,7 @@ func (r *resourceRepoImpl) GetById(id uint64, cols ...string) *entity.Resource {
return res
}
func (r *resourceRepoImpl) GetByIdIn(ids []uint64, toEntity interface{}, orderBy ...string) {
func (r *resourceRepoImpl) GetByIdIn(ids []uint64, toEntity any, orderBy ...string) {
model.GetByIdIn(new(entity.Resource), toEntity, ids, orderBy...)
}
@@ -38,7 +38,7 @@ func (r *resourceRepoImpl) GetByCondition(condition *entity.Resource, cols ...st
return model.GetBy(condition, cols...)
}
func (r *resourceRepoImpl) GetAccountResources(accountId uint64, toEntity interface{}) {
func (r *resourceRepoImpl) GetAccountResources(accountId uint64, toEntity any) {
sql := `SELECT
m.id,
m.pid,

View File

@@ -13,7 +13,7 @@ func newRoleRepo() repository.Role {
return new(roleRepoImpl)
}
func (m *roleRepoImpl) GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *roleRepoImpl) GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity, orderBy...)
}
@@ -35,7 +35,7 @@ func (m *roleRepoImpl) GetRoleResourceIds(roleId uint64) []uint64 {
return rids
}
func (m *roleRepoImpl) GetRoleResources(roleId uint64, toEntity interface{}) {
func (m *roleRepoImpl) GetRoleResources(roleId uint64, toEntity any) {
sql := "select rr.creator AS creator, rr.create_time AS CreateTime, rr.resource_id AS id, r.pid AS pid, " +
"r.name AS name, r.type AS type, r.status AS status " +
"FROM t_sys_role_resource rr JOIN t_sys_resource r ON rr.resource_id = r.id " +
@@ -74,7 +74,7 @@ func (m *roleRepoImpl) DeleteAccountRole(accountId, roleId uint64) {
}
// 获取账号角色信息列表
func (m *roleRepoImpl) GetAccountRoles(accountId uint64, toEntity interface{}) {
func (m *roleRepoImpl) GetAccountRoles(accountId uint64, toEntity any) {
sql := "SELECT r.status, r.name, ar.create_time AS CreateTime, ar.creator AS creator " +
"FROM t_sys_role r JOIN t_sys_account_role ar ON r.id = ar.role_id AND ar.account_id = ? " +
"ORDER BY ar.create_time DESC"

View File

@@ -12,7 +12,7 @@ func newSyslogRepo() repository.Syslog {
return new(syslogRepoImpl)
}
func (m *syslogRepoImpl) GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (m *syslogRepoImpl) GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity, orderBy...)
}

View File

@@ -111,20 +111,20 @@ func (p *Team) SaveTags(rc *req.Ctx) {
teamId := form.TeamId
// 将[]uint64转为[]interface{}
// 将[]uint64转为[]any
oIds := p.TeamApp.ListTagIds(teamId)
var oldIds []interface{}
var oldIds []any
for _, v := range oIds {
oldIds = append(oldIds, v)
}
var newIds []interface{}
var newIds []any
for _, v := range form.TagIds {
newIds = append(newIds, v)
}
// 比较新旧两合集
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 interface{}) bool {
addIds, delIds, _ := utils.ArrayCompare(newIds, oldIds, func(i1, i2 any) bool {
return i1.(uint64) == i2.(uint64)
})

View File

@@ -16,7 +16,7 @@ import (
)
type TagTree interface {
ListByQuery(condition *entity.TagTreeQuery, toEntity interface{})
ListByQuery(condition *entity.TagTreeQuery, toEntity any)
GetById(id uint64) *entity.TagTree
@@ -96,7 +96,7 @@ func (p *tagTreeAppImpl) Save(tag *entity.TagTree) {
p.tagTreeRepo.UpdateById(tag)
}
func (p *tagTreeAppImpl) ListByQuery(condition *entity.TagTreeQuery, toEntity interface{}) {
func (p *tagTreeAppImpl) ListByQuery(condition *entity.TagTreeQuery, toEntity any) {
p.tagTreeRepo.SelectByCondition(condition, toEntity)
}

View File

@@ -9,7 +9,7 @@ import (
type Team interface {
// 分页获取项目团队信息列表
GetPageList(condition *entity.Team, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Team, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Save(team *entity.Team)
@@ -17,7 +17,7 @@ type Team interface {
//--------------- 团队成员相关接口 ---------------
GetMemberPage(condition *entity.TeamMember, pageParam *model.PageParam, toEntity interface{}) *model.PageResult
GetMemberPage(condition *entity.TeamMember, pageParam *model.PageParam, toEntity any) *model.PageResult
SaveMember(tagTeamMember *entity.TeamMember)
@@ -51,7 +51,7 @@ type teamAppImpl struct {
tagTreeTeamRepo repository.TagTreeTeam
}
func (p *teamAppImpl) GetPageList(condition *entity.Team, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (p *teamAppImpl) GetPageList(condition *entity.Team, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return p.teamRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
}
@@ -70,7 +70,7 @@ func (p *teamAppImpl) Delete(id uint64) {
// --------------- 团队成员相关接口 ---------------
func (p *teamAppImpl) GetMemberPage(condition *entity.TeamMember, pageParam *model.PageParam, toEntity interface{}) *model.PageResult {
func (p *teamAppImpl) GetMemberPage(condition *entity.TeamMember, pageParam *model.PageParam, toEntity any) *model.PageResult {
return p.teamMemberRepo.GetPageList(condition, pageParam, toEntity)
}

View File

@@ -6,7 +6,7 @@ import (
type TagTree interface {
// 根据条件查询
SelectByCondition(condition *entity.TagTreeQuery, toEntity interface{}, orderBy ...string)
SelectByCondition(condition *entity.TagTreeQuery, toEntity any, orderBy ...string)
GetBy(condition *entity.TagTree, cols ...string) error

View File

@@ -5,7 +5,7 @@ import "mayfly-go/internal/tag/domain/entity"
type TagTreeTeam interface {
// 获取团队标签信息列表
ListTag(condition *entity.TagTreeTeam, toEntity interface{}, orderBy ...string)
ListTag(condition *entity.TagTreeTeam, toEntity any, orderBy ...string)
Save(mp *entity.TagTreeTeam)

View File

@@ -6,7 +6,7 @@ import (
)
type Team interface {
GetPageList(condition *entity.Team, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
GetPageList(condition *entity.Team, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult
Insert(p *entity.Team)

View File

@@ -8,11 +8,11 @@ import (
type TeamMember interface {
// 获取项目成员列表
ListMemeber(condition *entity.TeamMember, toEntity interface{}, orderBy ...string)
ListMemeber(condition *entity.TeamMember, toEntity any, orderBy ...string)
Save(mp *entity.TeamMember)
GetPageList(condition *entity.TeamMember, pageParam *model.PageParam, toEntity interface{}) *model.PageResult
GetPageList(condition *entity.TeamMember, pageParam *model.PageParam, toEntity any) *model.PageResult
DeleteBy(condition *entity.TeamMember)

View File

@@ -15,7 +15,7 @@ func newTagTreeRepo() repository.TagTree {
return new(tagTreeRepoImpl)
}
func (p *tagTreeRepoImpl) SelectByCondition(condition *entity.TagTreeQuery, toEntity interface{}, orderBy ...string) {
func (p *tagTreeRepoImpl) SelectByCondition(condition *entity.TagTreeQuery, toEntity any, orderBy ...string) {
sql := "SELECT DISTINCT(p.id), p.pid, p.code, p.code_path, p.name, p.remark, p.create_time, p.creator, p.update_time, p.modifier FROM t_tag_tree p WHERE 1 = 1 "
if condition.Name != "" {
sql = sql + " AND p.name LIKE '%" + condition.Name + "%'"

View File

@@ -13,7 +13,7 @@ func newTagTreeTeamRepo() repository.TagTreeTeam {
return new(tagTreeTeamRepoImpl)
}
func (p *tagTreeTeamRepoImpl) ListTag(condition *entity.TagTreeTeam, toEntity interface{}, orderBy ...string) {
func (p *tagTreeTeamRepoImpl) ListTag(condition *entity.TagTreeTeam, toEntity any, orderBy ...string) {
model.ListByOrder(condition, toEntity, orderBy...)
}

View File

@@ -13,7 +13,7 @@ func newTeamRepo() repository.Team {
return new(teamRepoImpl)
}
func (p *teamRepoImpl) GetPageList(condition *entity.Team, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
func (p *teamRepoImpl) GetPageList(condition *entity.Team, pageParam *model.PageParam, toEntity any, orderBy ...string) *model.PageResult {
return model.GetPage(pageParam, condition, condition, toEntity, orderBy...)
}

View File

@@ -14,7 +14,7 @@ func newTeamMemberRepo() repository.TeamMember {
return new(teamMemberRepoImpl)
}
func (p *teamMemberRepoImpl) ListMemeber(condition *entity.TeamMember, toEntity interface{}, orderBy ...string) {
func (p *teamMemberRepoImpl) ListMemeber(condition *entity.TeamMember, toEntity any, orderBy ...string) {
model.ListByOrder(condition, toEntity, orderBy...)
}
@@ -22,7 +22,7 @@ func (p *teamMemberRepoImpl) Save(pm *entity.TeamMember) {
biz.ErrIsNilAppendErr(model.Insert(pm), "保存团队成员失败:%s")
}
func (p *teamMemberRepoImpl) GetPageList(condition *entity.TeamMember, pageParam *model.PageParam, toEntity interface{}) *model.PageResult {
func (p *teamMemberRepoImpl) GetPageList(condition *entity.TeamMember, pageParam *model.PageParam, toEntity any) *model.PageResult {
sql := "SELECT d.*, a.name FROM t_team_member d JOIN t_sys_account a ON d.account_id = a.id WHERE a.status = 1 "
if condition.AccountId != 0 {
@@ -32,7 +32,7 @@ func (p *teamMemberRepoImpl) GetPageList(condition *entity.TeamMember, pageParam
sql = fmt.Sprintf("%s AND d.team_id = %d", sql, condition.TeamId)
}
values := make([]interface{}, 0)
values := make([]any, 0)
if condition.Username != "" {
sql = sql + " AND d.Username LIKE ?"
values = append(values, "%"+condition.Username+"%")