Add the deleted time.
This commit is contained in:
parent
82047f4504
commit
76e7359c69
@ -163,7 +163,7 @@ func (this *DavController) debug(writer http.ResponseWriter, request *http.Reque
|
|||||||
func (this *DavController) Index(writer http.ResponseWriter, request *http.Request, subPath string) {
|
func (this *DavController) Index(writer http.ResponseWriter, request *http.Request, subPath string) {
|
||||||
|
|
||||||
//when debugging. open it.
|
//when debugging. open it.
|
||||||
this.debug(writer, request, subPath)
|
//this.debug(writer, request, subPath)
|
||||||
|
|
||||||
user := this.CheckCurrentUser(writer, request)
|
user := this.CheckCurrentUser(writer, request)
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ func (this *DavService) HandlePropfind(writer http.ResponseWriter, request *http
|
|||||||
matters = []*Matter{matter}
|
matters = []*Matter{matter}
|
||||||
} else {
|
} else {
|
||||||
// len(matters) == 0 means empty directory
|
// len(matters) == 0 means empty directory
|
||||||
matters = this.matterDao.FindByPuuidAndUserUuid(matter.Uuid, user.Uuid, nil)
|
matters = this.matterDao.FindByPuuidAndUserUuidAndDeleted(matter.Uuid, user.Uuid, FALSE, nil)
|
||||||
|
|
||||||
//add this matter to head.
|
//add this matter to head.
|
||||||
matters = append([]*Matter{matter}, matters...)
|
matters = append([]*Matter{matter}, matters...)
|
||||||
@ -373,7 +373,7 @@ func (this *DavService) HandleDelete(w http.ResponseWriter, r *http.Request, use
|
|||||||
|
|
||||||
matter := this.matterDao.CheckWithRootByPath(subPath, user)
|
matter := this.matterDao.CheckWithRootByPath(subPath, user)
|
||||||
|
|
||||||
this.matterService.AtomicDelete(r, matter, user)
|
this.matterService.AtomicSoftDelete(r, matter, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
//crate a directory
|
//crate a directory
|
||||||
|
@ -213,10 +213,19 @@ func (this *MatterDao) FindByUserUuidAndPuuidAndDirAndName(userUuid string, puui
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *MatterDao) FindByPuuidAndUserUuid(puuid string, userUuid string, sortArray []builder.OrderPair) []*Matter {
|
func (this *MatterDao) FindByPuuidAndUserUuid(puuid string, userUuid string, sortArray []builder.OrderPair) []*Matter {
|
||||||
|
return this.FindByPuuidAndUserUuidAndDeleted(puuid, userUuid, "", sortArray)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *MatterDao) FindByPuuidAndUserUuidAndDeleted(puuid string, userUuid string, deleted string, sortArray []builder.OrderPair) []*Matter {
|
||||||
var matters []*Matter
|
var matters []*Matter
|
||||||
|
|
||||||
var wp = &builder.WherePair{}
|
var wp = &builder.WherePair{}
|
||||||
wp = wp.And(&builder.WherePair{Query: "puuid = ? AND user_uuid = ?", Args: []interface{}{puuid, userUuid}})
|
wp = wp.And(&builder.WherePair{Query: "puuid = ? AND user_uuid = ?", Args: []interface{}{puuid, userUuid}})
|
||||||
|
if deleted == TRUE {
|
||||||
|
wp = wp.And(&builder.WherePair{Query: "deleted = 1", Args: []interface{}{}})
|
||||||
|
} else if deleted == FALSE {
|
||||||
|
wp = wp.And(&builder.WherePair{Query: "deleted = 0", Args: []interface{}{}})
|
||||||
|
}
|
||||||
|
|
||||||
if sortArray == nil {
|
if sortArray == nil {
|
||||||
|
|
||||||
@ -429,13 +438,13 @@ func (this *MatterDao) SoftDelete(matter *Matter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//soft delete from db.
|
//soft delete from db.
|
||||||
db := core.CONTEXT.GetDB().Model(&Matter{}).Where("uuid = ?", matter.Uuid).Update(map[string]interface{}{"deleted": 1})
|
db := core.CONTEXT.GetDB().Model(&Matter{}).Where("uuid = ?", matter.Uuid).Update(map[string]interface{}{"deleted": 1, "delete_time": time.Now()})
|
||||||
this.PanicError(db.Error)
|
this.PanicError(db.Error)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//soft delete from db.
|
//soft delete from db.
|
||||||
db := core.CONTEXT.GetDB().Model(&Matter{}).Where("uuid = ?", matter.Uuid).Update(map[string]interface{}{"deleted": 1})
|
db := core.CONTEXT.GetDB().Model(&Matter{}).Where("uuid = ?", matter.Uuid).Update(map[string]interface{}{"deleted": 1, "delete_time": time.Now()})
|
||||||
this.PanicError(db.Error)
|
this.PanicError(db.Error)
|
||||||
|
|
||||||
//no need to delete its image cache.
|
//no need to delete its image cache.
|
||||||
|
@ -46,6 +46,7 @@ type Matter struct {
|
|||||||
Prop string `json:"prop" gorm:"type:varchar(1024) not null;default:'{}'"`
|
Prop string `json:"prop" gorm:"type:varchar(1024) not null;default:'{}'"`
|
||||||
VisitTime time.Time `json:"visitTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"`
|
VisitTime time.Time `json:"visitTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"`
|
||||||
Deleted bool `json:"deleted" gorm:"type:tinyint(1) not null;default:0"`
|
Deleted bool `json:"deleted" gorm:"type:tinyint(1) not null;default:0"`
|
||||||
|
DeleteTime time.Time `json:"deleteTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// set File's table name to be `profiles`
|
// set File's table name to be `profiles`
|
||||||
|
Loading…
Reference in New Issue
Block a user