权限管理优化

This commit is contained in:
hoteas 2022-08-01 16:45:24 +08:00
parent 39d67d1775
commit 6fe44cb1cb
3 changed files with 14 additions and 10 deletions

18
code.go
View File

@ -711,14 +711,16 @@ var TptProject = Proj{
} }
for _, v := range reData { for _, v := range reData {
v.RangeSort(func(k string, v1 interface{}) (isEnd bool) { for k, _ := range v {
//v1:=v.GetMap(k)
//v.RangeSort(func(k string, v1 interface{}) (isEnd bool) {
//如果有table字段则代为link //如果有table字段则代为link
if v["table"] != nil && v["table_id"] != nil { if v["table"] != nil && v["table_id"] != nil {
id := v.GetCeilInt64("table_id") id := v.GetCeilInt64("table_id")
tableName := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(v.GetString("table")).GetString("label") tableNameLabel := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(v.GetString("table")).GetString("label")
v["table_table_name"] = strings.Replace(tableName, "管理", "", -1) //v["table_table_name"] = strings.Replace(tableNameLabel, "管理", "", -1)
v["table_table_name"] = tableNameLabel
sname := "name" sname := "name"
if that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("table")][sname] == nil { if that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("table")][sname] == nil {
sname = "title" sname = "title"
@ -738,7 +740,7 @@ var TptProject = Proj{
column := that.MakeCodeRouter[hotimeName].TableColumns[tableName][k] column := that.MakeCodeRouter[hotimeName].TableColumns[tableName][k]
if column == nil { if column == nil {
return isEnd break
} }
if (column["list"] == nil || column["list"] == true) && column["name"] == "parent_id" && column.GetString("link") != "" { if (column["list"] == nil || column["list"] == true) && column["name"] == "parent_id" && column.GetString("link") != "" {
@ -750,8 +752,8 @@ var TptProject = Proj{
} }
} }
return isEnd //return isEnd
}) }
} }
if download == 1 { if download == 1 {
@ -784,7 +786,7 @@ var TptProject = Proj{
} }
if v.GetString("name") == "table" { if v.GetString("name") == "table" {
f.SetCellValue(tableNameLabel, convertToTitle(n)+ObjToStr(k1+2), that.MakeCodeRouter[hotimeName].TableConfig.GetMap(v1.GetString("table")).GetString("label")) f.SetCellValue(tableNameLabel, convertToTitle(n)+ObjToStr(k1+2), v1.GetString("table_"+v.GetString("name")+"_name"))
continue continue
} }

View File

@ -185,6 +185,10 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
{"type": "search", "name": "sort", "label": "排序", "value": nil}, {"type": "search", "name": "sort", "label": "排序", "value": nil},
}, },
} }
if v.GetString("name") == "logs" {
that.TableConfig.GetMap(v.GetString("name"))["auth"] = []string{"show", "download"}
}
} }
//初始化 //初始化

View File

@ -6,7 +6,6 @@ import (
"database/sql" "database/sql"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -619,7 +618,6 @@ func (that *HoTimeDB) where(data Map) (string, []interface{}) {
if v != nil && reflect.ValueOf(v).Type().String() == "common.Slice" && len(v.(Slice)) == 0 { if v != nil && reflect.ValueOf(v).Type().String() == "common.Slice" && len(v.(Slice)) == 0 {
continue continue
} }
fmt.Println(reflect.ValueOf(v).Type().String())
if v != nil && strings.Contains(reflect.ValueOf(v).Type().String(), "[]") && len(ObjToSlice(v)) == 0 { if v != nil && strings.Contains(reflect.ValueOf(v).Type().String(), "[]") && len(ObjToSlice(v)) == 0 {
continue continue
} }