init: init refactor
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
)
|
||||
|
||||
type DeleteRoleLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRoleLogic {
|
||||
return &DeleteRoleLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *DeleteRoleLogic) DeleteRole(req *types.IdsReq) error {
|
||||
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&sysModel.SundynixRole{}).Error; err != nil {
|
||||
return fmt.Errorf("删除角色失败")
|
||||
}
|
||||
// 清理角色菜单关联
|
||||
l.svcCtx.DB.Where("role_id IN ?", req.Ids).Delete(&sysModel.SundynixRoleMenu{})
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user