58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
// Code scaffolded by goctl. Safe to edit.
|
||
// goctl 1.9.2
|
||
|
||
package socialService
|
||
|
||
import (
|
||
"context"
|
||
|
||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||
"github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/model"
|
||
"github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types"
|
||
|
||
"github.com/zeromicro/go-zero/core/logx"
|
||
)
|
||
|
||
type DeleteSocialServiceLogic struct {
|
||
logx.Logger
|
||
ctx context.Context
|
||
cfg *config.Config
|
||
model model.SocialServiceModel
|
||
}
|
||
|
||
func NewDeleteSocialServiceLogic(ctx context.Context, cfg *config.Config, model model.SocialServiceModel) *DeleteSocialServiceLogic {
|
||
return &DeleteSocialServiceLogic{
|
||
Logger: logx.WithContext(ctx),
|
||
ctx: ctx,
|
||
cfg: cfg,
|
||
model: model,
|
||
}
|
||
}
|
||
|
||
func (l *DeleteSocialServiceLogic) DeleteSocialService(req *types.DeleteSocialServiceReq) (resp *types.DeleteSocialServiceResp, err error) {
|
||
// 1. 二次校验 ID 有效性(请求层已校验,此处可选增强)
|
||
if req.Id <= 0 {
|
||
l.Logger.Errorf("删除社会服务失败:无效的ID,id=%d", req.Id)
|
||
return &types.DeleteSocialServiceResp{
|
||
Code: 400,
|
||
Msg: "删除失败:ID无效",
|
||
}, nil
|
||
}
|
||
|
||
// 2. 调用 model 执行逻辑删除(更新 is_delete=1)
|
||
err = l.model.Delete(context.Background(), req.Id)
|
||
if err != nil {
|
||
l.Logger.Errorf("删除社会服务失败,id=%d, err=%v", req.Id, err)
|
||
return &types.DeleteSocialServiceResp{
|
||
Code: 500,
|
||
Msg: "删除失败:数据库更新异常",
|
||
}, nil
|
||
}
|
||
|
||
// 3. 构造成功响应
|
||
return &types.DeleteSocialServiceResp{
|
||
Code: 0,
|
||
Msg: "删除成功(逻辑删除)",
|
||
}, nil
|
||
}
|