mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-10-12 13:03:45 +08:00
发布v2.8.4版本,更新内容请查看:https://github.com/bufanyun/hotgo/tree/v2.0/docs/guide-zh-CN/addon-version-upgrade.md
This commit is contained in:
@@ -7,9 +7,8 @@ package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/api/admin/attachment"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/library/storager"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
@@ -22,18 +21,13 @@ 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)
|
||||
err = service.SysAttachment().Delete(ctx, &req.AttachmentDeleteInp)
|
||||
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})
|
||||
data, err := service.SysAttachment().View(ctx, &req.AttachmentViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -45,20 +39,55 @@ func (c *cAttachment) View(ctx context.Context, req *attachment.ViewReq) (res *a
|
||||
|
||||
// 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)
|
||||
list, totalCount, err := service.SysAttachment().List(ctx, &req.AttachmentListInp)
|
||||
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
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// ChooserOption 获取选择器选项
|
||||
func (c *cAttachment) ChooserOption(ctx context.Context, req *attachment.ChooserOptionReq) (res *attachment.ChooserOptionRes, err error) {
|
||||
res = new(attachment.ChooserOptionRes)
|
||||
|
||||
res.Drive, err = service.SysDictData().Select(ctx, &sysin.DataSelectInp{Type: "config_upload_drive"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var kinds = []attachment.KindSelect{
|
||||
{
|
||||
Label: "全部", Key: "", Value: "",
|
||||
},
|
||||
{
|
||||
Label: "图片", Key: storager.KindImg, Value: storager.KindImg, Icon: "PictureOutlined", Tag: "success",
|
||||
},
|
||||
{
|
||||
Label: "文档", Key: storager.KindDoc, Value: storager.KindDoc, Icon: "FileWordOutlined", Tag: "primary",
|
||||
},
|
||||
{
|
||||
Label: "音频", Key: storager.KindAudio, Value: storager.KindAudio, Icon: "CustomerServiceOutlined", Tag: "info",
|
||||
},
|
||||
{
|
||||
Label: "视频", Key: storager.KindVideo, Value: storager.KindVideo, Icon: "PlaySquareOutlined", Tag: "warning",
|
||||
},
|
||||
{
|
||||
Label: "压缩包", Key: storager.KindZip, Value: storager.KindZip, Icon: "FileZipOutlined", Tag: "error",
|
||||
},
|
||||
{
|
||||
Label: "其他", Key: storager.KindOther, Value: storager.KindOther, Icon: "PlusOutlined", Tag: "default",
|
||||
},
|
||||
}
|
||||
res.Kind = append(res.Kind, kinds...)
|
||||
return
|
||||
}
|
||||
|
||||
// ClearKind 清空上传类型
|
||||
func (c *cAttachment) ClearKind(ctx context.Context, req *attachment.ClearKindReq) (res *attachment.ClearKindRes, err error) {
|
||||
err = service.SysAttachment().ClearKind(ctx, &req.AttachmentClearKindInp)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user