50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
|
|
v1 "git.5iot.com/iotlcm-public/iotlcm-admin-svr/api/common/v1"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
|
|
)
|
|
|
|
func (c *ControllerV1) DownloadCenterList(ctx context.Context, req *v1.DownloadCenterListReq) (res *v1.DownloadCenterListRes, err error) {
|
|
list, totalCount, err := service.CommonDownloadCenter().List(ctx, &req.DownloadCenterListParam)
|
|
if err != nil {
|
|
return
|
|
}
|
|
if list == nil {
|
|
list = []*model.DownloadCenterListModel{}
|
|
}
|
|
res = new(v1.DownloadCenterListRes)
|
|
res.Items = list
|
|
res.PageResult.Page = req.Page
|
|
res.PageResult.PageSize = req.PageSize
|
|
res.PageResult.Total = totalCount
|
|
return
|
|
}
|
|
|
|
func (c *ControllerV1) DownloadCenterRecent(ctx context.Context, req *v1.DownloadCenterRecentReq) (res *v1.DownloadCenterRecentRes, err error) {
|
|
data, err := service.CommonDownloadCenter().Recent(ctx, &req.DownloadCenterRecentParam)
|
|
if err != nil {
|
|
return
|
|
}
|
|
res = new(v1.DownloadCenterRecentRes)
|
|
res.DownloadCenterRecentModel = data
|
|
return
|
|
}
|
|
|
|
func (c *ControllerV1) DownloadCenterDownload(ctx context.Context, req *v1.DownloadCenterDownloadReq) (res *v1.DownloadCenterDownloadRes, err error) {
|
|
if err = service.CommonDownloadCenter().Download(ctx, &req.DownloadCenterTaskParam); err != nil {
|
|
return nil, err
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (c *ControllerV1) DownloadCenterRemove(ctx context.Context, req *v1.DownloadCenterRemoveReq) (res *v1.DownloadCenterRemoveRes, err error) {
|
|
if err = service.CommonDownloadCenter().Remove(ctx, &req.DownloadCenterTaskParam); err != nil {
|
|
return nil, err
|
|
}
|
|
return new(v1.DownloadCenterRemoveRes), nil
|
|
}
|