refactor all service dependency injection
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package user
|
||||
|
||||
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.MgtLinkUserApp{AppId: appId, UserId: 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: "user_id"}},
|
||||
DoUpdates: clause.AssignmentColumns([]string{"app_id", "pmn_id", "user_id"}),
|
||||
@@ -102,7 +104,7 @@ func ModifyPmn(c *gin.Context) {
|
||||
Appdta = models.MgtLinkUserApp{AppId: appId, UserId: 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 user_id = ?", appId, request.Id).Delete(&models.MgtLinkUserPmn{}).Error; err != nil {
|
||||
printer.Error("删除用户权限关联失败: %v", err)
|
||||
return err
|
||||
@@ -160,7 +162,7 @@ func DelPmn(c *gin.Context) {
|
||||
}
|
||||
pmnIds = append(pmnIds, v)
|
||||
}
|
||||
if err := models.DBService.Where("app_id = ? AND user_id = ? AND pmn_id in ?", appId, request.Id, pmnIds).
|
||||
if err := impl.DBService.Where("app_id = ? AND user_id = ? AND pmn_id in ?", appId, request.Id, pmnIds).
|
||||
Delete(&models.MgtLinkUserPmn{}).Error; err != nil {
|
||||
infra.Response.Error(c, errcode.ErrDB)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user