multi-tenant

This commit is contained in:
2024-06-19 11:15:39 +08:00
parent b9c9734b16
commit 7a785182b7
9 changed files with 247 additions and 55 deletions

View File

@@ -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
}