29 lines
876 B
Go
29 lines
876 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
plantModel "sundynix-micro-go/app/plant/model"
|
|
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
|
"sundynix-micro-go/app/plant/rpc/plant"
|
|
)
|
|
|
|
type DeleteCarePlanLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewDeleteCarePlanLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteCarePlanLogic {
|
|
return &DeleteCarePlanLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
|
|
}
|
|
|
|
func (l *DeleteCarePlanLogic) DeleteCarePlan(in *plant.IdsReq) (*plant.CommonResp, error) {
|
|
if err := l.svcCtx.DB.Where("id IN ?", in.Ids).Delete(&plantModel.CarePlan{}).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
// 同步删除关联任务
|
|
l.svcCtx.DB.Where("plan_id IN ?", in.Ids).Delete(&plantModel.CareTask{})
|
|
return &plant.CommonResp{Code: 0, Msg: "ok"}, nil
|
|
}
|