作者 yangfu

修改: 1.角色仓储增加缓存

... ... @@ -58,20 +58,12 @@ func (repository *RoleRepository) Remove(Role *domain.Role) (*domain.Role, error
if _, err := repository.Query(queryFunc, cacheRoleIdKey(Role.Id)); err != nil {
return Role, err
}
//if _, err := tx.Model(RoleModel).Where("id = ?", Role.Id).Delete(); err != nil {
// return Role, err
//}
return Role, nil
}
func (repository *RoleRepository) FindOne(queryOptions map[string]interface{}) (*domain.Role, error) {
tx := repository.transactionContext.PgDd
RoleModel := new(models.Role)
//query := NewQuery(tx.Model(RoleModel), queryOptions)
//query.SetWhere("id = ?", "id")
//if err := query.First(); err != nil {
// return nil, fmt.Errorf("query row not found")
//}
queryFunc := func() (interface{}, error) {
query := NewQuery(tx.Model(RoleModel), queryOptions)
query.SetWhere("id = ?", "id")
... ...