Files

43 lines
1.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package method 业务逻辑方法包,实现反馈相关的业务操作
package method
import (
"context"
"errors"
"bsm/full/module/base/feedback/internal/impl"
"bsm/full/module/base/feedback/internal/models"
pb "bsm/full/module/base/feedback/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"gorm.io/gorm"
)
// Get 根据ID获取反馈记录详情
// ctx: 上下文
// in: 查询请求参数包含记录ID
// 返回: 反馈记录详情
func Get(ctx context.Context, in *pb.GetRequest) (reply *pb.GetReply, err error) {
// 验证请求参数
if in.GetIdentity() == "" {
return nil, errcode.ErrInvalidArgument
}
out := new(pb.GetReply)
record := new(models.FeedbackItem)
// 查询记录,预加载关联的图片信息
err = impl.DBService.Preload("Images").Where("identity = ?", in.GetIdentity()).First(record).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, errcode.ErrRecordNotFound
}
return nil, err
}
// 转换为响应格式
item := convert(*record)
out.Record = item
out.Exists = true
return out, nil
}