39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package admin_notification
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 
 | |
| 	"tyc-server/app/main/api/internal/svc"
 | |
| 	"tyc-server/app/main/api/internal/types"
 | |
| 	"tyc-server/common/xerr"
 | |
| 
 | |
| 	"github.com/pkg/errors"
 | |
| 	"github.com/zeromicro/go-zero/core/logx"
 | |
| )
 | |
| 
 | |
| type AdminDeleteNotificationLogic struct {
 | |
| 	logx.Logger
 | |
| 	ctx    context.Context
 | |
| 	svcCtx *svc.ServiceContext
 | |
| }
 | |
| 
 | |
| func NewAdminDeleteNotificationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminDeleteNotificationLogic {
 | |
| 	return &AdminDeleteNotificationLogic{
 | |
| 		Logger: logx.WithContext(ctx),
 | |
| 		ctx:    ctx,
 | |
| 		svcCtx: svcCtx,
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func (l *AdminDeleteNotificationLogic) AdminDeleteNotification(req *types.AdminDeleteNotificationReq) (resp *types.AdminDeleteNotificationResp, err error) {
 | |
| 	notification, err := l.svcCtx.GlobalNotificationsModel.FindOne(l.ctx, req.Id)
 | |
| 	if err != nil {
 | |
| 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查找通知失败, err: %v, id: %d", err, req.Id)
 | |
| 	}
 | |
| 	err = l.svcCtx.GlobalNotificationsModel.DeleteSoft(l.ctx, nil, notification)
 | |
| 	if err != nil {
 | |
| 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "删除通知失败, err: %v, id: %d", err, req.Id)
 | |
| 	}
 | |
| 	return &types.AdminDeleteNotificationResp{Success: true}, nil
 | |
| }
 |