Finish half translation work.
This commit is contained in:
@ -14,43 +14,51 @@ type BridgeDao struct {
|
||||
BaseDao
|
||||
}
|
||||
|
||||
//按照Id查询文件
|
||||
//find by uuid. if not found return nil.
|
||||
func (this *BridgeDao) FindByUuid(uuid string) *Bridge {
|
||||
|
||||
// Read
|
||||
var bridge Bridge
|
||||
db := core.CONTEXT.GetDB().Where(&Bridge{Base: Base{Uuid: uuid}}).First(&bridge)
|
||||
var bridge = &Bridge{}
|
||||
db := core.CONTEXT.GetDB().Where("uuid = ?", uuid).First(bridge)
|
||||
if db.Error != nil {
|
||||
return nil
|
||||
if db.Error.Error() == result.DB_ERROR_NOT_FOUND {
|
||||
return nil
|
||||
} else {
|
||||
panic(db.Error)
|
||||
}
|
||||
}
|
||||
return &bridge
|
||||
return bridge
|
||||
|
||||
}
|
||||
|
||||
//按照Id查询文件
|
||||
//find by uuid. if not found panic NotFound error
|
||||
func (this *BridgeDao) CheckByUuid(uuid string) *Bridge {
|
||||
|
||||
// Read
|
||||
var bridge Bridge
|
||||
db := core.CONTEXT.GetDB().Where(&Bridge{Base: Base{Uuid: uuid}}).First(&bridge)
|
||||
this.PanicError(db.Error)
|
||||
entity := this.FindByUuid(uuid)
|
||||
if entity == nil {
|
||||
panic(result.NotFound("not found record with uuid = %s", uuid))
|
||||
}
|
||||
|
||||
return &bridge
|
||||
return entity
|
||||
|
||||
}
|
||||
|
||||
//按照shareUuid和matterUuid查找
|
||||
//find by shareUuid and matterUuid. if not found panic NotFound error.
|
||||
func (this *BridgeDao) CheckByShareUuidAndMatterUuid(shareUuid string, matterUuid string) *Bridge {
|
||||
|
||||
// Read
|
||||
var bridge Bridge
|
||||
db := core.CONTEXT.GetDB().Where("share_uuid = ? AND matter_uuid = ?", shareUuid, matterUuid).First(&bridge)
|
||||
this.PanicError(db.Error)
|
||||
|
||||
return &bridge
|
||||
var bridge = &Bridge{}
|
||||
db := core.CONTEXT.GetDB().Where("share_uuid = ? AND matter_uuid = ?", shareUuid, matterUuid).First(bridge)
|
||||
if db.Error != nil {
|
||||
if db.Error.Error() == result.DB_ERROR_NOT_FOUND {
|
||||
panic(result.NotFound("not found record with shareUuid = %s and matterUuid = %s", shareUuid, matterUuid))
|
||||
} else {
|
||||
panic(db.Error)
|
||||
}
|
||||
}
|
||||
|
||||
return bridge
|
||||
}
|
||||
|
||||
//按分页条件获取分页
|
||||
//get pager
|
||||
func (this *BridgeDao) Page(page int, pageSize int, shareUuid string, sortArray []builder.OrderPair) *Pager {
|
||||
|
||||
var wp = &builder.WherePair{}
|
||||
@ -74,7 +82,6 @@ func (this *BridgeDao) Page(page int, pageSize int, shareUuid string, sortArray
|
||||
return pager
|
||||
}
|
||||
|
||||
//创建
|
||||
func (this *BridgeDao) Create(bridge *Bridge) *Bridge {
|
||||
|
||||
timeUUID, _ := uuid.NewV4()
|
||||
@ -88,7 +95,6 @@ func (this *BridgeDao) Create(bridge *Bridge) *Bridge {
|
||||
return bridge
|
||||
}
|
||||
|
||||
//修改一条记录
|
||||
func (this *BridgeDao) Save(bridge *Bridge) *Bridge {
|
||||
|
||||
bridge.UpdateTime = time.Now()
|
||||
@ -98,39 +104,33 @@ func (this *BridgeDao) Save(bridge *Bridge) *Bridge {
|
||||
return bridge
|
||||
}
|
||||
|
||||
//删除一条记录
|
||||
func (this *BridgeDao) Delete(bridge *Bridge) {
|
||||
|
||||
db := core.CONTEXT.GetDB().Delete(&bridge)
|
||||
this.PanicError(db.Error)
|
||||
}
|
||||
|
||||
//删除一个matter对应的所有缓存
|
||||
func (this *BridgeDao) DeleteByMatterUuid(matterUuid string) {
|
||||
|
||||
var wp = &builder.WherePair{}
|
||||
|
||||
wp = wp.And(&builder.WherePair{Query: "matter_uuid = ?", Args: []interface{}{matterUuid}})
|
||||
|
||||
//删除文件记录
|
||||
db := core.CONTEXT.GetDB().Where(wp.Query, wp.Args).Delete(Bridge{})
|
||||
this.PanicError(db.Error)
|
||||
}
|
||||
|
||||
//删除一个share对应的所有缓存
|
||||
func (this *BridgeDao) DeleteByShareUuid(shareUuid string) {
|
||||
|
||||
var wp = &builder.WherePair{}
|
||||
|
||||
wp = wp.And(&builder.WherePair{Query: "share_uuid = ?", Args: []interface{}{shareUuid}})
|
||||
|
||||
//删除文件记录
|
||||
db := core.CONTEXT.GetDB().Where(wp.Query, wp.Args).Delete(Bridge{})
|
||||
this.PanicError(db.Error)
|
||||
}
|
||||
|
||||
//根据shareUuid获取关联的所有matter.
|
||||
func (this *BridgeDao) ListByShareUuid(shareUuid string) []*Bridge {
|
||||
func (this *BridgeDao) FindByShareUuid(shareUuid string) []*Bridge {
|
||||
|
||||
if shareUuid == "" {
|
||||
panic(result.BadRequest("shareUuid cannot be nil"))
|
||||
@ -146,9 +146,8 @@ func (this *BridgeDao) ListByShareUuid(shareUuid string) []*Bridge {
|
||||
return bridges
|
||||
}
|
||||
|
||||
//执行清理操作
|
||||
func (this *BridgeDao) Cleanup() {
|
||||
this.logger.Info("[BridgeDao]执行清理:清除数据库中所有Bridge记录。")
|
||||
this.logger.Info("[BridgeDao] cleanup: delete all bridge records.")
|
||||
db := core.CONTEXT.GetDB().Where("uuid is not null").Delete(Bridge{})
|
||||
this.PanicError(db.Error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user