fix version 1
This commit is contained in:
@@ -8,20 +8,36 @@ import (
|
||||
"bsm/full/module/ec/mall/internal/models"
|
||||
pb "bsm/full/module/ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// 获取店铺基础配置
|
||||
func GetSetting(ctx context.Context, in *pb.IdentRequest) (reply *pb.StoreBasic, err error) {
|
||||
// parse authorization meta.
|
||||
auth, err := service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// valildate request id,identity.
|
||||
if in.Id == 0 && in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// 只能读取当前登录者所属店铺的配置
|
||||
owner, _ := auth.Owner.(map[string]any)
|
||||
storeIdentity, _ := owner["store_identity"].(string)
|
||||
|
||||
var data models.MallStore
|
||||
if err := impl.DBService.Where("id=? or identity=?", in.GetId(), in.GetIdentity()).First(&data).Error; err != nil {
|
||||
print(err.Error())
|
||||
tx := impl.DBService.Where("id=? or identity=?", in.GetId(), in.GetIdentity()).
|
||||
Where("identity = ?", storeIdentity).Find(&data)
|
||||
if tx.Error != nil {
|
||||
print(tx.Error.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
// TODO: add your logic code & delete this line.
|
||||
if storeIdentity == "" || tx.RowsAffected == 0 {
|
||||
return nil, errcode.ErrPermissionDenied
|
||||
}
|
||||
|
||||
return &pb.StoreBasic{
|
||||
Id: int64(data.ID),
|
||||
|
||||
Reference in New Issue
Block a user