mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-26 16:46:14 +08:00
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
// Package sys
|
|
// @Link https://github.com/bufanyun/hotgo
|
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
|
// @Author Ms <133814250@qq.com>
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
|
package sys
|
|
|
|
import (
|
|
"context"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"hotgo/api/admin/attachment"
|
|
"hotgo/internal/model/input/form"
|
|
"hotgo/internal/model/input/sysin"
|
|
"hotgo/internal/service"
|
|
)
|
|
|
|
var (
|
|
Attachment = cAttachment{}
|
|
)
|
|
|
|
type cAttachment struct{}
|
|
|
|
// Delete 删除附件
|
|
func (c *cAttachment) Delete(ctx context.Context, req *attachment.DeleteReq) (res *attachment.DeleteRes, err error) {
|
|
var in sysin.AttachmentDeleteInp
|
|
if err = gconv.Scan(req, &in); err != nil {
|
|
return
|
|
}
|
|
|
|
err = service.SysAttachment().Delete(ctx, in)
|
|
return
|
|
}
|
|
|
|
// View 获取指定附件信息
|
|
func (c *cAttachment) View(ctx context.Context, req *attachment.ViewReq) (res *attachment.ViewRes, err error) {
|
|
data, err := service.SysAttachment().View(ctx, sysin.AttachmentViewInp{Id: req.Id})
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
res = new(attachment.ViewRes)
|
|
res.AttachmentViewModel = data
|
|
return
|
|
}
|
|
|
|
// List 查看附件列表
|
|
func (c *cAttachment) List(ctx context.Context, req *attachment.ListReq) (res *attachment.ListRes, err error) {
|
|
var in sysin.AttachmentListInp
|
|
if err = gconv.Scan(req, &in); err != nil {
|
|
return
|
|
}
|
|
|
|
list, totalCount, err := service.SysAttachment().List(ctx, in)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
res = new(attachment.ListRes)
|
|
res.List = list
|
|
res.PageCount = form.CalPageCount(totalCount, req.PerPage)
|
|
res.Page = req.Page
|
|
res.PerPage = req.PerPage
|
|
return
|
|
}
|