允许uayu

This commit is contained in:
2024-04-09 10:43:17 +08:00
parent 57fe832e38
commit ce06c5a0d4
13 changed files with 180 additions and 213 deletions
+5 -5
View File
@@ -101,9 +101,9 @@ func (a *FileApi) UploadFiles(c *gin.Context) {
func (a *FileApi) GetList(c *gin.Context) {
list := []models.File{}
userInfo, _ := base.GetCurrentUserInfo(c)
// userInfo, _ := base.GetCurrentUserInfo(c)
var count int64
if err := global.Db.Order("created_at desc").Find(&list, "user_id=?", userInfo.ID).Count(&count).Error; err != nil {
if err := global.Db.Order("created_at desc").Find(&list).Count(&count).Error; err != nil {
apiReturn.ErrorDatabase(c, err.Error())
return
}
@@ -124,7 +124,7 @@ func (a *FileApi) GetList(c *gin.Context) {
func (a *FileApi) Deletes(c *gin.Context) {
req := commonApiStructs.RequestDeleteIds[uint]{}
userInfo, _ := base.GetCurrentUserInfo(c)
// userInfo, _ := base.GetCurrentUserInfo(c)
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
apiReturn.ErrorParamFomat(c, err.Error())
return
@@ -133,7 +133,7 @@ func (a *FileApi) Deletes(c *gin.Context) {
global.Db.Transaction(func(tx *gorm.DB) error {
files := []models.File{}
if err := tx.Order("created_at desc").Find(&files, "user_id=? AND id in ?", userInfo.ID, req.Ids).Error; err != nil {
if err := tx.Order("created_at desc").Find(&files, " id in ?", req.Ids).Error; err != nil {
return err
}
@@ -141,7 +141,7 @@ func (a *FileApi) Deletes(c *gin.Context) {
os.Remove(v.Src)
}
if err := tx.Order("created_at desc").Delete(&files, "user_id=? AND id in ?", userInfo.ID, req.Ids).Error; err != nil {
if err := tx.Order("created_at desc").Delete(&files, "id in ?", req.Ids).Error; err != nil {
return err
}