multi-tenant
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"be.ems/src/modules/system/model"
|
||||
"be.ems/src/modules/system/service"
|
||||
|
||||
dborm "be.ems/lib/core/datasource"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -42,6 +43,11 @@ func (s *SysLogOperateController) List(c *gin.Context) {
|
||||
querys["title"] = i18n.TFindKeyPrefix(language, "log.operate.title", v.(string))
|
||||
}
|
||||
|
||||
// multi-tenancy, only filter user setting tenant_id
|
||||
userName := ctx.LoginUserToUserName(c)
|
||||
if s.IsTenancyUser(userName) {
|
||||
querys["operName"] = userName
|
||||
}
|
||||
data := s.SysLogOperateService.SelectSysLogOperatePage(querys)
|
||||
rows := data["rows"].([]model.SysLogOperate)
|
||||
|
||||
@@ -204,3 +210,12 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
|
||||
|
||||
c.FileAttachment(saveFilePath, fileName)
|
||||
}
|
||||
|
||||
func (s *SysLogOperateController) IsTenancyUser(userName string) bool {
|
||||
var tenantID []int64
|
||||
dborm.DefaultDB().Table("sys_user").Where("user_name=?", userName).Cols("tenant_id").Find(&tenantID)
|
||||
if len(tenantID) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user