refactor all service dependency injection

This commit is contained in:
2026-08-10 11:35:48 +08:00
parent 007a7ba38a
commit c883cc52a2
152 changed files with 1030 additions and 223 deletions

View File

@@ -1,9 +1,11 @@
package role
import (
"bsm/full/module/base/mgt/internal/impl"
"bsm/full/module/base/mgt/internal/libs"
"bsm/full/module/base/mgt/internal/models"
"bsm/full/module/base/mgt/internal/types"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/infra"
"git.apinb.com/bsm-sdk/core/printer"
@@ -45,7 +47,7 @@ func SetPmn(c *gin.Context) {
Appdta = models.MgtLinkRoleApp{AppId: appId, RoleId: request.Id}
}
if err := models.DBService.Transaction(func(tx *gorm.DB) error {
if err := impl.DBService.Transaction(func(tx *gorm.DB) error {
if err := tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "app_id"}, {Name: "pmn_id"}, {Name: "role_id"}},
DoUpdates: clause.AssignmentColumns([]string{"app_id", "pmn_id", "role_id"}),
@@ -104,7 +106,7 @@ func ModifyPmn(c *gin.Context) {
Appdta = models.MgtLinkRoleApp{AppId: appId, RoleId: request.Id}
}
if err := models.DBService.Transaction(func(tx *gorm.DB) error {
if err := impl.DBService.Transaction(func(tx *gorm.DB) error {
if err := tx.Where("app_id = ? and role_id = ?", appId, request.Id).Delete(&models.MgtLinkRolePmn{}).Error; err != nil {
printer.Error("删除角色权限关联失败: %v", err)
return err
@@ -159,7 +161,7 @@ func DelPmn(c *gin.Context) {
}
pmnIds = append(pmnIds, v)
}
if err := models.DBService.Where("app_id = ? AND role_id = ? AND pmn_id in ?", appId, request.Id, pmnIds).
if err := impl.DBService.Where("app_id = ? AND role_id = ? AND pmn_id in ?", appId, request.Id, pmnIds).
Delete(&models.MgtLinkRolePmn{}).Error; err != nil {
infra.Response.Error(c, errcode.ErrDB)
return