2026-08-09 10:43:45 +08:00
|
|
|
|
// Package method 业务逻辑方法包,实现反馈相关的业务操作
|
|
|
|
|
|
package method
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"context"
|
|
|
|
|
|
"time"
|
|
|
|
|
|
|
2026-08-09 12:41:08 +08:00
|
|
|
|
"bsm/full/module/base/feedback/internal/impl"
|
|
|
|
|
|
"bsm/full/module/base/feedback/internal/models"
|
|
|
|
|
|
pb "bsm/full/module/base/feedback/pb"
|
2026-08-09 15:10:19 +08:00
|
|
|
|
"git.apinb.com/bsm-sdk/core/errcode"
|
2026-08-09 10:43:45 +08:00
|
|
|
|
"git.apinb.com/bsm-sdk/core/service"
|
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/types"
|
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/utils"
|
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/vars"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Modify 修改反馈记录
|
|
|
|
|
|
// ctx: 上下文,包含用户认证信息
|
|
|
|
|
|
// in: 修改请求参数,包含记录ID和要修改的字段
|
|
|
|
|
|
// 返回: 修改操作结果
|
|
|
|
|
|
func Modify(ctx context.Context, in *pb.ModifyRequest) (reply *pb.StatusReply, err error) {
|
|
|
|
|
|
// 解析用户认证信息
|
|
|
|
|
|
auth, err := service.ParseMetaCtx(ctx, nil)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 验证请求参数
|
|
|
|
|
|
if in.GetIdentity() == "" {
|
2026-08-09 15:10:19 +08:00
|
|
|
|
return nil, errcode.ErrInvalidArgument
|
2026-08-09 10:43:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 构建更新记录
|
|
|
|
|
|
record := &models.FeedbackItem{
|
|
|
|
|
|
Std_IICUDS: types.Std_IICUDS{
|
|
|
|
|
|
Identity: utils.UUID(),
|
|
|
|
|
|
},
|
|
|
|
|
|
Std_Passport: types.Std_Passport{
|
|
|
|
|
|
PassportID: auth.ID, // 用户ID
|
|
|
|
|
|
PassportIdentity: auth.Identity, // 用户身份标识
|
|
|
|
|
|
},
|
|
|
|
|
|
UserName: in.GetUserName(), // 用户名
|
|
|
|
|
|
Email: in.GetEmail(), // 邮箱
|
|
|
|
|
|
Phone: in.GetPhone(), // 手机号
|
|
|
|
|
|
Status: in.GetStatus(), // 状态
|
|
|
|
|
|
Title: in.GetTitle(), // 标题
|
|
|
|
|
|
Content: in.GetContent(), // 内容
|
|
|
|
|
|
Category: in.GetCategory(), // 分类
|
|
|
|
|
|
Images: make([]models.FeedbackImage, 0, len(in.GetImages())), // 图片列表
|
|
|
|
|
|
Accessories: make([]models.FeedbackAccessory, 0, len(in.GetAccessories())), // 附件列表
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理图片信息
|
|
|
|
|
|
for _, v := range in.GetImages() {
|
|
|
|
|
|
identity := v.GetIdentity()
|
|
|
|
|
|
if identity == "" {
|
|
|
|
|
|
identity = utils.UUID() // 生成新的图片ID
|
|
|
|
|
|
}
|
|
|
|
|
|
record.Images = append(record.Images, models.FeedbackImage{
|
|
|
|
|
|
Std_IICUDS: types.Std_IICUDS{
|
|
|
|
|
|
Identity: identity,
|
|
|
|
|
|
},
|
|
|
|
|
|
ItemIdentity: in.GetIdentity(), // 关联的反馈记录ID
|
|
|
|
|
|
URL: v.GetUrl(), // 图片URL
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理附件信息
|
|
|
|
|
|
for _, v := range in.GetAccessories() {
|
|
|
|
|
|
record.Accessories = append(record.Accessories, models.FeedbackAccessory{
|
|
|
|
|
|
ItemIdentity: in.GetIdentity(), // 关联的反馈记录ID
|
|
|
|
|
|
Title: v.Title, // 附件标题
|
|
|
|
|
|
FilePath: v.FilePath, // 附件文件路径
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 先删除关联的图片和附件
|
|
|
|
|
|
err = impl.DBService.Where("item_identity = ?", in.GetIdentity()).Delete(&models.FeedbackImage{}).Error
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
|
|
|
|
|
err = impl.DBService.Where("item_identity = ?", in.GetIdentity()).Delete(&models.FeedbackAccessory{}).Error
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 更新主记录
|
|
|
|
|
|
err = impl.DBService.Where("identity = ?", in.GetIdentity()).Updates(record).Error
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 重新创建关联的图片和附件
|
|
|
|
|
|
if len(record.Images) > 0 {
|
|
|
|
|
|
err = impl.DBService.Create(&record.Images).Error
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if len(record.Accessories) > 0 {
|
|
|
|
|
|
err = impl.DBService.Create(&record.Accessories).Error
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return &pb.StatusReply{
|
|
|
|
|
|
Message: vars.OK,
|
|
|
|
|
|
Timeseq: time.Now().UnixMilli(),
|
|
|
|
|
|
}, nil
|
|
|
|
|
|
}
|