feat: 迁移plant
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package banner
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantModel "sundynix-micro-go/app/plant/model"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateBannerLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateBannerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBannerLogic {
|
||||
return &UpdateBannerLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateBannerLogic) UpdateBanner(req *types.UpdateBannerReq) error {
|
||||
updates := map[string]interface{}{}
|
||||
if req.Title != "" {
|
||||
updates["title"] = req.Title
|
||||
}
|
||||
if req.ImageId != "" {
|
||||
updates["image_id"] = req.ImageId
|
||||
}
|
||||
if req.Sort != 0 {
|
||||
updates["sort"] = req.Sort
|
||||
}
|
||||
if req.IsActive != 0 {
|
||||
updates["is_active"] = req.IsActive
|
||||
}
|
||||
if req.TargetUrl != "" {
|
||||
updates["target_url"] = req.TargetUrl
|
||||
}
|
||||
return l.svcCtx.DB.Model(&plantModel.Banner{}).Where("id = ?", req.Id).Updates(updates).Error
|
||||
}
|
||||
Reference in New Issue
Block a user