// ================================================================================= // This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. // ================================================================================= package dao import ( "context" "github.com/gogf/gf/v2/errors/gerror" "hotgo/internal/consts" "hotgo/internal/dao/internal" "hotgo/internal/model/input/sysin" "hotgo/internal/service" "hotgo/utility/format" ) // internalSysAttachmentDao is internal type for wrapping internal DAO implements. type internalSysAttachmentDao = *internal.SysAttachmentDao // sysAttachmentDao is the data access object for table hg_sys_attachment. // You can define custom methods on it to extend its functionality as you wish. type sysAttachmentDao struct { internalSysAttachmentDao } var ( // SysAttachment is globally public accessible object for table hg_sys_attachment operations. SysAttachment = sysAttachmentDao{ internal.NewSysAttachmentDao(), } ) func (dao *sysAttachmentDao) GetMd5File(ctx context.Context, md5 string) (data *sysin.AttachmentListModel, err error) { if err = dao.Ctx(ctx). Where("md5", md5). Where("status", consts.StatusEnabled). Scan(&data); err != nil { err = gerror.Wrap(err, consts.ErrorORM) return nil, err } if data == nil { return nil, nil } data.SizeFormat = format.FileSize(data.Size) data.FileUrl = service.CommonUpload().LastUrl(ctx, data.FileUrl, data.Drive) return data, nil }