附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

db_file.go 761 B

3 months ago
123456789101112131415161718192021222324252627282930313233
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils/logx"
  5. "xorm.io/xorm"
  6. )
  7. // 通过文件名目录与文件名查找文件
  8. func FileGetByPFidAndName(Db *xorm.Engine, dirId, fname string) (*model.SysFile, error) {
  9. var f model.SysFile
  10. if has, err := Db.Where("parent_fid = ? AND show_name = ?", dirId, fname).Get(&f); !has || err != nil {
  11. return nil, logx.Warn(err)
  12. }
  13. return &f, nil
  14. }
  15. // 插入文件信息
  16. func FileInsert(Db *xorm.Engine, f *model.SysFile) error {
  17. if _, err := Db.InsertOne(f); err != nil {
  18. return logx.Warn(err)
  19. }
  20. return nil
  21. }
  22. // 文件信息更新
  23. func FileUpdate(Db *xorm.Engine, f *model.SysFile) error {
  24. if _, err := Db.Where("`fid` = ?", f.Fid).Update(f); err != nil {
  25. return logx.Warn(err)
  26. }
  27. return nil
  28. }