Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	go.sum
  • Loading branch information
godLei6 committed Oct 23, 2024
2 parents 66ccd59 + 189b5dc commit 344d14d
Show file tree
Hide file tree
Showing 21 changed files with 4,325 additions and 4,236 deletions.
66 changes: 65 additions & 1 deletion service/apisvr/http/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5725,7 +5725,7 @@
"title": "返回的消息"
},
"data": {
"$ref": "#/definitions/UserDeviceShareMultiInfo"
"$ref": "#/definitions/UserDeviceShareMultiIndexResp"
}
}
}
Expand Down Expand Up @@ -8798,6 +8798,35 @@
"payload"
]
},
"DeviceShareInfo": {
"type": "object",
"properties": {
"productID": {
"type": "string",
"description": "产品ID"
},
"productName": {
"type": "string"
},
"productImg": {
"type": "string",
"description": "产品图片"
},
"deviceName": {
"type": "string",
"description": "设备名称"
},
"deviceAlias": {
"type": "string",
"description": "设备别名 读写"
}
},
"title": "DeviceShareInfo",
"required": [
"productID",
"deviceName"
]
},
"FirmwareCreateReq": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -12462,6 +12491,41 @@
},
"title": "UserDeviceShareMultiDeleteReq"
},
"UserDeviceShareMultiIndexResp": {
"type": "object",
"properties": {
"devices": {
"type": "array",
"items": {
"$ref": "#/definitions/DeviceShareInfo"
},
"description": "批量设备信息"
},
"authType": {
"type": "integer",
"format": "int64",
"description": "授权类型:1:全部授权 2:部分授权"
},
"schemaPerm": {
"type": "object",
"description": "普通功能权限 2:读写权限 3读权限"
},
"accessPerm": {
"type": "object",
"description": "系统功能权限 2:读写权限 3读权限"
},
"expTime": {
"type": "integer",
"format": "int64",
"description": "到期时间"
},
"createdTime": {
"type": "integer",
"format": "int64"
}
},
"title": "UserDeviceShareMultiIndexResp"
},
"UserDeviceShareMultiInfo": {
"type": "object",
"properties": {
Expand Down
17 changes: 16 additions & 1 deletion service/apisvr/http/things/user/device.api
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ service api {
post /multi-create (UserDeviceShareMultiInfo) returns (UserDeviceShareMultiToken)
@doc "获取批量分享的设备列表"
@handler multiIndex
post /multi-index (UserDeviceShareMultiToken) returns (UserDeviceShareMultiInfo)
post /multi-index (UserDeviceShareMultiToken) returns (UserDeviceShareMultiIndexResp)
@doc "接受批量分享设备"
@handler multiAccept
post /multi-accept (UserDeviceShareMultiAcceptInfo) returns ()
Expand Down Expand Up @@ -111,6 +111,21 @@ type (
List []*UserDeviceShareInfo `json:"list,optional"`
Total int64 `json:"total,optional"`
}
UserDeviceShareMultiIndexResp{
Devices []*DeviceShareInfo `json:"devices,optional"` //批量设备信息
AuthType int64 `json:"authType,optional"`//授权类型:1:全部授权 2:部分授权
SchemaPerm map[string ]*SharePerm `json:"schemaPerm,optional"`//普通功能权限 2:读写权限 3读权限
AccessPerm map[string ]*SharePerm `json:"accessPerm,optional"`//系统功能权限 2:读写权限 3读权限
ExpTime int64 `json:"expTime,optional"` //到期时间
CreatedTime int64 `json:"createdTime,optional"`
}
DeviceShareInfo{
ProductID string `json:"productID"` //产品ID
ProductName string `json:"productName,optional,omitempty"`
ProductImg string `json:"productImg,optional,omitempty"` //产品图片
DeviceName string `json:"deviceName"` //设备名称
DeviceAlias string `json:"deviceAlias,optional"` //设备别名 读写
}
)

type (
Expand Down
25 changes: 17 additions & 8 deletions service/apisvr/internal/logic/things/user/device/share/assemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ func ToMuitlSharePb(in *types.UserDeviceShareMultiInfo) *dm.UserDeviceShareMulti
if in == nil {
return nil
}
devices := in.Devices
var dvs []*dm.DeviceShareInfo
for _, v := range in.Devices {
dvs = append(dvs, &dm.DeviceShareInfo{
DeviceName: v.DeviceName,
ProductID: v.ProductID,
})
}
return &dm.UserDeviceShareMultiInfo{
Devices: ToSharesDevices(devices),
Devices: dvs,
AuthType: in.AuthType,
ExpTime: in.ExpTime,
AccessPerm: utils.CopyMap[dm.SharePerm](in.AccessPerm),
Expand All @@ -73,18 +79,21 @@ func ToSharesDevices(in []*types.DeviceCore) (ret []*dm.DeviceCore) {
}
return ret
}
func ToMultiShareTypes(in *dm.UserDeviceShareMultiInfo) *types.UserDeviceShareMultiInfo {
func ToMultiShareTypes(in *dm.UserDeviceShareMultiInfo) *types.UserDeviceShareMultiIndexResp {
if in == nil {
return nil
}
var dvs []*types.DeviceCore
var dvs []*types.DeviceShareInfo
for _, v := range in.Devices {
dvs = append(dvs, &types.DeviceCore{
DeviceName: v.DeviceName,
ProductID: v.ProductID,
dvs = append(dvs, &types.DeviceShareInfo{
DeviceName: v.DeviceName,
ProductID: v.ProductID,
ProductName: v.ProductName,
DeviceAlias: v.DeviceAlias.GetValue(),
ProductImg: v.ProductImg,
})
}
return &types.UserDeviceShareMultiInfo{
return &types.UserDeviceShareMultiIndexResp{
Devices: dvs,
AuthType: in.AuthType,
CreatedTime: in.CreatedTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ func NewMultiIndexLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MultiI
}
}

func (l *MultiIndexLogic) MultiIndex(req *types.UserDeviceShareMultiToken) (resp *types.UserDeviceShareMultiInfo, err error) {

func (l *MultiIndexLogic) MultiIndex(req *types.UserDeviceShareMultiToken) (resp *types.UserDeviceShareMultiIndexResp, err error) {
ret, err := l.svcCtx.UserDevice.UserDeivceShareMultiIndex(l.ctx, &dm.UserDeviceShareMultiToken{ShareToken: req.ShareToken})
if err != nil {
return nil, err
Expand Down
17 changes: 17 additions & 0 deletions service/apisvr/internal/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/devicegroup/deviceGroup.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/deviceinteract/deviceInteract.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/devicemanage/deviceManage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/devicemsg/deviceMsg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/otamanage/otaManage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/productmanage/productManage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/protocolmanage/protocolManage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/remoteconfig/remoteConfig.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/schemamanage/schemaManage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/dmsvr/client/userdevice/userDevice.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func NewUserDeivceShareMultiIndexLogic(ctx context.Context, svcCtx *svc.ServiceC
}

// 扫码后获取设备列表
// 如果有分页需求,在前端处理
func (l *UserDeivceShareMultiIndexLogic) UserDeivceShareMultiIndex(in *dm.UserDeviceShareMultiToken) (*dm.UserDeviceShareMultiInfo, error) {
resp, err := l.svcCtx.UserMultiDeviceShare.GetData(l.ctx, in.ShareToken)
return resp, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func NewUserDeviceShareMultiCreateLogic(ctx context.Context, svcCtx *svc.Service
}
}

// rpc userDeviceOtaGetVersion(UserDeviceOtaGetVersionReq)returns(userDeviceOtaGetVersionResp);
func (l *UserDeviceShareMultiCreateLogic) UserDeviceShareMultiCreate(in *dm.UserDeviceShareMultiInfo) (*dm.UserDeviceShareMultiToken, error) {
// 写入caches
shareToken, _ := uuid.GenerateUUID()
Expand Down Expand Up @@ -58,9 +57,24 @@ func (l *UserDeviceShareMultiCreateLogic) UserDeviceShareMultiCreate(in *dm.User
return nil, errors.Permissions.AddMsg("您无权分享所选的设备")
}
}
d.DeviceAlias = di.DeviceAlias
d.ProductName = di.ProductName
d.ProductImg = di.ProductImg
}
}
}
for _, d := range in.Devices {
//补全设备信息
if d.ProductImg == "" {
di, _ := l.svcCtx.DeviceCache.GetData(l.ctx, devices.Core{
ProductID: d.ProductID,
DeviceName: d.DeviceName,
})
d.DeviceAlias = di.DeviceAlias
d.ProductName = di.ProductName
d.ProductImg = di.ProductImg
}
}
l.svcCtx.UserMultiDeviceShare.SetData(l.ctx, shareToken, in)
return &dm.UserDeviceShareMultiToken{ShareToken: shareToken}, nil
}
2 changes: 2 additions & 0 deletions service/dmsvr/internal/repo/relationDB/userDeviceShare.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package relationDB

import (
"context"

"gitee.com/unitedrhino/share/devices"
"gitee.com/unitedrhino/share/stores"
"gorm.io/gorm"
Expand Down Expand Up @@ -73,6 +74,7 @@ func (p UserDeviceShareRepo) fmtFilter(ctx context.Context, f UserDeviceShareFil
}

func (p UserDeviceShareRepo) Insert(ctx context.Context, data *DmUserDeviceShare) error {

result := p.db.WithContext(ctx).Create(data)
return stores.ErrFmt(result.Error)
}
Expand Down
Loading

0 comments on commit 344d14d

Please sign in to comment.